Invalid value for attribute cx=”NaN” using NVD3.js-open source projects novus/nvd3
i get an ‘Invalid value for attribute cx=”NaN”‘ when using barlinechart with nvd3.js. the chart gets displayed but the yAxis shows wrong integer values (too low) and the tooltips on the chart do not pop up on hovering it. input data is listed below.
js part:
function drawCumulativeChart(selector, jsondata ){
nv.addGraph(function() {
var chart = nv.models.cumulativeLineChart()
.x(function(d) { return d[0] })
.y(function(d) { return d[1] })
.color(d3.scale.category10().range());
chart.xAxis.tickFormat(function (d) {
return d3.time.format("%m/%y")(new Date(d));
});
chart.yAxis.tickFormat(d3.format(',.2f'));
d3.select(selector)
.datum( **jsondata** )
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
}
jsondata:
[{
"key":"usercount",
"values":[
["2011-12-31T23:00:00.000Z",22],
["2012-01-31T23:00:00.000Z",45],
["2012-02-29T23:00:00.000Z",64],
["2012-03-31T22:00:00.000Z",86],
["2012-04-30T22:00:00.000Z",109],
["2012-05-31T22:00:00.000Z",123],
["2012-06-30T22:00:00.000Z",145],
["2012-07-31T22:00:00.000Z",174],
["2012-08-31T22:00:00.000Z",195],
["2012-09-30T22:00:00.000Z",207],
["2012-10-31T23:00:00.000Z",221],
["2012-11-30T23:00:00.000Z",235]
]
}]
database raw dataformat:
[time:2012-01-01 00:00:00.0, count:2]