Skip to content

Commit ac800c5

Browse files
committed
feat: Display the card version on the card (useful for debugging)
1 parent 094280d commit ac800c5

File tree

6 files changed

+25
-1
lines changed

6 files changed

+25
-1
lines changed

.devcontainer/ui-lovelace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,8 @@ views:
13641364
stacked: true
13651365
cache: false
13661366
graph_span: 5min
1367+
show:
1368+
version: true
13671369
header:
13681370
show: true
13691371
show_states: true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ series:
279279
| ---- | :--: | :-----: | :---: | ----------- |
280280
| `loading` | boolean | `true` | v1.0.0 | Displays a spinning icon while the data is loading/updating |
281281
| `last_updated` | boolean | `false` | v1.10.0 | Show the last time the chart was updated on the bottom right |
282+
| `version` | boolean | `false` | NEXT_VERSION | Show the card version on the bottom left (useful for debug) |
282283

283284
### `header` Options
284285

src/apexcharts-card.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class ChartsCard extends LitElement {
593593
${this._config.series_in_brush.length ? html`<div id="brush"></div>` : ``}
594594
</div>
595595
</div>
596-
${this._renderLastUpdated()}
596+
${this._renderLastUpdated()} ${this._renderVersion()}
597597
</ha-card>
598598
`;
599599
}
@@ -759,6 +759,13 @@ class ChartsCard extends LitElement {
759759
return html``;
760760
}
761761

762+
private _renderVersion(): TemplateResult {
763+
if (this._config?.show?.version) {
764+
return html` <div id="version_info">apexcharts-card v${pjson.version}</div> `;
765+
}
766+
return html``;
767+
}
768+
762769
private async _initialLoad() {
763770
await this.updateComplete;
764771

src/styles.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ export const stylesApex: CSSResultGroup = css`
121121
opacity: 0.5;
122122
}
123123
124+
#version_info {
125+
font-size: 0.63em;
126+
font-weight: 300;
127+
overflow: hidden;
128+
white-space: nowrap;
129+
text-overflow: ellipsis;
130+
position: absolute;
131+
bottom: 0px;
132+
left: 4px;
133+
opacity: 0.5;
134+
}
135+
124136
/* Apex Charts Default CSS */
125137
.apexcharts-canvas {
126138
position: relative;

src/types-config-ti.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const ChartCardExternalConfig = t.iface([], {
3131
"show": t.opt(t.iface([], {
3232
"loading": t.opt("boolean"),
3333
"last_updated": t.opt("boolean"),
34+
"version": t.opt("boolean"),
3435
})),
3536
"cache": t.opt("boolean"),
3637
"stacked": t.opt("boolean"),

src/types-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface ChartCardExternalConfig {
2525
show?: {
2626
loading?: boolean;
2727
last_updated?: boolean;
28+
version?: boolean;
2829
};
2930
cache?: boolean;
3031
stacked?: boolean;

0 commit comments

Comments
 (0)