Skip to content

fix(s2): use Spectrum 2 chart-size dash patterns for line types - #968

Open
c-lamoureux wants to merge 1 commit into
mainfrom
fix/s2-dotted-line-gap
Open

c-lamoureux wants to merge 1 commit into
mainfrom
fix/s2-dotted-line-gap

Conversation

@c-lamoureux

Copy link
Copy Markdown
Contributor

Description

S2 line types now use Spectrum 2 dash and gap sizes for each chart size (S/M/L), compensated for round line caps.

Previously S2 reused S1 dash arrays, which were tuned for butt caps. With S2's round caps, every dash grew by the stroke width and every gap shrank by it (e.g. twoDash gaps disappeared, dotted gaps were too tight), and patterns did not change with chart size.

Changes

  • getStrokeDashFromLineType (S2) returns the medium-size visible lengths (dash including caps, gap) from a per-size design table.
  • New getChartSizeDashExpr builds a Vega expression that picks the cap-compensated dash for the current chart size from the rscChartSizeStrokeWidth signal. Used for static line types and alternate segments (forecast).
  • Data-driven lineType uses a new lineTypeChartSize ordinal scale that mirrors the lineType scale's domain with chart-size dash expressions.
  • Custom number[] line types are treated as visible lengths at medium chart size and scale with stroke width.
  • Line strokeDash moved from enter to update so it reacts to resize.
  • Butt-capped marks (legend symbols, bar, trendline) use the medium-size visible lengths as-is.
  • Docs updated for lineType.

Rendered dash arrays (dash excluding caps, gap)

S M L
dashed 4.5, 3.5 4.5, 4 6, 5
dotted 0, 2.5 0, 4 0, 5.5
dotDash 0, 3.5, 4.5, 3.5 0, 4, 4.5, 4 0, 5, 6, 5
shortDash 1.5, 3.5 2, 4 2.5, 5
longDash 9, 3.5 9, 4 12, 5
twoDash 4.5, 3.5, 9, 3.5 4.5, 4, 9, 4 6, 5, 12, 5

How Has This Been Tested?

  • Unit tests for getChartSizeDashes, getChartSizeDashExpr, getLineStrokeDash, alternate segments, and the new scale.
  • Integration tests asserting rendered stroke-dasharray at S and L widths.
  • New story: React Spectrum Charts 2/Line/Features/Line Type Chart Size (resizable, one series per line type).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Named line types use per-chart-size dash and gap values compensated for
round line caps. Custom dash arrays are treated as visible lengths at
medium chart size and scale with chart size. Adds a resizable LineType
chart size story.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@c-lamoureux c-lamoureux added bug Something isn't working rsc:Line s2 labels Oct 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working rsc:Line s2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant