-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Provide a way to lookup chart instance given canvas element #7236
Comments
A better way to do this might be if we stored a map from canvas ID to chart instance internally. I do see that |
Can you give an example of how this would work please? |
We'd provide some API like |
Sounds great, would love to see that implemented. Would help my current predicament massively |
|
This works well enough, but would be nice if there was a more intuitive method |
i just named my canvas myself, and I know how to find it...easy chartjs doesn't know I named it |
Feature Proposal
Upon instantiation of the Chart, it would be great if a reference to the Chart instance could be tagged to the
HTMLCanvasElement
for later usage, rather than having to use hacky ways to access them.Feature Use Case
I'm looking for a way to reference the instance of one of my charts which is defined in a different JS module to the one I want to reference it in. Exporting the instance doesn't seem to work, and I took a look at @vijayj's implementation, and it would've worked fine, but I push the Chart instances to the
window.charts
AFTER importing my other JS module, so when I came to accesswindow.charts
, it's empty until my other JS module is loaded and executed.ChartJS already adds a
$chartjs
property onto theHTMLCanvasElement
once instantiated, so it would make sense to add the instance to that property.Possible Implementation
index.html
module1.js
module2.js
The text was updated successfully, but these errors were encountered: