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

Disable Rotation Drag on Polar when dragmode = false #5219

Closed
Phil-DS opened this issue Oct 19, 2020 · 7 comments · Fixed by #6147
Closed

Disable Rotation Drag on Polar when dragmode = false #5219

Phil-DS opened this issue Oct 19, 2020 · 7 comments · Fixed by #6147
Labels
bug something broken

Comments

@Phil-DS
Copy link

Phil-DS commented Oct 19, 2020

When I set dragmode to false, I'm expecting all drag events to be halted. On polar, the zoom event was halted, but you are still able to click and drag the outer edge of the polar chart, and rotate the chart, which is seemingly impossible to disable without going deep into the halting of events, or making it a static chart (Which means that you lose any sort of interactivity that is enabled by Plotly)

@archmoj archmoj added the bug something broken label Oct 19, 2020
@Peque
Copy link

Peque commented Jan 30, 2021

@Phil-DS Did you find any workaround for this?

@TheLogan
Copy link

TheLogan commented Feb 4, 2021

I could also use a fix for this, been trying a multitude of things, but dragmode is the one that makes most sense, but it doesn't seem there is a way to do it :(

@nicolaskruchten
Copy link
Contributor

We'd accept a PR for this if someone is interested :)

@TheLogan
Copy link

TheLogan commented Feb 5, 2021

Had a look at the source code, it's beyond me I'm afraid =/

@Phil-DS
Copy link
Author

Phil-DS commented Feb 5, 2021

Sadly, I never found a fix for it. While I could have lived without removing the drag rotation, it had another aspect that it disabled click events, which were pivotal to the use case I had. I did update to the latest today to see if the click events were still disabled by it, and they were. In the end, I ignored the issue.

I did have a deeper look into the source code at the time, and unless I did some major overriding, I wouldn't be able to get the click events working with disabling the rotation and zoom.

@miketwo
Copy link

miketwo commented Aug 30, 2021

I have a workaround if you're using react-plotly, but it's ugly...

// Add the following state
const [rotation, setRotation] = useState(90);
const [revision, setRevision] = useState(1);

// Add a callback that we will use whenever the layout is updated.
  const onLayoutCallbacks = data => {
    if (data['polar.angularaxis.rotation']) {
      setRotation(90);
      setRevision(revision + 1);
    }
  };

// Add the callback to the component. 
// Be sure the layout is based on state, and that it takes in a "revision"
<Plot
  onRelayout={onLayoutCallbacks}
  onRelayouting={onLayoutCallbacks}
  ...
  layout={{
    revision: revision,
    polar: {
      angularaxis: {
        rotation: rotation,

It should make it so that callback is executed on/during layout changes, and it specifically resets the angular rotation if that's the data being changed. The result is that you get a gazillion refreshes if someone drags the axis, but it shouldn't change what it looks like. YMMV.

@sup3rcow
Copy link

sup3rcow commented Feb 1, 2024

This will turn off drag event on element that is responsible for drag/rotate action.
.angulardrag {
pointer-events: none !important;
}

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

Successfully merging a pull request may close this issue.

7 participants