Question

I am trying to plot some data correctly using Morris Charts.

The data & chart look like this: http://cl.ly/LDZC enter image description here

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']
            });
  });

};

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top