Skip to content

feat: add hover and color-scale support to DensityMapbox#415

Closed
jqnatividad wants to merge 1 commit into
plotly:mainfrom
dathere:feat/densitymapbox-hover-upstream
Closed

feat: add hover and color-scale support to DensityMapbox#415
jqnatividad wants to merge 1 commit into
plotly:mainfrom
dathere:feat/densitymapbox-hover-upstream

Conversation

@jqnatividad

Copy link
Copy Markdown
Contributor

Summary

DensityMapbox previously exposed only a small subset of the plotly.js densitymapbox attributes — notably no hover configuration and no color-scale controls — so a density heatmap could not show per-point hover text or a custom/reversed colorscale + colorbar.

This PR adds those attributes, following the existing FieldSetter conventions and mirroring the field/type/serde choices already used by ScatterMapbox and ChoroplethMap. All existing fields are untouched, so the change is purely additive.

Closes #413.

What changed

Added Option<T> fields to DensityMapbox:

  • Hover/text: text, hovertext, hoverinfo, hovertemplate, hovertemplatefallback, hoverlabel
  • Color controls: colorscale, autocolorscale, reversescale, showscale, colorbar, coloraxis
  • Data/misc: ids, meta, customdata, uirevision, below

The FieldSetter derive generates both scalar and _array setters (e.g. hover_text / hover_text_array), so per-point hover text and shared colorscales are now expressible. The two dead commented-out color_continuous_* placeholder lines were removed. The serialize_density_mapbox unit test is extended to cover the new keys.

Out of scope (intentionally not changed)

  • radius stays Option<u8> (scalar). plotly.js allows number or array; widening to Dim<_> is a breaking change to the existing setter and left as a follow-up.
  • The pre-existing zoom and line fields are not valid densitymapbox trace attributes (zoom belongs on layout.mapbox.zoom); removing them would be breaking, so they're left for a separate cleanup.

Testing

  • cargo test -p plotlyserialize_density_mapbox passes with the new keys.
  • cargo clippy --features all -- -D warnings -A deprecated — clean.
  • cargo +nightly fmt --all -- --check — clean.

🤖 Generated with Claude Code

Extend the DensityMapbox trace with the hover, data-array, and
color-control attributes it was missing relative to the plotly.js
densitymapbox reference:

- hover/text: text, hovertext, hoverinfo, hovertemplate,
  hovertemplatefallback, hoverlabel
- data/misc: ids, meta, customdata, uirevision, below
- color: colorscale, autocolorscale, reversescale, showscale,
  colorbar, coloraxis

The FieldSetter derive generates the scalar and *_array builder
setters (e.g. hover_text/hover_text_array), so per-point hover text
and shared colorscales are now expressible. Existing fields are
unchanged. Extends the serialize_density_mapbox test to cover the
new keys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jqnatividad

Copy link
Copy Markdown
Contributor Author

Closing this. On reflection, adding hover/color-scale to densitymapbox isn't the right direction: plotly.js has deprecated the Mapbox-based traces in favor of the MapLibre map subplot, so the better home for these attributes is densitymap.

#416 adds a DensityMap trace with the same hover and color-scale surface (hovertemplate, colorscale/colorbar/showscale/reversescale/ autocolorscale/coloraxis, hoverlabel, etc.) on the non-deprecated trace, which covers the original need in #413. I'd rather not expand the API surface of a deprecated trace, so I'll let #416 stand as the successor and keep #413 open against that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DensityMapbox is missing hover, color-scale, and data-array attributes

1 participant