Repository navigation
Bar stack/fill with an x axis: one bar per cell, in x order - #26
Merged
Merged
Conversation
…an x 1.0.18 collapsed a cell into one stacked bar only without an x axis. With an x axis that gives every value its own position (e.g. the colour factor on x), stack and fill still drew separate bars, as ggplot had nothing to stack at any x. Collapse in that case too, ordering the stack by the x axis. When values share an x position, stacking per x is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- utils.R: the bar placement moves into pure functions (crosstab_x_position, collapse_bars, stack_cells, bar_layer) so it can be tested without a Tercen context. The output is unchanged: 12 Studio projections (customer and synthetic data, x and no x, dodge/stack/fill) are pixel-identical before and after. - unit_tests/run.R: base-R checks (no testthat in the image) that build the bar layer and read back what ggplot computes: one bar per cell, stack order (crosstab order without x, x order with the colour on x), fill to 1, and plain ggplot behaviour when values share an x. Verified to fail on the 1.0.17 read order, the 1.0.18 no-x-only rule and an upside-down stack. - .github/workflows/unit-tests.yml: builds the image and runs the tests in it on pull requests and pushes to master. - README: how bar.position behaves, and how to run the tests. Co-Authored-By: Claude Opus 5.5 <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.
Follow-up to #25 (1.0.18).
Problem
1.0.18 draws a cell as one stacked bar only when there is no x axis. With an x axis that gives each value of a cell its own position, stack and fill still draw separate bars, the same as dodge. A common case is the colour factor on x, which is what the customer did on tercen.com. There, no x position holds more than one value, so ggplot has nothing to stack.
Fix (
utils.R, ChartBar)Verification
Each case ran on local Tercen Studio in dodge, stack and fill. Each was compared with the released 1.0.18 image, once as released and once with this
utils.Rmounted.Unit tests (new)
utils.Rmoves the bar placement into pure functions:crosstab_x_position,collapse_bars,stack_cellsandbar_layer. They can be tested without a Tercen context. The output is unchanged: 12 Studio projections are pixel-identical before and after.unit_tests/run.R. 24 base-R checks, with no testthat added to the image. Each builds the bar layer and reads back what ggplot computes:.github/workflows/unit-tests.yml. Builds the image and runs the tests in it on every pull request and on pushes to master. It is green on this PR.unit_tests/, nottests/, which Tercen's installer and the library scan treat as platform golden tests.🤖 Generated with Claude Code