Let's not ignore NaN
Feature Proposal
I expect to draw an image similar to the one below, where the dataset contains some NaN points that can help deep learning practitioners identify whether situations like gradient explosion have occurred:
However, I did not find any relevant API in the Chart.js documentation that prevents NaN from being ignored. Is it possible to add a similar feature? Many thanks!
Possible Implementation
No response
You can set the spanGaps property to true in the dataset.
This will give you the result you want.
https://www.chartjs.org/docs/4.5.0/charts/line.html#line-styling
You can set the
spanGapsproperty totruein the dataset.
Thank you for your reply! When I set it to True,the chart looks like:
The point with index 5 is NaN, but I can't get the element through this:
const position = getRelativePosition(e, chart)
// NaN points do not appear in the items.
const items = Interaction.modes.nearest(chart, e, { intersect: false, axis: 'x' }, useFinalPosition)
So this interaction is like:
https://github.com/user-attachments/assets/415313f7-3f3a-4f8f-b83e-9642e42631d3
Is there any API that allows me to locate the points with NaN? After all, this is a canvas, and I can draw it myself.
Sorry for the late reply but as far as I know there is not such an API. But with some custom code you can get every value on the line including your nan points. You can customize this so that it will suit your requirements. https://codepen.io/kurkle/pen/WNpdwgE