Repository navigation
feat: duration curve, time in each state, cost, goal, formula, rolling window, usual range, calendar events, scatter fit, tile feature, table view, keyboard, summaries and state map - #127
Merged
Conversation
Per-entity state_map draws words such as heating/idle as numbers on every style, live and in history. The value text keeps the word. Set it in the editor under States as numbers, which suggests the entity's known states.
A tile card can now show a small Chartdeck chart under (or beside) its name: type custom:chartdeck-feature in the tile's features. Three looks: a sparkline of the last hours of history (filled below unless fill is off), the same history in columns per hour (two days or less) or per day, or a bar filled to the current value between min and max with the target marked. It reads the tile's entity unless it names its own, so a plug's switch tile can show the plug's power. It reads its options through the card's own config code, as the badge does: min, max and target (numbers or entities), colour bands, unit, decimals, attribute and tap/hold/double-tap actions mean what they mean on the card. Drawing reuses the sparkline style's sparkline() and columnPoints(), stretched to HA's feature strip (--feature-height, --feature-border-radius). Columns add up the rise per column for meters (state_class total/total_increasing) and average anything else, unless aggregate says otherwise. The colour is its own, else its band's, else the tile's. It registers in window.customCardFeatures with isSupported(hass, context) and the older supported(stateObj): entities with a numeric state, unit or state class, a numeric attribute (current_temperature, brightness, ...), or a numeric sensor on the same device (power first). The stub picks the same source. It takes the tile's entity from context (HA 2025.2+) or stateObj (older). Edge cases: an unavailable entity greys the line and empties the bar; a missing entity or no history draws a faint dashed line; gaps break the line; it redraws only for the entities it reads. Editor: opening the feature in the tile card editor shows look, entity (empty = the tile's), attribute, hours with fill or what each column holds, unit, decimals, colour, then min, max and (bar) target, colour bands and actions.
A new annotation kind, `type: calendar`, draws the events of a calendar.* entity on the line chart. Timed events get a dashed line at their start with the event's title as its label; all-day events, and timed events lasting a day or more, get a shaded span labelled at its start (or at the left edge when the event was already going). `label` replaces the titles with fixed text, `color` sets the colour (purple by default), `shade: true` shades timed events' length as well, and `match` keeps only events whose title contains one of a comma-separated list of words, in any case. Events are loaded with Home Assistant's calendar REST call (GET calendars/<entity>?start=&end=, the one the Calendar panel uses), so recurring events arrive already expanded. All-day dates are placed at midnight in the card's time zone. Each card keeps what it loaded and loads again when the span moves past it (previous/next period, a longer span), and every ten minutes while the chart reaches the present; a reload keeps the old events on show. If the call fails, or Home Assistant has no REST call, the chart draws without the marks. The calendar entity is watched, so its state changing redraws the card. Hovering (or tapping) the chart lists the events going on at that time under the series' values in the tooltip, with "All day" or their times, three at most and then "+N more". An event with no length counts within 1% of the span of its line. Calendar labels share the top label rows with time and state marks, so none overlap; above 60 events on one annotation only the lines and spans are drawn. In the editor: Annotations, "+ Calendar events" adds one on the first calendar Home Assistant has, with a calendar picker, a title filter, a shade switch, label and colour. Strings are in all 20 languages.
A new history style, state_duration, draws how long each entity (or an attribute such as a thermostat's hvac_action) spent in each state, as stacked columns per hour, day, week or month: "heating 6.3 h, idle 9.7 h, off 8 h" for each of the last 7 days. How: states load as words through the shared history frame, become spans with the state timeline's stateSpans, and each span's time is split across the calendar groups (history/timezone boundaries, so days follow the card's time zone and DST). The maths is in src/chart/state-duration.ts. Colours are the timeline's: the card's state_colors, then HA's --state-<domain>-<state>-color theme variables, then defaults. Options: period (default the last 7 days), group_by auto|hour|day|week| month (auto picks one for the span, as the column chart does), stack normal (hours; minutes when grouped by hour, axis topped at the group's length, ticks every 6 h or 15 min) or percent (share of the time recorded), states (which to show, bottom of the stack first; unset shows every state, busiest at the bottom and quiet ones like off and idle on top), labels (time on each slice that has room), state_colors, the shared axes, tooltip, header and compact options. Several entities stand side by side in each slot. Edge cases: unavailable and unknown leave a gap rather than a slice; a group with nothing recorded is empty; today's column counts only up to now; a numeric sensor with many values gets the timeline's "a line chart suits this one" message; quiet states each get a fainter grey than the one below, with a hairline between slices, so two greys never merge. Source must be history (statistics keep no states). A tap on a column opens its entity; the tooltip lists each state's time for the slot. Editor: pick "Time in each state" in the History group. The Chart section has the period, group by, stack, states to show, slice labels, axes and layout, then the state colours list shared with the timeline.
A scatter chart can now draw a least-squares straight line through each series' dots (`fit: linear`) and say how well it fits: a row under the chart gives the slope in the entities' own units and R², for example "-0.21 kW per °C · R² 0.93" (with the series name when there are several). The same text is added to the chart's screen-reader label. `now_point: true` puts a ring, labelled "Now", where the entities are at the moment: the bottom entity's state against each series' state. How: the maths is in src/chart/fit.ts as pure functions. The fit uses every paired reading before the 800-dot drawing cap, never the jittered positions, and sums about the means so readings in the thousands keep their precision. The line is drawn only across the range of readings it was fitted to (no extrapolation to the rounded axis ends) and clipped to the plot, over a halo in the card colour so it reads against dots of the same colour. The slope is shown to two significant figures. The ring is HTML over the plot so it stays round, and the axes stretch to include it. Edge cases: a series with fewer than two paired readings, or with every reading across the same, gets no line and no legend item. Without a unit on the bottom entity the text reads "Slope -0.21 kW". The ring shows only when the period reaches the present (not on yesterday or an earlier period) and only when both entities have a number. Plotting against time, and the bubble chart, ignore both options. Editor: Chart section, under Dot size and Jitter: "Fit line" (None or Straight line (least squares)) and "Ring where they are now". Both are hidden when "Along the bottom" is Time.
An entity can now be a formula of other entities instead of one sensor:
indoor less outdoor, power times price, the larger of two readings.
entities:
- formula: "a - b"
vars:
a: sensor.lounge_temp
b: sensor.outdoor_temp
name: Indoor - outdoor
The formula is read by a small parser of Chartdeck's own (src/formula.ts):
numbers, the names in vars, + - * / ^ (also written as × ÷ −), brackets,
unary minus and the functions min, max, abs and round (round(x, 2) to two
places). Nothing is passed to eval, Function or a template, so a formula
can only ever be arithmetic on numbers. Mistakes give a readable error
("Formula: it ends too soon", "Formula uses "c": add it to vars").
The current value is worked out from the variables' current states, on
and off reading as 1 and 0. A variable that is unavailable or not a
number, or a division by zero, leaves the value unavailable. History is
loaded for each variable (once, in the same request as the card's other
series) and joined on time: each variable keeps its last reading until it
changes, and the formula is worked out again at every change. A gap in any
variable is a gap in the series. Long-term statistics join row by row.
Live states of any variable add a point as they arrive.
"entity" is optional on a formula row: without it, the first entity the
formula reads gives the row its icon and more-info, and the formula is its
name. The unit is the one every variable shares (none when they differ,
as power times price); set unit and decimals as on any entity. A formula
of meters only (energy in less energy out) counts as a meter that can go
down, so a column chart of it shows the net change per day, a running
total adds its changes and a rate of change sees no resets.
It works wherever an entity's value or history is read: every value style
(bar, gauges...), the history charts drawn on the shared frame (line,
column, area and the rest), earlier-span comparisons, box plot,
candlestick and the badge's sparkline. Charts that read states as words
(timeline, the 24-hour clock's rings) and the gauge's ghost ignore it.
In the editor, each entity's options have a "Calculate from other
entities" group: a Formula field, then an entity picker for each name the
formula uses, so vars always matches it. While the formula doesn't read
yet, a warning under it says why.
The line, column and area charts take a new option:
point_action:
action: history # none (default) | history
window: 2h # s, min, h or d, at most 31d
With it on, clicking the plot with a mouse opens the History panel
(/history?entity_id=...&start_date=...&end_date=...) for every series on
the card, centred on the reading nearest the pointer, snapped the same
way as the tooltip. The tooltip gains an "Open in History" link, so on a
phone the first tap still shows the values and the link opens History;
with the tooltip off a tap opens it straight away.
The span is the window centred on the point, slid back so it never ends
in the future. A grouped point opens its whole group: a day's column
opens that day, today's ends now. Long-term statistics with no entity
are left out of the list; with nothing left there is no link. Small
multiples open their own panel's entity.
Navigation goes through Home Assistant's own navigate action (a
hass-action event), so there is no page reload; the tooltip link is a
real link, so opening it in a new tab works too. A drag (zoom select or
pan) is not a click, a click on something with its own tap (a series
name over the plot, a button) is left to it, and with zoom on a click
waits a moment so a double-click still resets the zoom.
Editor: Chart section, Axes group, under the tooltip switch: "Tapping a
point" (Does nothing / Opens History there) and "History window".
Setting both back to their defaults removes the option.
New style `duration_curve` (under Distributions). Each entity's readings
are sorted from highest to lowest, each as wide as the time it held, so the
bottom runs from 0 to 100% of the time and the height at 14% is the value
the sensor was at or above for 14% of it: the classic load or output
duration curve, for solar output, power use, flow and the like. Several
entities draw several curves on the same axes.
`markers: [2]` (a number, a list, or text such as "2, 5") marks values: a
dashed guide to where each curve crosses the value, a drop line to the
bottom, a dot, and the sentence "Above 2 kW for 14% of the time". With one
curve the sentence sits beside its dot; with several curves, with the
header over the chart, or for a value off the chart, the sentences are
listed under the chart, curve by curve, with the curve's name. Every
sentence is also in the chart's screen-reader label. `skip_zero: true`
leaves readings of exactly 0 out of the time, so a solar curve covers only
the hours the panels produced.
How: readings are weighted by time with the histogram's pointWeights, so
history (held until the next reading), long-term statistics and grouped
readings count the same way they do there; gaps count nothing. The maths
is in src/chart/duration-curve.ts as pure functions. A curve with more
than 200 distinct values is resampled at 400 even shares of the time. The
chart is a normal history chart: period, calendar spans and navigation,
statistics, grouping, axes, y range, compact and header over, and the
per-entity condition, running total and rate options all apply. Hovering
shows each curve's value at that share of the time.
Edge cases: an entity with no readings draws nothing and the others still
draw; none at all shows "No readings in this period". All readings equal
draw one flat line. A marker above every reading is 0%, below every
reading 100%. Markers print with the decimals they were typed with. The
value axis starts at zero unless a reading is below it.
Editor: Chart section: "Values to mark (e.g. 2, 5)", "Leave out time at
zero", then the usual axes ("Labels along the bottom") and layout. Each
entity has a "Line colour".
`normal_range: true` on a line chart shades, behind each series, the
usual range for every hour of the day: what the same entity read at that
hour over the last few weeks, from a low to a high percentile (10th to
90th by default), with a dotted median through it. Readings outside the
range get an anomaly-style marker, one per stretch outside (at the
reading furthest out), whose title says how far: "Inside: 31.0 °C, above
the usual 18.2-21.9 °C". A key under the header names the range and what
it covers ("Usual range · 10-90 percentile · days back: 28").
Options: normal_range_days (every_day, or same_weekday to compare a
Monday only with earlier Mondays), normal_range_weeks (1-12, default 4),
normal_range_low and normal_range_high (percentiles), normal_range_median
and normal_range_marks (both on by default) and normal_range_color for
the markers (amber by default).
The earlier weeks come from the recorder's hourly statistics, which last
far longer than history and are small to load. An entity without
statistics, or a series read from an attribute, falls back to its history
averaged per hour by how long each reading held. Each chart day is
matched to the same wall-clock hour on the earlier days through the
calendar, so a clock change in between does not shift the band. An hour
with fewer than three earlier values is left as a gap. The band's values
widen the value axis so it is never cut off. The earlier weeks load once
and again only when the span moves on; the band is worked out again only
when the hour or the loaded data changes.
No band is drawn for a series with a transform (running total or rate),
on charts longer than two weeks or grouped by day or longer, or while the
earlier weeks load or if neither statistics nor history can be had: the
chart then draws as before.
In the editor: Chart section, Extras, "Shade the usual range for the
time of day", then its options. Strings are in all 20 languages.
With `table_toggle: true`, a line, column or area chart gets a Chart | Table switch at the end
of its header. The table lists what the chart draws: one row per group (or per reading when
ungrouped), the time, each series' value, and how far each value sits from that series' average
over the span ("vs avg"; `table_change: false` leaves those columns out). The choice is kept on
the card and in the browser's localStorage under a key made from the card's config, the same way
the legend toggles remember hidden series, so a dashboard comes back the way it was left.
How: src/chart/table-view.ts holds the options, the switch, the table and its maths. Rows come
from the column chart's columnTable(), so several series line up on every time any of them has a
reading, each holding its value until it changes. Numbers use the series' decimals and Home
Assistant's number format; times use its language, zone and clock, and grouped rows are named the
way the column tooltip names them ("Tue 17 Nov", "26 Oct – 1 Nov"). Energy drawn below the axis
reads positive.
Edge cases: grouped values are averaged once each, ungrouped readings by how long each was held.
A total (sum or change) for a group still running is not compared with whole groups and reads
"so far"; a running mean is compared. Gaps and a zero average read "—". Long histories keep the
latest 250 rows and the caption says so. Loading, error and empty messages still show, with the
switch. A hidden header keeps a row for the switch so the chart can always come back; a header
over the plot moves above the table. The table is a real <table> with a caption, column and row
headers, scrolls inside the plot's own height (sticky header row and time column, times wrap on a
narrow card), and is a focusable region so it can be scrolled from the keyboard. Storage that
throws (private windows) only means the choice lasts until the page reloads.
Editor: Chart section, Layout group: "Chart | Table switch", then "Table: change from average"
once the switch is on. Strings added to every language.
A new `cost` option, on the card or on one entity, draws money instead of
energy. The price is an entity (its history, so each reading is priced at
what the price was then) or a fixed number per kWh, with optional
time-of-use tariff periods laid over it every day in Home Assistant's time
zone:
cost:
price: sensor.octopus_rate # or 0.24
tariff:
- { from: "00:30", to: "05:30", price: 0.09, name: Off-peak }
- { from: "16:00", to: "19:00", price: 0.32, name: Peak }
currency: GBP # default: Home Assistant's currency
split: true # column chart: stack by tariff band
How it adds up: a meter (total_increasing or total) is priced by how much
it rose between readings at the mean price between them; a power sensor
(W, kW, MW) is integrated over time at the price of each stretch; Wh and
MWh are converted to kWh, other units (m3 of gas) are priced per their own
unit. Long-term statistics, and `source: energy`, are read as each hour's
change and priced at that hour's mean price. Line and area charts draw the
running total over the span, the column chart each group's cost. The header,
tooltip and totals show money in the language's currency format ("£4.82",
"4,82 €"). With `source: energy` and no price of its own, each flow uses
the price from the Energy settings. An entity can opt out with
`cost: false` or override the card's keys with its own.
Edge cases: a price entity's first known price stands for the time before
it and its unavailable stretches keep the last price; negative prices
work; a meter's rise across a gap still counts; no price at all shows
"Set a price or a tariff to show the cost". `cost` with `transform` on the
same entity, or on another style, is refused with a readable error.
Editor: a Cost section under the line, area and column chart options
(switch, price entity, price per unit, currency, stack by band on columns,
then tariff periods with time pickers, add and remove). Each entity's
options gain "Count its cost" and "Its own price entity" while a cost is
set. Strings in all 20 languages.
Line, area and column charts now carry a short plain-language summary of
what they show, for example "Rose from 18.1 °C to 22.0 °C over 6 h. Peak
23.1 °C at 14:10. Now falling." Screen readers read it with the chart:
the plot keeps role="img" and its aria-label, and gains
aria-describedby pointing at the summary paragraph. With show_summary the
same paragraph is printed under the chart; otherwise it is visually
hidden.
Options: summary: auto (default, written from the readings), off (none),
or any other text, used as written. show_summary: true prints it. In the
editor both are in the Chart section's Layout fold: "Summary for screen
readers" and "Show the summary under the chart".
How it is worded (src/chart/summary.ts, pure tested functions): where the
series started and ended ("Rose"/"Fell" from-to, or "Ended about where it
started" when the change is under a tenth of its spread); the peak and
the low only when they stand out from both ends; "Now rising / falling /
steady" from the last tenth of the span, only when the span reaches the
present. Times are clock times for a day or less, dates beyond, and the
column's own group ("Wed, Nov 18") on a grouped column chart, where "now"
is left out. Spans read "24 h" up to two days, then "7 d". Several series
are each named. Gaps are skipped; a series with nothing recorded is left
out, and with nothing to say there is no summary and no describedby.
The sentences are in every language, with no counted nouns, so no plural
forms are needed.
chartArea takes the summary as an option, so another history chart can
opt in with one line.
A new `goal` option on the line chart shows whether a total is on track
for a target over a calendar period:
goal:
target: 300 # or an entity whose state is the target
period: month # day | week | month | year
direction: below # below: stay under it; above: reach it
project: linear # linear: pace since the start; recent: pace of late
The chart then spans the whole period (the card's offset and previous /
next buttons still work) and draws the first entity as its running total
from the period's start, reusing the cumulative transform (a meter's rises
with resets handled, a power integrated over time). Behind it go the ideal
pace (zero at the start to the target at the end) and the target line;
from the latest total a dotted projection runs to the period's end with
its value. The header gets a pill such as "On pace for 342 kWh · 14% over",
green when the projection is on the right side of the target for
`direction`, red otherwise; a finished period says "Ended at …". `recent`
measures the pace over the last 3 hours of a day, 2 days of a week, 7 days
of a month or 30 days of a year (or since the start when less has passed).
Edge cases: a target entity that isn't a number hides the target, pill and
verdict colour but keeps the total and projection; nothing read yet draws
no projection; the value axis starts at zero unless the card sets y_min;
grouping is ignored while a goal is set. Colours come from the theme's
success and error colours; percentages use the language's percent format.
Editor: a Goal section under the line chart options (switch, target
number or target entity, period, "Good when", projection). Strings in all
20 languages.
A new per-entity transform draws, at each moment, a statistic of the
entity over the window before it: a 2 hour mean that turns jumpy CO2
readings into a calm trend, or a 24 hour maximum that carries the day's
peak along.
entities:
- entity: sensor.office_co2
transform: rolling
transform_window: 2h # 30min, 2h, 1d... up to 7 days
transform_stat: mean # mean, median, min or max
transform_raw: true # line chart: readings faint behind it
Readings hold until the next one, so every statistic is weighted by
time: a value that held for an hour counts sixty times one that held for
a minute. The mean is the area under the readings over the window over
the time covered; the median is the value the readings sat below half the
time; the lowest and highest take every value that held at any moment of
the window, the one carried in from before it included. The window
trails (the point at 14:00 covers 12:00 to 14:00) and history loads one
window early, so the chart's left edge already has a full window behind
it.
The statistic is worked out where it can change: where a reading
arrives, where one leaves the window, and now. The mean changes in a
straight line between those, so the line is exact. Median, lowest and
highest hold still between changes; only where each value starts is
kept (and the end of a long flat stretch), so a line through them is
smooth rather than wobbling over a staircase. Unavailable stretches are
left out of the window; the series has a gap only where the whole
window is one. A median over a window of more than 401 readings is taken
from an even sample of them.
With transform_raw on, the line chart keeps the readings as a faint line
behind the rolling one (the same faint line a "when" condition uses). The
header shows the latest rolling value. Like the running total and rate of
change, it works on every history chart that reads numbers; box plot,
candlestick and the 24-hour clock get it without the early load.
In the editor it is "Rolling window" in each entity's Transform
dropdown, with Window, Show (mean, median, lowest, highest) and the raw
line switch once an entity uses it.
now-marker: near midnight the marker sits at the very edge of the current day's column and is hidden, so the column chart test failed late in the evening. It now runs at midday local time. cumulative: on a busy machine the card's own now fell a few ms after the test's, moving the 24 h window and turning 23,000 Wh into 22,999 Wh. Date is now pinned for the test.
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map
The day clock shows today, and the fake readings sit 3-5 h before now. Just after midnight they fell on yesterday and the ring read 0.0 kWh, so the test failed between midnight and 05:00. It now runs at midday local time.
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map
A line, column or area chart is now one Tab stop. Left and right move between the readings of
one series, up and down between series, Page Up and Page Down jump a tenth of the readings, Home
and End go to the first and last, Enter opens the focused series' more-info, and Escape lets go.
The focused reading shows the tooltip as the pointer would, gets a ring of its own, and is read
out by screen readers through a polite live region ("Inside, Fri 20 Nov 14:05: 21.0 °C").
`keyboard_nav: false` turns it off.
How: src/chart/keyboard.ts works out the moves (pure functions) and keeps where the keyboard is
per card. The focused reading becomes the chart's hover time (new setHoverTime in tooltip.ts), so
the tooltip, the column chart's slot highlight and the guide on charts synced with this one all
follow it exactly as they follow the pointer. chartArea takes the key handlers and makes the plot
area focusable, with a name that says how to use it.
Edge cases: zoomed, the keys only land on readings inside the window. The zoom's overview slider
and reset button keep their own keys (keys pressed on anything inside the plot are left alone),
and keys with Ctrl, Alt or Meta pass through. Gaps are stepped over, a series with no readings is
skipped, and series hidden from the legend can't be focused. Moving the mouse takes the hover
over and hides the ring; the next arrow carries on from where the pointer was. Leaving the chart
clears the tooltip. With the tooltip turned off the ring and the read-out still work. On a stacked
area or column the ring sits on top of the focused series' layer; on side-by-side columns it sits
on that series' own column. Arrows follow the time axis as drawn, so in right-to-left languages,
where charts still run left to right, the right arrow is still later. Energy statistics with no
entity have nothing to open on Enter.
Editor: Chart section, Axes group, "Read values with the keyboard" (on by default). Strings added
to every language.
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/chart/frame.ts # src/editor/chartdeck-card-editor.ts # src/types.ts
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # dist/chartdeck-card.tr-D6P8oYNI.js # dist/chartdeck-card.ur-CNn7Ol0E.js # src/editor/chart-editors.ts # src/locales/ar.json # src/locales/bn.json # src/locales/de.json # src/locales/en.json # src/locales/es.json # src/locales/fr.json # src/locales/hi.json # src/locales/id.json # src/locales/it.json # src/locales/ja.json # src/locales/ko.json # src/locales/nl.json # src/locales/pl.json # src/locales/pt.json # src/locales/ru.json # src/locales/tr.json # src/locales/ur.json # src/locales/vi.json # src/locales/zh-Hans.json # src/locales/zh-Hant.json # src/styles/line.ts
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/locales/ar.json # src/locales/bn.json # src/locales/de.json # src/locales/en.json # src/locales/es.json # src/locales/fr.json # src/locales/hi.json # src/locales/id.json # src/locales/it.json # src/locales/ja.json # src/locales/ko.json # src/locales/nl.json # src/locales/pl.json # src/locales/pt.json # src/locales/ru.json # src/locales/tr.json # src/locales/ur.json # src/locales/vi.json # src/locales/zh-Hans.json # src/locales/zh-Hant.json # src/styles/line.ts
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/styles/line.ts
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/chart/grid.ts # src/editor/chart-editors.ts
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/editor/chart-editors.ts # src/styles/area.ts # src/styles/column.ts # src/styles/line.ts
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/chart/grid.ts # src/editor/chart-editors.ts # src/locales/ar.json # src/locales/bn.json # src/locales/de.json # src/locales/en.json # src/locales/es.json # src/locales/fr.json # src/locales/hi.json # src/locales/id.json # src/locales/it.json # src/locales/ja.json # src/locales/ko.json # src/locales/nl.json # src/locales/pl.json # src/locales/pt.json # src/locales/ru.json # src/locales/tr.json # src/locales/ur.json # src/locales/vi.json # src/locales/zh-Hans.json # src/locales/zh-Hant.json # src/styles/area.ts # src/styles/column.ts # src/styles/line.ts # test/line.test.ts
With keyboard reading on, the focusable plot area is a labelled group (chart name plus the keys) and the SVG inside it was also a labelled image, so screen readers announced the chart twice and the summary hung off the inner image. The plot area now carries the name and aria-describedby pointing at the summary; the SVG inside it is aria-hidden. With keyboard_nav: false the SVG stays the labelled image, described by the summary, as before.
The day clock shows today and the fake readings sit 1-2 h before now, so between midnight and 02:00 they fell on yesterday and the 4 kW peak was missing. The test now runs at midday local time, as the now-marker and running-total tests do.
A goal draws its first entity as a running total by setting transform: cumulative on it. With transform: rolling or derivative on that entity the goal silently replaced it, so the chart showed a total the user had not asked for. validateGoal now throws a readable error naming the transform; transform: cumulative (with its own reset) is still accepted.
The usual-range band is built from the entity's own hourly readings. A series drawn as a running total, rate or rolling statistic (transform), as money (cost) or as a goal's running total cannot be compared with it, and the line chart quietly drew no band. These combinations now throw a readable error instead. An entity with cost: false still works next to a costed card.
Cost columns are sums of money with float noise (0.30000000000000004), so the summary said "Fell from £0.30 to £0.00. Peak £0.30 at ..." with the peak equal to the start. A peak or low is now named only when its written value differs from the start and end.
cost + rolling: a rolling series makes the frame load a window early; the merge trims a cost series back to the span so its running total doesn't grow by the early readings (without the trim the total was £5.10 instead of £3.30). keyboard + history action: Enter on the focused plot opens more-info and never History; a mouse click still opens History.
Fresh build of the integrated tree: main file, its map, and one hashed chunk + map per language. Removes the stale language chunks each merged branch carried in.
The conditional series test checked that no extreme label contained "30" (the 30 kW reading came while away). When the 9 kW high happened at half past an hour its label read "High 9.0 kW · 8:30 AM", so the test failed at some times of day. Match the value and unit instead.
A price entity's unit now sets its scale. Pence and cents (p/kWh, GBp/kWh, ct/kWh, c/kWh, ¢/kWh, öre/kWh) are hundredths of the currency, and a price per MWh is a thousandth per kWh, so a 30p/kWh rate no longer comes out 100 times too high. The cost is always shown in the card's currency, else Home Assistant's. On a grouped chart reading long-term statistics, a costed card reads each hour's change. A power sensor has no change, so it drew nothing. Power series now read their hourly mean, and each hour's energy is that mean times the hour.
# Conflicts: # dist/chartdeck-card.js # dist/chartdeck-card.js.map # src/badge.ts # src/chart/compare-ghost.ts # src/chart/frame.ts # src/editor/entities-editor.ts # src/history/fetch.ts # src/history/types.ts # src/resolve.ts # src/styles/box-plot.ts # src/styles/candlestick.ts # src/types.ts
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 21, 2026
## [2.4.0](v2.3.0...v2.4.0) (2026-11-21) ### Features * duration curve, time in each state, cost, goal, formula, rolling window, usual range, calendar events, scatter fit, tile feature, table view, keyboard, summaries and state map ([#127](#127)) ([2a6ea1b](2a6ea1b)) ### Documentation * mark the new charts and extras as 2.4 in the README ([#128](#128)) ([58f88c1](58f88c1))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fourteen new features from the wave 4 ideas, the
state_mapoption, and fixes found while putting them together. Everything is in the visual editor, translated into all 20 languages, and documented in the wiki.New charts
duration_curve): a sensor's readings sorted high to low, weighted by time, with markers such as "Above 2 kW for 14% of the time". Several entities draw several curves;skip_zeroleaves out time at exactly 0.state_duration): stacked columns of how long each entity (or an attribute such ashvac_action) spent in each state per hour, day, week or month, as hours or as a share.Line, area and column extras
formula: "a - b"withvars, worked out from other entities' states and history. Own parser, no templates.transform: rollingwith a window and mean, median, min or max, optionally with the raw readings faint behind.p/kWh,ct/kWh) and per MWh are scaled from the price entity's unit. Columns can be split by tariff band; power sensors are priced from statistics by their hourly mean.goalon the line chart draws the running total, the ideal pace, the target and the projected end, with an "On pace for … · 14% over" pill.normal_rangeshades each hour's usual range (p10–p90 by default) over recent weeks and marks readings outside it.calendarannotation draws events from a calendar entity as markers or shaded spans.table_toggleadds a Chart | Table switch.show_summaryalso prints under the chart.point_action: historyopens Home Assistant's History panel around a clicked point.Elsewhere
fit: linearadds a least-squares line with slope and R²;now_pointrings the current values.custom:chartdeck-featuredraws a sparkline, columns or a bar inside a tile card.state_mapmaps words such asheatoridleto numbers for any chart.Fixes
Tested on a Home Assistant OS test instance: every feature on its own dashboard view, with tile features, History links, keyboard and the table checked by browser automation.