Skip to content

Commit 2935b4e

Browse files
committed
feat(series): Support for stack group of columns
Closes #673, Closes #550
1 parent 5b5906f commit 2935b4e

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

.devcontainer/ui-lovelace.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,28 @@ views:
13481348
type: mean
13491349
period: 5minute
13501350
- entity: sensor.temperature
1351+
- title: Test 3
1352+
panel: false
1353+
cards:
1354+
- type: custom:apexcharts-card
1355+
stacked: true
1356+
# cache: false
1357+
graph_span: 5min
1358+
series:
1359+
- entity: sensor.random0_100
1360+
stack_group: group1
1361+
group_by:
1362+
duration: 1min
1363+
type: column
1364+
name: tes2t
1365+
group_by:
1366+
duration: 1min
1367+
- entity: sensor.random0_100
1368+
stack_group: group1
1369+
type: column
1370+
# name: pioup
1371+
- entity: sensor.random_0_1000
1372+
type: column
1373+
group_by:
1374+
duration: 1min
1375+
# stack_group: group1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ The card stricly validates all the options available (but not for the `apex_conf
162162
| :white_check_mark: `entity` | string | | v1.0.0 | The `entity_id` of the sensor to display |
163163
| `attribute` | string | | v1.4.0 | Instead of retrieving the state, it will retrieve an `attribute` of the entity. Make sure you increase `update_delay` if the chart doesn't reflect the last value of the attribute |
164164
| `name` | string | | v1.0.0 | Override the name of the entity |
165+
| `stack_group` | string | | NEXT_VERSION | When `stacked` is `true`, groups the different series with the name `stack_group` together. Only works for `type: column`. All series' names need to be be unique because of a bug in apexcharts.js |
165166
| `color` | string | | v1.1.0 | Color of the serie. Supported formats: `yellow`, `#aabbcc`, `rgb(128, 128, 128)` or `var(--css-color-variable)` |
166167
| `opacity` | number | `0.7` for `area`<br/>else `1` | v1.6.0 | The opacity of the line or filled area, between `0` and `1` |
167168
| `stroke_width` | number | `5` | v1.6.0 | Change the width of the line. Only works for `area` and `line` |

src/apex-layouts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ function getSeries(config: ChartCardConfig, hass: HomeAssistant | undefined, bru
189189
return series.map((serie, index) => {
190190
return {
191191
name: computeName(index, series, undefined, hass?.states[serie.entity]),
192+
group: config.stacked && serie.type === 'column' ? serie.stack_group : undefined,
192193
type: serie.type,
193194
data: [],
194195
};

src/types-config-ti.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const ChartCardAllSeriesExternalConfig = t.iface([], {
6868
"attribute": t.opt("string"),
6969
"name": t.opt("string"),
7070
"type": t.opt(t.union(t.lit('line'), t.lit('column'), t.lit('area'))),
71+
"stack_group": t.opt("string"),
7172
"color": t.opt("string"),
7273
"opacity": t.opt("number"),
7374
"curve": t.opt(t.union(t.lit('smooth'), t.lit('straight'), t.lit('stepline'), t.lit('monotoneCubic'))),

src/types-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface ChartCardAllSeriesExternalConfig {
6868
attribute?: string;
6969
name?: string;
7070
type?: 'line' | 'column' | 'area';
71+
stack_group?: string;
7172
color?: string;
7273
opacity?: number;
7374
curve?: 'smooth' | 'straight' | 'stepline' | 'monotoneCubic';

0 commit comments

Comments
 (0)