GithubHelp home page GithubHelp logo

Comments (2)

Shravya-Siluveru avatar Shravya-Siluveru commented on April 26, 2024 1

@mbostock Thank you for getting back to me. I implemented single directional zoom based on mouse direction. This works perfect for my requirement, Here is the block https://bl.ocks.org/Shravya-Siluveru/d958edfcbd6333e1a07054c15060ebd9/a6907c80f62202136ec2201cf15b776374e27732

from d3-brush.

mbostock avatar mbostock commented on April 26, 2024

This is essentially what happens when you hold down Shift; the brush sets the internal lockX or lockY flag based on the subsequent movement of the mouse.

d3-brush/src/brush.js

Lines 361 to 364 in c8fe9fa

if (shifting && !lockX && !lockY) {
if (Math.abs(point1[0] - point[0]) > Math.abs(point1[1] - point[1])) lockY = true;
else lockX = true;
}

I can’t think of an obvious way of triggering this behavior programmatically (meaning without requiring Shift to be held down), but, maybe it’s possible? I think the ideal would be some way of overriding the logic that determines which mode the brush is in during interaction. But there are a lot of different modes, so I’m not sure how to do that elegantly. The quickest path to implementing this is probably to fork the code and modify the internal logic.

from d3-brush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.