Reputation: 401
I am trying to plot some data correctly using Morris Charts.
The data & chart look like this: http://cl.ly/LDZC
The data coming back seems to be correct, however it looks like the series are not mapping correctly. Not sure why there are those undefined series..
heres the Javascript
var getChartData = function() {
$.get('/dashboard/chart_data', 'json')
.done(function(data) {
alert(JSON.stringify(data))
Morris.Line({
element: 'orders_chart',
data: data,
xkey: 'purchased_at',
ykeys: 'price',
labels: ['Revenue']
});
});
};
Upvotes: 2
Views: 1454
Reputation: 1039
Try change the line for your coding using $.parseJSON(your_json_data);
Morris.Line({
element: 'orders_chart',
data: $.parseJSON(data),
xkey: 'purchased_at',
ykeys: 'price',
labels: ['Revenue']
});
i have similar problem using this chart. You just need to parse the JSON object from the callback.
Upvotes: 2