Repository navigation
Fix zero-value bar stubs (#263) and Y-axis overshoot below zero (#304) - #382
Merged
Merged
Conversation
#263: BarChart.GetBarDrawingProperties enforced MinBarHeight on every bar, so a zero-value bar was drawn as a 4px stub. Enforce the minimum height only for non-zero bars. #304: MeasureHelper.CalculateYAxis counted ticks from the nice data range instead of the actual [niceMin, niceMax] axis span, so the labels could overshoot below niceMin (a gridline below zero for all-positive data) or drop the final tick. Count ticks over niceMax - niceMin so the labels span exactly the axis. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses two BarChart/axis-rendering bugs in Microcharts: (1) preventing zero-value bars from rendering as a visible “stub”, and (2) ensuring Y-axis tick labels span exactly the computed nice axis range so the axis doesn’t overshoot below zero or drop the 0 tick.
Changes:
- Adjust bar height enforcement so
MinBarHeightis only applied to non-zero bars (fixing zero-value stubs; #263). - Fix Y-axis tick counting to use the
[niceMin, niceMax]span rather than the “nice data range” (fixing overshoot / missing zero tick; #304).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Sources/Microcharts/Charts/BarChart.cs | Changes MinBarHeight enforcement so zero-value bars stay empty, and updates bar sizing logic. |
| Sources/Microcharts/Helpers/MeasureHelper.cs | Fixes Y-axis tick count to align tick labels with the computed nice axis bounds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot review on #382: when enforcing MinBarHeight on a small non-zero bar, the code compared against the chart bottom rather than the axis origin, so a small positive bar in a mixed positive/negative range extended below the origin into the negative area. Anchor to origin instead - positive bars grow up from it, negative bars grow down. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Two BarChart / axis rendering fixes.
#263 — zero-value bars rendered a stub
BarChart.GetBarDrawingPropertiesusedMath.Max(MinBarHeight, Abs(origin - barY)), so a zero-value bar (true height 0) was forced up toMinBarHeight(4px). The minimum is now enforced only for non-zero bars, so zero-value bars stay empty.#304 — Y-axis could show a tick below zero (and could drop the 0 tick)
MeasureHelper.CalculateYAxiscounted ticks from the nice data range (NiceScale'srangeoutput) rather than the actual[niceMin, niceMax]axis span, so the labels could overshoot belowniceMin. For all-positive data this drew a gridline below zero for some max values, and dropped the0tick for others. Counting ticks overniceMax - niceMinmakes the labels span exactly the axis every time:600, 400, 200, 0,-200600, 400, 200, 01000, 800, 600, 400, 200(no 0)1000, 800, 600, 400, 200,0Verification
Closes #263.
Closes #304.
🤖 Generated with Claude Code