I'm trying to plot a graph using jquery flot plugin with JSON data. What I need to do is.
- When the page loads it will makes an ajax call and receives json data from the server.
- from the received json I need to add 'x' and 'y' axis label. And I want to draw the graph
- according to points in json data.
- 'Y' axis must have values from 0 to 100
- 'X' axis should have only json data value
My Script is:
//var maxDate = new Date();
//var minDate = new Date();
var options = {
series: {
lines: {
show: true
},
points: {
show: true
}
},
grid: {
hoverable: true,
clickable: true
},
xaxis: { //min: minDate.setMonth(maxDate.getMonth() - 12),
//max: maxDate,
mode: "time",
monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
timeformat: "%b(%Y)"
},
yaxis: {
min: 0,
max: 100,
ticks: 10
}
var data = [];
var placeholder = $("#trigo");
var dataurl = 'cprogress.php?action=overall';
// then fetch the data with jQuery
function onDataReceived(series) {
data.push(series);
$.plot(placeholder, data, options);
setData(data);
}
$.ajax({
url: dataurl,
method: 'GET',
dataType: 'json',
success: onDataReceived
});
Now my graph Looks like this

And the JSON
[["2013-11-05",8.3333333333333],["2013-12-05",0]]
What I want to print is November(2013) and December(2013) and have to draw graph from 8.33 to 0 Now it is print January(1970) Why I don't know.
Please any one help me to solve this issue. I'm struggling to solve this from two days. Thanks...