← All Components
<mth-chart>
Wrap-first Apache ECharts <mth-chart> visualization element supporting 19 chart types, declarative <mth-chart-series> children, --mth-* token palette sync, SSR <table slot="fallback">, and RTL/reduced-motion support.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-chart>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/charts/chart"></script>
<mth-chart type="line" renderer="canvas">Example</mth-chart>import '@methane-ui/charts/chart';
import '@methane-ui/react';
export function Example() {
return <mth-chart type="line" renderer="canvas">Example</mth-chart>;
}<script setup lang="ts">
import '@methane-ui/charts/chart';
</script>
<template>
<mth-chart type="line" renderer="canvas">Example</mth-chart>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/charts/chart';
import { MthChartDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthChartDirective],
template: `<mth-chart type="line" renderer="canvas">Example</mth-chart>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/charts/chart';
import MthChart from '@methane-ui/svelte/MthChart.svelte';
</script>
<MthChart type="line" renderer="canvas">Example</MthChart>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
chartTitle | chart-title | string | "" | Accessible chart heading displayed in the header and used as default ARIA label. |
subtitle | subtitle | string | "" | Optional descriptive subtitle under the chart heading. |
type | type | unknown | "line" | Default chart visualization type when providing direct data / data-json on <mth-chart>. |
renderer | renderer | 'canvas' | 'svg' | "canvas" | ECharts rendering backend (canvas or svg). |
size | size | 'sm' | 'md' | 'lg' | 'full' | "md" | Preset block-size height (sm, md, lg, full). |
showLegend | show-legend | boolean | true | Controls visibility of the ECharts legend component. |
showTooltip | show-tooltip | boolean | true | Controls visibility of interactive chart tooltips. |
showFallback | show-fallback | boolean | false | When true, visually reveals the slotted <table slot="fallback"> content. |
categoriesJson | categories-json | string | "" | JSON-encoded category axis labels array. |
categories | — | ReadonlyArray<string> | — | Structured JS category axis labels array. |
dataJson | data-json | string | "" | JSON-encoded data array for single-series declarative usage. |
data | — | ReadonlyArray<unknown> | — | Structured JS data array for single-series usage. |
series | — | ReadonlyArray<unknown> | — | Programmatic series array supporting all 19 chart types. |
option | — | Record<string, unknown> | — | Optional raw ECharts option overrides merged onto the generated configuration. |
loading | loading | boolean | false | Displays accessible loading state. |
empty | empty | boolean | false | Displays accessible empty state. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-chart-ready | { renderer: 'canvas' | 'svg'; mode: 'echarts' | 'headless' } | Emitted when the ECharts engine handle initializes. |
mth-chart-render | { seriesCount: number } | Emitted after chart options are applied to the engine. |
mth-point-select | { seriesName: string; dataIndex: number; name: string; value: unknown } | Emitted when a data point is clicked in the chart. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | focus is on the data table toggle button | toggles visibility of the accessible data table fallback |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-chart.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(loading), :state(empty), :state(reduced-motion). | Conformance suite |
| i18n | Routes 5 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |