Repository navigation
fix(layout): keep a colorbar's end labels and thin the rest evenly - #3507
jgregoriorincon merged 5 commits into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewI read the diff, the colorbar planner, the shared Bugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared with main (merge base 44d7e19 to PR head b4dda7e), covering the whole PR.
|
Code reviewI found no bugs, security issues or AGENTS.md breaks in this PR. The colorbar change is sound. The one case that used to drop a label silently (both ends fit but touch) now counts the dropped end in Bugs: none found. Security: none found. Performance: none found. The extra work is O(n²) over a handful of labels. Quality (all low confidence; left for the release quality pass unless noted):
AGENTS.md: none found. Two rules are worth a note:
Prior reviews: 2 earlier concerns left alone, both answered and verified in 8f5ec33. The ends-touch end was previously dropped with no notice. It is now counted in Not run: I have no build or test tooling here, so the PR's own test results are unverified by me. Change sizeCompared: the whole PR against main (merge base 44d7e19 to PR head 8f5ec33).
|
…, and document the touching-end loss
Code reviewI found no bugs, security problems or AGENTS.md breaks in the changed code. I could not compile or run the tests here (no shell), so this rests on reading the code. I left two quality notes as inline comments. BugsNone found. I checked:
Confidence: high. SecurityNone found. The change is render-only, with no input parsing or new I/O. PerformanceNone significant. Quality
AGENTS.mdNo breaks found. I checked:
Earlier concerns left aloneThree earlier review threads are already answered and addressed in this diff, so I did not repost them: the test helper matching labels by text (now asserted unique), the dropped end not being said (now counted in Change sizeCompared: the whole PR against main (merge base 44d7e19 to PR head 4601eba).
|
📖 Docs preview
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 |
…eck its page notice
Code reviewI found no bugs, security problems or AGENTS.md breaks in this change. I posted no inline comments because I had no finding worth one. The remaining notes are minor. Bugs: None found. I traced the new logic in
Security: None. The change is pure layout arithmetic and takes no external input. Performance: None. The planner is O(labels²) at most, with label counts bounded by Quality (minor, could wait for the release quality pass):
AGENTS.md: No breaks found.
Twins checked: The colorbar is not one of the families the review rules name. The closest sibling is the scale bar, which reuses Prior review threads: I left 3 concerns alone, all already on the PR. Two were answered by the author in 8f5ec33 and 4601eba, and one was a test-helper fragility that the author fixed. I checked that the fix is in place: the uniqueness assert is at Change sizeCompared: the whole PR against main (merge base 44d7e19 to PR head 3669ef8).
|
Code reviewReviewed the colorbar label-thinning change (#3501) against the base branch, BugsNone found. Confidence: high. I checked:
SecurityNone found. PerformanceNone found. QualityNothing worth an inline comment. Two low-priority points that could wait for the release quality pass:
AGENTS.mdNone found. The change has no new commands, saved fields, or background work. Its reach is stated in the PR body. The guide and Earlier concernsI left three earlier concerns alone because each was already raised and then answered by the author with a code change. I verified each change in the current code:
Change sizeCompared: the whole PR against main (merge base 44d7e19 to PR head 3669ef8).
|
Summary
When a layout colorbar's labels didn't all fit, they were skipped along the bar: each was drawn only if it cleared the one before it. The last one could go that way, so a five-tick bar could read
415.82 530.84with its maximum,569.18, unlabelled.Now the colorbar keeps its labels as the scale bar does (#3490): the first and last that fit in the element and every
stepth one between them, wherestepis the smallest even share of the gaps at which no two touch; only those two when none fits. The rule is the same function,scale_bar_kept, applied incolorbar_planto the labels that stay inside the element. The drawing and the cut-off check both read that plan. It covers gradient, classified and unique-value colorbars, horizontal and vertical, reversed or not.Where even those two would touch, only the one nearer the left, or the top, is drawn, so no label is drawn over another, and the other end is counted in the cut-off warning.
What changes besides the fix: a colorbar whose labels all fit draws as before. A crowded one can show fewer labels than before. With a prime number of gaps (six ticks, or twelve unique values) there is no even step between "all" and "only the ends", so a crowded one shows the two ends. A label that would spill out of the element is now counted in the cut-off warning even if it would also have touched its neighbour.
Reach: the change is in the page renderer, so it reaches the layout view, PNG, PDF and SVG exports, desktop, browser, command line and Python alike. No command, parameter, pane or saved field changes, so ribbon, search, Assistant, MCP and plugins have nothing new to show; undo is unaffected.
Testing
crates/render/src/layout/tests/colorbar_labels.rs: a sweep over element widths and heights for each scale kind, orientation and direction, checking that labels keep their gap, that the first and last are kept with the others evenly spaced between them, and that where those two would touch only one is drawn and the other is counted as cut off. The three sweep tests failed with the old loop.ui_shotbefore and after ondem.tif(A5, five ticks, 16 pt, two decimals): the 50 mm horizontal bar differs; the wider, narrower and vertical ones export the same bytes.rustgis-geolibre, 1 symbology smoke test), in code this change doesn't touch. After the last commit: fmt, clippy and the 1,181rustgis-rendertests pass.UI evidence
A five-tick colorbar 50 mm wide at 16 pt.
Related issue
Closes #3501
Summary by CodeRabbit
Improvements
Documentation