-
Notifications
You must be signed in to change notification settings - Fork 341
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
Hiding annotations along with datasets #244
Comments
I think |
@joshkel @kurkle I have some doubts about the proposed solution based on new property The dataset index can change during the lyfe cycle of a chart (a dataset can be removed and add new dataset at the same index of the array). This could create an inconsistent behavior. The current CHART.JS implementation doesn 't have any configurable unique id at dataset level because the datasets are managed in a array. CHART.JS should change the dataset property in order to have an object (where every property contains a dataset) like has been done for the scales, in version 3. But in my opinion it's a disruptive change that in my opinion does not make sense. You should add a custom property into the dataset (like Nevertheless, like other plugins, see Datalabels, you should configure the plugin at dataset level. In this way, you don't need to configure any index or key. In this way, the annotation can work strictly to the life cycle of the dataset. About |
Good points @stockiNail. I'm not sure if dataset level config works currently, but that would seem like a good approach. |
@kurkle No, it doesn't, at least when I had a look to the plugin (I have re-written it in java for my project), 1 month ago. Anyway, another change to do, before addressing the plugin options at dataset level, it's to remove the usage of array into configuration (see chartjs/Chart.js#7754) because the configuration can not be merged correctly. In my java implementation I have removed the array going to a object and every annotation has got own id (like the scales in CHART.JS version 3). Having that, you should think to start implementing the configuration at dataset level because in this way you can integrate the configuration of the other levels. Maybe that's not the right issue (I'm gonna open some new ones, when I have more time than now) about some missing capabilities that I implemented in my project:
I didn't raise any PR or issue, because the project looked like unmaintained |
@kurkle I am gonna submit a PR about this issue:
Make sense? |
@kurkle @joshkel PR #246 has been submitted. I found an issue on the signature of the CHART.JS plugin interface methods ( As usual, I'm not a javascript coder, therefore feel free to help me to improve that code is needed. |
I have some annotations that are closely tied with particular datasets, so I'd like to hide them whenever the user hides the corresponding dataset by clicking on the dataset's legend item.
I can think of a couple of possible ways of doing this:
Would you be interested in a PR implementing either a direct way to hide annotations (via an
enabled
ordisplay
orhidden
boolean property) or implementing the datasetIndex approach? The datasetIndex approach makes a lot of sense to me, but if that's too special-purpose to want to support in chartjs-plugin-annotation, then that's fine.Thank you.
The text was updated successfully, but these errors were encountered: