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

getElementsAtEventForMode does not return elements with null data #11693

Open
halvtomat opened this issue Feb 29, 2024 · 3 comments
Open

getElementsAtEventForMode does not return elements with null data #11693

halvtomat opened this issue Feb 29, 2024 · 3 comments

Comments

@halvtomat
Copy link

halvtomat commented Feb 29, 2024

Expected behavior

I expect the method to return elements at the event position regardless of the values in the data. (Even with includeInvisible = true)

I need the elements to sync a crosshair in other graphs based on the cursor location in this graph so whatever the element data values are is not relevant for my use case.

I understand that this might be expected or desired behavior in all cases but it should at least be optional.

The problem stems from these 2 code snippets in the following files.

core/core.interaction.js

 if (!element.skip) {
        handler(element, index, j);
      }

src/controllers/controller.line.js

      const parsed = this.getParsed(i);
      const nullData = isNullOrUndef(parsed[vAxis]);
      const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);
      const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);

      properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;

Current behavior

The method filteres out elements that are null from the results.

Reproducible sample

https://codepen.io/halvtomat/pen/vYMYyMR

Optional extra steps/info to reproduce

Check console for elements at mouse position, drag the mouse over the area with null points, console should be filled with ELEMENTS []

Possible solution

No response

Context

No response

chart.js version

v4.2.1

Browser name and version

No response

Link to your project

No response

@LeeLenaleee
Copy link
Collaborator

You linked the template reproducible sample, can you update it to your correct reproducible sample?

@halvtomat
Copy link
Author

You linked the template reproducible sample, can you update it to your correct reproducible sample?

Sorry, apparently I didn't save my example, fixing ASAP

@halvtomat
Copy link
Author

@LeeLenaleee Updated now!

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

2 participants