问题是dimple js 将测量轴(y - 成本)的数据值视为整数,其中它们是十进制值。任何建议如何解决这个问题?这是jsfiddle:http://jsfiddle.net/Ra2xS/7/

    var dim = {"width":590,"height":450}; //chart container width
var data = [{"date":"01-02-2010","cost":"9.7862"},{"date":"01-03-2010","cost":"9.915"},{"date":"01-04-2010","cost":"10.2634"}];

function barplot(id,dim,data)
{
    keys = Object.keys(data[0]);
    var xcord = keys[0];
    var ycord = keys[1];
    var svg = dimple.newSvg(id, dim.width, dim.height);

    var myChart = new dimple.chart(svg,data);
    myChart.setBounds(60, 30, 505, 305);

    var x = myChart.addCategoryAxis("x", xcord);
    x.addOrderRule(xcord);
    x.showGridlines = true;

    var y = myChart.addMeasureAxis("y", ycord);
    y.showGridlines = true;

    var s = myChart.addSeries(null, dimple.plot.bar);
    var s1 = myChart.addSeries(null, dimple.plot.line);
    s1.lineWeight = 3;
    s1.lineMarkers = true;

    myChart.draw(1500);

}

barplot("body",dim,data);

最佳答案

工具提示从轴获取数据,因此为了获得更高的精度,您必须更改 y 轴的刻度格式:

y.tickFormat = ',.1f';

完成演示 here

关于javascript - 酒窝 js 测量轴值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22988109/

10-12 12:53