Frage

Problem is dimple js treating data values of measure axis (y - cost) as integer where they are decimal values. Any suggestions how to fix this? Here is the 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);
War es hilfreich?

Lösung

The tool tip gets its data from the axis, so to get more precision there you have to change the tick format for the y axis:

y.tickFormat = ',.1f';

Complete demo here.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top