Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pRatikSathaye opened this issue May 21, 2019 · 3 comments
Open

Comments

@pRatikSathaye
Copy link

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
Copy link
Author

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

@aomran
Copy link
Collaborator

aomran commented Aug 3, 2019

this was fixed by #104

@pRatikSathaye
Copy link
Author

Thank you @aomran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants