md-sparkline spec card
Identity · when to use / when NOT · decision cues · behavioural contract · do/don't · anti-patterns · full API. Paste into your agent when you're implementing with this component.
A micro-chart with no chrome. A trend line, bar, or area sized to sit inside a table cell, a card, or a line of text. No axes, no legend, no title — just the shape story.
<md-sparkline variant="line" color="primary" style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
color="primary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
color="primary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
color="primary"
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="line"
color="primary"
/>
Already installed? See the
Installation guide for one-time package setup
(core + tokens, fonts). Each tab below shows two patterns for using
md-sparkline in your project: Option A registers every AWC UI
component at once (simplest), Option B imports only this component for
tree-shake-friendly bundles.
<!-- ─── Option A: global registration (all components) ─── -->
<script type="module">
import '@awc-ui/core/define';
</script>
<!-- ─── Option B: single import (tree-shake only md-sparkline) ─── -->
<script type="module">
import '@awc-ui/core/components/md-sparkline';
</script>
<md-sparkline></md-sparkline>// ─── Option A: typed React wrapper (registers all components) ───
// Importing from '@awc-ui/react' calls defineCustomElements() as a
// side effect, so every md-* element becomes available in the browser.
import { MdSparkline } from '@awc-ui/react';
export function Example() {
return <MdSparkline></MdSparkline>;
}
// ─── Option B: single import (tree-shake to only md-sparkline) ───
// Skip the wrapper and use the raw custom element. Smallest bundle,
// but you lose typed props/events on JSX.
import '@awc-ui/core/components/md-sparkline';
export function ExampleTreeShaken() {
return <md-sparkline></md-sparkline>;
}// ─── Option A: schema module (any md-* element accepted) ───
// Pair with `defineCustomElements(window)` in main.ts.
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@Component({
standalone: true,
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `<md-sparkline></md-sparkline>`,
})
export class ExampleComponent {}
// ─── Option B: typed directive (tree-shake friendly) ───
// Pair with `import '@awc-ui/core/components/md-sparkline'` in main.ts.
import { Component } from '@angular/core';
import { MdSparkline } from '@awc-ui/angular';
@Component({
standalone: true,
imports: [MdSparkline],
template: `<md-sparkline></md-sparkline>`,
})
export class ExampleTreeShakenComponent {}<!-- ─── Option A: typed Vue wrapper (registers all components) ─── -->
<script setup lang="ts">
import { MdSparkline } from '@awc-ui/vue';
</script>
<template>
<MdSparkline></MdSparkline>
</template>
<!-- ─── Option B: single import (tree-shake to only md-sparkline) ─── -->
<script setup lang="ts">
import '@awc-ui/core/components/md-sparkline';
</script>
<template>
<md-sparkline></md-sparkline>
</template><!-- ─── Option A: global registration (done once in main entry) ─── -->
<!-- main.ts: -->
<!-- import { defineCustomElements } from '@awc-ui/svelte'; -->
<!-- defineCustomElements(window); -->
<md-sparkline></md-sparkline>
<!-- ─── Option B: single import (tree-shake to only md-sparkline) ─── -->
<script lang="ts">
import '@awc-ui/core/components/md-sparkline';
</script>
<md-sparkline></md-sparkline>| Situation | Use instead |
|---|---|
| A chart users will read values from | md-line-chart |
| Comparing categories | md-bar-chart |
| Parts of a whole | md-pie-chart |
| Cumulative volume as the main story | md-area-chart |
| Anything needing axes, a legend, or a title | The full chart components |
| A determinate progress bar | md-progress-indicator |
| A single value | Plain text, md-badge |
| Need | Setting |
|---|---|
| Trend line | variant="line" (default) |
| Discrete periods | variant="bar" |
| Filled trend | variant="area" |
| Highlight high/low | show-marks="extremes" (default) |
| First and last points | show-marks="edges" |
| No point markers | show-marks="none" |
| Semantic colour | color="primary | error | success | …", or any CSS colour |
| A fixed scale across several sparklines | min / max |
| Shade a stretch of the series (a campaign, an outage) | referenceAreas |
| Silent (no hover readout) | show-tooltip="false" |
<md-sparkline variant="line" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="line"
/><md-sparkline variant="bar" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="bar"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="bar"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="bar"
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="bar"
/><md-sparkline variant="area" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="area"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="area"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="area"
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="area"
/><md-sparkline variant="bar" color="primary" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [8, 9, 7, 10, 9, 11, 10];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [8, 9, 7, 10, 9, 11, 10];
export function Chart() {
return (
<MdSparkline
data={data}
variant="bar"
color="primary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="bar"
color="primary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [8, 9, 7, 10, 9, 11, 10];
}<script setup lang="ts">
const data = [8, 9, 7, 10, 9, 11, 10];
</script>
<template>
<md-sparkline
:data="data"
variant="bar"
color="primary"
/>
</template><script lang="ts">
const data = [8, 9, 7, 10, 9, 11, 10];
</script>
<md-sparkline
data={data}
variant="bar"
color="primary"
/><md-sparkline variant="bar" color="primary" min="0" max="100" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [8, 9, 7, 10, 9, 11, 10];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [8, 9, 7, 10, 9, 11, 10];
export function Chart() {
return (
<MdSparkline
data={data}
variant="bar"
color="primary"
min="0"
max="100"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="bar"
color="primary"
min="0"
max="100"
></md-sparkline>
`,
})
export class ChartComponent {
data = [8, 9, 7, 10, 9, 11, 10];
}<script setup lang="ts">
const data = [8, 9, 7, 10, 9, 11, 10];
</script>
<template>
<md-sparkline
:data="data"
variant="bar"
color="primary"
min="0"
max="100"
/>
</template><script lang="ts">
const data = [8, 9, 7, 10, 9, 11, 10];
</script>
<md-sparkline
data={data}
variant="bar"
color="primary"
min="0"
max="100"
/>show-marks | Behaviour |
|---|---|
none | No dots |
extremes | Min and max only (default) |
edges | First and last only |
all | Every point |
Don’t reach for all on a long series — a dot per sample becomes noise.
extremes anchors the read. (all exists because on a monotonic line the
extremes are the edges, so a combined “extremes + edges” mode collapsed to two
dots and read as nothing.)
<md-sparkline variant="line" show-marks="all" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
show-marks="all"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
show-marks="all"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
show-marks="all"
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="line"
show-marks="all"
/><md-sparkline variant="line" show-marks="none" style="inline-size: 100%; block-size: 44px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
show-marks="none"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
show-marks="none"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
show-marks="none"
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="line"
show-marks="none"
/>Shade a vertical stripe across the plot — a campaign window, an outage, a weekend. Use this instead of absolutely-positioned overlays.
color is optional: leave it off and the band is the series colour at 12%
opacity. If you do set it, pass a #hex or rgb() colour — those are the
two forms the alpha blend understands. A colour role name (error, success)
or a named CSS colour is passed to the canvas unchanged, so it paints fully
opaque, or not at all.
A label is worth adding: it is the only part of the band that reaches a screen
reader, appended to the host’s generated summary as “Highlighted: …”.
<md-sparkline variant="line" min="0" max="100" style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [22, 35, 48, 61, 74, 68, 82, 91, 77, 63];
const referenceAreas = [
{
from: 1,
to: 3,
color: "#b3261e",
label: "incident"
},
{
from: 6,
to: 8,
label: "campaign window"
}
];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data, referenceAreas });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [22, 35, 48, 61, 74, 68, 82, 91, 77, 63];
const referenceAreas = [
{
from: 1,
to: 3,
color: "#b3261e",
label: "incident"
},
{
from: 6,
to: 8,
label: "campaign window"
}
];
export function Chart() {
return (
<MdSparkline
data={data}
referenceAreas={referenceAreas}
variant="line"
min="0"
max="100"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
[referenceAreas]="referenceAreas"
variant="line"
min="0"
max="100"
></md-sparkline>
`,
})
export class ChartComponent {
data = [22, 35, 48, 61, 74, 68, 82, 91, 77, 63];
referenceAreas = [
{
from: 1,
to: 3,
color: "#b3261e",
label: "incident"
},
{
from: 6,
to: 8,
label: "campaign window"
}
];
}<script setup lang="ts">
const data = [22, 35, 48, 61, 74, 68, 82, 91, 77, 63];
const referenceAreas = [
{
from: 1,
to: 3,
color: "#b3261e",
label: "incident"
},
{
from: 6,
to: 8,
label: "campaign window"
}
];
</script>
<template>
<md-sparkline
:data="data"
:referenceAreas="referenceAreas"
variant="line"
min="0"
max="100"
/>
</template><script lang="ts">
const data = [22, 35, 48, 61, 74, 68, 82, 91, 77, 63];
const referenceAreas = [
{
from: 1,
to: 3,
color: "#b3261e",
label: "incident"
},
{
from: 6,
to: 8,
label: "campaign window"
}
];
</script>
<md-sparkline
data={data}
referenceAreas={referenceAreas}
variant="line"
min="0"
max="100"
/>A sparkline has no axis, so it can only ever say “the shape went like this”. Always pair it with the actual number.
<md-sparkline variant="area" color="tertiary" style="block-size: 44px; inline-size: 100%;"></md-sparkline>
<script type="module">
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
export function Chart() {
return (
<MdSparkline
data={data}
variant="area"
color="tertiary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="area"
color="tertiary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
}<script setup lang="ts">
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>
<template>
<md-sparkline
:data="data"
variant="area"
color="tertiary"
/>
</template><script lang="ts">
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>
<md-sparkline
data={data}
variant="area"
color="tertiary"
/>The composition it belongs in — the number first, the shape underneath it:
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<md-card variant="outlined" style="max-inline-size:260px;padding:16px;display:grid;gap:6px;">
<span style="font-size:.75rem;opacity:.7;">Visits this week</span>
<strong style="font-size:1.75rem;line-height:1;">12,480</strong>
<span style="font-size:.75rem;opacity:.7;">up 8% on last week</span>
<md-sparkline id="kpi-spark" variant="area" color="primary" height="32px"></md-sparkline>
</md-card>
<script type="module">
const spark = document.getElementById('kpi-spark');
spark.data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>import { MdCard, MdSparkline } from '@awc-ui/react';
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
export function Demo() {
return (
<>
<MdCard variant="outlined" style={{ maxInlineSize: '260px', padding: '16px', display: 'grid', gap: '6px' }}>
<span style={{ fontSize: '.75rem', opacity: '.7' }}>Visits this week</span>
<strong style={{ fontSize: '1.75rem', lineHeight: '1' }}>12,480</strong>
<span style={{ fontSize: '.75rem', opacity: '.7' }}>up 8% on last week</span>
<MdSparkline id="kpi-spark"
data={data} variant="area" color="primary" height="32px"></MdSparkline>
</MdCard>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
// app.component.ts — the bound values live on the class
import { Component } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './app.component.html',
})
export class DemoComponent {
data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
}
<!-- app.component.html -->
<md-card variant="outlined" style="max-inline-size:260px;padding:16px;display:grid;gap:6px;">
<span style="font-size:.75rem;opacity:.7;">Visits this week</span>
<strong style="font-size:1.75rem;line-height:1;">12,480</strong>
<span style="font-size:.75rem;opacity:.7;">up 8% on last week</span>
<md-sparkline id="kpi-spark"
[data]="data" variant="area" color="primary" height="32px"></md-sparkline>
</md-card><script setup>
import '@awc-ui/core/define';
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>
<template>
<md-card variant="outlined" style="max-inline-size:260px;padding:16px;display:grid;gap:6px;">
<span style="font-size:.75rem;opacity:.7;">Visits this week</span>
<strong style="font-size:1.75rem;line-height:1;">12,480</strong>
<span style="font-size:.75rem;opacity:.7;">up 8% on last week</span>
<md-sparkline id="kpi-spark"
:data="data" variant="area" color="primary" height="32px"></md-sparkline>
</md-card>
</template><script>
import '@awc-ui/core/define';
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>
<md-card variant="outlined" style="max-inline-size:260px;padding:16px;display:grid;gap:6px;">
<span style="font-size:.75rem;opacity:.7;">Visits this week</span>
<strong style="font-size:1.75rem;line-height:1;">12,480</strong>
<span style="font-size:.75rem;opacity:.7;">up 8% on last week</span>
<md-sparkline id="kpi-spark"
{data} variant="area" color="primary" height="32px"></md-sparkline>
</md-card>Turn the tooltip off inside an already-clickable row — it competes with the row
target — and set min / max so every row shares one scale.
<md-sparkline variant="bar" min="0" max="100" show-tooltip="false" style="inline-size: 100%; block-size: 40px;"></md-sparkline>
<script type="module">
const data = [45, 52, 38, 61, 55, 70, 64, 72];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [45, 52, 38, 61, 55, 70, 64, 72];
export function Chart() {
return (
<MdSparkline
data={data}
variant="bar"
min="0"
max="100"
show-tooltip="false"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="bar"
min="0"
max="100"
show-tooltip="false"
></md-sparkline>
`,
})
export class ChartComponent {
data = [45, 52, 38, 61, 55, 70, 64, 72];
}<script setup lang="ts">
const data = [45, 52, 38, 61, 55, 70, 64, 72];
</script>
<template>
<md-sparkline
:data="data"
variant="bar"
min="0"
max="100"
show-tooltip="false"
/>
</template><script lang="ts">
const data = [45, 52, 38, 61, 55, 70, 64, 72];
</script>
<md-sparkline
data={data}
variant="bar"
min="0"
max="100"
show-tooltip="false"
/>curve shapes the line between points, exactly as on
md-line-chart: smooth (default), linear,
monotone, step, step-before, step-middle.
At sparkline size the difference is small but not cosmetic — smooth overshoots
between samples, so a 7-point series can imply a peak it never reached. When the
shape is a claim rather than decoration, use linear or monotone.
<md-sparkline variant="line" curve="smooth" show-marks="all" color="primary" style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [12, 34, 22, 48, 30, 56, 41];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 34, 22, 48, 30, 56, 41];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
curve="smooth"
show-marks="all"
color="primary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
curve="smooth"
show-marks="all"
color="primary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 34, 22, 48, 30, 56, 41];
}<script setup lang="ts">
const data = [12, 34, 22, 48, 30, 56, 41];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
curve="smooth"
show-marks="all"
color="primary"
/>
</template><script lang="ts">
const data = [12, 34, 22, 48, 30, 56, 41];
</script>
<md-sparkline
data={data}
variant="line"
curve="smooth"
show-marks="all"
color="primary"
/><md-sparkline variant="line" curve="linear" show-marks="all" color="primary" style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [12, 34, 22, 48, 30, 56, 41];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 34, 22, 48, 30, 56, 41];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
curve="linear"
show-marks="all"
color="primary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
curve="linear"
show-marks="all"
color="primary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 34, 22, 48, 30, 56, 41];
}<script setup lang="ts">
const data = [12, 34, 22, 48, 30, 56, 41];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
curve="linear"
show-marks="all"
color="primary"
/>
</template><script lang="ts">
const data = [12, 34, 22, 48, 30, 56, 41];
</script>
<md-sparkline
data={data}
variant="line"
curve="linear"
show-marks="all"
color="primary"
/>The drawn weight is tunable, which matters at this size: a sparkline is a few hundred pixels wide, so a default stroke that reads well in a chart can look heavy in a table cell.
| Prop | Applies to | Effect |
|---|---|---|
line-width | line, area | Stroke weight of the trend line |
mark-size | line, area | Radius of the marker dots (the bar variant draws none) |
bar-width | bar | Width of each bar, in px |
corner-radius | bar | Rounds the bar ends |
height | all | Explicit block-size. Without it the host is 28px tall (--md-sparkline-block-size); only the width fills the box |
<md-sparkline variant="line" line-width="3" mark-size="5" show-marks="extremes" color="tertiary" style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [8, 14, 11, 22, 18, 27, 24, 31];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [8, 14, 11, 22, 18, 27, 24, 31];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
line-width="3"
mark-size="5"
show-marks="extremes"
color="tertiary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
line-width="3"
mark-size="5"
show-marks="extremes"
color="tertiary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [8, 14, 11, 22, 18, 27, 24, 31];
}<script setup lang="ts">
const data = [8, 14, 11, 22, 18, 27, 24, 31];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
line-width="3"
mark-size="5"
show-marks="extremes"
color="tertiary"
/>
</template><script lang="ts">
const data = [8, 14, 11, 22, 18, 27, 24, 31];
</script>
<md-sparkline
data={data}
variant="line"
line-width="3"
mark-size="5"
show-marks="extremes"
color="tertiary"
/><md-sparkline variant="bar" bar-width="8" corner-radius="4" color="primary" style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [12, 19, 15, 24, 28, 22, 30];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 19, 15, 24, 28, 22, 30];
export function Chart() {
return (
<MdSparkline
data={data}
variant="bar"
bar-width="8"
corner-radius="4"
color="primary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="bar"
bar-width="8"
corner-radius="4"
color="primary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 19, 15, 24, 28, 22, 30];
}<script setup lang="ts">
const data = [12, 19, 15, 24, 28, 22, 30];
</script>
<template>
<md-sparkline
:data="data"
variant="bar"
bar-width="8"
corner-radius="4"
color="primary"
/>
</template><script lang="ts">
const data = [12, 19, 15, 24, 28, 22, 30];
</script>
<md-sparkline
data={data}
variant="bar"
bar-width="8"
corner-radius="4"
color="primary"
/>The entry animation is the same family as the other charts and honours
prefers-reduced-motion. Set no-animation when the sparkline sits in a list
or table: dozens of tiny charts all animating at once reads as noise, not
delight.
<md-sparkline variant="line" color="primary" no-animation style="inline-size: 100%; block-size: 72px;"></md-sparkline>
<script type="module">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
color="primary"
no-animation
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
color="primary"
no-animation
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
}<script setup lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
color="primary"
no-animation
/>
</template><script lang="ts">
const data = [12, 14, 13, 18, 22, 20, 24, 28, 26, 32, 36, 40];
</script>
<md-sparkline
data={data}
variant="line"
color="primary"
no-animation
/>| Event | Cancelable | Detail | Fires |
|---|---|---|---|
mdSparkClick | yes | { dataIndex, value } | A point or bar is clicked |
mdReady | yes | void | The engine has mounted and drawn |
Both are Stencil defaults — bubbles, composed and cancelable all true —
though nothing in the component acts on preventDefault().
This is the sparkline the snippets below wire up. Click a point and the handler
logs dataIndex and value — open your console to watch the payloads arrive.
<md-sparkline id="trend" variant="area" color="primary" height="32px"></md-sparkline>
<script type="module">
const spark = document.getElementById('trend');
spark.data = [3, 5, 4, 8, 6, 9, 7];
spark.labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
spark.valueFormatter = (v) => new Intl.NumberFormat('en-US').format(v ?? 0);
spark.addEventListener('mdSparkClick', (e) => {
console.log(e.detail.dataIndex, e.detail.value);
});
</script>import { MdSparkline } from '@awc-ui/react';
const data = [3, 5, 4, 8, 6, 9, 7];
const labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const valueFormatter = (v: number | null) => new Intl.NumberFormat('en-US').format(v ?? 0);
export function Trend() {
return (
<MdSparkline
data={data}
labels={labels}
valueFormatter={valueFormatter}
variant="area"
color="primary"
height="32px"
onMdSparkClick={(e) => console.log(e.detail.dataIndex, e.detail.value)}
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-trend',
template: `
<md-sparkline
[data]="data"
[labels]="labels"
[valueFormatter]="valueFormatter"
variant="area"
color="primary"
height="32px"
(mdSparkClick)="onClick($event)"
></md-sparkline>
`,
})
export class TrendComponent {
data = [3, 5, 4, 8, 6, 9, 7];
labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
valueFormatter = (v: number | null) => new Intl.NumberFormat('en-US').format(v ?? 0);
onClick(e: CustomEvent) { console.log(e.detail.dataIndex, e.detail.value); }
}<script setup lang="ts">
const data = [3, 5, 4, 8, 6, 9, 7];
const labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const valueFormatter = (v: number | null) => new Intl.NumberFormat('en-US').format(v ?? 0);
function onClick(e: CustomEvent) {
console.log(e.detail.dataIndex, e.detail.value);
}
</script>
<template>
<md-sparkline
:data="data"
:labels="labels"
:valueFormatter="valueFormatter"
variant="area"
color="primary"
height="32px"
@mdSparkClick="onClick"
/>
</template><script lang="ts">
const data = [3, 5, 4, 8, 6, 9, 7];
const labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
const valueFormatter = (v: number | null) => new Intl.NumberFormat('en-US').format(v ?? 0);
function onClick(e: CustomEvent) {
console.log(e.detail.dataIndex, e.detail.value);
}
</script>
<md-sparkline
data={data}
labels={labels}
valueFormatter={valueFormatter}
variant="area"
color="primary"
height="32px"
on:mdSparkClick={onClick}
/>mdSparkClick — fired when a click lands on a point or a bar.
| Field | Type | Meaning |
|---|---|---|
dataIndex | number | Index of the point in data |
value | number | null | Raw value there — null for a gap |
Those two fields are the whole payload. There is no label in the detail — look
the index up in your own labels array if you need it.
Not every click emits. On a line / area sparkline the engine takes the
sample nearest the pointer along the x-axis and fires only if the pointer is
also within ~26px of it; a click further off the trace produces nothing. This is
independent of show-marks — every sample is clickable whether or not a dot is
drawn for it. On a bar sparkline the test is exact: the click has to land
inside a bar, and plot whitespace emits nothing.
| Property | Attribute | Type | Default | Reflects |
|---|---|---|---|---|
data | JS only | MdChartDataPoint[] | [] | — |
labels | JS only | (string | number | Date)[] | undefined | — | — |
variant | variant | 'line' | 'bar' | 'area' | 'line' | Yes |
color | color | MdChartColorRole | string | 'primary' | — |
curve | curve | MdChartCurve | 'smooth' | — |
showTooltip | show-tooltip | boolean | true | — |
showMarks | show-marks | 'none' | 'extremes' | 'edges' | 'all' | 'extremes' | — |
referenceAreas | JS only | MdSparklineReferenceArea[] | undefined | — | — |
valueFormatter | JS only | (value: number | null) => string | — | — |
heightProp | height | string | — | — |
noAnimation | no-animation | boolean | false | — |
cornerRadius | corner-radius | number | 2 | — |
min | min | number | — | — |
max | max | number | — | — |
lineWidth | line-width | number | — | — |
markSize | mark-size | number | — | — |
barWidth | bar-width | number | — | — |
| Method | Parameters |
|---|---|
refreshTheme() | none |
resize() | none |
getInstance() | none |
Override on the host element for per-instance theming:
| Property | Description |
|---|---|
--md-sparkline-block-size | Default block-size (default: 28px) |
--md-sparkline-inline-size | Default inline-size (default: 100%) |
--md-sparkline-min-inline-size | Minimum inline-size before clipping (default: 32px) |
Style internal elements through shadow DOM with ::part():
| Part | Description |
|---|---|
canvas | ECharts SVG container |
role="img" with a generated
aria-label — “Sparkline, latest 36, range 12 to 36.”, plus “Highlighted:
…” for any reference area that has a label. Values run through
valueFormatter, and an all-null series announces “Sparkline, no data.”aria-hidden="true" on it and let the text speak once.show-tooltip off inside an interactive row so it doesn’t stack a
tooltip on top of the row’s click target.prefers-reduced-motion with no-animation.<md-sparkline variant="line" color="primary" show-tooltip="false" aria-hidden="true" style="inline-size: 100%; block-size: 56px;"></md-sparkline>
<script type="module">
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
export function Chart() {
return (
<MdSparkline
data={data}
variant="line"
color="primary"
show-tooltip="false"
aria-hidden="true"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="line"
color="primary"
show-tooltip="false"
aria-hidden="true"
></md-sparkline>
`,
})
export class ChartComponent {
data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
}<script setup lang="ts">
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>
<template>
<md-sparkline
:data="data"
variant="line"
color="primary"
show-tooltip="false"
aria-hidden="true"
/>
</template><script lang="ts">
const data = [40, 38, 42, 35, 52, 48, 55, 41, 60, 58, 65, 70];
</script>
<md-sparkline
data={data}
variant="line"
color="primary"
show-tooltip="false"
aria-hidden="true"
/><md-sparkline variant="area" color="tertiary" style="inline-size: 100%; block-size: 56px;"></md-sparkline>
<script type="module">
const data = [12, 18, 15, 24, 31, 27, 36];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 18, 15, 24, 31, 27, 36];
export function Chart() {
return (
<MdSparkline
data={data}
variant="area"
color="tertiary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="area"
color="tertiary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [12, 18, 15, 24, 31, 27, 36];
}<script setup lang="ts">
const data = [12, 18, 15, 24, 31, 27, 36];
</script>
<template>
<md-sparkline
:data="data"
variant="area"
color="tertiary"
/>
</template><script lang="ts">
const data = [12, 18, 15, 24, 31, 27, 36];
</script>
<md-sparkline
data={data}
variant="area"
color="tertiary"
/>RTL — the series draws from the reading start, so it mirrors under
dir="rtl": the first sample sits on the right and the series runs leftwards.
Indices, values and event payloads are identical in both directions — only
pixels move. See RTL.
dir="ltr" vs dir="rtl"<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">ltr</span>
<md-sparkline id="sp-dir-ltr" dir="ltr" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">rtl</span>
<md-sparkline id="sp-dir-rtl" dir="rtl" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
</div>
<script type="module">
const ltr = document.getElementById('sp-dir-ltr');
const rtl = document.getElementById('sp-dir-rtl');
ltr.data = [4, 9, 14, 20, 27, 35, 44];
rtl.data = [4, 9, 14, 20, 27, 35, 44];
</script>import { MdSparkline } from '@awc-ui/react';
const data = [4, 9, 14, 20, 27, 35, 44];
export function Demo() {
return (
<>
<div style={{ display: 'grid', gridTemplateColumns: 'auto 1fr', gap: '14px 16px', alignItems: 'center', inlineSize: '100%' }}>
<span style={{ inlineSize: '3.5rem', opacity: '.65', fontSize: '.75rem', fontFamily: 'ui-monospace,monospace' }}>ltr</span>
<MdSparkline id="sp-dir-ltr"
data={data} dir="ltr" variant="bar" color="primary" min="0" height="64px"></MdSparkline>
<span style={{ inlineSize: '3.5rem', opacity: '.65', fontSize: '.75rem', fontFamily: 'ui-monospace,monospace' }}>rtl</span>
<MdSparkline id="sp-dir-rtl"
data={data} dir="rtl" variant="bar" color="primary" min="0" height="64px"></MdSparkline>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
// app.component.ts — the bound values live on the class
import { Component } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './app.component.html',
})
export class DemoComponent {
data = [4, 9, 14, 20, 27, 35, 44];
}
<!-- app.component.html -->
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">ltr</span>
<md-sparkline id="sp-dir-ltr"
[data]="data" dir="ltr" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">rtl</span>
<md-sparkline id="sp-dir-rtl"
[data]="data" dir="rtl" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
</div><script setup>
import '@awc-ui/core/define';
const data = [4, 9, 14, 20, 27, 35, 44];
</script>
<template>
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">ltr</span>
<md-sparkline id="sp-dir-ltr"
:data="data" dir="ltr" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">rtl</span>
<md-sparkline id="sp-dir-rtl"
:data="data" dir="rtl" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
</div>
</template><script>
import '@awc-ui/core/define';
const data = [4, 9, 14, 20, 27, 35, 44];
</script>
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">ltr</span>
<md-sparkline id="sp-dir-ltr"
{data} dir="ltr" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">rtl</span>
<md-sparkline id="sp-dir-rtl"
{data} dir="rtl" variant="bar" color="primary" min="0" height="64px"></md-sparkline>
</div>Density — no density prop, and the host doesn’t taper with an inherited
data-density rung either: size it with height and
--md-sparkline-block-size / --md-sparkline-inline-size /
--md-sparkline-min-inline-size. See Density.
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">0</span>
<md-sparkline id="sp-den-0" variant="area" color="primary"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">-4</span>
<div data-density="-4"><md-sparkline id="sp-den-4" variant="area" color="primary"></md-sparkline></div>
</div>
<script type="module">
const den0 = document.getElementById('sp-den-0');
const den4 = document.getElementById('sp-den-4');
den0.data = [12, 18, 15, 24, 31, 27, 36];
den4.data = [12, 18, 15, 24, 31, 27, 36];
</script>import { MdSparkline } from '@awc-ui/react';
const data = [12, 18, 15, 24, 31, 27, 36];
export function Demo() {
return (
<>
<div style={{ display: 'grid', gridTemplateColumns: 'auto 1fr', gap: '14px 16px', alignItems: 'center', inlineSize: '100%' }}>
<span style={{ inlineSize: '3.5rem', opacity: '.65', fontSize: '.75rem', fontFamily: 'ui-monospace,monospace' }}>0</span>
<MdSparkline id="sp-den-0"
data={data} variant="area" color="primary"></MdSparkline>
<span style={{ inlineSize: '3.5rem', opacity: '.65', fontSize: '.75rem', fontFamily: 'ui-monospace,monospace' }}>-4</span>
<div data-density="-4"><MdSparkline id="sp-den-4"
data={data} variant="area" color="primary"></MdSparkline></div>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
// app.component.ts — the bound values live on the class
import { Component } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './app.component.html',
})
export class DemoComponent {
data = [12, 18, 15, 24, 31, 27, 36];
}
<!-- app.component.html -->
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">0</span>
<md-sparkline id="sp-den-0"
[data]="data" variant="area" color="primary"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">-4</span>
<div data-density="-4"><md-sparkline id="sp-den-4"
[data]="data" variant="area" color="primary"></md-sparkline></div>
</div><script setup>
import '@awc-ui/core/define';
const data = [12, 18, 15, 24, 31, 27, 36];
</script>
<template>
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">0</span>
<md-sparkline id="sp-den-0"
:data="data" variant="area" color="primary"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">-4</span>
<div data-density="-4"><md-sparkline id="sp-den-4"
:data="data" variant="area" color="primary"></md-sparkline></div>
</div>
</template><script>
import '@awc-ui/core/define';
const data = [12, 18, 15, 24, 31, 27, 36];
</script>
<div style="display:grid;grid-template-columns:auto 1fr;gap:14px 16px;align-items:center;inline-size:100%;">
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">0</span>
<md-sparkline id="sp-den-0"
{data} variant="area" color="primary"></md-sparkline>
<span style="inline-size:3.5rem;opacity:.65;font-size:.75rem;font-family:ui-monospace,monospace;">-4</span>
<div data-density="-4"><md-sparkline id="sp-den-4"
{data} variant="area" color="primary"></md-sparkline></div>
</div>i18n — labels and valueFormatter feed the tooltip; format numbers with
Intl. Both are JS properties.
In Storybook: dark theme.
| Custom property | Purpose | Default |
|---|---|---|
--md-sparkline-block-size | Height | 28px |
--md-sparkline-inline-size | Width | 100% |
--md-sparkline-min-inline-size | Minimum width before clipping | 32px |
<md-sparkline variant="area" color="tertiary" style="--md-sparkline-block-size: 36px; --md-sparkline-min-inline-size: 48px; inline-size: 100%;"></md-sparkline>
<script type="module">
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
const el = document.querySelector("md-sparkline");
Object.assign(el, { data });
</script>import { MdSparkline } from '@awc-ui/react';
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
export function Chart() {
return (
<MdSparkline
data={data}
variant="area"
color="tertiary"
/>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
template: `
<md-sparkline
[data]="data"
variant="area"
color="tertiary"
></md-sparkline>
`,
})
export class ChartComponent {
data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
}<script setup lang="ts">
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
</script>
<template>
<md-sparkline
:data="data"
variant="area"
color="tertiary"
/>
</template><script lang="ts">
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
</script>
<md-sparkline
data={data}
variant="area"
color="tertiary"
/>md-sparkline.tile-sparkline { --md-sparkline-block-size: 36px; --md-sparkline-min-inline-size: 48px;}CSS part — canvas, the element the engine draws into. It is the only part,
and there are no slots.
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<style>
.sp-parted::part(canvas) {
outline: 1px dashed rgba(124, 111, 214, .55);
outline-offset: 3px;
border-radius: 4px;
}
</style>
<div style="padding:8px 4px;">
<md-sparkline id="sp-part" class="sp-parted" variant="line" color="primary" height="48px"></md-sparkline>
</div>
<script type="module">
const spark = document.getElementById('sp-part');
spark.data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
</script>import { MdSparkline } from '@awc-ui/react';
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
export function Demo() {
return (
<>
<style>
.sp-parted::part(canvas) {
outline: 1px dashed rgba(124, 111, 214, .55);
outline-offset: 3px;
border-radius: 4px;
}
</style>
<div style={{ padding: '8px 4px' }}>
<MdSparkline id="sp-part"
data={data} className="sp-parted" variant="line" color="primary" height="48px"></MdSparkline>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
// app.component.ts — the bound values live on the class
import { Component } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './app.component.html',
})
export class DemoComponent {
data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
}
<!-- app.component.html -->
<style>
.sp-parted::part(canvas) {
outline: 1px dashed rgba(124, 111, 214, .55);
outline-offset: 3px;
border-radius: 4px;
}
</style>
<div style="padding:8px 4px;">
<md-sparkline id="sp-part"
[data]="data" class="sp-parted" variant="line" color="primary" height="48px"></md-sparkline>
</div><script setup>
import '@awc-ui/core/define';
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
</script>
<template>
<style>
.sp-parted::part(canvas) {
outline: 1px dashed rgba(124, 111, 214, .55);
outline-offset: 3px;
border-radius: 4px;
}
</style>
<div style="padding:8px 4px;">
<md-sparkline id="sp-part"
:data="data" class="sp-parted" variant="line" color="primary" height="48px"></md-sparkline>
</div>
</template><script>
import '@awc-ui/core/define';
const data = [22, 26, 24, 31, 29, 38, 44, 41, 50];
</script>
<style>
.sp-parted::part(canvas) {
outline: 1px dashed rgba(124, 111, 214, .55);
outline-offset: 3px;
border-radius: 4px;
}
</style>
<div style="padding:8px 4px;">
<md-sparkline id="sp-part"
{data} class="sp-parted" variant="line" color="primary" height="48px"></md-sparkline>
</div>md-sparkline::part(canvas) { outline: 1px dashed rgba(124, 111, 214, 0.55); outline-offset: 3px;}md-line-chart ·
md-bar-chart ·
md-area-chart ·
md-pie-chart ·
md-card ·
md-table-cell ·
md-progress-indicator
md-sparklineTwo artefacts to give your AI agent so it generates correct UI with this component. The per-component spec answers "how do I use this exact tag?". The main-llm spec answers "which tag should I pick in the first place?".
md-sparkline spec card
Identity · when to use / when NOT · decision cues · behavioural contract · do/don't · anti-patterns · full API. Paste into your agent when you're implementing with this component.
System-prompt preamble · decision matrix · token reference · page recipes · anti-patterns. Paste into the system prompt at the start of a piece of work.