docs: adopt astro-chartjs-editor 1.3.1, live offset control - #259
Open
kurkle wants to merge 2 commits into
Open
Conversation
…b, add an offset control - Bump @kurkle/astro-chartjs-editor to ^1.3.1. - customize.md: inline the separate options block into config so the default tab shows the full sample instead of three lines of glue. - offset.md: replace the three offset-flipping buttons with a choices radio control, dropping the plugins.title readout it used to drive. - starlight.css: widen the shared :root block with the heading scale and add a content-panel padding rule (additive, per the fleet convention of never replacing this file's prior rules).
Deploying chartjs-plugin-autocolors with
|
| Latest commit: |
713f610
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c95891fa.chartjs-plugin-autocolors.pages.dev |
| Branch Preview URL: | https://docs-sample-structure.chartjs-plugin-autocolors.pages.dev |
The choices radio from the previous commit updated the live option value and its readout but never actually recolored the bars, for the same reason the buttons it replaced never did: chartjs-plugin-autocolors' dataset mode only assigns a color once per dataset object, and the editor's choice-driven rebuild reuses the same (already colored) dataset objects across recreations when only an options.* path changes. Replace the dead control with charts: three fixed variants, one per offset value, each built by a factory that creates fresh dataset objects per call so autocolors can color each chart independently. The underlying data values are shared across all three so only the color assignment differs.
|
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
@kurkle/astro-chartjs-editordevDependency^1.0.0→^1.3.1(resolves to1.3.1, confirmed vianpm ls).customize.md: inline the separateoptionsblock intoconfig, so the defaultconfigtab shows the whole sample instead of three lines of glue plus an extra tab.offset.md: rebuilt as three side-by-sidechartsvariants (offset: 0/1/2), each built by amakeConfig(offset)factory that creates its own fresh dataset objects. All three variants use the exact same underlying data values (generated once), so the only difference between them is color assignment. See "Offset — whychoiceswas replaced withcharts" below for why this isn't achoicescontrol.docs/styles/starlight.css: added to the existing:rootblock (heading scale) and added a new.content-panelrule, per the fleet convention of never replacing this file's existing rules.bar.md/update.md: checked, no changes. Neither fence has atitle=attribute duplicating the page h1.update.md's "Add data" action is a real action (pushes new data points) and stays as-is.repeat.md: left unchanged — see "Repeat — left alone" below.Verification
npm ls @kurkle/astro-chartjs-editor→chartjs-plugin-autocolors@0.0.0-development→@kurkle/astro-chartjs-editor@1.3.1.rm -rf node_modules/.astroonce before the first build (pre-1.3.1 cache had no version stamp), thennpm run docsbuilt cleanly (9 pages generated, no errors) on every iteration.astro previewand drove it with Playwright at 1400×900 and 1200-wide. Every changed page rendered non-blank charts, measured by counting non-transparent canvas pixels:customize.mdcode panel now shows exactly 2 tabs (config,data) instead of 3 — confirmed by screenshot.npm run lintandnpm test(fixture tests +kurkle-check-package, 14 tests / 19 package checks) pass. The pre-commit hook additionally ran typecheck/build/docs, all green, on both commits.Offset — why
choiceswas replaced withchartsThe first version of this PR gave
offset.mdachoicesradio. It updated the live option value and its on-page readout, but never actually recolored the bars — I measured this with MD5 hashes of canvas-only screenshots (identical across offset 0/1/2 after full animation settle) and with a diagnostic action that readchart.data.datasets[i].backgroundColorstraight off the live chart (also identical). Root cause:chartjs-plugin-autocolors's default'dataset'mode only assigns a color once per dataset object (dataset.backgroundColor = dataset.backgroundColor || background), and the editor'schoicesmechanism only clones config containers along the changed path — sinceoffsetlives underoptions,config.data(and every dataset object in it) is reused by reference across the rebuild, so the already-colored objects never get touched again. This was not a regression: the pre-existing buttons had the identical limitation (verified — clicking through the oldOffset: 0/1/2buttons only ever changed theplugins.titletext; bars were pixel-identical before and after onmain).Per the coordinator's direction,
offset.mdnow useschartsinstead: three fixed variants (offset: 0,1,2), each produced bymakeConfig(offset), which builds its owndatasetsarray from a sharedvaluesarray on every call. Because each variant gets brand-new dataset objects, autocolors colors each one independently — no shared, already-colored objects to get stuck.Measured proof it works, by sampling each chart's rendered bar colors directly off its canvas (Playwright +
getImageData, run left-to-right at the row with the most distinct color runs):f7ab53b8…,51345668…,e6610aa3…— all distinct.offset: 0andoffset: 1directly (no shift): 0/23 bars match — every single bar's color changed.offset: 0's bar N+1 tooffset: 1's bar N (i.e. "shifted by one color"): 21/22 match (95%).offset: 1's bar N+1 tooffset: 2's bar N: 21/22 match (95%).offset: 0→202,81,81/128,52,52/52,128,128;offset: 1→128,50,50/82,203,203/143,203,82; noteoffset:1's bar 1 ≈offset:0's bar 2, confirming the one-step shift.This is exactly what the sample's prose now describes: three charts sharing the same data, each with its own autocolors instance whose palette starts one color further along.
Repeat — left alone
I did not apply the analogous
choicesconversion torepeat.md, because that sample is different fromoffset.md: its existing "editrepeatin the code panel and click Run" workflow actually works. I verified this directly — editingrepeat: 3→1in the live code editor and clicking Run re-executes the whole script, producing fresh dataset objects and a genuinely different, correctly-recolored chart (confirmed by canvas screenshot: distinct per-bar coloring before/after, matching a real repeat-of-1 pattern). Achoicescontrol there would hit the exact same stale-object issue diagnosed above and would be a real regression — replacing a working interaction with a non-working one.repeat.mdis left exactly as it is onmain, pending a decision on how (or whether) to work around the underlying editor/plugin interaction for that sample too.Separately, while diagnosing this I found what looks like an unrelated one-line typo in
src/index.js'ssetColors(): formode: 'data'it setsdataset.border = borderinstead ofdataset.borderColor = border, so per-datapoint border colors are silently dropped. Not fixed here — confirmed with the coordinator this is afix:-type change to published plugin source that needs its own PR and test, after this one lands.Test plan
npm ls @kurkle/astro-chartjs-editorresolves to1.3.1npm run docsbuilds without errors (both commits)customize.mdshows 2 tabs instead of 3offset.md's three charts are pairwise distinct and each one's palette is the previous one shifted by one color (measured, numbers above)repeat.mdunchanged frommain(confirmed viagit diffand the GitHub compare API)npm run lintpasses (pre-existing warnings only, unchanged frommain)npm testpasses (14 fixture tests, 19 package checks)🤖 Generated with Claude Code