Skip to content

Improve gauge labels and increase gradient steps#963

Merged
emeeks merged 3 commits into
mainfrom
click-testing-fixes
May 22, 2026
Merged

Improve gauge labels and increase gradient steps#963
emeeks merged 3 commits into
mainfrom
click-testing-fixes

Conversation

@emeeks
Copy link
Copy Markdown
Member

@emeeks emeeks commented May 22, 2026

Render radial tick marks and reposition gauge labels outside the arc with clock-based alignment and configurable font size; draw 2px-spanning marks and use CSS vars for text styling. Also increase the default gradientSteps from 48 to 240 for smoother gauge gradients and update the test expectation accordingly.

Render radial tick marks and reposition gauge labels outside the arc with clock-based alignment and configurable font size; draw 2px-spanning marks and use CSS vars for text styling. Also increase the default gradientSteps from 48 to 240 for smoother gauge gradients and update the test expectation accordingly.
Comment thread src/components/charts/ordinal/GaugeChart.tsx Fixed
// Clock hour from labelAngle: 12 at top, clockwise.
const hour = (((labelAngle + Math.PI / 2) / (2 * Math.PI)) * 12 + 12) % 12
let textAnchor: "start" | "middle" | "end" = "middle"
let dominantBaseline: "auto" | "middle" | "hanging" = "middle"
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GaugeChart’s scale-label rendering to add radial tick marks and place labels outside the arc with clock-position-based alignment, and increases the default gradient sampling density for smoother gauge gradients.

Changes:

  • Increase buildGaugeArcModel default gradientSteps from 48 → 240 to improve gradient smoothness.
  • Render radial tick marks for gauge-label annotations and reposition label text outside the arc with adaptive textAnchor/dominantBaseline.
  • Update the unit test expectation to match the new default gradient slice budget.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/components/charts/shared/gaugeGradient.ts Raises default gradient sampling steps for gauge gradient bands.
src/components/charts/ordinal/GaugeChart.tsx Adds radial tick marks and moves/re-aligns scale labels outside the arc; introduces a CSS-var font size for those labels.
src/components/charts/ordinal/GaugeChart.test.tsx Updates gradient slice-count expectation to match the new default budget.

Comment on lines +354 to +355
// reads as 2px wider than the arc total.
const markInner = innerRadius - 1
Comment on lines 351 to 367
const cx = (context.width || width) / 2
const cy = (context.height || height) / 2
// Radial tick mark spanning the arc band — 1px past each edge so it
// reads as 2px wider than the arc total.
const markInner = innerRadius - 1
const markOuter = radius + 1
const mx1 = Math.cos(labelAngle) * markInner
const my1 = Math.sin(labelAngle) * markInner
const mx2 = Math.cos(labelAngle) * markOuter
const my2 = Math.sin(labelAngle) * markOuter
// Text sits outside the arc. Alignment follows the clock position
// of the mark: top sector (11–1) centered above, right sector (1–5)
// left-aligned, bottom sector (5–7) centered below, left sector
// (7–11) right-aligned.
const labelR = radius + 10
const lx = Math.cos(labelAngle) * labelR
const ly = Math.sin(labelAngle) * labelR
Comment thread src/components/charts/ordinal/GaugeChart.tsx
@emeeks emeeks force-pushed the click-testing-fixes branch from ee7286d to 20a4f1b Compare May 22, 2026 02:08
const ly = Math.sin(labelAngle) * labelR
// Clock hour from labelAngle: 12 at top, clockwise.
const hour = (((labelAngle + Math.PI / 2) / (2 * Math.PI)) * 12 + 12) % 12
let textAnchor: "start" | "middle" | "end" = "middle"
Replace --update-snapshots=changed with --update-snapshots=missing in the Playwright bootstrap step. Updated both the GitHub Actions workflow and the package.json script so snapshot baselines are only created when missing, avoiding flaky/renamed-test cases that could leave CI permanently failing.
@emeeks emeeks merged commit c9561da into main May 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants