2012-06-29 85 views
0

我使用下面的代碼使用銳圖表以產生柱狀圖:如何在YUI圖表中定製y軸刻度?

YUI().use('charts', function(Y) { 
    //Data for the chart 
    var myDataValues = barResponse.data; 
    // Instantiate and render the chart 
    var mychart = new Y.Chart({ 
     dataProvider: myDataValues, 
     legend: { 
      position: "right", 
      width: 300, 
      height: 300, 
      styles: { 
       hAlign: "center", 
       hSpacing: 4 
      } 
     }, 
     axes: { 
      category: { 
       styles: { 
        label: { 
         rotation: -45 
        } 
       } 
      } 
     }, 
     render: "#mychart", 
     type: "column" 
    }); 
}); 

其中barResponse是包含數據JSON對象,myChart是HTML DIV其中圖表將被繪製:

<div id="mychart"></div> 

由於我的數據是一樣低的值:0.028,0.047 ..等爲y軸0之間自動定義爲1。這是它的外觀,我在圖表中變得非常小酒吧:

enter image description here

問題是我如何定製y軸的刻度範圍:例如從0.0到0.3?或換句話說,如何使相同數據集的直方圖條更大?

我檢查了API文檔,但它很混亂。

回答

0

YAHOO.widget.NumericAxis.maximum設置爲所需的值。

官方的文檔指定:

...如果沒有明確設置,軸最高將被自動計算。

參考:

+0

加入這兩行修復該問題: '變種leftAxis = mychart.getAxisByKey( 「值」); leftAxis.set(「maximum」,0.1);' – Sami