ember-cli-chart icon indicating copy to clipboard operation
ember-cli-chart copied to clipboard

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

Open pRatikSathaye opened this issue 5 years ago • 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?

pRatikSathaye avatar May 21 '19 05:05 pRatikSathaye

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

pRatikSathaye avatar May 21 '19 08:05 pRatikSathaye

this was fixed by https://github.com/aomran/ember-cli-chart/pull/104

aomran avatar Aug 03 '19 23:08 aomran

Thank you @aomran

pRatikSathaye avatar Aug 05 '19 08:08 pRatikSathaye