-
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
Add support for hiding axis when a dataset visibility is toggled #5885
Add support for hiding axis when a dataset visibility is toggled #5885
Conversation
To me, it would appear logical for an axis with no referencing visible datasets to be hidden (by default in next major?) . Maybe display could be set to 'auto'? I dislike another configuration option for this. |
I agree entirely. Showing an axis for hidden data is confusing, and just adds clutter. I just didn't want to change any default behaviour as part of this PR 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer display: 'auto'
instead of introducing a new option which is redundant with display
:
display: true
(default): always display the axisdisplay: false
: never display the axisdisplay: 'auto'
: display the axis only if there is at least one visible associated dataset
The scale should also not participate to the layout when hidden so everywhere we check scale.options.display
, we also need to apply this new logic (thus the _isVisible()
refactor).
We also need to consider situations where all datasets are hidden: how the chart behaves in that case?
Thanks for the review; much tidier. Recommended changes made, new Fiddle at https://jsfiddle.net/jyontsh6/. If this seems like a good thing to do, I'll start working on some tests 👍 |
|
Thanks @davesalomon, it looks good to me! I would go ahead and write unit tests for this new feature. |
I like it. Just needs tests |
This looks good unless it changes the current default behavior. |
Tests added; checking that Review comments worked in as well. To confirm, this PR doesn't change any default behaviour; |
I agree, later we should find a way to prevent the call of |
Tests checking the geometry added, and |
Thanks @davesalomon |
👍, my pleasure, and thank you again for all your work going in to this excellent library! |
…tjs#5885) When `display: 'auto'`, the axis is visible only if at least one associated dataset is visible.
I'd like to have an option to hide an axis on a line graph when a dataset visibility is toggled off/on (by clicking the legend).
I've attempted to add support for this for my exact use case; I'm happy to build it out further if needed.
JS Fiddle example: https://jsfiddle.net/y0whvnvk/99/
Note that the 'Foo' dataset is hidden by default. Toggling it on will display the axis. Toggling it back off will re-hide the axis.