AbelHeinsbroek/chartjs-plugin-crosshair

How to update zoomed graph datapoints if dataset is is shifted in x axis ?

Opened this issue · 0 comments

Hi, first of all thanks for your work on this plugin!
Is there any way to update the zoomed area to reload the datapoints ?

I have following problem:
I have 2 wattage graphs from fit files in 1 canvas.
Sometimes the recordings are slightly time shifted, so i implemented the possibility to shift the x axis timestamps to be able to move the graphs to match them.

The moving is implemented through manipulation of actual data ( the timestamps are epoch in milliseconds):

 data.map((element) => {
        element["x"] =  element["x"] - 1000
        return element["x"]["y"];
      });
chart.update();

The shifting works fine and graphs gets updated but when the graph moves no additional datapoints where loaded.
So is there any way to call something like chart.crosshair.update(); to tell the plugin to reload the datapoints for the selected time range ?

Here a video wich shows the problem:
( If i zoom out and in again after shifting, all datapoints are present but not if i shift zoomed in)

Bildschirmaufnahme.2023-12-15.um.08.30.36.mp4

I tried to find something in code of plugin, but i´m not a js developer and didn't understand it well.
Some help would be great, thanks in advanced !