Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add min/max scale limits for geo plots#7371

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
camdecoster wants to merge18 commits intomaster
base:master
Choose a base branch
Loading
fromcam/5192/add-min-max-scale-limits

Conversation

@camdecoster
Copy link
Contributor

@camdecostercamdecoster commentedFeb 18, 2025
edited
Loading

Description

Addminscale andmaxscale attributes to geo plots. These set the min and max scale extents for a plot (how far a user can zoom out/in). This PR supersedes#5192 which will be closed after this is merged.

Changes

  • Addsminscale andmaxscale attributes to geo plots. Defaults are 0 and -1, respectively.
  • Enforces scale extents on zoom mouse events, mode bar button clicks
  • Manually creates zoom event to enforce scale extents on first render (treating the middle of the plot as the zoom point)

Demo Video or Screenshot(s):

Before:

Screencast.From.2025-02-22.11-25-20.mp4

After:

Screencast.From.2025-02-22.11-29-21.mp4

Testing

  • Start the dev dashboard withnpm start
  • Search for a geo mock and load it (I usedgeo_legendonly)
  • Zoom in and out and note how you can go as far as you want in either direction
  • Edit the mock file and add the following attributes under the"geo" key
    • "minscale": 2
    • "maxscale": 4
  • Reload the mock in the dashboard
  • Note that the mock appears zoomed in upon first load
  • Zoom in and out and note how you're now limited in how far you can go

mojoaxel reacted with thumbs up emoji
@camdecostercamdecosterforce-pushed thecam/5192/add-min-max-scale-limits branch fromc7b5ec3 to29b4316CompareFebruary 18, 2025 14:15
@gvwilsongvwilson added P1needed for current cycle fixfixes something broken labelsFeb 18, 2025
@camdecoster
Copy link
ContributorAuthor

I believe that some tests are failing because there's now an extra zoom event on every call toupdateFx (fordragMode === 'pan'). I think I need to restrict that call to only happen upon first load. I'll keep looking into it.

@camdecoster
Copy link
ContributorAuthor

@archmoj this PR should now be good to review. We don't need both this and#7482. I'd like to argue that we should use the approach of usingscaleExtent (the native D3 mechanism) rather than limiting the scale on our side.

archmoj reacted with thumbs up emoji

maxscale:{
valType:'number',
min:0,
dflt:-1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try settingdflt: 0 in the API and handle the case of zero instead of -1.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

We representInfinity with -1 sinceInfinity isn't valid in JSON. If we made this change, how would we handle when a user wants to useInfinity instead of 0 (which is also a valid value).

@archmoj
Copy link
Contributor

Openinggeo_canadian-cities mock in the dashboard gives me the following error:

plotly.js:9976 Uncaught (in promise) RangeError: Maximum call stack size exceeded    at String.replace (<anonymous>)    at stringInputToObject (plotly.js:9976:27)    at inputToRGB (plotly.js:9412:22)    at new tinycolor (plotly.js:9165:22)    at tinycolor (plotly.js:9163:20)    at color2.fill (plotly.js:11073:18)    at d3_selectionPrototype.call (plotly.js:1352:20)    at SVGGElement.<anonymous> (plotly.js:145654:18)    at plotly.js:1339:22    at d3_selection_each (plotly.js:1345:36)

@camdecoster do you get the same?

@camdecoster
Copy link
ContributorAuthor

@archmoj that should be fixed by some recent commits. Are you on the latest version of the branch? I'm not seeing that error.

@archmoj
Copy link
Contributor

geo_canadian-cities

Thanks@camdecoster. My local test branch was not up-to-date. I confirm now it renders with no error.

camdecoster reacted with thumbs up emoji

@archmoj
Copy link
Contributor

If you add

"projection": { "minscale": 0.5, "maxscale": 2 },

togeo_canadian-cities under "geo" object, the map renders smaller withgd._fullLayout.geo.projection.scale: 0.3013880580354019.

@camdecoster Could you please investigate that?

@archmoj
Copy link
Contributor

If you add

"projection": { "minscale": 0.5, "maxscale": 2 },

togeo_canadian-cities under "geo" object, the map renders smaller withgd._fullLayout.geo.projection.scale: 0.3013880580354019.

@camdecoster Could you please investigate that?

Here is acodepen displaying the bug.

@archmojarchmoj added featuresomething new and removed fixfixes something broken labelsJul 28, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@alexcjohnsonalexcjohnsonAwaiting requested review from alexcjohnson

@emilyklemilyklAwaiting requested review from emilykl

@marthacryanmarthacryanAwaiting requested review from marthacryan

1 more reviewer

@archmojarchmojarchmoj left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

@camdecostercamdecoster

Labels

featuresomething newP1needed for current cycle

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

allow user to set zoom/scale limits for choropleth maps

5 participants

@camdecoster@archmoj@gvwilson@mojoaxel

[8]ページ先頭

©2009-2025 Movatter.jp