dimanche 16 octobre 2016

To display data from mock server into chartjs using ember

I have data coming from mock-server, which I can view using ember inspector. I need to display these data in bar chart using chartjs.

This is my code from component - chart.js

import Ember from 'ember';

export default Ember.Component.extend({
   updateGraph: function(){
    var barcontent = this.get('timeSeriesBarContent');
    console.log('updateGraph called');
    eventdata.forEach(function(item,index){
     timeSeriesBarContent.append({time: item.timeStamp, label: item.eventType, value: (item.event +" : "+ item.device) })
    });
  }.observes('eventdata'),
  timeSeriesBarContent: [{}];

And this is my code from template - chart.hbs



The bar chart gets displayed if I use static data inside

timeSeriesBarContent: [{
time: d3.time.format('%Y-%m-%d').parse("2013-05-15"),
       label: "test data",
       value: 49668,
       type: "money"
}];

But I am not being able to load the data coming from mock-server. Can anyone help me with this please?




Aucun commentaire:

Enregistrer un commentaire