Skip to content

hd-graph

Attributes and example

hd-graph

A chart of any data, not only recorded readings: over time or categories as lines, areas, columns, stacked columns, steps, a scatter or a heatmap; or the shares of a whole as a pie, donut, rose, bar list, treemap, funnel or radar. The data comes from a data setting (source="{{ settings.source }}": a data feed, typed JSON, a text variable or Homey values, kept current) or as JSON in data (data="{{ list | json }}", at most 64 KB). Without paths it finds the numbers itself: a number list, [time, value] pairs, { "name": number } objects, or lists of objects. A list drawn as lines runs along its labels; lines drawn as a pie give each line’s latest value. Colours follow the theme’s chart colours; on e-ink the slices are named instead of coloured. What you put inside it (a donut’s total) is centred on the chart. Part: ::part(middle).

AttributeWhat it is
variantWhat it draws.One of line, area, columns, stacked, step, scatter, heatmap, pie, donut, rose, bars, treemap, funnel, radar. Default line.
sourceA data setting of the widget, as {{ settings.<name> }} (it renders as @data/<name>): the chart follows it as it changes.
dataThe data as JSON instead of a source, e.g. data="{{ settings.rows | json }}" or a text variable’s value. At most 64 KB.
itemsWhere the list is in the JSON, as a path: $.rooms, $.data.hours[*]. Without it the JSON itself is the list.
valueWhere each item’s number is, inside the item: kwh, values[1]; @ for the item itself.
labelWhere each item’s name is, inside the item: name; ~ for its key in an object.
timeWhere each item’s time is (an ISO date, or seconds or milliseconds since 1970): makes the chart run over time.
xWhere each item’s number to run along is, instead of a time (a scatter).
unitShown after the values, e.g. kWh.
nameThe name of a single line, in its tooltip.
colorA theme colour name (accent, lit, cool, good, warn, danger, text, surface, canvas, chart-1…chart-6) or #rrggbb: whatever a Colour setting gives.One of accent, lit, cool, good, warn, danger, chart-1, chart-2, chart-3, chart-4, chart-5, chart-6.
smoothGently curved lines.
compactFor a small tile: lines, areas, columns and steps without axes, legend or tooltip, with a dot on the latest value, like hd-sparkline.
legendThe legend over the chart: with two lines or more (a pie, donut, rose or funnel without names on its slices: always), always, or never.One of auto, show, none. Default auto.
labelsNames on the slices of a pie, donut, rose or funnel instead of a legend: on e-ink only, always, or never.One of auto, show, none. Default auto.
percentShares as percentages of the whole, rather than the amounts.
sortThe items of a share of a whole: largest first, smallest first, or as they came.One of none, desc, asc. Default none.
topShows this many items at most; the rest are added up as Other.
<hd-graph variant="donut" data='{"Kitchen": 3.2, "Living": 5.1, "Office": 1.4}' unit="kWh"></hd-graph>

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-bar-size
CSS input read by hd-graph.
--hd-canvas
The page behind the tiles: a colour or a gradient.
--hd-ease-out
The easing of most movement.
--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-surface
A tile’s colour.
--hd-text
Text and big numbers.
--hd-text-faint
The quietest text: hints, units, times.
--hd-text-muted
Labels and secondary text.
--hd-track
The empty part of a slider, bar or ring.

Exposed parts

hd-graph::part(middle) {  /* Your styles */}

Style the host

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