leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.48k stars 370 forks source link

Fix null error in syncLegend-method #900

Closed progitect closed 3 months ago

progitect commented 4 months ago

This pull request fixes a null error in the syncLegend function. This error would occur when syncLegend was called before the legends were fully loaded/created.

leeoniya commented 4 months ago

thanks for the PR :)

before the legends were fully loaded/created.

would you mind making a jsfiddle similar to https://jsfiddle.net/0bvks7cw/1/ that reproduces this issue?

i think there might be a better way to fix this but i'll need to verify that it works.

progitect commented 4 months ago

Thanks for your input. I will try to reproduce it in a jsfiddle, but I do not have the time at this moment to create it. Will update when I have reproduced it.

progitect commented 3 months ago

After trying to reproduce this issue in a jsfiddle, it turned out that the problem was only occurring when syncing to a timeline chart (https://leeoniya.github.io/uPlot/demos/timeline-discrete.html) like the 'Merged same consecutive states' one. I have fixed it with some extra code in the timeline plug-in. Basically I added some code to force that the setCursor hook is only executed when all series are drawn.

As the isssue is solved I will close this PR,