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

Handling overlapping labels #356

Open
LondonAppDev opened this issue Dec 12, 2022 · 0 comments
Open

Handling overlapping labels #356

LondonAppDev opened this issue Dec 12, 2022 · 0 comments

Comments

@LondonAppDev
Copy link

Hello! I'm using this plugin to show data labels on a scatter graph.

Here is a fully working example on Codepen: https://codepen.io/LondonAppDev/pen/oNyReVr

I want to implement a "bring to the front" effect of labels when you hover over them. So all labels are visible and overlap, but when I hover over a point/label it is brought to the foreground.

After reading the docs, I see that the order is determined using the dataIndex and then datasetIndex, so I tried to implement it by adding the following to options.plugins.datalabels.labels.value:

    listeners: {
        enter: function(context) {
          context.dataIndex = 999;
          context.datasetIndex = 999;
          return true;
        },
        leave: function(context) {
          context.dataIndex = 0;
          context.datasetIndex = 0;
          return true;
        }
      }

This unfortunately doesn't work, it just seems to crash when I hover.

Does anyone know if this is possible to achieve?

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

No branches or pull requests

1 participant