生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

Sparkline new ​

Charts component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="sparkline": root · summary · band · reference-line · area-fill · line · bar · dot

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-sparkline>
Vue componentsXhSparkline
ComposableuseSparkline
State machinesparklineMachine
Skin@xihan-ui/styles/sparkline.css

Props ​

PropTypeRequired
datareadonly (number | null | undefined)[] | readonly ChartRow[]
xstring
ystring
variantSparklineVariant
curveSparklineCurve
markersSparklineMarkers
bandreadonly [number, number]
referenceSparklineReference
toneTone
formatNumberFormatSpec | ((value: number) => string)
animatedboolean
localestring
translationsPartial<SparklineTranslations>

State ​

Public state is written to data-state.

PartValues
root'error' | 'empty' | undefined

The following names are internal to the state machine.

States: idle

Events: RESIZE · METRICS · SCENE.FRAME

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
modelSparklineModel
sceneScene
measuredboolean
emptyboolean
summarystring
getRootProps() => T['element']
getSummaryProps() => T['element']
getMarkProps(mark: Mark) => T['element']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

No keyboard interaction: the component takes no focus, or focus behavior comes entirely from native elements.

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-describedbyid of the summary part
rootrole'img'

Style reference ​

Skin ​

@xihan-ui/styles/sparkline.css is written against [data-scope="sparkline"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-sparkline in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-state'error' | 'empty' | undefined
rootdata-toneprops.tone
rootdata-variantprops.variant

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-sparkline-accent-colorbar
dot
root
filldefault
marker
not([data-tone='neutral'])
tone
tone=neutral
--xh-_tone
--xh-chart-categorical-1
--xh-sparkline-band-bgbandfilldefault--xh-bg-subtle
--xh-sparkline-bar-maxroot--xh-_chart-metric-bar-maxdefault--xh-chart-bar-max
--xh-sparkline-bar-radiusroot--xh-_chart-metric-radiusdefault--xh-shape-inset
--xh-sparkline-colorarea-fill
bar
line
root
fill
stroke
default
not([data-tone='neutral'])
tone
tone=neutral
--xh-_tone
--xh-chart-deemphasis
--xh-sparkline-heightrootblock-sizedefault--xh-text-body-line-h
1lh
--xh-sparkline-line-widthlegend-swatch
line
root
tooltip-swatch
--xh-_chart-dash
background
block-size
stroke-width
@media (forced-colors: active)
@media print
default
mark=line
where([data-xh-chart-patterns])
xh-chart-pattern
xh-chart-pattern=2
xh-chart-pattern=3
xh-chart-pattern=4
xh-chart-pattern=5
xh-chart-pattern=6
xh-chart-pattern=7
xh-chart-pattern=8
xh-chart-patterns
--xh-chart-line-width
--xh-sparkline-marker-sizelegend-swatch
root
tooltip-swatch
background@media (forced-colors: active)
@media print
where([data-xh-chart-patterns])
xh-chart-pattern
xh-chart-pattern=1
xh-chart-pattern=2
xh-chart-pattern=3
xh-chart-pattern=4
xh-chart-pattern=5
xh-chart-pattern=6
xh-chart-pattern=7
xh-chart-pattern=8
xh-chart-patterns
--xh-chart-point-size
--xh-sparkline-reference-colorreference-linestrokedefault--xh-chart-label
--xh-sparkline-widthrootinline-sizedefault6rem

Released under The MIT License