Chart
Five chart types (bar / line / area / pie / donut). Geometry, ticks, hit-testing and formatting consume @lh-ui/share/core/chart; the canvas uses <canvas type="2d"> (geometry path strings are consumed via Path2D, the same source as web SVG), and theme colors are resolved from --lh-chart-* tokens via a hidden probe view (following light / dark themes automatically).
Basic usage
vue
<template>
<lh-chart :data="data" type="line" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
const data = ref({
labels: ['Jan', 'Feb', 'Mar', 'Apr'],
series: [{ name: 'Ink wash', data: [12, 28, 22, 40] }],
})
</script>Pie / donut
For pie, legend and hit semantics are slices (labels); bar/line/area use series.
vue
<template>
<lh-chart :data="data" type="pie" />
<lh-chart :data="data" type="donut" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
const data = ref({
labels: ['Ink wash', 'Danqing', 'Gongbi', 'Xieyi'],
series: [{ name: 'Share', data: [45, 25, 18, 12] }],
})
</script>Bar (negative values and stacking)
vue
<template>
<lh-chart :data="data" type="bar" />
<lh-chart :data="data" type="bar" stack />
</template>Legend toggling and touch tooltip
Click a legend item to hide a series / slice; touch the canvas for a tooltip, and release fires the select event (detail: label / seriesName / value / x / y).
vue
<template>
<lh-chart :data="data" type="line" @select="onSelect" />
</template>Props
| Prop | Description | Type | Default |
|---|---|---|---|
| type | Chart type | 'bar' | 'line' | 'area' | 'pie' | 'donut' | 'line' |
| data | Data (labels + series) | LhChartData | { series: [] } |
| height | Canvas height px (width follows container) | number | 320 |
| animated | Entry animation | boolean | true |
| showLegend | Show legend (clickable) | boolean | true |
| showTooltip | Touch tooltip | boolean | true |
| smooth | Smooth polyline (line / area) | boolean | false |
| stack | Stacked form (bar / area) | boolean | false |
| innerRadius | pie inner radius ratio (donut defaults 0.6) | number | 0 |
| emptyText | Empty-state text | string | locale chart.empty |
| customClass | Custom class (root node) | string | — |
| sx | Shorthand layout props | — | — |
Events
| Event | Description | Payload |
|---|---|---|
| select | Touch hit on a data point (fires on release) | (detail: { label, seriesName, value, x, y }) |
Accessibility
- Root element
aria-role="img"+ accessible name (localechart.ariaLabel) - Empty-state text is accessible; legend items are clickable views with hidden-state modifiers
In-repo degradations
- The bar corner token
--lh-chart-bar-radiusis not drawn in v1 (canvas roundRect support unverified); bars render square-cornered - When the theme probe fails, the built-in palette (
LH_CHART_FALLBACK_COLORS) derived from the same tokens is used

