mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Gauge Card: Fix if value is greater than max (#5887)
This commit is contained in:
parent
c88439ba2f
commit
67a3f5d87b
@ -131,6 +131,14 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const sliderBarColor = this._computeSeverity(state);
|
const sliderBarColor = this._computeSeverity(state);
|
||||||
|
|
||||||
|
let value: number | undefined;
|
||||||
|
|
||||||
|
if (this._config.max === null || isNaN(this._config.max!)) {
|
||||||
|
value = undefined;
|
||||||
|
} else {
|
||||||
|
value = Math.min(this._config.max!, state);
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card
|
<ha-card
|
||||||
@click=${this._handleClick}
|
@click=${this._handleClick}
|
||||||
@ -143,7 +151,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
readonly
|
readonly
|
||||||
arcLength="180"
|
arcLength="180"
|
||||||
startAngle="180"
|
startAngle="180"
|
||||||
.value=${state}
|
.value=${value}
|
||||||
.min=${this._config.min}
|
.min=${this._config.min}
|
||||||
.max=${this._config.max}
|
.max=${this._config.max}
|
||||||
></round-slider>
|
></round-slider>
|
||||||
@ -243,6 +251,10 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _measureCard() {
|
private _measureCard() {
|
||||||
|
if (!this.isConnected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.offsetWidth < 200) {
|
if (this.offsetWidth < 200) {
|
||||||
this.setAttribute("narrow", "");
|
this.setAttribute("narrow", "");
|
||||||
} else {
|
} else {
|
||||||
@ -257,6 +269,10 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
ha-card {
|
ha-card {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user