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

Dim other series when hovering #9899

Closed
oysteinmoseng opened this issue Jan 16, 2019 · 2 comments
Closed

Dim other series when hovering #9899

oysteinmoseng opened this issue Jan 16, 2019 · 2 comments
Assignees
Milestone

Comments

@oysteinmoseng
Copy link
Member

For accessibility and usability purposes it would be great to have an option to dim/fade other series when a series is hovered. This could also be reflected when hovering over the series' legend item.

@TorsteinHonsi
Copy link
Collaborator

In styled mode it is already implemented, purely by CSS and the :not selector.

Scope

In non-styled mode, this feature should be available for whatever item is represented in the legend. So for pies and such, which have legendType: 'point', hovering a point should dim other points. For other series types (like line, area), where the full data set is in focus, hovering should dim other series.

Implementation

We need an option on the state, for example plotOptions.pie.states.hover.otherOpacity = 0.1.

Then, add logic to the setState function (or fire a setState event that we can listen to) that loops over all items and sets the opacity. Here's a simple implementation for points, but we also need to consider other element than point.graphic - like point.dataLabel etc.:

            setState: function (state) {
                // Make this data stand out by setting the opacity of the others
                this.series.points.forEach(function (otherPoint) {
                    if (otherPoint !== this) {
                        otherPoint.graphic.animate(
                            { opacity: state === 'hover' ? 0.1 : 1 },
                            this.series.options.states[state || 'normal'].animation
                        );
                    }
                }, this);
            },

@oysteinmoseng
Copy link
Member Author

After discussion, we landed on introducing a new series state inactive that would be applied to other series when a series is hovered.

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

No branches or pull requests

3 participants