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

查看生态总览
Skip to content

CartesianChart 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="cartesian-chart": root · caption · legend · legend-item · legend-swatch · legend-label · legend-scale · legend-scale-name · legend-scale-bar · legend-scale-value · viewport · underlay · canvas · plot · defs · pattern · pattern-line · clip-path · clip-rect · grid · grid-line · axis · axis-line · tick · tick-label · axis-title · series · bar · stem · connector · candle · wick · box · whisker · median · outlier · line · area-fill · dot · point · data-label · total-label · end-label · leader-line · annotation · annotation-label · brush · crosshair · focus-ring · tooltip · tooltip-header · tooltip-row · tooltip-swatch · tooltip-value · tooltip-name · empty · zoom-slider · zoom-track · zoom-window · zoom-handle · zoom-preview · zoom-preview-line · summary · table-region · table

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-cartesian-chart>
Vue componentsXhCartesianChartCaption XhCartesianChartEmpty XhCartesianChartLegend XhCartesianChartPlot XhCartesianChartRoot XhCartesianChartTooltip XhCartesianChartViewport XhCartesianChartZoomSlider
ComposableuseCartesianChart
State machinecartesianChartMachine
Skin@xihan-ui/styles/cartesian-chart.css

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
hidden-series-changeChartHiddenSeriesChangeDetails
active-key-changeChartActiveKeyChangeDetails
window-changeCartesianWindowChangeDetails
follow-changeCartesianFollowChangeDetails
brush-selection-changeCartesianBrushSelectionChangeDetails
datum-activeChartDatumDetails
datum-pressChartDatumDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhCartesianChartRootdefaultCartesianChartRootSlotProps
XhCartesianChartRootcaption—
XhCartesianChartRoottooltipCartesianChartTooltipSlotProps
XhCartesianChartRootempty—
XhCartesianChartTooltipdefaultCartesianChartTooltipSlotProps

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhCartesianChartRootdatareadonly ChartRow[] | ColumnSource
XhCartesianChartRootseriesreadonly CartesianSeries[]
XhCartesianChartRootxAxisCartesianAxis
XhCartesianChartRootyAxisCartesianAxis
XhCartesianChartRootorientationCartesianOrientation
XhCartesianChartRootrendererCartesianRenderer
XhCartesianChartRoottriggerCartesianTrigger
XhCartesianChartRoottotalsboolean
XhCartesianChartRoottooltipOrderCartesianTooltipOrder
XhCartesianChartRootpaletteChartPalette
XhCartesianChartRootannotationsreadonly CartesianAnnotation[]
XhCartesianChartRootzoomCartesianZoom
XhCartesianChartRootwindowCartesianWindow
XhCartesianChartRootdefaultWindowCartesianWindow
XhCartesianChartRootonWindowChangeCartesianChartProps['onWindowChange']
XhCartesianChartRootfollowboolean
XhCartesianChartRootdefaultFollowboolean
XhCartesianChartRootonFollowChangeCartesianChartProps['onFollowChange']
XhCartesianChartRootbrushCartesianBrush
XhCartesianChartRootbrushSelectionCartesianBrushSelection | null
XhCartesianChartRootdefaultBrushSelectionCartesianBrushSelection | null
XhCartesianChartRootonBrushSelectionChangeCartesianChartProps['onBrushSelectionChange']
XhCartesianChartRoothiddenSeriesstring[]
XhCartesianChartRootdefaultHiddenSeriesstring[]
XhCartesianChartRootactiveKeyChartKey | null
XhCartesianChartRootpendingboolean
XhCartesianChartRootanimatedboolean
XhCartesianChartRootlocalestring
XhCartesianChartRoottranslationsPartial<CartesianChartTranslations>
XhCartesianChartRootonHiddenSeriesChangeCartesianChartProps['onHiddenSeriesChange']
XhCartesianChartRootonActiveKeyChangeCartesianChartProps['onActiveKeyChange']
XhCartesianChartRootonDatumActiveCartesianChartProps['onDatumActive']
XhCartesianChartRootonDatumPressCartesianChartProps['onDatumPress']
XhCartesianChartRootcaptionReactNode
XhCartesianChartRootrenderTooltip(props: CartesianChartTooltipSlotProps) => ReactNode
XhCartesianChartRootemptyReactNode
XhCartesianChartRootchildrenSlotChildren<CartesianChartRootSlotProps>
XhCartesianChartTooltipchildrenSlotChildren<CartesianChartTooltipSlotProps>

State ​

Public state is written to data-state.

PartValues
root'error' | undefined
tooltip'visible' | 'hidden'
empty'loading' | undefined

The following names are internal to the state machine.

States: idle

Events: WINDOW.SET · DRAG.START · DRAG.END · BRUSH.START · BRUSH.MOVE · BRUSH.END · BRUSH.SET · BRUSH.ANCHOR · DATA.TICK

connect API ​

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

MemberType
modelCartesianModel
renderer'svg' | 'canvas'
layersCartesianLayers
sceneScene
overlayCartesianOverlay
measuredboolean
emptyboolean
legendItemsreadonly CartesianLegendItem[]
legendScaleCartesianLegendScale | null
patternsreadonly ChartPattern[]
activeChartDatumDetails | null
tooltipCartesianTooltipModel | null
summarystring
tableTableModel
emptyTextstring
tableCaptionstring
activeKeyChartKey | null
hiddenSeriesstring[]
toggleSeries(id: string) => void
setFocusedDatum(ref: { seriesId: string, index: number } | null) => void
markTag(mark: Mark) => CartesianMarkTag
zoom{ readonly x: boolean, readonly y: boolean, readonly window: CartesianWindow, readonly ratio: CartesianWindowRatio }
clip{ readonly id: string, readonly x: number, readonly y: number, readonly width: number, readonly height: number } | null
setWindow(window: CartesianWindow) => void
brush{ readonly x: boolean readonly y: boolean readonly selection: CartesianBrushSelection | null readonly rect: { readonly x: number, readonly y: number, readonly width: number, readonly height: number } | null }
setBrushSelection(selection: CartesianBrushSelection | null) => void
getRootProps() => T['element']
getCaptionProps() => T['element']
getLegendProps() => T['element']
getLegendItemProps(item: CartesianLegendItem) => T['button']
getLegendSwatchProps(item: CartesianLegendItem) => T['element']
getLegendLabelProps(item: CartesianLegendItem) => T['element']
getLegendScaleProps() => T['element']
getLegendScaleNameProps() => T['element']
getLegendScaleBarProps() => T['element']
getLegendScaleValueProps(edge: 'min' | 'max') => T['element']
getViewportProps() => T['element']
getPlotProps() => T['element']
getUnderlayProps() => T['element']
getCanvasProps() => T['element']
getDefsProps() => T['element']
getPatternProps(pattern: ChartPattern) => T['element']
getPatternLineProps(pattern: ChartPattern) => T['element']
getMarkProps(mark: Mark) => T['element']
getTooltipProps() => T['element']
getTooltipHeaderProps() => T['element']
getTooltipRowProps(row: CartesianTooltipRow) => T['element']
getTooltipSwatchProps(row: CartesianTooltipRow) => T['element']
getTooltipValueProps(row: CartesianTooltipRow) => T['element']
getTooltipNameProps(row: CartesianTooltipRow) => T['element']
getEmptyProps() => T['element']
getClipPathProps() => T['element']
getClipRectProps() => T['element']
getZoomSliderProps() => T['element']
getZoomTrackProps() => T['element']
getZoomWindowProps() => T['element']
getZoomHandleProps(edge: 'start' | 'end') => T['element']
getZoomPreviewProps() => T['element']
getZoomPreviewLineProps() => T['element']
getSummaryProps() => T['element']
getTableRegionProps() => T['element']
getTableProps() => 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.

KeysBehavior
Tab / Shift+Tabcartesian-chart.kbd.tab
ArrowRightcartesian-chart.kbd.next
ArrowLeftcartesian-chart.kbd.prev
ArrowUpcartesian-chart.kbd.series-next
ArrowDowncartesian-chart.kbd.series-prev
Homecartesian-chart.kbd.first
Endcartesian-chart.kbd.last
PageUp / PageDowncartesian-chart.kbd.page
Enter / Spacecartesian-chart.kbd.press
+ / =cartesian-chart.kbd.zoom-in
- / _cartesian-chart.kbd.zoom-out
ArrowLeft / ArrowRight / ArrowDown / ArrowUp / PageUp / PageDown / Home / Endcartesian-chart.kbd.zoom-edge
Shift+ArrowRight / Shift+ArrowLeft / Shift+Home / Shift+End / Shift+PageUp / Shift+PageDowncartesian-chart.kbd.brush
Escapecartesian-chart.kbd.dismiss
ArrowLeft / ArrowRight / Home / Endcartesian-chart.kbd.legend-move
Enter / Spacecartesian-chart.kbd.legend-toggle

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-busy'true' | undefined
legendaria-labeltranslations.legendLabel
legendrole'toolbar'
legend-itemaria-pressed'false' | 'true'
legend-swatcharia-hidden'true'
legend-scalearia-hidden'true'
underlayaria-hidden'true'
canvasaria-hidden'true'
plotaria-describedbyid of the summary part
plotaria-roledescriptiontranslations.chartRoleDescription
plotrole'graphics-document'
tooltiparia-hidden'true'
zoom-slideraria-labeltranslations.zoomLabel
zoom-sliderrole'group'
zoom-handlearia-labeltranslations.zoomStartLabel | translations.zoomEndLabel
zoom-handlearia-orientation'horizontal'
zoom-handlearia-valuemax100
zoom-handlearia-valuemin0
zoom-handlearia-valuenowMath.round(shown.x[edge] * 100)
zoom-handlearia-valuetextedgeText(shown.x[edge], edge)
zoom-handlerole'slider'
zoom-previewaria-hidden'true'
markaria-hiddenmark.exiting || undefined
markaria-labelundefined | spec?.name
markaria-roledescriptionundefined | translations.seriesRoleDescription
markroleundefined | 'graphics-object'

Style reference ​

Skin ​

@xihan-ui/styles/cartesian-chart.css is written against [data-scope="cartesian-chart"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-cartesian-chart 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-loading'' (present only while the condition holds)
rootdata-orientationmodel.spec.orientation
rootdata-paletteprops.palette
rootdata-state'error' | undefined
rootdata-xh-chart-part'root'
captiondata-xh-chart-part'caption'
legenddata-xh-chart-part'legend'
legend-itemdata-pressed'' (present only while the condition holds)
legend-itemdata-toneitem.tone
legend-itemdata-valueitem.id
legend-itemdata-xh-action-control''
legend-itemdata-xh-action-profile'text'
legend-itemdata-xh-action-size'xs'
legend-itemdata-xh-action-variant'ghost'
legend-itemdata-xh-chart-part'legend-item'
legend-itemdata-xh-chart-patternpatternOf(item.id)
legend-itemdata-xh-chart-scale'sequential' | undefined
legend-itemdata-xh-chart-slotundefined | String(item.slot)
legend-swatchdata-markswatchMark(item)
legend-swatchdata-symbolitem.symbol
legend-swatchdata-xh-chart-part'legend-swatch'
legend-scale-valuedata-edgeedge
viewportdata-xh-chart-part'viewport'
canvasdata-empty'' (present only while the condition holds)
plotdata-dragging'' (present only while the condition holds)
plotdata-selectable'' (present only while the condition holds)
plotdata-touch-axis'both' | 'horizontal' | 'vertical' | undefined
plotdata-xh-chart-part'plot'
plotdata-zoomed'' (present only while the condition holds)
defsdata-xh-chart-part'defs'
patterndata-tonepattern.tone
patterndata-xh-chart-part'pattern'
patterndata-xh-chart-slotundefined | String(pattern.slot)
pattern-linedata-xh-chart-part'pattern-line'
tooltipdata-placement'top' | 'bottom'-'right' | 'left' | undefined
tooltipdata-state'visible' | 'hidden'
tooltipdata-xh-chart-part'tooltip'
tooltip-headerdata-xh-chart-part'tooltip-header'
tooltip-rowdata-current'' (present only while the condition holds)
tooltip-rowdata-series-idrow.seriesId
tooltip-rowdata-tonerow.tone
tooltip-rowdata-xh-chart-part'tooltip-row'
tooltip-rowdata-xh-chart-patternpatternOf(row.seriesId)
tooltip-rowdata-xh-chart-scale'sequential' | undefined
tooltip-rowdata-xh-chart-slotundefined | String(row.slot)
tooltip-swatchdata-markswatchMark(row)
tooltip-swatchdata-segundefined | sequentialStop(row.t).seg
tooltip-swatchdata-symbolrow.symbol
tooltip-swatchdata-xh-chart-part'tooltip-swatch'
tooltip-valuedata-xh-chart-part'tooltip-value'
tooltip-namedata-xh-chart-part'tooltip-name'
emptydata-loading'' (present only while the condition holds)
emptydata-state'loading' | undefined
emptydata-xh-chart-part'empty'
emptydata-xh-loading-ring''
zoom-sliderdata-dragging'' (present only while the condition holds)
zoom-handledata-placementedge
markdata-axismark.key.slice('axis:'.length) | undefined
markdata-dimmed'' (present only while the condition holds)
markdata-drawing'' (present only while the condition holds)
markdata-kindnote?.kind
markdata-markspec?.mark
markdata-placementmodel.scene?.placements.get(mark.key) | undefined | undefined
markdata-series-idmark.key.slice('series:'.length)
markdata-tonespec?.tone
markdata-xh-chart-partmark.part | undefined
markdata-xh-chart-patternpatternOf(id)
markdata-xh-chart-scale'sequential' | undefined
markdata-xh-chart-slotundefined | String(spec.slot)

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-cartesian-chart-bar-maxroot--xh-_chart-metric-bar-maxdefault--xh-chart-bar-max
--xh-cartesian-chart-bar-radiusroot--xh-_chart-metric-radiusdefault--xh-shape-inset
--xh-cartesian-chart-brush-bgbrushfilldefault--xh-bg-brand-subtle
--xh-cartesian-chart-brush-borderbrushstrokedefault--xh-border-control-focus
--xh-cartesian-chart-empty-gapemptygapstate=loading--xh-space-2
--xh-cartesian-chart-gaprootgapdefault--xh-space-3
--xh-cartesian-chart-heightviewportblock-sizedefault--xh-chart-height
--xh-cartesian-chart-legend-gaplegendgapdefault--xh-space-1
--xh-cartesian-chart-legend-scale-bar-radiuslegend-scale-barborder-radiusdefault--xh-shape-inset
--xh-cartesian-chart-legend-scale-gaplegend-scalegapdefault--xh-space-2
--xh-cartesian-chart-legend-scale-widthlegend-scale-barinline-sizedefault--xh-chart-legend-scale-width
--xh-cartesian-chart-legend-swatch-line-radiuslegend-swatchborder-radiusmark=line--xh-shape-pill
--xh-cartesian-chart-legend-swatch-radiuslegend-swatchborder-radiusdefault--xh-shape-inset
--xh-cartesian-chart-line-widthannotation
candle
legend-swatch
line
median
root
stem
tooltip-swatch
background
block-size
stroke-dasharray
stroke-width
@media (forced-colors: active)
@media print
default
drawing
kind=trend
mark=line
method=moving-average
not([data-drawing])
style=ohlc
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-cartesian-chart-point-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-cartesian-chart-series-colorannotation
area-fill
bar
box
candle
dot
legend-item
legend-swatch
line
median
outlier
pattern-line
point
stem
tooltip-swatch
whisker
wick
background
border
fill
stroke
@media (forced-colors: active)
@media print
kind=average
kind=point
kind=trend
mark=line
mark=point
not([data-symbol='circle'], [data-symbol='square'])
style=ohlc
symbol=circle
symbol=square
tone
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-slot=1
xh-chart-slot=2
xh-chart-slot=3
xh-chart-slot=4
xh-chart-slot=5
xh-chart-slot=6
xh-chart-slot=7
xh-chart-slot=8
--xh-_tone
--xh-chart-categorical-1
--xh-chart-categorical-2
--xh-chart-categorical-3
--xh-chart-categorical-4
--xh-chart-categorical-5
--xh-chart-categorical-6
--xh-chart-categorical-7
--xh-chart-categorical-8
--xh-cartesian-chart-tooltip-gaptooltipgapdefault--xh-space-1
--xh-cartesian-chart-tooltip-pxtooltippadding-inlinedefault--xh-surface-pad-sm
--xh-cartesian-chart-tooltip-pytooltippadding-blockdefault--xh-surface-pad-sm
--xh-cartesian-chart-tooltip-radiustooltipborder-radiusdefault--xh-shape-overlay
--xh-cartesian-chart-tooltip-row-gaptooltip-rowgapdefault--xh-space-2
--xh-cartesian-chart-tooltip-shadowtooltipbox-shadowdefault--xh-material-frosted-shadow
--xh-cartesian-chart-tooltip-swatch-line-radiustooltip-swatchborder-radiusmark=line--xh-shape-pill
--xh-cartesian-chart-tooltip-swatch-radiustooltip-swatchborder-radiusdefault--xh-shape-inset
--xh-cartesian-chart-zoom-hzoom-sliderblock-sizedefault--xh-space-6
--xh-cartesian-chart-zoom-handle-bgzoom-handlebackgrounddefault--xh-bg-brand
--xh-cartesian-chart-zoom-handle-radiuszoom-handleborder-radiusdefault--xh-shape-inset
--xh-cartesian-chart-zoom-handle-wzoom-handleinline-sizedefault--xh-space-2
--xh-cartesian-chart-zoom-preview-colorzoom-preview-linestrokedefault--xh-chart-deemphasis
--xh-cartesian-chart-zoom-track-bgzoom-trackbackgrounddefault--xh-bg-subtle
--xh-cartesian-chart-zoom-track-radiuszoom-trackborder-radiusdefault--xh-shape-inset
--xh-cartesian-chart-zoom-window-bgzoom-windowbackgrounddefault--xh-bg-brand-subtle
--xh-cartesian-chart-zoom-window-radiuszoom-windowborder-radiusdefault--xh-shape-inset

Released under The MIT License