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

Zoom speed on large data #356

Closed
diamond95 opened this issue May 13, 2020 · 6 comments · Fixed by #434
Closed

Zoom speed on large data #356

diamond95 opened this issue May 13, 2020 · 6 comments · Fixed by #434

Comments

@diamond95
Copy link

Hi.

I'm trying to make faster zooming when there is large data in chart.

My chart looks like this: https://imgur.com/a/9EvD3ua

So problem is when I'm trying to zoom in, I must scroll too much ( 10 seconds ) to zoom in to maximum.

I've used this props:
zoom: { enabled: true, drag: false, mode: "x", speed: 0.1, sensitivity: 0.01 },

Is there any option, solution for faster zooming ?
Thanks!

@ghost
Copy link

ghost commented May 15, 2020

Hi,

had exactly the same issue. After some searches on GitHub and rest of the web, I can say that there is actually no solution for this. Best you can do is setting these options:
zoom: {
enabled: true,
mode: 'x',
speed: 1,
threshold: 0,
sensitivity: 0
}

cf: speed and sensitivity concerned.
That will allow you to faster zoom, but I know that it remains slow.
It seems that chartjs zoom will be releasing an update soon, we can hope that they will change this.

@datainvestor
Copy link

I faced similar problem. I think it was sort of resolved when I changed X-axis to be of type "time"

 xAxes: [
            {
              type: "time"
            }
          ],

And that made the zoom and panning quite smooth.

@DjovDev
Copy link

DjovDev commented Jun 17, 2020

I faced similar problem. I think it was sort of resolved when I changed X-axis to be of type "time"

 xAxes: [
            {
              type: "time"
            }
          ],

And that made the zoom and panning quite smooth.

This does not resolve anything for me.

@diamond95
Copy link
Author

I faced similar problem. I think it was sort of resolved when I changed X-axis to be of type "time"

 xAxes: [
            {
              type: "time"
            }
          ],

And that made the zoom and panning quite smooth.

Same, it's doing nothing 👎

@DjovDev
Copy link

DjovDev commented Jun 18, 2020

I got it to work :)
You need to populate your labels (x axis) with Moment objects
Then I defined the xAxes like so:
xAxes: [{ type: "time", time: { format: 'HH:mm', unit: 'minute', displayFormats: { minute: 'HH:mm' } }

@michael-harley
Copy link

michael-harley commented Feb 14, 2021

I got this to work after a lot of trial and error looking for answers.
In case anyone of you wondering how to make it work (Zoom faster with type time)

{
    scales: {
        xAxes: [
        {
            type: "time",
            time: { unit: "day", displayFormats: { day: "DD-MM-YYYY" } },
            // distribution: "series", // Careful with this, this creates another problem when you pan the chart. Issue: #361
        },
        ],
        yAxes: [
        {
            ticks: { beginAtZero: true },
        },
        ],
    },
    plugins: {
        zoom: {
        pan: {
            enabled: true,
            mode: "x",
            speed: 15,
            threshold: 5,
            onPan: (x) => console.log("Pan!", x),
            onPanComplete: (x) => console.log("Complete Pan!", x),
        },
        zoom: {
            enabled: true,
            // drag: {
            //   animationDuration: 1000,
            // },
            mode: "x",
            speed: 0.1,
            threshold: 2,
            sensitivity: 3,
            onZoom: (x) => console.log("Zoom!", x),
            onZoomComplete: (x) => console.log("Complete Zoom!", x),
        },
        },
    },
}

Related Issue:

  1. Distribution series problem when Panning the chart. Prevent scale change on pan #361

@kurkle kurkle linked a pull request Mar 8, 2021 that will close this issue
@kurkle kurkle closed this as completed Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants