Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-chart>

@methane-ui/charts~9.0 KB brotli shell + lazy engine~2.6 KB shell · lazy engine chunk

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

Interactive StageLive Custom Element · <mth-chart> (@methane-ui/charts)
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>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
chartTitlechart-titlestring""Accessible chart heading displayed in the header and used as default ARIA label.
subtitlesubtitlestring""Optional descriptive subtitle under the chart heading.
typetypeunknown"line"Default chart visualization type when providing direct data / data-json on <mth-chart>.
rendererrenderer'canvas' | 'svg'"canvas"ECharts rendering backend (canvas or svg).
sizesize'sm' | 'md' | 'lg' | 'full'"md"Preset block-size height (sm, md, lg, full).
showLegendshow-legendbooleantrueControls visibility of the ECharts legend component.
showTooltipshow-tooltipbooleantrueControls visibility of interactive chart tooltips.
showFallbackshow-fallbackbooleanfalseWhen true, visually reveals the slotted <table slot="fallback"> content.
categoriesJsoncategories-jsonstring""JSON-encoded category axis labels array.
categories—ReadonlyArray<string>—Structured JS category axis labels array.
dataJsondata-jsonstring""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.
loadingloadingbooleanfalseDisplays accessible loading state.
emptyemptybooleanfalseDisplays accessible empty state.

Events

EventDetail TypeDescription
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

KeyDirectionWhenExpected Behavior
Enterbothfocus is on the data table toggle buttontoggles visibility of the accessible data table fallback

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 1 APG keyboard transitions across LTR/RTL.mth-chart.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(loading), :state(empty), :state(reduced-motion).Conformance suite
i18nRoutes 5 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test