Skip to content
Source
Sign inSign up
TanStack/charts

[Feature] Guide lines: a `shapeRendering` option for crisp hairlines #199

Opentoomingos(GitHub profile, opens in a new tab) opened this issue 0 comments

Version: @tanstack/charts 1.1.0 (57774e1).

ChartGuideLineStyle exposes stroke, strokeOpacity, strokeWidth, strokeDasharray and lineCap (types.ts:419-425). It has no rendering hint, and SceneStyle has none either (types.ts:1394-1404). The SVG renderer writes only those channels (svg-renderer.ts:206-216), and guideLineStyle copies only those five fields (scene.ts:1719-1735).

A 1px hairline grid on a fractional device offset is therefore anti-aliased across two rows at half intensity. Charts built on visx (whose GridRows defaults to shapeRendering="crispEdges") paint one crisp row. The only way to match that today is a CSS rule on the renderer's .ts-chart__grid line elements, which keys on a class name the docs do not promise.

Repro

import { renderChartSvg } from './svg'
// scene from any chart with a y axis grid, e.g. lineY with scales.y.grid: { strokeWidth: 1 }
expect(renderChartSvg(scene, { ariaLabel: 'c' })).toMatch(/shape-rendering="crispEdges"/)

There is no option that makes this pass; grep -ri shape-rendering packages/charts-core/src docs returns nothing.

Proposal

Add shapeRendering?: 'auto' | 'crispEdges' | 'geometricPrecision' | 'optimizeSpeed' to ChartGuideLineStyle, emitted as the SVG attribute on grid, axis and guide lines (ignored by canvas). A generic SVG presentation-attribute passthrough on guide lines would also work.

Follows #131, which added ChartGuideLineStyle. Checked against 57774e14a1a86081eddb3a23523724a40da05640 (v1.1.0).

  1. toomingos(GitHub profile, opens in a new tab) changed the title

Sign in to join this conversation.