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

Zooming on one axis #227

Open
torranto opened this issue Aug 30, 2018 · 2 comments
Open

Zooming on one axis #227

torranto opened this issue Aug 30, 2018 · 2 comments

Comments

@torranto
Copy link

In example Plot Zooming scaling is done on two axes.

It is necessary to make scaling on different axes separately:

  • mousewheel - scaling on X-axes
  • mousewheel and shift key - scaling on Y-axes
  • mousemove - move chart

I tried to do so this:

function zoomed() {

	if (d3.event.sourceEvent.type == "wheel") {
		if (d3.event.sourceEvent.shiftKey) {
			var rescaledY = d3.event.transform.rescaleY(y);
			yAxis.scale(rescaledY);
			candlestick.yScale(rescaledY);
		} else {
			x.zoomable().domain(d3.event.transform.rescaleX(zoomableInit).domain());
		}
	}
	else { // d3.event.sourceEvent.type == "mousemove"
		var rescaledY = d3.event.transform.rescaleY(y);
		yAxis.scale(rescaledY);
		candlestick.yScale(rescaledY);

		x.zoomable().domain(d3.event.transform.rescaleX(zoomableInit).domain());
	}

	draw();
}

"Mouse wheel" works as it should, but after that "mouse move" work wrongly, scale is breaking down.
Correctly works "mouse wheel" or "mouse move", but not together.
How can be fix it?

@offtopic
Copy link

@torranto, I need the same functionality, but i want only to zoom the xAxis on the x-axis component.
Have you already solved your problem?

@torranto
Copy link
Author

torranto commented Oct 2, 2018

@offtopic, no, I could not solve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants