Fix area fill curve to match line stroke in LineChart - #124
Conversation
…ead of straight segments buildAreaPath always re-traced each segment with buildLinePath, so a series with curve="smooth" and area=true drew a Bezier stroke over a polygonal fill. It now takes the series curve and traces each segment with the same builder as the line. Added a play() test to the AreaFill story as a regression check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Auhd9pkaf5zD88BE9Q7Nbg
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Storybook Tests failed on the The failing test is Root cause: a timing race in
I reproduced this locally, both ways:
Proposed fix: wait in const emulateReducedMotion: boolean =
storyContext.parameters?.["emulateReducedMotion"] === true;
+ // `matchMedia(...).matches` flips as soon as the emulation changes, but
+ // the query's `change` event is only dispatched a few frames later. Framer
+ // Motion caches the preference from that event, so a story that mounts in
+ // between reads reduced motion in CSS and in `play()` but still animates
+ // in JavaScript. Wait for the event before the story renders.
+ const changing: boolean = await page.evaluate(
+ (reduce: boolean): boolean => {
+ const query: MediaQueryList = window.matchMedia(
+ "(prefers-reduced-motion: reduce)",
+ );
+ if (query.matches === reduce) {
+ return false;
+ }
+ const flagged = window as Window & { __reducedMotionChanged?: boolean };
+ flagged.__reducedMotionChanged = false;
+ query.addEventListener(
+ "change",
+ (): void => {
+ flagged.__reducedMotionChanged = true;
+ },
+ { once: true },
+ );
+ return true;
+ },
+ emulateReducedMotion,
+ );
+
await page.emulateMedia({
reducedMotion: emulateReducedMotion ? "reduce" : "no-preference",
});
+
+ if (changing) {
+ await page.waitForFunction(
+ (): boolean =>
+ (window as Window & { __reducedMotionChanged?: boolean })
+ .__reducedMotionChanged === true,
+ );
+ }With this patch the DashboardLayout suite passed 24 out of 24 runs. I've re-run the failed job once. Generated by Claude Code |
Summary
Fixed a bug in the LineChart component where the area fill's top edge did not match the smoothed line stroke when using the
curve="smooth"option. The fill was always drawn with straight lines, causing a visual mismatch between the stroke and the fill boundary.Changes
buildCurvePath()function that returns either a smooth or linear path based on the curve type.buildAreaPath()signature: Changed to acceptpointsandcurveparameters instead of a pre-builtlinePath, allowing the function to build the correct curve for each segment.linePathparameter and now build the curve path directly withinbuildAreaPath()for each segment, ensuring the fill's top edge traces the same curve as the stroke.buildCurvePath()function.play()interaction test to theAreaFillstory that verifies the area path contains cubic Bézier curve commands (C) and that the fill's top edge matches the line stroke path.Implementation Details
The key insight is that
buildAreaPath()needs to know which curve type to use when re-tracing each segment, rather than relying on a pre-built line path. This ensures the fill's top edge sits exactly under the stroke, regardless of whether smooth or linear curves are used.https://claude.ai/code/session_01Auhd9pkaf5zD88BE9Q7Nbg