leeoniya / leeoniya/uPlot

After continuous magnification, the coordinate axis becomes the same

Open
#691 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
463
PR merge metrics
No merged PRs in 30d

Description

Is there any way to limit the magnification, such as limiting the magnification multiple, or when the selected range is less than a certain value, it is not allowed to enlarge.
Screenshot from 2022-05-10 16-07-32

I try to set scale and set range for each coordinate axis. As in the example, unfortunately, only the x-axis setting takes effect, but the y-axis does not take effect, and the function does not seem to be called.
My option:

{
  cursor: {
    drag: { x: true, y: true, uni: 10, dist: 5 },
  },
  scales: {
    x: {
      time: false,
      min: xRange[0],
      max: xRange[1],
      range: (self, newMin, newMax) => {
        let curMin = self.scales.x.min;
        let curMax = self.scales.x.max;

        // prevent zoom
        if (newMax - newMin < 10) return [curMin, curMax];

        // allow zoom
        return [newMin, newMax];
      },
    },
    y: {
      time: false,
      min: yRange[0],
      max: yRange[1],
      range: (self, newMin, newMax) => {
        let curMin = self.scales.y.min;
        let curMax = self.scales.y.max;

        // prevent zoom
        if (newMax - newMin < 5) return [curMin, curMax];

        // allow zoom
        return [newMin, newMax];
      },
    },
  },
}

My version of uplot is 1.6.13. Thank you very much for your work. This library is very cool.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the scale range callbacks in the supplied configuration and reproduce the continuous magnification using the linked jsfiddle and uPlot 1.6.13. Compare the x- and y-axis behavior, then verify that both configured minimum ranges prevent further enlargement.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.