Repository navigation
fix(core): one rule for text on coloured chart areas - #947
Merged
Merged
Conversation
…ouped bars One rule for text on a coloured fill, in both themes (#914): - treemap: every label in --pk-text on a plate in --pk-surface, so all tiles look alike whatever their colour - heatmap: each number in --pk-text or --pk-surface, else black or white, whichever reaches 4.5:1 on the cell (labelColorOn) - high and low points, reference lines: glyph, value and words in the text colour; the dot keeps the series colour High and low points and reference lines (#913): - a point's label sits over its own bar in grouped bars and never crosses another bar; without room it is left out - narrow charts write a line's value, a trend its name - an average's sample takes colorMap and chart.colors tests/fill-contrast.js measures a label's contrast on its fill in both themes, for tests of any package. Closes #913 Closes #914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d-fills # Conflicts: # packages/pivotkit-core/CHANGELOG.md # packages/pivotkit-element/CHANGELOG.md # packages/pivotkit-report/CHANGELOG.md
…aving it out A high or low point's label that has no room over its bar or beside its dot now stands over the highest bar of its category's group, inside the plot. Labels that still have no room are left out, and the tooltip has the value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hout words decorateOption takes tileOf, a treemap's tiles after a first draw, and drawnTiles reads them from an ECharts instance. pivotkit-react and pivotkit-report draw a treemap twice, as they do for pixelOf. Each label's padding then puts its lines in the tile's middle. A label too wide for its tile has no plate and takes the ink that reads on the tile, so no plate stands empty or cuts a name early. Docs and changelogs name labelColorOn's black and white results, the tokens of point and reference-line labels, and what happens without a --pk-surface the chart can draw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rged branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tile with no room for one line on a plate lost its label: the padding that centres the lines pushed the text out of the box. Such a label now has no plate, as one too wide for its tile, and a centred label is never moved below one line. The browser test counts the tiles without words and measures the contrast of labels with and without a plate; the SVG test checks that the report centres them too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d-fills # Conflicts: # scripts/growth-baseline.json
…rowth baseline After the merge of main the chart group measures 261.5 KiB gzip on an official Node 24 build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re they fit - Treemap: every label sits on a plate in the tile's middle. A name wider than its tile is cut with an ellipsis, a value line that does not fit is left out, and a tile with room for fewer than 3 characters has no label. The bare per-tile ink stays only for a theme without a readable surface. - drawnTiles matches an item by name as well as by place, so in a tree with children no tile is taken for another item's (checked against ECharts 6.1.0, with a server-side rendered test). - Reference lines below 480 px keep their names when every label fits in 30 % of the width, else write the values as before. - In dense grouped bars, the chart's highest and lowest point labels are placed first. - barSlots documents that it assumes ECharts' default bar gaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p limits Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dense grouped bars Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bars only On lines, placing them first left a close low without its label; the series' order moves the labels apart instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ites the values Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lines of a tile kept 5 px above and below, so a tile of 66 x 31 px at 14 px text lost its label. Now a pixel above and below is enough; the sides keep their padding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chart pages gain the treemap label rule, reference lines on phones, the bar gap limits and two restored bullets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cut name now keeps at least 4 characters before the ellipsis; a tile with less room shows no label, and its tooltip gives name and value. The treemap label constants live in chart-measure.js, so the browser spec derives its size gate from them instead of repeating numbers. Docs and changelogs name the muted text colour (--pk-muted) for point and reference-line labels and use one wording (30 % of the width) for narrow reference lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l below the smallest tile On a touch screen at 390 px, a tap on a tile without words and on one with a cut name shows the tooltip with the whole name and the value. A tile too narrow even for the narrowest cut name, or lower than a line, shows neither words nor a plate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cters 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.
Summary
One rule for text on coloured chart areas, readable in light and dark themes and after a theme switch.
Fixes #913
Fixes #914
--pk-surfacewith--pk-text, the same on every tile and centred in it. A name that does not fit ends in "…" after at least 4 characters. A value line that does not fit is dropped, never cut. A tile with less room, or lower than one line, shows no text and no empty plate. A tap or pointer shows its name and value.--pk-text/--pk-surfacehas the higher contrast on its cell if that reaches 4.5:1, else black or white--pk-muted) with a--pk-surfaceoutline, beside the dot or above the group. In dense grouped bars, the chart's highest and lowest are placed first; labels that do not fit are dropped, and the tooltip still has them.--pk-muted, after a dash sample in the line's colour. Below 480 px the kind word ("Average 25") stays when every label fits in 30 % of the width, else the value alone.Sizes, measured with Node 24 as in CI:
The growth baseline accepts 9 more lines on the two chart docs pages. They hold:
Known limit, documented in docs/concepts/charts.md: label placement beside grouped bars assumes ECharts' default
barGapandbarCategoryGap.Neutral review
I ran four rounds of independent review on the local branch before pushing. Fixed because of them:
The last round found nothing blocking.
Checklist (PRODUCT.md)
CHANGELOG.md(core, react, report, element) describe the new stateTest plan
npm run lint,npm run types,npm test,npm run growth,npm run pack:check: exit 0npm run test:browser, chart specs (fill-labels, types, reference-lines) in chromium, firefox and webkit: 138 passed🤖 Generated with Claude Code