I'm currently trying to render an nvd3 Line Chart in Meteor JS. I'm running Meteor 1.1.0.3 and running the nvd3 package on version 1.7.1.
Using the examples on the nvd3: http://nvd3.org/examples/line.html, I got the following code. However, even with correctly following the example, the graph draws but the dates are all 12/31/1969 and the y axis generates -1, 0, and 1 values. See the attached image:
Can anyone tell me what I'm missing here?
nv.addGraph(function() {
var chart = nv.models.lineChart()
.margin({ left: 25 })
.showLegend(true)
.showXAxis(true)
.showYAxis(true);
chart.xAxis
.axisLabel('Date')
.tickFormat(function(d) {
return d3.time.format('%x')(new Date(d));
});
chart.yAxis
.axisLabel('Data')
.tickFormat(d3.format('d'));
d3.select('#data-chart svg').datum(formattedData).call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
formattedData = [
{
key: 'Data', //key - the name of the series.
values: [{ date: 1439963723311, total: 3}, { date: 1441283002275, total: 1}, { date: 1441194849210, total: 2}], //values - represents the array of {x,y} data points
color: '#ff0000' //color - optional: choose your own line color.
}
];