chartjs/chartjs-plugin-zoom

Inconsistent behavior when using limits and new data points

estanglerbm opened this issue · 0 comments

Let's say that you have a chart with limits min/max = 'original', so that panning/zooming never exceeds the range of data points.

Then new data points arrive. (Like another day of data points with time x-axis, and we drop the oldest day of data points.)

  1. In the initial chart display--or after a resetZoom()--when the new data points arrive, they get displayed.

  2. But if you're zoomed and/or panned, and new data points arrive, then you cannot visit the new data points (by zooming out or panning over); the original range of data points is set in stone due to storeOriginalScaleLimits().

A partial workaround for zooming out is to call resetZoom() once you've zoomed all the way out:

onZoomComplete: ({chart}) => {

	if( !this.is_resetting_zoom && chart.getZoomLevel() == 1 ) {

		this.is_resetting_zoom = true;
		chart.resetZoom();
		this.is_resetting_zoom = false;
	}
}

No workaround for when you're zoomed in or panning.

I know you could update limits min/max with the range of the new data (like in #649), as it arrives, but that information may not be available, and not as convenient.