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

onrendered - this.api.data.values() error #665

Closed
DemersM opened this issue Nov 20, 2018 · 3 comments
Closed

onrendered - this.api.data.values() error #665

DemersM opened this issue Nov 20, 2018 · 3 comments
Labels

Comments

@DemersM
Copy link

DemersM commented Nov 20, 2018

there is an error when we try to use this.api.data.values() in the onrendered callback function

https://jsfiddle.net/y09cb1x5/5/

@netil netil added the question label Nov 21, 2018
@netil
Copy link
Member

netil commented Nov 21, 2018

@danelkhen, the use of this.api isn't adequate approach accessing private members.
Anyway, there're 2 options to solve this.

function onrendered() {
   // (1)
    console.log(this.api.data.values.call(this.api, "data1"));

   // (2)
   setTimeout(function() {
       console.log(chart.data.values("data1"));
   }, 0);
}

@DemersM
Copy link
Author

DemersM commented Nov 22, 2018

Thank you for your reply. I understand your point.

Won't it be more easy/logical to pass the chart instance in every callback?

function onrendered(chart) {
    chart.data.values("data1");
}

@netil
Copy link
Member

netil commented Feb 12, 2019

Roughly speaking, there're context inconsistency across all callbackish options. (And is quite complicate change to not break unexpected incompatibility, but at some point this should be arranged)

You can access via this keyword within onrendered callback, which is referring to ChartInternal instance.

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

No branches or pull requests

2 participants