From 7ea287a87a1190977b0127e9a140fb09b1a83616 Mon Sep 17 00:00:00 2001 From: Mindfreeze Date: Tue, 19 Jul 2022 11:08:01 +0300 Subject: [PATCH] #19 show_units option --- README.md | 1 + src/ha-sankey-chart.ts | 5 +++-- src/types.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a755533..89d61bf 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ This card is intended to display connections between entities with numeric state | show_icons | boolean | **Optional** | false | Display entity icons | show_names | boolean | **Optional** | false | Display entity names | show_states | boolean | **Optional** | true | Display entity states +| show_units | boolean | **Optional** | true | Display unit of measurement | min_box_height | number | **Optional** | 3 | Minimum size of an entity box | min_box_distance | number | **Optional** | 5 | Minimum space between entity boxes diff --git a/src/ha-sankey-chart.ts b/src/ha-sankey-chart.ts index 6dcc63a..4aa3347 100644 --- a/src/ha-sankey-chart.ts +++ b/src/ha-sankey-chart.ts @@ -86,6 +86,7 @@ export class SankeyChart extends LitElement { min_box_height: 3, min_box_distance: 5, show_states: true, + show_units: true, ...config, }; @@ -157,7 +158,7 @@ export class SankeyChart extends LitElement { } protected renderSection(index: number): TemplateResult { - const {show_names, show_icons, show_states} = this.config; + const {show_names, show_icons, show_states, show_units} = this.config; const section = this.sections[index]; const {boxes, spacerH} = section; const hasChildren = index < this.sections.length - 1 && boxes.some(b => b.children.length > 0); @@ -189,7 +190,7 @@ export class SankeyChart extends LitElement { ${show_icons ? html`` : null}
- ${show_states ? html`${formattedState}${box.unit_of_measurement}` : null} + ${show_states ? html`${formattedState}${show_units ? html`${box.unit_of_measurement}` : null}` : null} ${show_names ? html` ${name}` : null}
diff --git a/src/types.ts b/src/types.ts index 54d8e3a..63b4f97 100644 --- a/src/types.ts +++ b/src/types.ts @@ -45,9 +45,10 @@ export interface SankeyChartConfig extends LovelaceCardConfig { wide?: boolean; show_icons?: boolean; show_names?: boolean; + show_states?: boolean; + show_units?: boolean; min_box_height?: number, min_box_distance?: number, - show_states?: boolean; } export interface Config extends SankeyChartConfig {