Skip to content

Commit

Permalink
feat: Support for all ApexCharts options
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Jan 22, 2021
1 parent c5987f8 commit 03efa8d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ views:
hours_to_show: 0.20
cache: true
layout: minimal
apex_config:
chart:
height: 100%
- type: custom:apexcharts-card
stacked: true
series:
Expand All @@ -30,6 +33,9 @@ views:
type: bar
hours_to_show: 0.25
cache: true
apex_config:
chart:
height: 100%

- type: custom:apexcharts-card
stacked: true
Expand Down
8 changes: 7 additions & 1 deletion src/apex-layouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export function getLayoutConfig(config: ChartCardConfig): unknown {
right: 0,
},
},
subtitle: {
offsetY: -15,
},
title: {
offsetY: -15,
},
xaxis: {
labels: {
show: false,
Expand Down Expand Up @@ -141,5 +147,5 @@ export function getLayoutConfig(config: ChartCardConfig): unknown {
break;
}

return mergeDeep(def, conf);
return config.apex_config ? mergeDeep(mergeDeep(def, conf), config.apex_config) : mergeDeep(def, conf);
}
5 changes: 5 additions & 0 deletions src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const styles: CSSResult = css`
height: 100%;
}
/* Needed for minimal layout */
svg:not(:root) {
overflow: visible !important;
}
.apexcharts-canvas {
position: relative;
user-select: none;
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ApexOptions } from 'apexcharts';

export interface ChartCardConfig extends ChartCardExternalConfig {
series: ChartCardSeriesConfig[];
hours_to_show: number;
Expand All @@ -12,6 +14,7 @@ export interface ChartCardExternalConfig {
cache?: boolean;
stacked?: boolean;
layout?: string;
apex_config?: ApexOptions;
}

export interface ChartCardSeriesExternalConfig {
Expand Down

0 comments on commit 03efa8d

Please sign in to comment.