Skip to content

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 ​

PropDescriptionTypeDefault
typeChart type'bar' | 'line' | 'area' | 'pie' | 'donut''line'
dataData (labels + series)LhChartData{ series: [] }
heightCanvas height px (width follows container)number320
animatedEntry animationbooleantrue
showLegendShow legend (clickable)booleantrue
showTooltipTouch tooltipbooleantrue
smoothSmooth polyline (line / area)booleanfalse
stackStacked form (bar / area)booleanfalse
innerRadiuspie inner radius ratio (donut defaults 0.6)number0
emptyTextEmpty-state textstringlocale chart.empty
customClassCustom class (root node)string—
sxShorthand layout props——

Events ​

EventDescriptionPayload
selectTouch hit on a data point (fires on release)(detail: { label, seriesName, value, x, y })

Accessibility ​

  • Root element aria-role="img" + accessible name (locale chart.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-radius is 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