feat: add native point clustering to ScatterMap#418
Merged
Conversation
- add a `Cluster` option to the MapLibre `ScatterMap` trace, exposing plotly.js's `scattermap.cluster` attributes (`enabled`, `color`, `maxzoom`, `opacity`, `size`, `step`). Clustering groups nearby markers client-side (MapLibre supercluster) into bubbles that expand into individual points on zoom, decluttering dense point maps without dropping any data. This is a `scattermap`-only feature; the deprecated `ScatterMapbox` has no equivalent. Stacked on the ScatterMap trace addition (plotly#417). Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
c4d4d9f to
0c7fc5e
Compare
andrei-ng
approved these changes
Jul 9, 2026
Collaborator
|
@jqnatividad, thanks for the PRs! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native point clustering to the MapLibre
ScatterMaptrace (#417) via a newClusteroption, exposing plotly.js'sscattermap.clusterattributes.When enabled, nearby markers are grouped client-side (MapLibre's supercluster) into cluster bubbles that progressively expand into individual points as the map is zoomed in — decluttering dense point maps without dropping any data (every point still ships in the trace and becomes individually visible/hoverable at higher zoom).
This is a
scattermap-only feature: the deprecated Mapbox-basedScatterMapboxhas no equivalent, which is why it's a follow-up rather than part of the field-for-field port in #417.Clusterattaches toScatterMap, so this PR is stacked on #417 → #416 → #410 and should be reviewed/merged after them. Until they land inmain, the diff here also shows their commits; once merged, this diff reduces to just theClusteraddition.What changed
New
Clusterstruct onplotly::traces::scatter_map, plus acluster: Option<Cluster>field onScatterMap(with the usualFieldSetterbuilder):enabled(bool)color(color or per-step array,Dim<Box<dyn Color>>)maxzoom(0-24; zoom past which clusters expand into points)opacitysize(single or per-step array)step(single or per-step array;-1= auto)Includes a
serialize_clusterunit test and aClusterdoctest.Testing
cargo test -p plotly --lib scatter_map—serialize_clusterandserialize_scatter_mappass.cargo test -p plotly --doc scatter_map—ClusterandScatterMapdoctests pass.cargo clippy— clean.cargo +nightly fmt --all -- --check— clean.maxzoomavoids the MapLibreclusterMaxZoom > source maxzoomwarning.🤖 Generated with Claude Code