如何在YUI图表中自定义y轴刻度?

时间:2012-06-29 14:41:45

标签: javascript charts yui histogram

我使用以下代码使用YUI图表生成直方图:

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文档,但这令人困惑。

1 个答案:

答案 0 :(得分:0)

YAHOO.widget.NumericAxis.maximum设置为所需的值。

官方文件指明:

  

...如果未明确设置,将自动计算轴最大值。

<强>参考:

相关问题