I use nvd3 multichart. I have 2 lines and 1 bar chart.
The problem is if I put x equal number everything works fine but in my case x needs to be a date.
When I put the date the bar chart show well but not the lines.
Here is my code:
var testdata = [{
key: 'Stream',
values: [{x: '2015-01-01', y: -0.14459575778442077}, {x: '2015-02-01', y: 1.14459575778442077}, {x: '2015-03-01', y: -0.14459575778442077}]
},
{
key: 'Stream1',
values: [{x: "2015-01-01", y: 2}, {x: "2015-02-01", y: 1}, {x: "2015-03-01", y: 14}]
},
{
key: 'Stream2',
values: [{x: "2015-01-01", y: 0.14459575778442077}, {x: "2015-02-01", y: 1.45}, {x: "2015-03-01", y: 0.14459575778442077}]
}
];
testdata[0].type = "line";
testdata[0].yAxis = 1;
testdata[1].type = "line";
testdata[1].yAxis = 1;
testdata[2].type = "bar";
testdata[2].yAxis = 1;
nv.addGraph(function() {
var chart = nv.models.multiChart()
.margin({top: 30, right: 60, bottom: 50, left: 70})
.color(d3.scale.category10().range());
chart.xAxis.tickFormat(function(d) {
return d3.time.format('%m/%d/%y')(new Date(d))
});
chart.yAxis1.tickFormat(d3.format(',.1f'));
d3.select('#chart1 svg')
.datum(testdata)
.transition().duration(500).call(chart);
return chart;
});
Here is the error I got in the console:
Error: Invalid value for <path> attribute transform="translate(NaN,841)"
Error: Invalid value for <path> attribute transform="translate(NaN,764.3481053004498)"
Error: Invalid value for <path> attribute transform="translate(NaN,841)"
Error: Invalid value for <path> attribute transform="translate(NaN,713.4880468001999)"
Error: Invalid value for <path> attribute transform="translate(NaN,772.9453840335499)"
Error: Invalid value for <path> attribute transform="translate(NaN,0)"
Uncaught TypeError: Cannot read property 'x' of null
Does anyone know how I can make it works with my data format? Thanks