Reputation: 163
I have a problem with jQuery plot chart it works fine but when I load data from php and json it doesnt work it show me nothing.
This is my result from php
[{"label":"Patrik","data":4},{"label":"Miroslav","data":28}]
And flot
$.getJSON( "http://"+window.location.hostname+"/dashboard/getChartData", function( data ) {
console.log(data);
var options = {
series: {
bars: {
show: true
}
},
bars: {
align: "center",
barWidth: 0.5
},
xaxis: {
ticks: data.title
},
legend: {
noColumns: 0,
labelBoxBorderColor: "#fff",
position: "nw"
},
grid: {
hoverable: true,
borderWidth: 1,
borderColor: "#cecece",
backgroundColor: { colors: ["#ffffff", "#EDF5FF"] }
}
};
$.plot($("#chart_1_1"), [ data ], options);
});
Upvotes: 0
Views: 165
Reputation: 2271
The Json Data that You Receive needs to be converted to Array of arrays Format [[key,value],[key,value]]
before you can give it to jqplot. Currently You are having array of objects
Upvotes: 1