You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disable Diagonal Selection on cartesian zoombox drag #3923
I would like to enable the horizontal and vertical axis selection on bar/line charts, but I want to disable the diagonal selection – i.e. I don’t want to user to simultaneously select both axis, but only one at a time.
I have tried different solutions, but I could not get the desired effect. For example, setting fixedrange:true, disables either vertical or horizontal selection. But, I want to disable only diagonal selection, and keep both horizontal and vertical selections enabled.
Is it possible to have this feature for diagonal selection, like diagonalFixedRange:true? or have a flag to disable just the diagonal selection?
I'm using this library in ReactJS, the Plotly.js update will also ReactJS package?
Thank you very much for you help and the wonderful library 😊.
By select here I suspect you mean "zoombox" (as set via layout.dragmode: 'zoom'). In this case to achieve what you're looking for, we would probably need to either add an attribute similar to selectdirection but for dragmode: 'zoom' or expose some of these drag-zoom constants:
Yes, you are right, it's in dragmode: 'zoom' which is the default behavior, and yes it would be great if you can add an attribute similar to selectdirection for dragmode: 'zoom'.
Would it be possible to have an attribute to just enable/disable diagonal-selection? because the x-axis, y-axis selections are working perfectly with fixedrange:true, just only need to enable/disable diagonal.
plotly.js/src/plots/cartesian/constants.js
The MINZOOM constant, can also help for setting the threshold of selection, if easier, i would just only need MINZOOM for setting the threshold of diagonal-selection?
changed the title [-]Disable Diagonal Selection on Line and Bar Charts - fixedrange:true for diagonal-selection[/-][+]Disable Diagonal Selection on cartesian zoombox drag[/+]on May 30, 2019
Thanks @etpinard.
Does anyone know if it is possible nowadays to only allow "d" (=diagonal=rectangular box zoom=no horizontal/no vertical zoom) also for dragmode: 'zoom' ? @alexcjohnson
If not already possible, is there a dirty hack / monkeypatching to disable horizontal or vertical zoom ? And only allow rectangular (=diagonal) zoom?
@josephernest this feature has yet to be implemented and I'm not aware of any hacks to achieve your goal. We'd be happy to accept a PR adding a zoomdirection attribute.
@alexcjohnson I'll look at this! Do you think that setting one of these to value 1 would do it?
// pixels to move mouse before you stop clamping to starting point
MINDRAG: 8,
// smallest dimension allowed for a select box
MINSELECT: 12,
// smallest dimension allowed for a zoombox
MINZOOM: 20,
I kind of doubt it, but anyway the setting needs to be per-plot, so it would need to be applied at the point of use rather than in this constants file. I think we just need to find the logic around choosing x vs y vs d and have it ignore the disallowed flavors.
BTW I gather @AdnanBoota has moved on, but if we want to support the original use case zoomdirection would need a value xy in addition to x, y, and d.
Hi @alexcjohnson! This feature would be really useful for a project I am working on. I'd be happy to pick it up if the team is still open to PRs.
Is a new layout attribute zoomdirection with values x, y, d, and xy (and likely any as a default) still the desired direction here? I noticed selectdirection is a similar layout attribute for selections and uses h and v instead of x and y.
Absolutely! And you're right, let me revise my comment about the options to support: selectdirection takes values h, v, d, and any. For consistency we should probably use those same values (h rather than x etc), and rather than adding combinations ad hoc is there a reason not to use a flaglist, so we'd support any of them, not just h+v but also h+d and v+d, as well as h+v+d which would be a synonym for any?
Activity
etpinard commentedon May 30, 2019
Thanks for writing in!
By select here I suspect you mean "zoombox" (as set via
layout.dragmode: 'zoom'). In this case to achieve what you're looking for, we would probably need to either add an attribute similar toselectdirectionbut fordragmode: 'zoom'or expose some of these drag-zoom constants:plotly.js/src/plots/cartesian/constants.js
Lines 35 to 42 in f66aff3
AdnanBoota commentedon May 30, 2019
Hi etpinard,
Thanks for your quick response :)
Yes, you are right, it's in
dragmode: 'zoom'which is the default behavior, and yes it would be great if you can add an attribute similar toselectdirectionfordragmode: 'zoom'.Would it be possible to have an attribute to just enable/disable diagonal-selection? because the x-axis, y-axis selections are working perfectly with
fixedrange:true, just only need to enable/disable diagonal.plotly.js/src/plots/cartesian/constants.js
The
MINZOOMconstant, can also help for setting the threshold of selection, if easier, i would just only needMINZOOMfor setting the threshold of diagonal-selection?Again Thanks!
Adnan
[-]Disable Diagonal Selection on Line and Bar Charts - fixedrange:true for diagonal-selection[/-][+]Disable Diagonal Selection on cartesian zoombox drag[/+]josephernest commentedon Aug 8, 2023
Thanks @etpinard.
Does anyone know if it is possible nowadays to only allow "d" (=diagonal=rectangular box zoom=no horizontal/no vertical zoom) also for
dragmode: 'zoom'? @alexcjohnsonIf not already possible, is there a dirty hack / monkeypatching to disable horizontal or vertical zoom ? And only allow rectangular (=diagonal) zoom?
Maybe a modification of MINSELECT or MINDRAG?
alexcjohnson commentedon Aug 13, 2023
@josephernest this feature has yet to be implemented and I'm not aware of any hacks to achieve your goal. We'd be happy to accept a PR adding a
zoomdirectionattribute.josephernest commentedon Aug 13, 2023
@alexcjohnson I'll look at this! Do you think that setting one of these to value 1 would do it?
alexcjohnson commentedon Aug 13, 2023
I kind of doubt it, but anyway the setting needs to be per-plot, so it would need to be applied at the point of use rather than in this constants file. I think we just need to find the logic around choosing x vs y vs d and have it ignore the disallowed flavors.
BTW I gather @AdnanBoota has moved on, but if we want to support the original use case
zoomdirectionwould need a valuexyin addition tox,y, andd.EliasTalcott commentedon Nov 18, 2026
Hi @alexcjohnson! This feature would be really useful for a project I am working on. I'd be happy to pick it up if the team is still open to PRs.
Is a new layout attribute
zoomdirectionwith valuesx,y,d, andxy(and likelyanyas a default) still the desired direction here? I noticedselectdirectionis a similar layout attribute for selections and useshandvinstead ofxandy.alexcjohnson commentedon Nov 18, 2026
Absolutely! And you're right, let me revise my comment about the options to support:
selectdirectiontakes valuesh,v,d, andany. For consistency we should probably use those same values (hrather thanxetc), and rather than adding combinations ad hoc is there a reason not to use a flaglist, so we'd support any of them, not justh+vbut alsoh+dandv+d, as well ash+v+dwhich would be a synonym forany?feat: make Cartesian plot zoom direction configurable
feat: make Cartesian plot zoom direction configurable