You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(layout): choose a colorbar's label size and decimals - #3447
A layout colorbar takes two new options, in Format › Colorbar and in layout.addElement / layout.update:
textSize: its labels' size, 4 to 100 points (default 8). The bar makes room for them. As before, a label that would overlap the one before it is skipped without a notice, and one that would spill out of the element is left out and counted by the cut-off check.
decimals: "auto" (default, today's labels) or 0 to 6. With a number, ramp, class and value labels are all written with that many decimals, thousands set apart, following the layout's decimal mark, never shortened to K or M. As on a chart and a scale bar, null leaves them as they are and "auto" returns to the automatic ones.
Both are saved only when changed, under a new layout-colorbar-labels capability. A saved layout.update command can't tell what kind of element it changes, so there textSize and decimals keep requiring the capabilities they already did.
The scale bar's fixed-decimals formatting and its decimals parsing are now shared with the colorbar; the scale bar behaves as before. layout.publication and the wizard are unchanged. New UI strings wait for the release translation pass.
Surfaces: the desktop and browser Format pane, layout.addElement / layout.update (so the CLI, Python, scripts, plugins, and the Assistant and MCP, whose parameter help names the new options), saved projects, layout files and exports. The ribbon, shortcuts and command search have no new entry, and the phone interface has no layout editing. Undo covers both options.
Testing
New tests, written to fail first on the engine side: tests/layout_colorbar.rs (ranges, refusals, null, undo, duplicate, saved projects, files out of range); render tests for the labels with decimals and the room larger labels take; the repair count on read; the capability for saved layouts and commands; the Format pane rows.
Full run on this branch, on main at 689a25c: 11,482 of 11,490 tests pass, with fmt, clippy, doctests, layers and the schema check green. The 8 failures (seven rustgis-geolibre tests, no tool 'geolibre:…', and rustgis-ui-egui::smoke line_strokes_editor_edits_one_class) fail the same on main at 689a25c on the same machine and are outside this change. The later commits (a scale bar clamp, doc comments, and a Format-pane test that failed on CI's font and now picks the list item without the pointer) passed their targeted tests and clippy.
ui_shot replay before and after, below.
UI evidence
Colorbars before, and after with textSize 14 and decimals 2:
Colorbar labels support adjustable text size and decimal precision, with automatic formatting or up to six decimal places.
Set these options when adding a colorbar or in the layout format panel. Labels respect the project’s decimal mark and include thousands separators.
Bug Fixes
Colorbar settings are preserved when projects are saved, reopened, imported, duplicated, or undone and redone. Invalid saved values are brought within supported limits.
Documentation
Updated guidance describes the new colorbar label options and project compatibility requirements.
No actionable comments were generated in the recent review.
Walkthrough
Colorbar elements now support configurable label text size and decimal precision. Layout commands and the Format pane expose these settings. Rendering uses them for label formatting and layout sizing. Projects with non-default settings require the layout-colorbar-labels capability.
Changes: Colorbar label options
Layer / File(s)
Summary
Colorbar label data and normalization crates/map/src/layout/colorbar.rs, crates/map/src/layout/elements.rs, crates/map/src/layout/text.rs, crates/map/src/layout.rs, crates/map/src/layout/scale_bar.rs, crates/map/src/layout/tests.rs
Colorbar elements store label size and optional decimal precision. Defaults are omitted from serialization. Layout repair clamps or resets invalid values.
Command creation and updates crates/engine/src/cmd/layout/*, crates/engine/src/tests.rs, crates/engine/src/tests/layout_colorbar.rs
layout.addElement and layout.update accept colorbar textSize and decimals. Tests cover validation, normalization, undo/redo, duplication, and project reopening.
Label formatting and layout crates/render/src/layout/*
The renderer applies configured text size and decimal precision to colorbar labels and accounts for label size when laying out the bar. Tests cover formatting and label space.
Projects require layout-colorbar-labels when saved colorbars or commands use non-default label settings. Capability detection, schema declarations, and tests include the capability.
Format pane and option documentation crates/ui-egui/src/layoutview/format/colorbar.rs, crates/ui-egui/src/layoutview/tests.rs, crates/engine/src/cmd/layout.rs, docs/user-guide/layouts.md
The Format pane provides label size and decimal controls. The user guide and command documentation describe the options.
sequenceDiagram
participant FormatPane
participant ColorbarElement
participant ColorbarRenderer
FormatPane->>ColorbarElement: Set text_size or decimals
ColorbarElement->>ColorbarRenderer: Provide label settings
ColorbarRenderer->>ColorbarRenderer: Format labels and calculate layout
opengeos/RustGIS#2666: Defines shared decimal parsing and fixed-decimal formatting for scale bars, which this change also uses for colorbar labels.
opengeos/RustGIS#2537: Defines chart decimal and capability behavior that this change preserves for saved layout updates.
Suggested reviewers:giswqs, elpidioassinaturas
Merge Risk: Minimal · up to b7042
This change adds colorbar label text size and decimal precision controls across layout commands, the Format pane, rendering and saved-project capability handling. No concrete defect was found, and the reported test coverage is broad. The risk to merging is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(layout): choose a colorbar's label size and decimals" names the main change. The PR adds textSize and decimals options for layout colorbars, exposed in Format › Colorbar and through la…
Description check
The description covers the change summary, the two new options with their ranges and defaults, the new layout-colorbar-labels capability, and the scope of surfaces affected. It includes a Testing sect…
Linked Issues check
Directly linked issue #3437 has coding requirements only. The whole-PR change summary (merge base 9cdbec6 to head b704257) covers each one:
1. Text size, default 8 pt, range 4 to 100: `COLORBAR_TEXT…
Out of Scope Changes check
Every changed area supports the colorbar options from #3437 or keeps existing behavior:
- Shared formatting: gives_chart_options_to excludes decimals for colorbars as well as scale bars. `fixed_n…
Full details: Title check
Explanation
The title "feat(layout): choose a colorbar's label size and decimals" names the main change. The PR adds textSize and decimals options for layout colorbars, exposed in Format › Colorbar and through layout.addElement and layout.update. The title is concise, specific, and follows a conventional-commit style.
Full details: Description check
Explanation
The description covers the change summary, the two new options with their ranges and defaults, the new layout-colorbar-labels capability, and the scope of surfaces affected. It includes a Testing section with commands run, new test files, and the failing-test baseline. The UI evidence section has before and after screenshots, and the Related issue section references #3437. The template's UI evidence section is required and is filled in. The Summary and Testing sections are detailed and specific.
Full details: Linked Issues check
Explanation
Directly linked issue #3437 has coding requirements only. The whole-PR change summary (merge base 9cdbec6 to head b704257) covers each one:
Text size, default 8 pt, range 4 to 100: COLORBAR_TEXT_PT in crates/map/src/layout/text.rs. Layout::clamp in crates/map/src/layout.rs normalizes colorbar text size. textSize is accepted for colorbars in crates/engine/src/cmd/layout/elements.rs and update.rs. The renderer passes text_pt to Bar in crates/render/src/layout/colorbar.rs, and bar room uses it.
Decimals, auto or 0 to 6: given_decimals in crates/engine/src/cmd/layout/chart.rs. MAX_COLORBAR_DECIMALS = 6 in crates/map/src/layout/colorbar.rs. Fixed-decimal formatting uses fixed_number in crates/render/src/layout/scale_bar.rs. Ramp, step and value labels use the chosen precision.
Format › Colorbar: crates/ui-egui/src/layoutview/format/colorbar.rs adds a text-size control and a decimals selector. crates/ui-egui/src/layoutview/tests.rs covers it.
layout.addElement and layout.update accept both options (elements.rs, update.rs, docs/user-guide/layouts.md).
Capability layout-colorbar-labels: added in crates/engine/src/project.rs, project_capabilities.rs and schema/project.schema.json. Required only for non-default size or explicit decimals.
The issue alternatives are followed: layout-text-size is not reused, and no free-form patterns are added.
Tests: crates/engine/src/tests/layout_colorbar.rs, crates/render/src/layout/tests.rs, crates/map/src/layout/tests.rs and crates/ui-egui/src/layoutview/tests.rs.
Limit: the incremental diff from the previous reviewed head could not be read, because changed blobs are missing from the checkout. The verdict relies on the whole-PR summary and the prior PASS. The author reports test results. I did not run tests. No unmet requirement is found in the available evidence.
Full details: Out of Scope Changes check
Explanation
Every changed area supports the colorbar options from #3437 or keeps existing behavior:
Shared formatting: gives_chart_options_to excludes decimals for colorbars as well as scale bars. fixed_number is extracted from the scale-bar formatter for reuse. This supports the colorbar decimals requirement.
Scale bar changes (e.g., e2f90aa, the scale bar clamp): these keep scale-bar output unchanged, as the PR states. They are compatibility work, not new scope.
Publication colorbar (crates/engine/src/cmd/layout/publication/mod.rs): sets text_size and decimals to defaults, keeping publication output unchanged.
Docs, schema fixture, schema enum entry and the ONLY_LAYOUT_TEXT_SIZE diagnostic text document or validate the new options and capability.
Latest commits (doc comments, Format-pane test adjustment): their diffs could not be read. They are described as test and comment work and are not expected to add unrelated behavior. This is an unresolved uncertainty, not a finding.
No change is shown to be unrelated to the issue. layout.publication and the wizard are unchanged, as stated.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit sizes labels, neat and bright, Then sets the decimals just right. The colorbar makes room below, While exact values gently show. Old saved charts keep their way, New settings hop into play.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 7469ee66-9622-4d67-be10-632c62ef74d0
Commits
Reviewing files that changed from the base of the PR and between ec15f3d and b704257.
Files selected for processing: 16
crates/engine/src/cmd/layout.rs
crates/engine/src/cmd/layout/elements.rs
crates/engine/src/cmd/layout/publication/mod.rs
crates/engine/src/cmd/layout/text.rs
crates/engine/src/cmd/layout/update.rs
crates/engine/src/project_capabilities.rs
crates/engine/src/tests.rs
crates/engine/src/tests/layout_colorbar.rs
crates/map/src/layout.rs
crates/map/src/layout/elements.rs
crates/map/src/layout/tests.rs
crates/render/src/layout.rs
crates/render/src/layout/tests.rs
docs/maintaining.md
docs/user-guide/layouts.md
schema/project.schema.json
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
I read the full diff, the base-branch AGENTS.md, the staged metadata, and the surrounding code for the changed paths. There are no prior review threads, so none were left alone. I could not compile or run the tests (no shell here), so everything below is from reading the code.
Bugs
None found. I checked these paths and they hold:
Clamp and repair count: the colorbar arm in Layout::clamp (crates/map/src/layout.rs:705) changes values in place. The repair count is computed by comparing before and after (kind != was), so out-of-range text_size and decimals are counted. Invalid decimals map to the automatic marker.
Decimal comma:fixed_number runs with comma=false and colorbar_plan applies decimal(s, bar.comma) once, so the separators swap exactly once. The scale bar's 1e15 clamp and commas output match the old thousands path.
Scale bar refactor:given_decimals gives the same results as the old inline parsing (auto, null, count, error text), and the room formula for colorbar_bar_room is unchanged at 8 points.
Capabilities: a colorbar's labels add only layout-colorbar-labels. has_custom_text_size doesn't cover colorbars, so there is no double requirement. Saved layout.update keeps the capabilities it already had, and the older reader refuses those loudly rather than silently.
Construction sites:Colorbar is constructed in elements.rs and publication/mod.rs, and both are updated. Bar { literals in losses.rs, draw_page and the tests are updated, and colorbar_bar_room has no stale callers.
Confidence: high for the paths above. A compile failure from a missing import is not ruled out, since I could not build.
Security
None found. The change adds no I/O, parsing of untrusted strings beyond the existing de_scale_decimals and given_count paths, or command execution.
Performance
None significant. The added layout.import predicate re-parses the inline layout once more, but only when the needle matches. This follows the existing pattern. Confidence: high.
Quality
Inline comment on crates/render/src/layout/scale_bar.rs:37: the 1e15 clamp lives only in bar_number, and the doc doesn't say so. Suggested wording included. Confidence: medium.
Low-confidence notes, not posted:
With a chosen decimal count, a ramp can repeat labels (for example 0..1 at 0 decimals gives 0,0,0,1,1). The user guide mentions this, so it is disclosed.
fixed_number prints NaN and infinity as 0, which is quietly wrong. It is unreachable from the current callers: tick_labels drops non-finite bounds, and classes come from the user or from finite data. Confidence it is reachable: low.
colorbars_with_labels is a one-line wrapper that could be inlined as a closure. Style only.
AGENTS.md
No breaks found. The schema and fixture are updated (schema/project.schema.json, schema/fixtures/layout_colorbar_labels.rgis), docs are updated, the capability list and its tests are updated, and the new strings use tl!. The command-surface snapshot needs no change because no parameter keys were added. Confidence: high.
Change size
Compared with main (merge base 689a25c to PR head e2f90aa).
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).
Reviewed PR #3447 (colorbar label size and decimals) against the diff, the base-branch AGENTS.md and the surrounding code. I could not build or run the tests here (no shell), so the findings come from reading the code.
Bugs
Labels thinned by overlap are dropped without a notice (crates/render/src/layout/colorbar.rs:168, inline comment posted). The overlap continue skips the spilled count, so losses.rs never reports the drop. Larger text and chosen decimals make this common. Confidence: high (about 85%).
Security
None found. The new textSize and decimals values are range-checked in given_decimals and text_size_param, and Layout::clamp repairs them on read. Non-finite values print 0, and fixed_number has no unbounded loop.
Performance
None significant. The new per-label formatting runs on at most 21 labels per frame.
Quality
The decimals choice can repeat a label (for example 0,0,0,1,1 on a 0–1 ramp). The user guide documents this, so it is not raised as a defect. Consider a hint in the UI.
Test name a_file_s_text_size_and_decimals_are_brought_into_range has a stray s from a removed apostrophe. Left for the release quality pass.
AGENTS.md
The PR body's "Reach every surface" list does not say whether the phone interface (ui-touch), the ribbon, shortcuts, command search, plugins or the MCP tool descriptions are affected. AGENTS.md asks the PR to state this. Confidence: medium. The code changes are reached through layout.addElement and layout.update, so the command-line, Python and Assistant surfaces follow from them.
Checked and found correct
Capability gating: layout.addElement, layout.import, report.existingTemplate, script.run and saved project reads all handle the new capability. The layout.update path keeps the existing gates, as the doc comment says.
The ONLY_SCALE_BAR_DETAILS gate does not include decimals, so a colorbar's layout.update with decimals is not refused.
The scale bar's bar_number output is unchanged for in-range values. The 1e15 clamp matches the old thousands behaviour.
The schema, fixture and capability list agree.
command-surface.txt needs no update, since no parameter keys were added to a command's surface.
The earlier thread on the fixed_number doc wording is resolved and the current doc matches the fix, so I did not raise it again. One earlier concern left alone.
Change size
Compared: the whole PR against main (merge base 689a25c to PR head ec15f3d).
No bugs, security problems or AGENTS.md breaks found in the changed code. One test-coverage point is posted inline (crates/engine/src/cmd/layout/elements.rs:1146). I reviewed by reading only: I could not compile or run the tests here, so the PR's own test run (in its body) is the evidence for build and test status.
Bugs
None found. Checked the given_decimals refactor against the old scale-bar parsing (same results for null, "auto", counts and errors). Checked the bar_number → fixed_number change (the 1e15 clamp and thousands output match the old thousands path, and the sign rule is unchanged). Checked the decimal-comma swap in colorbar_plan, which correctly covers the thousands separator. Checked Layout::clamp (the SCALE_DECIMALS_INVALID marker, the 6-decimal cap, and the repair count). Checked that render and losses use the same colorbar_plan inputs. Confidence: high.
Security
None.
Performance
None material. Label formatting is bounded by the 21-tick cap. Confidence: high.
Quality
crates/engine/src/cmd/layout/elements.rs:1146 (inline): the "every key a kind reads" sample has no colorbar textSize or decimals, so dropping either key from ADD_COLORBAR_KEYS would not fail the test. Confidence: high.
Fixed decimals can give repeated labels with no notice (the test pins 0, 0, 0, 1, 1 for ramp(0, 1) at 0 decimals). The user guide documents it and the scale bar already behaves this way, so I'm not raising it as a silent-loss bug. Confidence in the concern: low-medium.
fixed_number uses Rust's {:.N}, which rounds exact halves to even (2.5 at 0 decimals gives "2"), while tick_labels uses .round(). Matches existing scale-bar output, so this is a consistency note only. Confidence: low.
Design note, not a defect: a saved layout.update with decimals on a colorbar requires layout-chart-look and layout-scale-bar-details, not the new capability. An older reader refuses it loudly, so nothing is lost silently. Confidence: high.
AGENTS.md
None found. Checked: no unwrap/panic in non-test code; the new capability is in both CAPABILITIES and the schema; the fixture is added; docs/maintaining.md and the user guide are updated; no new command, so the command surface is unchanged; new UI strings are left for the translation pass.
Twins checked: the scale-bar decimals parser (now shared); has_custom_text_size (colorbar intentionally excluded, covered by its own capability); null_resets; the layout.publication constructor; layout.duplicateElement; the layout.import, report.existingTemplate and script.run capability branches. The overlay-tool and add-data families are not touched by this diff.
Earlier review threads: one (the scale_bar.rs doc wording) was answered by the author and fixed in ec15f3d. I left it alone and did not re-raise it.
Change size
Compared: the whole PR against main (merge base 689a25c to PR head ec15f3d).
Checked: skipping a label that would overlap the one before is how the colorbar spaces its labels since #2638, and it is deliberately not counted (ColorbarPlan::spilled says so); counting it would warn on any ramp with more ticks than fit. What is reported is a label that would spill out of the element, or all of them when there is no room for a bar. Larger text and chosen decimals make labels wider, so fewer fit, as in a narrower element. Leaving the code as it is; the PR description now says which labels are counted.
The change adds a colorbar's label size (textSize) and decimals (decimals) across the layout model, render, engine commands, Format pane, docs and schema. I found no confirmed bugs, security issues, performance problems or AGENTS.md breaks. One low-confidence quality point is posted inline.
Bugs
None confirmed.
What I checked:
Scale bar behaviour is unchanged. The shared fixed_number plus the 1e15 clamp in bar_number match the old thousands clamp.
The decimal comma is applied once on each path. decimal swaps ./, and the chosen-decimals path calls it once in colorbar_plan.
Layout::clamp brings out-of-range text size and decimals into range and counts the repairs.
given_decimals refuses junk input without a panic.
The colorbar bar room is numerically the same as before at the default size.
Security
None found. All new parameters are bounded (4–100 pt, 0–6 decimals, u8).
Performance
None found. Two scalars per element, and label formatting runs only in the render path.
Quality
Low confidence, inline (crates/render/src/layout/scale_bar.rs:42): fixed_number prints a non-finite value as 0, and colorbar labels now use it when decimals is set. I could not find a reachable path to a non-finite colorbar edge, so this is low confidence.
Nits, grouped for the release quality pass:
crates/engine/src/tests/layout_colorbar.rs:508: the test name a_file_s_text_size_and_decimals_are_brought_into_range reads oddly. a_files_… would be clearer.
project_capabilities.rs: colorbars_with_labels is a one-line wrapper around colorbar_uses_labels. It could be passed directly.
The render tests repeat the full Bar { … } literal about ten times. A helper would shorten them.
AGENTS.md
None. The PR body covers the surfaces, the schema is regenerated for the capability lists, a fixture is added, the docs are updated, and the clamp repairs are counted.
Twins checked
Scale bar decimals across restyle, add_element and chart_update: all three use the shared path.
Colorbar is excluded from the layout-text-size capability on purpose, since it has its own capability.
Layout reads: layout.import, report.existingTemplate, script.run, and the .rgislayout header all go through the new check.
ONLY_LAYOUT_TEXT_SIZE: only tests reference the changed message.
No cfg(wasm32) branches are touched.
Prior review threads
Two earlier threads. I left both alone:
The test-coverage thread is answered. ADD_COLORBAR_KEYS gates only_add_keys, and layout_colorbar.rs calls addElement with both keys, so dropping one would fail those tests.
The fixed_number doc-wording thread is fixed in ec15f3da1. The inline finding above is about the behaviour, not the wording.
Change size
Compared: the whole PR against main (merge base 9cdbec6 to PR head b704257). The trees are not truncated.
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
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
A layout colorbar takes two new options, in Format › Colorbar and in
layout.addElement/layout.update:textSize: its labels' size, 4 to 100 points (default 8). The bar makes room for them. As before, a label that would overlap the one before it is skipped without a notice, and one that would spill out of the element is left out and counted by the cut-off check.decimals:"auto"(default, today's labels) or 0 to 6. With a number, ramp, class and value labels are all written with that many decimals, thousands set apart, following the layout's decimal mark, never shortened toKorM. As on a chart and a scale bar,nullleaves them as they are and"auto"returns to the automatic ones.Both are saved only when changed, under a new
layout-colorbar-labelscapability. A savedlayout.updatecommand can't tell what kind of element it changes, so theretextSizeanddecimalskeep requiring the capabilities they already did.The scale bar's fixed-decimals formatting and its
decimalsparsing are now shared with the colorbar; the scale bar behaves as before.layout.publicationand the wizard are unchanged. New UI strings wait for the release translation pass.Surfaces: the desktop and browser Format pane,
layout.addElement/layout.update(so the CLI, Python, scripts, plugins, and the Assistant and MCP, whose parameter help names the new options), saved projects, layout files and exports. The ribbon, shortcuts and command search have no new entry, and the phone interface has no layout editing. Undo covers both options.Testing
tests/layout_colorbar.rs(ranges, refusals,null, undo, duplicate, saved projects, files out of range); render tests for the labels with decimals and the room larger labels take; the repair count on read; the capability for saved layouts and commands; the Format pane rows.mainat 689a25c: 11,482 of 11,490 tests pass, with fmt, clippy, doctests, layers and the schema check green. The 8 failures (sevenrustgis-geolibretests,no tool 'geolibre:…', andrustgis-ui-egui::smoke line_strokes_editor_edits_one_class) fail the same onmainat 689a25c on the same machine and are outside this change. The later commits (a scale bar clamp, doc comments, and a Format-pane test that failed on CI's font and now picks the list item without the pointer) passed their targeted tests and clippy.ui_shotreplay before and after, below.UI evidence
Colorbars before, and after with
textSize14 anddecimals2:Format › Colorbar:
Related issue
Closes #3437
Summary by CodeRabbit