0👍
You need to connect your component with some data and data comes from the Route
… In your Route
‘s model
hook, you should return the records you have retrieved from the server. In your template, use something like {{time-series-chart barData=model}}
or some sub-object of your model.
Remember the Route
is responsible for hooking up the data to your component in the route’s template. So:
- Route’s
model
hook returns records from the store - Route’s template contains the component tag, connecting the component to the data.
0👍
- where is
eventdata
is defined , you need to use get function to access propertiesthis.get('eventdata')
- it looks
eventdata
is an array so your observer should beobserves('eventdata.[]'),
only then this will be triggered for every time new item is added/removed. -
You can define
timeSeriesBarContent:[]
inside init() by overriding and inupdateGraph
method instead ofappend
try to usepushObject
method only then this will update bounding template.export default Ember.Component.extend({ timeSeriesBarContent: [], eventData: [], init() { this._super(...arguments); this.set('timeSeriesBarContent', []); this.set('eventData', []); }, updateGraph: Ember.on('init', Ember.observer('eventdata.[]', function() { var barcontent = this.get('timeSeriesBarContent'); console.log('updateGraph called'); this.get('eventdata').forEach(function(item, index) { barcontent.pushObject({ 'time': item.timeStamp, 'label': item.eventType, 'value': item.event + " : " + item.device }) }); })),
});
- Chartjs-Chartjs how to update dynamically data from database(Chartjs cant get the data)
- Chartjs-ChartJS – aligning axis labels after rotation
Source:stackexchange.com