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

Scale issue with scale["y"].auto set as function #648

Open
Stinger-au opened this issue Jan 10, 2022 · 2 comments
Open

Scale issue with scale["y"].auto set as function #648

Stinger-au opened this issue Jan 10, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Stinger-au
Copy link

Currently, when I scale my x-axis only by dragging, my y-scale becomes invalid (essentially disappears).

In my options I have

      cursor: {
        drag: {
          x: true,
          y: true,
          dist: 8,
          uni: 15
        },

and

      scales: {
        x: { time: false },
	y: { auto: (_u,resetScales) => resetScales }
      },

My intent for this is for the plot to autoscale y when zooming full or changing data but not to autoscale when manually zooming.

I was able to get my desired outcome by adding extra checks against auto inside of setScales() specifically :
on line 1213

else if (wsc.auto(self, viaAutoScaleX)) { 
	      wsc.min = inf;
	      wsc.max = -inf;
}

and also on line 1277

if (wsc.auto(self, viaAutoScaleX) && wsc.from == null && (psc == null || psc.min == null)) {
	let minMax = wsc.range(
		self,
		wsc.min ==  inf ? null : wsc.min,
		wsc.max == -inf ? null : wsc.max,
		k
	);
	wsc.min = minMax[0];
	wsc.max = minMax[1];
}

Although there might be other places where this might need to be done also if this method makes sense.

@leeoniya
Copy link
Owner

awesome fix 👍, thanks!

@leeoniya
Copy link
Owner

leeoniya commented Jan 12, 2022

had to revert this for now since it breaks auto: false scales that implement e.g. scale.range: [0, 100].

there's quite a bit of nuance here. auto is intended to enable/disable the automatic data scanning to find limits. scale.range() must still be called if auto: false, but the fact that it gets fed back the exiting scale min/max and tries to auto-range from that on every redraw is problematic as it will cause continuous expansion. in the second part we may need to pass an additional flag into the scale.range() invocation to prevent it from thinking we're giving it data values that should be used for ranging...or some other strategy.

@leeoniya leeoniya added the bug Something isn't working label Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants