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

查看生态总览
Skip to content

Heatmap ​

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="heatmap": root · grid · month-block · row · week-day · month-label · row-label · column-label · cell · tooltip · legend · legend-label · legend-item · empty

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-heatmap>
Vue componentsXhHeatmapCell XhHeatmapColumnLabel XhHeatmapEmpty XhHeatmapGrid XhHeatmapLegend XhHeatmapLegendItem XhHeatmapLegendLabel XhHeatmapMonthBlock XhHeatmapMonthLabel XhHeatmapRoot XhHeatmapRow XhHeatmapRowLabel XhHeatmapTooltip XhHeatmapWeekDay
ComposableuseHeatmap
State machineheatmapMachine
Skin@xihan-ui/styles/heatmap.css

Props ​

PropTypeRequired
variantHeatmapVariant
valueHeatmapValue[]
rowsHeatmapAxisInput[]
columnsHeatmapAxisInput[]
startDatestring
endDatestring
levelsnumber
thresholdsnumber[]
scaleHeatmapScaleMode
midpointnumber
continuousboolean
firstDayOfWeeknumber
localestring
dirDirection
toneTone
paletteHeatmapPalette
sizeSize
animatedboolean
formatNumberFormatSpec | ((value: number) => string)
pendingboolean
activeKeystring | null
onActiveKeyChange(details: HeatmapActiveKeyChangeDetails) => void
translationsPartial<HeatmapTranslations>
onDatumActive(details: HeatmapDatumDetails | null) => void
onDatumPress(details: HeatmapDatumDetails) => void

Events ​

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

EventPayload
datum-activeHeatmapDatumDetails
datum-pressHeatmapDatumDetails
active-key-changeHeatmapActiveKeyChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhHeatmapRootdefaultHeatmapRootSlotProps
XhHeatmapRootcellHeatmapCellSlotProps
XhHeatmapRoottooltipHeatmapDatumDetails | null
XhHeatmapRootempty—

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
XhHeatmapCellvaluestringYes
XhHeatmapCellrowstring
XhHeatmapColumnLabelvaluestringYes
XhHeatmapLegendItemvaluenumber | stringYes
XhHeatmapLegendItempolarityHeatmapPolarity
XhHeatmapLegendLabelvalueHeatmapLegendBoundYes
XhHeatmapMonthBlockvaluestringYes
XhHeatmapMonthLabelvaluestringYes
XhHeatmapRootrenderCell(cell: HeatmapCellSlotProps) => ReactNode
XhHeatmapRootrenderTooltip(details: HeatmapDatumDetails | null) => ReactNode
XhHeatmapRootrenderEmpty() => ReactNode
XhHeatmapRootchildrenSlotChildren<HeatmapRootSlotProps>
XhHeatmapRowvaluenumber | string
XhHeatmapRowmonthstring
XhHeatmapRowLabelvaluestring
XhHeatmapWeekDayvaluenumber | string

State ​

Public state is written to data-state.

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

The following names are internal to the state machine.

States: idle

Events: CELL.FOCUS · CELL.BLUR · CELL.ENTER · CELL.LEAVE · DETAIL.DISMISS · FOCUS.SET · TRANSITION.END

connect API ​

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

MemberType
variantHeatmapVariant
scaleModeHeatmapScaleMode
legendItemsreadonly HeatmapLegendEntry[]
gridHeatmapGrid
monthGridHeatmapMonthGrid | null
matrixGridHeatmapMatrixGrid | null
focusedCellHeatmapCellRef | null
focusedDatestring | null
anchorCellHeatmapCellRef | null
anchorDatestring | null
activeCellHeatmapDatumDetails | null
activeKeystring | null
emptyboolean
emptyTextstring
detailOpenboolean
legendText{ low: string, high: string }
cellAt(date: string) => HeatmapCellMeta | null
setFocusedCell(cell: HeatmapCellRef | null) => void
setFocusedDate(date: string | null) => void
getRootProps() => T['element']
getGridProps() => T['element']
getMonthBlockProps(props: HeatmapMonthBlockProps) => T['element']
getRowProps(props: HeatmapRowProps) => T['element']
getWeekDayProps(props: HeatmapWeekDayProps) => T['element']
getMonthLabelProps(props: HeatmapMonthLabelProps) => T['element']
getRowLabelProps(props: HeatmapRowLabelProps) => T['element']
getColumnLabelProps(props: HeatmapColumnLabelProps) => T['element']
getCellProps(props: HeatmapCellProps) => T['element']
getTooltipProps() => T['element']
getLegendProps() => T['element']
getLegendLabelProps(props: HeatmapLegendLabelProps) => T['element']
getLegendItemProps(props: HeatmapLegendItemProps) => T['element']
getEmptyProps() => 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+Tabheatmap.kbd.tab
ArrowLeftheatmap.kbd.prev-week
ArrowRightheatmap.kbd.next-week
ArrowUpheatmap.kbd.prev-day
ArrowDownheatmap.kbd.next-day
Homeheatmap.kbd.row-start
Endheatmap.kbd.row-end
Ctrl+Homeheatmap.kbd.grid-start
Ctrl+Endheatmap.kbd.grid-end
Escapeheatmap.kbd.dismiss
Enterheatmap.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-busy'true' | undefined
gridaria-colcountcounts.columns | undefined
gridaria-labelgridLabel
gridaria-readonly'true'
gridaria-rowcountcounts.rows | undefined
gridrole'grid'
month-blockaria-labelmonthBlockOf.get(block.value)?.long
month-blockrole'rowgroup'
rowaria-hidden'true'
rowaria-labelundefined | grid.weekDays[row.weekDay]?.long
rowaria-rowindex1
rowrole'row'
week-dayaria-hidden'true'
month-labelaria-hidden'true'
row-labelaria-colindex1
row-labelaria-hidden'true'
row-labelrole'rowheader'
column-labelaria-colindexmeta.index + 2 | undefined
column-labelrole'columnheader'
cellaria-colindexmeta.columnIndex + 2 | undefined
cellaria-labelmatrixCellLabel(heatmapDatumDetails({ row, column }, …
cellrole'gridcell'
tooltiparia-hidden'true'
legendaria-labellegendLabel
legendrole'group'
legend-itemaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/heatmap.css is written against [data-scope="heatmap"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-heatmap in place of data-scope (same specificity) and sits in the xihan.components and xihan.motion layers. 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-animating'' (present only while the condition holds)
rootdata-loading'' (present only while the condition holds)
rootdata-paletteprops.palette
rootdata-scale'diverging' | undefined
rootdata-sizeprops.size
rootdata-toneprops.tone
rootdata-variantprops.variant
rowdata-weekString(row.week)
rowdata-week-dayundefined | String(row.weekDay)
week-daydata-week-dayundefined | String(label.weekDay)
celldata-drawing'' (present only while the condition holds)
celldata-highlighted'' (present only while the condition holds)
celldata-levelString(place.level)
celldata-polarityplace.polarity
tooltipdata-inline-anchorundefined | tip.inlineAnchor
tooltipdata-placementundefined | ((): 'block-start' | 'block-end' => { if (activeRef =…
tooltipdata-state'hidden' | 'visible'
tooltipdata-xh-chart-part'tooltip'
legenddata-xh-chart-part'legend'
legend-labeldata-boundlabel.bound
legend-itemdata-levelString(item.level)
legend-itemdata-polarityitem.polarity
emptydata-loading'' (present only while the condition holds)
emptydata-state'loading' | undefined
emptydata-xh-chart-part'empty'
emptydata-xh-loading-ring''

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-heatmap-bgroot
row-label
week-day
backgrounddefault--xh-bg-surface
--xh-heatmap-block-gapgrid
root
gapvariant=month--xh-_heatmap-gutter
--xh-heatmap-block-inner-gapmonth-blockgapdefault--xh-_heatmap-gap
--xh-heatmap-cell-bgcell
legend-item
backgrounddefault--xh-_heatmap-ink
--xh-heatmap-cell-bordercell
legend-item
box-shadowdefault--xh-border-default
--xh-heatmap-cell-border-highlightedcellbox-shadowhighlighted--xh-fg-default
--xh-heatmap-cell-radiuscell
legend-item
border-radiusdefault--xh-shape-inset
--xh-heatmap-cell-sizecell
legend-item
month-label
root
row
week-day
block-size
border
inline-size
margin-inline-start
@media print
default
first-child
level=1
level=2
level=3
size=lg
size=sm
variant=month
week
week-day
--xh-space-2
--xh-space-2_5
--xh-space-3
--xh-heatmap-column-wcell
column-label
root
inline-sizedefault
variant=matrix
--xh-_heatmap-row-h
--xh-heatmap-diverging-centercell
legend-item
root
background
background-color
@keyframes xh-heatmap-fill
scale=diverging
--xh-chart-diverging-center
--xh-heatmap-diverging-negativecell
legend-item
root
backgroundis([data-scope='heatmap'][data-part='cell'], [data-scope='heatmap'][data-part='legend-item'])
polarity=negative
scale=diverging
--xh-chart-diverging-negative
--xh-heatmap-diverging-positivecell
legend-item
root
backgroundis([data-scope='heatmap'][data-part='cell'], [data-scope='heatmap'][data-part='legend-item'])
polarity=positive
scale=diverging
--xh-chart-diverging-positive
--xh-heatmap-emptycell
legend-item
root
background
background-color
@keyframes xh-heatmap-fill
default
--xh-bg-subtle-opaque
--xh-heatmap-empty-gapemptygapstate=loading--xh-space-2
--xh-heatmap-fgrootcolordefault--xh-fg-muted
--xh-heatmap-font-sizerootfont-sizedefault--xh-_heatmap-font-size
--xh-heatmap-gaprootgapdefault--xh-space-2
--xh-heatmap-grid-gapgridgapdefault--xh-_heatmap-gap
--xh-heatmap-guttergrid
root
row-label
week-day
gap
inline-size
scroll-padding-inline-start
default
size=sm
variant=month
--xh-space-6
--xh-space-8
--xh-heatmap-inkcell
legend-item
root
backgrounddefault
is([data-theme='dark'] *, [data-theme='dark'])
palette=amber
palette=blue
palette=cyan
palette=gray
palette=green
palette=indigo
palette=lime
palette=orange
palette=pink
palette=purple
palette=red
palette=teal
palette=yellow
theme=dark
tone
--xh-_tone
--xh-bg-brand
--xh-color-amber-600
--xh-color-blue-600
--xh-color-cyan-600
--xh-color-green-600
--xh-color-indigo-600
--xh-color-lime-600
--xh-color-neutral-450
--xh-color-neutral-600
--xh-color-orange-600
--xh-color-pink-600
--xh-color-purple-600
--xh-color-red-600
--xh-color-teal-600
--xh-color-yellow-600
--xh-heatmap-label-fgcolumn-label
legend
month-label
root
row-label
week-day
colordefault
variant=month
week-day=0
week-day=2
week-day=4
week-day=6
--xh-fg-subtle
--xh-heatmap-legend-gaplegendgapdefault--xh-_heatmap-gap
--xh-heatmap-pyrootpadding-blockdefault--xh-_heatmap-gap
--xh-heatmap-row-gaprowgapdefault--xh-_heatmap-gap
--xh-heatmap-row-hcell
column-label
root
block-size
inline-size
default
size=lg
size=sm
variant=matrix
--xh-space-4
--xh-space-5
--xh-space-6
--xh-heatmap-sticky-layerrow-label
week-day
z-indexdefault1
--xh-heatmap-title-fgmonth-label
root
colorvariant=month--xh-fg-default
--xh-heatmap-tooltip-bgtooltipbackground-colordefault--xh-material-frosted-bg
--xh-heatmap-tooltip-bordertooltipborder-colordefault--xh-material-frosted-border
--xh-heatmap-tooltip-fgtooltipcolordefault--xh-material-frosted-fg
--xh-heatmap-tooltip-font-sizetooltipfont-sizedefault--xh-text-body-size
--xh-heatmap-tooltip-layertooltipz-indexdefault2
--xh-heatmap-tooltip-max-wtooltipmax-inline-sizedefault--xh-overlay-max-w
--xh-heatmap-tooltip-pxtooltippadding-inlinedefault--xh-surface-pad-sm
--xh-heatmap-tooltip-pytooltippadding-blockdefault--xh-surface-pad-sm
--xh-heatmap-tooltip-radiustooltipborder-radiusdefault--xh-shape-overlay
--xh-heatmap-tooltip-shadowtooltipbox-shadowdefault--xh-material-frosted-shadow
--xh-heatmap-week-day-skiproot
week-day
colorweek-day=0
week-day=2
week-day=4
week-day=6
transparent

Released under The MIT License