2015-10-12 71 views
0

我在正確使用我的x軸標籤時遇到了一些困難。我使用highcharts來繪製柱形圖,但不是使用我的分類作爲標籤,而是使用1的數字 - 但是有很多繪圖點。高難度柱形圖上的類別問題

這裏是代碼:

$('#bar').highcharts({ 

     chart: { 
       borderColor: "#FFFFFF", 
       borderRadius: 2, 
       backgroundColor: "#D8D8D8", 
       renderTo: 'chartdiv3', 
       type: 'column' 
     }, 
     title: { text: 'one year rain' }, 

     xAxis: [{ 
     type: "catagory", 
     catagories: [ 

      '09/19', 

      '09/12', 

      '09/05', 

      '08/29', 

      '08/22', 

      '08/15', 

      '08/08', 

      '08/01', 

      '07/25', 

      '07/18', 

      '07/11', 

      '07/04', 

      '10/12' 
     ], 
     labels: { 
      rotation: -45, 
      style: { 
       fontSize: '13px', 
       fontFamily: 'Verdana, sans-serif' 
      } 
     }, 
     title: { 
      text: 'week ending' 
     } 
     }], 

     yAxis: { 
     title: { text: 'inches'} 
     }, 


     plotOptions: { 
     column: { 
      pointPadding: 0.2, 
      borderWidth: 0 
     } 
     }, 

     // must move the month ahead because javascript indexes a month as a number between 0 and 11 
     series: [{ 
     name: 'rain', 
     color: "#2E64FE", 
     type: "column", 
     data: [ 

       0.0,  

       0.05,  

       0.2,  

       0.02,  

       1.48,  

       0.38,  

       1.75,  

       2.74,  

       1.07,  

       0.36,  

       2.72,  

       0.1,  

      0.0 
     ] 
     }] 

    }); 

情節看起來不錯,但無論是在工具提示和底部爲x軸的標籤只顯示編號1-12。

我很欣賞這裏的任何提示。我到處搜索。

回答

1

您拼寫錯誤的「類別」。

像這樣的東西應該工作:

categories: ['Apples', 'Bananas', 'Oranges'] 
+0

是做到了,非常感謝。 Jeez無法相信這一點。 :) – skrite

+0

如果有幫助,請將答案標記爲已接受。 – jjk