question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Zoom" action shouldn't escape the "Pan" range bounds

See original GitHub issue

I’m currently working to implement a chart with chartjs-plugin-streaming and chartjs-plugin-zoom to show real time data from a remote source, but I’m having a few issues with the zoom and pan side of my chart…

I’ve created a JSFiddle inspired by the chart inside my app, showing the behaviour I’m having trouble with. to summarise the configuration:

  • my app has a buffer with 5 minutes’ worth of data
  • this is shown in datasets linked to the realtime X-axis provided by the streaming plugin
  • I have the zoom plugin’s pan.rangeMin set to 0 and pan.rangeMax set to 5 * 60 * 1000 (matching the buffer duration)
  • I’m only using pan and zoom on the X-axis, with Y-axis scaling controlled automatically by Chart.js

when I zoom my chart out, the chart zooms central to the point it was zoomed from (as expected), but if either the left or right bound of the “zoom” range extends past the bounds of the “pan” range, the chart retains that visible range.

at the point, trying to pan either left or right, only then is the pan location updated to fall within it’s defined bounds.

I feel like this is an issue in the zooming plugin though, because I would expect the “zoom” action to stay within the “pan” bounds of the chart.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
benmccanncommented, Jun 24, 2019

Can you set zoom.rangeMin = pan.rangeMin and zoom.rangeMax = pan.rangeMax?

You chart sounds cool! I’d love to see it if it’s publicly available to share!

0reactions
ZaLiTHkAcommented, Jul 28, 2020

so, [looks at the date] I finally got a chance to get back to this… anyways, I got my desired behaviour working, my solution is two-fold:

  1. I’m updating the pan “rangeMax” dynamically based on current chart data, in such a way that it prevents the “pan” action from moving past either end of the currently rendered chart data.
  2. on panning or zooming, I clamp the chart’s “delay” value between 0 and a “sensible max delay” that I’m recalculating based on currently rendered chart data.

I implemented this in my hybrid mobile project and it’s working pretty damn well, so I’ve updated my original JSFiddle example to share it back here again. 😃

edit: found a small issue with panning/zooming a paused streaming chart, so I tweaked it a bit more, so now the duration calculations are based entirely on chart data, not “now vs earliest data timestamp”… my chart data source pauses when I pause the chart, so this tweak may be pretty specific.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Massive sandbox/weapon changes announced in the TWAB.
Honestly nerfing rangefinder, and the base range of Out of Bounds is stupid. ... Escape velocity has less range than most 15 zoom...
Read more >
Improve Any Basketball Offense or Set Play - YouTube
In this video, you will learn about a simple but highly effective motion offense action that will get you more points, the ZOOM...
Read more >
Pointer Events - W3C
9.1 The touch-action CSS property; 9.2 Determining supported touch ... agent touch behaviors (such as panning or zooming) so that all events ...
Read more >
External Dynamic List - Palo Alto Networks
No limits are enforced for the number of IP addresses per list. When the maximum supported ... An external dynamic list should not...
Read more >
Can I prevent panning Leaflet map out of the world's edge?
Leaflet allows you to control how much the map resists being dragged out of bounds with the maxBoundsViscosity option (value: 0 to 1)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found