Skip to content

hd-bars

Attributes and example

hd-bars

A period as bars against the previous one: each value a bar in its colour with a soft glow, the previous period’s value behind it as an outline, the running bar (current) drawn as “so far”, values below zero hanging under the line. Hover or tap a bar to read both. Bars grow in at full motion only; flat on e-ink. For any series of numbers: an hour by hour day, a week, a month.

AttributeWhat it is
valuesrequiredThe values, separated by commas, e.g. {{ energy.electricity.hours.values }}.
previousThe previous period’s values, drawn behind as outlines, e.g. {{ energy.electricity.hours.previous }}.
labelsA label per bar, separated by commas (Mon,Tue…); some are left out when they don’t fit.
currentIndex of the running bar (0 first), drawn as so far; the ones after it are still to come.
colorA theme colour name.One of accent, lit, cool, good, warn, danger, chart-1, chart-2, chart-3, chart-4, chart-5, chart-6. Default accent.
unitUnit for the values read out, e.g. kWh.
legendWhat the bars and the outlines are, separated by a comma, e.g. “This week,Last week”: drawn above the bars and read in the tooltip.
namesThe same words for the tooltip only, without drawing a legend: rows of bars under each other name theirs this way, e.g. {{ energy.periods.week.electricity.bars.names }}.
axisWhether the labels show under the bars; none keeps them for the tooltip only, so of rows under each other only the last carries them.One of labels, none. Default labels.
<hd-bars values="{{ energy.electricity.compare.week.bars.values }}" previous="{{ energy.electricity.compare.week.bars.previous }}" labels="{{ energy.electricity.compare.week.bars.labels }}" current="{{ energy.electricity.compare.week.bars.current }}" unit="kWh"></hd-bars>

Styling

Set CSS variables on the component element. Its internal elements live in Shadow DOM; only the exposed named parts can be styled with ::part.

--hd-accent
The theme’s accent: active controls, links, highlights.
--hd-border
Lines round tiles and between parts.
--hd-border-width
How thick borders are.
--hd-chart-fill
How strongly an area under a chart line is filled, 0 to 1 (0 on e-ink).
--hd-ease-out
The easing of most movement.
--hd-flat
1 on e-ink: no colours, glows or gradients, only black and white.
--hd-font-mono
The monospaced font of small labels.
--hd-font-ui
The font of labels and running text.
--hd-motion-slow
A slow change, like a theme switching.
--hd-shadow
A tile’s shadow.
--hd-surface-raised
Something on a tile that stands out from it, like a button.
--hd-text
Text and big numbers.
--hd-text-faint
The quietest text: hints, units, times.
--hd-text-muted
Labels and secondary text.

Exposed parts

hd-bars::part(chart) {  /* Your styles */}

Style the host

hd-bars {  --hd-accent: #2563eb;  max-width: 100%;}
Theme variables