chartjs-plugin-crosshair icon indicating copy to clipboard operation
chartjs-plugin-crosshair copied to clipboard

Zoom dont work on line chart

Open nduginets opened this issue 5 years ago • 6 comments

Hi, there is a problem that the zoom does not work for graphs with the type of "line". I use several graphs, and I need synchronization of the crosshair and such synchronization with the zoom, now the crosshair is working properly, but after performing the zoom, all data disappears from the graphs. Any idea how to fix this?

nduginets avatar Feb 28 '19 20:02 nduginets

@nduginets did you ever resolve this issue? I am having the same problem.

dszidi avatar Jul 25 '19 15:07 dszidi

https://github.com/AbelHeinsbroek/chartjs-plugin-crosshair/issues/15

anatoly314 avatar Aug 05 '19 13:08 anatoly314

+1

maxwell-oroark avatar Aug 31 '20 18:08 maxwell-oroark

Crazy update... I got this to work by debouncing my onClick handler on the component. e.g.

<Line onClick={() => debounce(myFunc(), { trailing: true }) } /> 

Crazier still - I thought for sure the plugin just wasn't happy with having zoom + onClick handler but when you remove the onClick handler you get the same bug. No data on chart. So you need an onClick handler AND you need to debounce it for it to work with line component. Wow.

cc @anatoly314 @dszidi @nduginets @AbelHeinsbroek

maxwell-oroark avatar Mar 08 '21 20:03 maxwell-oroark

I'm guessing that by waiting for a bit and then forcing the Line component to update is what's causing this ^ to work

maxwell-oroark avatar Mar 08 '21 21:03 maxwell-oroark

Still experiencing this with Vue in 2024. The problem was in X-scale that used date adapter: seems like this plugin returns floats as start and end values for zooming and this throws adapter in disarray. For now I disabled the adapter (i.e. switch to text date labels instead of actual dates), and zooming works fine.

scales: {
            x: {
                // type: 'time',
                // time: {
                //     unit: 'hour',
                //     displayFormats: { hour: 'MMM D, HH:mm' }
                // },
                // adapter: { date: { locale: 'en-GB' } },
                title: {
                    display: true,
                    text: 'Time'
                }
            },

movy avatar Apr 18 '24 03:04 movy