Skip to content

Commit 03efa8d

Browse files
committed
feat: Support for all ApexCharts options
1 parent c5987f8 commit 03efa8d

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

.devcontainer/ui-lovelace.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ views:
1919
hours_to_show: 0.20
2020
cache: true
2121
layout: minimal
22+
apex_config:
23+
chart:
24+
height: 100%
2225
- type: custom:apexcharts-card
2326
stacked: true
2427
series:
@@ -30,6 +33,9 @@ views:
3033
type: bar
3134
hours_to_show: 0.25
3235
cache: true
36+
apex_config:
37+
chart:
38+
height: 100%
3339

3440
- type: custom:apexcharts-card
3541
stacked: true

src/apex-layouts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export function getLayoutConfig(config: ChartCardConfig): unknown {
107107
right: 0,
108108
},
109109
},
110+
subtitle: {
111+
offsetY: -15,
112+
},
113+
title: {
114+
offsetY: -15,
115+
},
110116
xaxis: {
111117
labels: {
112118
show: false,
@@ -141,5 +147,5 @@ export function getLayoutConfig(config: ChartCardConfig): unknown {
141147
break;
142148
}
143149

144-
return mergeDeep(def, conf);
150+
return config.apex_config ? mergeDeep(mergeDeep(def, conf), config.apex_config) : mergeDeep(def, conf);
145151
}

src/styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export const styles: CSSResult = css`
1717
height: 100%;
1818
}
1919
20+
/* Needed for minimal layout */
21+
svg:not(:root) {
22+
overflow: visible !important;
23+
}
24+
2025
.apexcharts-canvas {
2126
position: relative;
2227
user-select: none;

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ApexOptions } from 'apexcharts';
2+
13
export interface ChartCardConfig extends ChartCardExternalConfig {
24
series: ChartCardSeriesConfig[];
35
hours_to_show: number;
@@ -12,6 +14,7 @@ export interface ChartCardExternalConfig {
1214
cache?: boolean;
1315
stacked?: boolean;
1416
layout?: string;
17+
apex_config?: ApexOptions;
1518
}
1619

1720
export interface ChartCardSeriesExternalConfig {

0 commit comments

Comments
 (0)