adopted-ember-addons/ember-cli-chart

updating options does not override scales.yAxes[0].ticks.callback

Opened this issue · 3 comments

Hello,

I have embedded ember-cli-chart in my hbs file as

<div class="chart">
    {{ember-chart type='line' data=data options=options}}
</div>

In my component file I have created an options property as

options: computed('metric', function() {
  let opts = defaultOptions;
  if (this.metric === 'height') {
     opts.scales.yAxes = [{
         ticks: {
             callback: function(value, index, values) {
              // code to return labels
             }
        }
     }]
  } else {
     opts.scales.yAxes = [{
         ticks: {
             callback: function(item, index, items) {
                 // code to return labels
             }
        }
     }]
     return opts;
  }
});

So when first time chart loads it renders correct labels and if I change the metric then the same callback is getting used and renders same labels but with updated data values.
Can anyone help on this?

Please correct me if I am wrong.
In chart.js documentation,
https://www.chartjs.org/docs/latest/developers/updates.html
It is mentioned that prior to v2.6 we need to use chart.config.data and chart.config.options to update data and options values.
but if we are using chart.js v2.7.0, then why we are using chart.config.data and chart.config.options instead of using chart.options and chart.data.
https://github.com/aomran/ember-cli-chart/blob/master/addon/components/ember-chart.js#L40-L41

this was fixed by #104

Thank you @aomran