@progressive-development/pd-chart
v0.2.1
Published
Progressive Development chart components: line, bar and pie views on one data shape, plus sparkline.
Maintainers
Readme
@progressive-development/pd-chart
Chart components on one data shape: a pd-chart shell that picks a view by type (line in stage 1; bar and pie follow), plus pd-sparkline for tiny inline trends.
Features
- One data shape for every view –
ChartData { series: [{ key, name, points: [{ x, y }], color?, role? }], categories? } - Line view – nice axis ticks, zero line, optional area fill and end labels
- Crosshair & tooltip – one tooltip listing every series at the snapped x; keyboard equivalent (arrows, Home/End, Enter, Escape)
- Selection – click fixes an x;
selectedcan be controlled from outside;pd-chart-selectreports changes - Legend with toggles – hide/show series;
hiddenSeriescontrolled or not - Roles –
primary,compare(dashed),context(gray) so identity never relies on color alone - Mini variant –
variant="mini" expandablerenders a sparkline that opens the full chart in a dialog - Accessible –
role="img"with a generated label and a visually hidden data table - Themeable –
--pd-chart-*tokens; series palette--pd-chart-series-1..8from pd-shared-styles, validated for light and dark surfaces
Installation
npm install @progressive-development/pd-chartQuick Start
<script type="module">
import "@progressive-development/pd-chart/pd-chart";
</script>
<pd-chart type="line" chart-title="Punkte" selectable></pd-chart>
<script>
document.querySelector("pd-chart").data = {
series: [
{ key: "a", name: "Anna", points: [{ x: 1, y: 10 }, { x: 2, y: 14 }, { x: 3, y: 9 }] },
{ key: "b", name: "Bert", points: [{ x: 1, y: 4 }, { x: 2, y: 8 }, { x: 3, y: 12 }], role: "compare" },
],
};
</script>Components
| Component | Description |
|-----------|-------------|
| <pd-chart> | Shell: data, type, options, selection, legend, hidden table; variant="mini" for inline use |
| <pd-sparkline> | Miniature curve of one series, optionally clickable |
See the Storybook for the full API (properties, events, CSS custom properties).
