jeudi 23 juillet 2015

Setting the chart type using a computed property with Ember Highcharts

I'm using Ember Highcharts in my app and I'm trying to display a different type of chart depending on the JSON response that I receive.

I was going to use a computed property in my controller to return the correct value for the "type" property, but this doesn't seem to work.

This:

chartOptions: {
  chart: {
    type: 'line',
    height: 550,
    zoomType: 'x',
},
...

works as expected with a hard-coded value, but:

chartOptions: {
  chart: {
    type: Ember.computed(function() {
      return 'line';
    }),
    height: 550,
    zoomType: 'x',
  },
...

Gives me the following error:

Uncaught Highcharts error #17: http://ift.tt/1KmJDXy

(which is because the type value is invalid)

I'm sure there is a better way to do this!




Aucun commentaire:

Enregistrer un commentaire