2017-09-02 13 views
0

私のXaxisラベルで月を見たいですが、追加しようとすると0から2まで表示されますが、月は表示されません。どうすれば修正できますか?私はjaxisをXaxisに追加するために月の一部だけを取得しようとしましたが、動作しませんでした。どのように動作させることができますか?それのためのヒント、これは私のコードがこれまでのように見える方法です。Xaxis monthsラベルが機能しません。

var sales_by_month = new Array(); 
    var month = new Array(); 
    $.ajax({ 
     url: URL_GET_SALES_BY_MONTH, 
     type: 'POST', 
     dataType: 'json', 
     success: function (data) { 
      for (i = 0; i < data.length; i++) { 
       sales_by_month.push([data[i].month, data[i].total]); 
       month.push(data[i].month); 
      } 
      Highcharts.chart('income_chart', { 
       title: { 
        text: 'Total Earnings' 
       }, 
       yAxis: { 
        title: { 
         text: '' 
        } 
       }, 
       xAxis: { 
        type: 'date' 
       }, 
       legend: { 
        enabled: false 

       }, 
       credits: { 
        enabled: false 
       }, 
       exporting: { 
        buttons: { 
         contextButton: { 
          menuItems: [{ 
           textKey: 'downloadPNG', 
           onclick: function() { 
            this.exportChart(); 
           } 
         }, { 
           textKey: 'downloadJPEG', 
           onclick: function() { 
            this.exportChart({ 
             type: 'image/jpeg' 
            }); 
           } 
         }, { 
           textKey: 'downloadPDF', 
           onclick: function() { 
            this.exportChart({ 
             type: 'application/pdf' 
            }); 
           } 
         }] 
         } 
        } 
       }, 
       series: [{ 
        name: 'Sales & Distribution', 
        data: sales_by_month 
      }] 

      }); 
     } 
    }); 

JSON

[{"orders":3,"total":9500,"month":"June"},{"orders":55,"total":71200,"month":"July"},{"orders":10,"total":1529,"month":"August"}] 

graph

+0

単に 'xAxis.categories'としてヶ月配列を使用します。例:http://jsfiddle.net/eayzkk0r/。 –

答えて

0

details.YouためのAPI xAxis.categoriesをチェックxAxis設定にそれを渡す必要がありますmonths.Youの配列を作成しています。

Fiddleデモ

Highcharts.chart('income_chart', { 

    title: { 
      text: 'Total Earnings' 
     }, 
    yAxis: { 
     title: { 
      text: '' 
     } 
    }, 
    xAxis: { 
     categories:month 
    }, 
    legend: { 
     enabled: false 

    }, 
    credits: { 
     enabled: false 
    }, 
    exporting: { 
     buttons: { 
      contextButton: { 
       menuItems: [{ 
        textKey: 'downloadPNG', 
        onclick: function() { 
         this.exportChart(); 
        } 
      }, { 
        textKey: 'downloadJPEG', 
        onclick: function() { 
         this.exportChart({ 
          type: 'image/jpeg' 
         }); 
        } 
      }, { 
        textKey: 'downloadPDF', 
        onclick: function() { 
         this.exportChart({ 
          type: 'application/pdf' 
         }); 
        } 
      }] 
      } 
     } 
    }, 
    series: [{ 
     name: 'Sales & Distribution', 
     data: sales_by_month 
}] 

}); 
関連する問題