I am trying to render a simple vertical bar chart using the Ember Charts add on but I can't get it to render on the page. I have been following the tutorial provided here with no luck.
\\ dashboard.hbs
<div class="chart-container">
<h1>text</h1>
</div>
\\ dashboard.js (controller)
import Controller from '@ember/controller';
export default Controller.extend({
ajax: Ember.inject.service(),
init: function() {
this._super;
this.get('ajax')
.request('barchart').then((data)=>{
this.set('bardata', data);
})
}
});
\\ ajax.js (service)
import Service from '@ember/service';
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
export default AjaxService.extend({
host:
'http://server:port/api'
});
When I load the route there is an empty space where I would expect the chart to be.
When I investigate the Network developer tools I can see that the 'barchart' data is succesfully retrieved in the following format:
[
{"value":74,"label":"2017-12-20"},
{"value":16,"label":"2017-12-21"}
]
where value is an integer and label is varchar which seems to be correct as per the documentation.
Console produces the following error:
Uncaught TypeError: Cannot read property 'color' of undefined
at colorable.js:89
at vertical-bar-chart.js:412
at Array.forEach (<anonymous>)
at Class.<anonymous> (vertical-bar-chart.js:411)
at ComputedPropertyPrototype.get (ember-metal.js:3252)
at get (ember-metal.js:2594)
at Class.get (observable.js:37)
at Class.<anonymous> (vertical-bar-chart.js:441)
at ComputedPropertyPrototype.get (ember-metal.js:3252)
at get (ember-metal.js:2594)
I tried adding a manual selectedSeedColor but there was no change in the response.
Aucun commentaire:
Enregistrer un commentaire