jqchart formatting date correctly
Question
My line data is such that:
var line1 = [[2012-07-06, 4], [2012-07-05, 10], [2012-07-04, 3]];
var line2 = [[2012-07-06, 15], [2012-07-05, 0], [2012-07-04, 9]];
I am having difficulty getting the date to show in the xaxis. While my dates are all yyyy-mm-dd, it keeps showing only years but not even the correct years. It's showing 1991, 1992, 1993, etc.
My axes looks like:
axes:{ xaxis:{ type: 'dateTime', labels: { stringFormat: 'yyyy-mm-dd' } } }
What am I missing?
Solution
I think you have to use the Date()
data type.
See documentation here http://www.jqchart.com/samples/ChartAxes/DateTimeAxis.
Example from their site:
$('#jqChart').jqChart({
title: { text: 'DateTime Axis' },
axes: [
{
type: 'dateTime',
location: 'bottom',
minimum: new Date(2011, 1, 4),
maximum: new Date(2011, 1, 18),
interval: 1,
intervalType: 'days'
}
],
series: [
{
type: 'line',
data: [[new Date(2011, 1, 6), 70], [new Date(2011, 1, 8), 82],
[new Date(2011, 1, 10), 85], [new Date(2011, 1, 12), 70],
[new Date(2011, 1, 14), 65], [new Date(2011, 1, 16), 68]]
}
]
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow