I want to display a time series chart with C3.js
using a date in the format 2015-09-17 18:20:34
and the format string \'%Y-%m-%d %H:%M:%S\'>
I found the solution to my problem:
The format in the axis
object is just to define how the date will be displayed. If you want to specify the format for the date parsing you have to use xFormat
in the data
object.
var chart = c3.generate({
bindto: '#chart',
data: {
x: 'times',
xFormat: '%Y-%m-%d %H:%M:%S', // how the date is parsed
columns: [
['times','2015-09-17 18:20:34','2015-09-17 18:25:42','2015-09-17 18:30:48'],
['data','1539','1546','1546','1550']
]
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d %H:%M:%S' // how the date is displayed
}
}
}
});