Skip to content

feat: New cartesian axis modebardisable attribute #7358

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alexcjohnson
Copy link
Collaborator

Gives you the ability to disable certain modebar buttons for an axis, without otherwise impacting the interactivity of that axis. This is useful for example if you have one axis with data over a very broad range (like a time series, or in my case, data down a several-thousand-meter drill hole) and the opposite axes have a relatively limited, well-defined range that you don't need to change much.

I made this attribute as a flaglist, mostly for future expansion if needed since there are only two flags right now: auto sets whether the autorange button affects this axis, and inout sets whether the zoom in / zoom out buttons affect this axis. You can also use all (default) and none as shorthands.

@gvwilson gvwilson requested a review from emilykl February 10, 2025 14:49
@gvwilson gvwilson added feature something new P1 needed for current cycle labels Feb 10, 2025
@emilykl
Copy link
Contributor

emilykl commented Feb 17, 2025

@alexcjohnson It's not entirely clear to me how to think about which buttons are intended to be included/excluded by these options. The most extreme interpretation of, say, inout would seem to be that every other modebar button besides zoomin / zoomout has no effect on that axis -- including e.g. zoom, pan, boxselect. I'm not sure that's a desired behavior (and that's not the behavior of your PR) -- but how can we clarify to the user that buttons like zoom and pan are not affected by this flag? Feel free to let me know if I'm thinking about this the wrong way.

Also a few thoughts on naming —

auto is a bit confusing to me as it makes me think of "automatically choose which modebar buttons affect this axis" rather than "autoscale". How about simply autoscale?

Maybe zoominout rather than inout as well?

@alexcjohnson
Copy link
Collaborator Author

Good point. Maybe this would be clearer as a container with booleans in it, rather than a flaglist? That would also be more extensible, since those booleans could default to true which you can't do with a flaglist. This would work with a flaglist of buttons to disable, but that seems even more confusing.

So perhaps:

modebarbuttons: {
    autoscale: false,
    zoominout: false
}

That's more verbose when you want to disable both, but seems clearer about exactly what it applies to. Thoughts?

@archmoj
Copy link
Contributor

archmoj commented Jun 4, 2025

Very useful feature. Thanks @alexcjohnson.
Since this feature only involves zoom interactions, I was wondering if ax.zoom may be a better attribute name instead of ax.modebarbuttons?

@emilykl
Copy link
Contributor

emilykl commented Jun 5, 2025

Hi @alexcjohnson ! Revisiting this one because we'd love to get it into the next minor release.

Taking another look at the diff, I noticed there's an existing axis property called fixedrange. How would that interact with the modebarbuttons property? Is the difference that fixedrange disables ALL zooming (i.e. via box select) and e.g. modebarbuttons: 'none' would disable only zooming which is triggered by clicking on the modebar buttons, but box select zoom would still be allowed?

@alexcjohnson
Copy link
Collaborator Author

Since this feature only involves zoom interactions, I was wondering if ax.zoom may be a better attribute name instead of ax.modebarbuttons?

I think ax.zoom would be too broad in other ways - like as @emilykl points out there's also ax.fixedrange, ax.zoom='none' kind of implies there's NOTHING you can do to zoom in or out. And @emilykl yes your understanding is correct, the goal here is just to give more control over what the zoom & autorange modebar buttons do, while still allowing you to adjust the range of this axis in other ways, ie box zoom or dragging on the axis ends.

Perhaps ax.modebarzoom would be a more precise name?

@emilykl
Copy link
Contributor

emilykl commented Jun 6, 2025

Perhaps ax.modebarzoom would be a more precise name?

So ax.modebarzoom would be a boolean, where true (default) means the current behavior (no change), and false means that both the autorange and zoom in/out buttons do not affect this axis? That seems reasonable to me.

Or do you mean ax.modebarzoom as a flaglist? IMO if we go the flaglist route, the flags need to be just the names of the modebar buttons themselves, otherwise there's too many arbitrary flag names and it's difficult to keep track of which buttons they affect. On the other hand, the concept of "disabling" a button for an axis isn't meaningful for all button types (e.g. what would that mean for drawrect?) so button-by-button might open up some confusing possibilities. I suppose we could support just a subset of button types though, and ignore the others.

edit: on rereading your earlier post @alexcjohnson, I guess ax.modebarbuttons as a flaglist or a dict of buttonName: boolean is roughly equivalent, it's just a question of naming. Maybe a flaglist called ax.modebardisable?

@archmoj
Copy link
Contributor

archmoj commented Jul 15, 2025

Ping @alexcjohnson

@alexcjohnson
Copy link
Collaborator Author

Maybe a flaglist called ax.modebardisable?

@emilykl I like that! with the same flags as in this PR, auto and inout, just inverting the meaning? I might then remove the all extra, to give us more flexibility later on in case we want to add zoom and pan as additional things you can disable without a breaking change to what all means.

So we'd end up with this as the attribute:

    modebardisable: {
        valType: 'flaglist',
        flags: ['auto', 'inout'],
        extras: ['none'],
        dflt: 'none',
        editType: 'modebar',
        description: [
            'Disables certain modebar buttons for this axis.',
            '*auto* disables the autoscale buttons, *inout* disables the',
            'zoom-in and zoom-out buttons.'
        ].join(' ')
    },

If we're agreed on this I'll be happy to make that change in the PR.

@archmoj
Copy link
Contributor

archmoj commented Jul 16, 2025

Maybe a flaglist called ax.modebardisable?

@emilykl I like that! with the same flags as in this PR, auto and inout, just inverting the meaning? I might then remove the all extra, to give us more flexibility later on in case we want to add zoom and pan as additional things you can disable without a breaking change to what all means.

So we'd end up with this as the attribute:

    modebardisable: {
        valType: 'flaglist',
        flags: ['auto', 'inout'],
        extras: ['none'],
        dflt: 'none',
        editType: 'modebar',
        description: [
            'Disables certain modebar buttons for this axis.',
            '*auto* disables the autoscale buttons, *inout* disables the',
            'zoom-in and zoom-out buttons.'
        ].join(' ')
    },

If we're agreed on this I'll be happy to make that change in the PR.

I like this suggestion.
@emilykl How about you?

@archmoj archmoj changed the title New cartesian axis modebarbuttons attribute feat: New cartesian axis modebardisable attribute Jul 16, 2025
@gvwilson gvwilson assigned archmoj and unassigned emilykl Jul 17, 2025
@emilykl
Copy link
Contributor

emilykl commented Jul 17, 2025

@alexcjohnson @archmoj I like this EXCEPT I would prefer the flag names autoscale and zoominout instead for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P1 needed for current cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants