Skip to content

Configurable legends for viewer-charts - #3221

Merged
texodus merged 3 commits into
masterfrom
legend-of-the-pr
Aug 26, 2026
Merged

Configurable legends for viewer-charts#3221
texodus merged 3 commits into
masterfrom
legend-of-the-pr

Conversation

@texodus

@texodus texodus commented Aug 26, 2026

Copy link
Copy Markdown
Member

New legends

Screenshot 2026-08-26 at 4 14 15 PM

Legends are now a fully configurable chart element across all charts:

  • legend_mode"sidebar" (default, the existing right-gutter legend), "none", or "floating": a movable panel overlaying the plot.
  • Scroll + windowed painting — every legend scrolls on vertical overflow, and only the visible rows are measured and painted, so charts with hundreds of series stay cheap.
  • Direct manipulation — sidebar legends resize horizontally by dragging their divider; floating legends resize on all edges/corners and move by their header. Double-clicking a resizable edge resets that dimension to its default. Every gesture persists through plugin_config.
  • Floating geometry is anchor-relative: legend_x/legend_y are normalized offsets measured from legend_anchor, so a corner-glued legend stays glued across panel resizes and off-canvas placement is inexpressible.

Signed numeric color domains now pivot symmetrically around zero (colorRangePivot): a column spanning e.g. [-3, 17] colors and labels as [-17, 17], so hue encodes sign consistently in the glyphs (line/scatter) and the gradient legend agrees with them.

Map tile sources

  • Provider definitions moved out of TypeScript into map/tile-sources.json; the code is a generic registry (TileSourceRegistry) over TileSourceSpec entries (id, label, template, subdomains?, attribution, tile_size?, max_zoom?). Bundled providers: OpenStreetMap (osm) and VersaTiles satellite (versatiles-satellite). JSON order is the one knob: it defines the settings-panel enum order, the unknown-id fallback, and the default provider (first entry).
  • Public API: registerTileSource(spec) / tileSources() (module exports and statics on the plugin element class) add providers at runtime — they join the settings enum and resolve on every current and future map chart. API keys are embedded in the registered template and never enter plugin_config/save(). The resolved spec rides the existing setPluginConfig/init transport messages alongside the config that names it — no separate sync channel, no ordering hazards. Tile-cache identity is content-derived, so re-registering an id with a new URL invalidates cached tiles automatically.
  • The CARTO basemaps moved out of the bundle and into the docs site, which registers them through the public API at bootstrap; they double as the worked example on the new guide page (docs/md/how_to/javascript/map_tile_sources.md).

Map numeric axes: numeric_axes

  • On (default): standard numeric axes on map charts with tick labels in degrees (122.4°W / 37.77°N), not Mercator meters.
  • Off: the plot fills the entire plugin canvas.

New plugin_config keys

Key Type Default Applies to
legend_mode "sidebar" | "none" | "floating" "sidebar" all legend-capable charts
legend_width_px number 0–512 0 (auto) sidebar + floating width
legend_height_px number 48–1024 160 floating panel height
legend_anchor "top-left" | "top-right" | "bottom-left" | "bottom-right" "top-right" floating
legend_x number 0–1 0 floating; offset from anchor
legend_y number 0–1 0 floating; offset from anchor
legend_opacity number 0–1 1 floating background
numeric_axes boolean true map charts only

Fixes #3189

Signed-off-by: Andrew Stein <steinlink@gmail.com>
Signed-off-by: Andrew Stein <steinlink@gmail.com>
Signed-off-by: Andrew Stein <steinlink@gmail.com>
@texodus texodus added the enhancement Feature requests or improvements label Aug 26, 2026
@texodus
texodus merged commit 8e1e284 into master Aug 26, 2026
21 of 28 checks passed
@texodus
texodus deleted the legend-of-the-pr branch August 26, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests or improvements

Development

Successfully merging this pull request may close these issues.

Gracefully handle long categorical legend labels (ellipsis/wrap/scroll)

1 participant