8000 add support for min/max scale limits by mojoaxel · Pull Request #5192 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

add support for min/max scale limits #5192

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 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: use dflt: -1 instad of null
  • Loading branch information
mojoaxel committed Jun 10, 2024
commit 388c0b0072f11d4077b246cde1a6f8ebc12e0627
1 change: 1 addition & 0 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ function handleGeo(gd, ev) {
var minscale = geoLayout.projection.minscale;
var maxscale = geoLayout.projection.maxscale;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we need to handle

if(maxscale === null) maxscale = Infinity;

or

if(maxscale === -1) maxscale = Infinity;

if we decide to use -1 instead of null which is not a number.
@alexcjohnson your idea on which one is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With e722947 I changed the default to -1 instead of null. Scales with less than 0 make no sense here so this should be a valid solution.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose -1 as a default is OK if we really need a "no max" value - it's better than null which behaves oddly in relayout.

But I wonder if we can't pick a decent default that's more zoomed in than is generally ever useful. I have occasionally gotten in a situation by accidentally scroll zooming so far in that everything freezes up because the SVG engine is having trouble drawing all the off-screen elements. If we cover 99% of cases and avoid this pitfall I'd say that's a reasonable tradeoff, and avoids making a coded value. Something like 10,000?

Similarly, is there a default we could use for minscale, to avoid zooming the whole map away to a point? 0.1 perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like 10,000?
Similarly, is there a default we could use for minscale, to avoid zooming the whole map away to a point? 0.1 perhaps?

Makes sense!
(I'll have a look tomorrow. It's getting late her in europe 😴)


if(maxscale < 0) maxscale = Infinity;
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale;

// make sure the scale is within the min/max bounds
Expand Down
2 changes: 1 addition & 1 deletion src/plots/geo/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var attrs = module.exports = overrideAll({
maxscale: {
valType: 'number',
min: 0,
dflt: null,
dflt: -1,
description: [
'Maximal zoom level of the map view.',
'A maxScale of *2* (200%) corresponds to a zoom level',
Expand Down
0