fix: align diagonal Canvas gradients on non-square charts #258
main fromtaren/gradient-current-0212·merged by tannerlinsley Canvas diagonal gradients shift color stops when the chart geometry has unequal width and height. Project the gradient normal through the chart transform so the stops line up with the intended direction. The regression tests cover the non-square case along with very large and very small dimensions.
The focused Canvas suite and package checks pass. The two affected bundles are 40.399 and 46.845 kB gzip, within the approved ceilings of 40.399 and 46.846 kB. This addresses the Canvas gradient part of #191.
Summary by CodeRabbit#
Bug Fixes
- Corrected linear-gradient projections for non-square Canvas areas, improving alignment between Canvas gradients and SVG rendering.
Documentation
- Updated chart comparison results to reflect the measured workspace revision.
Chores
- Adjusted bundle size budgets to match current measurements.
- 1
No actionable comments were generated in the recent review.
Walkthrough
-
Canvas linear-gradient endpoint calculation now adjusts the gradient normal for non-square bounds when dimensions and endpoint deltas are nonzero. Tests check unit-space projection across multiple dimensions and directions. The changeset, benchmark metadata, comparison revision notes, and two bundle budgets are also updated.
Changes: Canvas Linear-Gradient Projection
Layer / File(s) Summary Gradient projection calculation
packages/charts-core/src/canvas.ts,packages/charts-core/src/canvas.test.ts,.changeset/canvas-linear-gradient-projection.mdThe Canvas gradient endpoint vector is recalculated for non-square bounds when the dimensions and endpoint deltas are nonzero. Tests check the projection for varied dimensions and directions. A patch changeset records the update. Benchmark and comparison records
benchmarks/comparison/bundle-baseline.json,benchmarks/conformance/previews/manifest.json,docs/comparison.md,packages/charts-core/docs/comparison.md,scripts/measure-bundles.mjsThe benchmark source revision and digest, preview source hash, and comparison revision notes are updated. Two bundle budgets increase. Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
- TanStack/charts issue 191 — The PR addresses its Canvas gradient geometry topic. Its stop-tweening and SVG gradient-units topics remain unaddressed.
Suggested reviewers:
greglum
Merge Risk:
Minimal · up to6d13e-
Non-square Canvas gradients are corrected, with no actionable merge-blocking issue identified.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Description Check Check skipped - CodeRabbit’s high-level summary is enabled. Title check The title clearly and concisely describes the main change: fixing diagonal Canvas gradient alignment on non-square charts. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files. (5 skipped: 5 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
807905d7-0d00-4b3e-a27f-e2f0e450cc79
Commits-
Reviewing files that changed from the base of the PR and between b62bb678bcce4b92ff8741a75b48349a4ef01987 and 6d13e89be5eaf8448d2a1553ab22ae8ac718e243.
Files selected for processing: 8-
.changeset/canvas-linear-gradient-projection.mdbenchmarks/comparison/bundle-baseline.jsonbenchmarks/conformance/previews/manifest.jsondocs/comparison.mdpackages/charts-core/docs/comparison.mdpackages/charts-core/src/canvas.test.tspackages/charts-core/src/canvas.tsscripts/measure-bundles.mjs
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
-
-
View your CI Pipeline Execution ↗ for commit 6d13e89be5eaf8448d2a1553ab22ae8ac718e243
Command Status Duration Result nx run charts-workspace:ci-distributed✅ Succeeded 6m 45s View ↗ nx run charts-workspace:package-check✅ Succeeded 1m 43s View ↗ nx run charts-workspace:benchmark-check✅ Succeeded 46s View ↗
☁️ Nx Cloud last updated this comment at
2026-11-04 19:51:55UTCtannerlinsley merged this3b8922a
tannerlinsley closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 6d13e89be5eaf8448d2a1553ab22ae8ac718e243
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR