chartjs / chartjs-plugin-zoom

Zoom and pan plugin for Chart.js
MIT License
598 stars 327 forks source link

Feature request: Add maxRange option #757

Closed iliubinskii closed 1 year ago

iliubinskii commented 1 year ago

Hi,

You already have minRange option hear:

export interface ScaleLimits {
  min?: number | 'original';
  max?: number | 'original';
  minRange?: number;
}

I see the reason why you didn't add maxRange. This is because you assumed that user starts from seeing all the data. So, there is no reason to limit him in returning to this initial state.

However, chart.js has min/max options:

  scales: {
    x: { min: 0, max: 20 },
    y: { min: 0, max: 100 }
  }

In this case the chart will start from showing 20 points, even if data contains 10000 points.

Then I may want to zoom in to 10 points at most and to zoom out to 1000 points at most. I may use minRange range for the first (10 points min). And I could use maxRange for the second (1000 points max).

Thank you for great plugin!