I'm having issues getting c3js' timeseries to work with my json data. Right now I'm getting a few errors, the most significant of which is "Error: Invalid value for attribute x="NaN". It appears that my x values aren't being parsed correctly despite the fact that they are in the specified format. What could be the problem?
The code is here:
var chart = c3.generate({
data: {
json: [
{"key": "2015-03-27", "value": "261"},
{"key": "2015-03-28", "value": "177"},
{"key": "2015-03-29", "value": "145"},
{"key": "2015-03-30", "value": "145"},
{"key": "2015-03-31", "value": "145"},
{"key": "2015-04-01", "value": "146"},
{"key": "2015-04-02", "value": "125"},
{"key": "2015-04-03", "value": "125"},
{"key": "2015-04-04", "value": "133"},
{"key": "2015-04-05", "value": "89"},
{"key": "2015-04-06", "value": "89"},
{"key": "2015-04-07", "value": "87"},
{"key": "2015-04-08", "value": "93"},
{"key": "2015-04-09", "value": "163"},
{"key": "2015-04-10", "value": "121"},
{"key": "2015-04-11", "value": "153"},
{"key": "2015-04-12", "value": "105"},
{"key": "2015-04-13", "value": "105"},
{"key": "2015-04-14", "value": "104"},
{"key": "2015-04-15", "value": "113"},
{"key": "2015-04-16", "value": "97"},
{"key": "2015-04-17", "value": "114"},
{"key": "2015-04-18", "value": "123"},
{"key": "2015-04-19", "value": "118"},
{"key": "2015-04-20", "value": "118"},
{"key": "2015-04-21", "value": "114"},
{"key": "2015-04-22", "value": "112"},
],
keys: {
x: 'key',
xFormat: '%Y-%m-%d',
value: ['value']
},
type: 'area'
},
axis: {
y: {
label: { //ADD
text: 'Y Label',
position: 'outer-middle'
}
},
x: {
label: {
text: 'X Label',
position: 'outer-center',
type: 'timeseries',
tick: {
format: '%Y-%m-%d'
}
}
}
},
legend: {
position: 'right'
},
padding: {
bottom: 20
}
});
{"key": "2015-03-27", "value": "261"},
should be
{"key": 20150327, "value": "261"},
since it's expecting a number and the -
can't be parsed into a number