mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Remove name from the chart series when using showNames = false (#23995)
* Remove name from the chart series when using showNames = false * Remove translations
This commit is contained in:
parent
d4497ca39c
commit
816989ab4d
@ -152,7 +152,10 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
value += source;
|
value += source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param.seriesName) {
|
||||||
return `${param.marker} ${param.seriesName}: ${value}`;
|
return `${param.marker} ${param.seriesName}: ${value}`;
|
||||||
|
}
|
||||||
|
return `${param.marker} ${value}`;
|
||||||
})
|
})
|
||||||
.join("<br>")
|
.join("<br>")
|
||||||
);
|
);
|
||||||
@ -410,13 +413,21 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
entityState.attributes.target_temp_low
|
entityState.attributes.target_temp_low
|
||||||
);
|
);
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.climate.current_temperature", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.current_temperature", {
|
||||||
name: name,
|
name: name,
|
||||||
})}`
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.current_temperature.name"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if (hasHeat) {
|
if (hasHeat) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.climate.heating", { name: name })}`,
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.heating", { name: name })
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.hvac_action.state.heating"
|
||||||
|
),
|
||||||
computedStyles.getPropertyValue("--state-climate-heat-color"),
|
computedStyles.getPropertyValue("--state-climate-heat-color"),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@ -425,7 +436,11 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
}
|
}
|
||||||
if (hasCool) {
|
if (hasCool) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.climate.cooling", { name: name })}`,
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.cooling", { name: name })
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.hvac_action.state.cooling"
|
||||||
|
),
|
||||||
computedStyles.getPropertyValue("--state-climate-cool-color"),
|
computedStyles.getPropertyValue("--state-climate-cool-color"),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@ -435,22 +450,37 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
|
|
||||||
if (hasTargetRange) {
|
if (hasTargetRange) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.climate.target_temperature_mode", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.target_temperature_mode", {
|
||||||
name: name,
|
name: name,
|
||||||
mode: this.hass.localize("ui.card.climate.high"),
|
mode: this.hass.localize("ui.card.climate.high"),
|
||||||
})}`
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.target_temp_high.name"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.climate.target_temperature_mode", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.target_temperature_mode", {
|
||||||
name: name,
|
name: name,
|
||||||
mode: this.hass.localize("ui.card.climate.low"),
|
mode: this.hass.localize("ui.card.climate.low"),
|
||||||
})}`
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.target_temp_low.name"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.climate.target_temperature_entity", {
|
this.showNames
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.card.climate.target_temperature_entity",
|
||||||
|
{
|
||||||
name: name,
|
name: name,
|
||||||
})}`
|
}
|
||||||
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.temperature.name"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,19 +533,27 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
);
|
);
|
||||||
|
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.humidifier.target_humidity_entity", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.humidifier.target_humidity_entity", {
|
||||||
name: name,
|
name: name,
|
||||||
})}`
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.humidifier.entity_component._.state_attributes.humidity.name"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasCurrent) {
|
if (hasCurrent) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize(
|
this.showNames
|
||||||
|
? this.hass.localize(
|
||||||
"ui.card.humidifier.current_humidity_entity",
|
"ui.card.humidifier.current_humidity_entity",
|
||||||
{
|
{
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
)}`
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.humidifier.entity_component._.state_attributes.current_humidity.name"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,25 +561,37 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
// If action attribute is not available, we shade the area when the device is on
|
// If action attribute is not available, we shade the area when the device is on
|
||||||
if (hasHumidifying) {
|
if (hasHumidifying) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.humidifier.humidifying", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.humidifier.humidifying", {
|
||||||
name: name,
|
name: name,
|
||||||
})}`,
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.humidifier.entity_component._.state_attributes.action.state.humidifying"
|
||||||
|
),
|
||||||
computedStyles.getPropertyValue("--state-humidifier-on-color"),
|
computedStyles.getPropertyValue("--state-humidifier-on-color"),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
} else if (hasDrying) {
|
} else if (hasDrying) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.humidifier.drying", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.humidifier.drying", {
|
||||||
name: name,
|
name: name,
|
||||||
})}`,
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.humidifier.entity_component._.state_attributes.action.state.drying"
|
||||||
|
),
|
||||||
computedStyles.getPropertyValue("--state-humidifier-on-color"),
|
computedStyles.getPropertyValue("--state-humidifier-on-color"),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
`${this.hass.localize("ui.card.humidifier.on_entity", {
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.humidifier.on_entity", {
|
||||||
name: name,
|
name: name,
|
||||||
})}`,
|
})
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.humidifier.entity_component._.state.on"
|
||||||
|
),
|
||||||
undefined,
|
undefined,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@ -574,7 +624,7 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
pushData(new Date(entityState.last_changed), series);
|
pushData(new Date(entityState.last_changed), series);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addDataSet(name);
|
addDataSet(this.showNames ? name : "");
|
||||||
|
|
||||||
let lastValue: number;
|
let lastValue: number;
|
||||||
let lastDate: Date;
|
let lastDate: Date;
|
||||||
|
@ -132,7 +132,9 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
const { value, name, marker } = Array.isArray(params)
|
const { value, name, marker } = Array.isArray(params)
|
||||||
? params[0]
|
? params[0]
|
||||||
: params;
|
: params;
|
||||||
const title = `<h4 style="text-align: center; margin: 0;">${value![0]}</h4>`;
|
const title = value![0]
|
||||||
|
? `<h4 style="text-align: center; margin: 0;">${value![0]}</h4>`
|
||||||
|
: "";
|
||||||
const durationInMs = value![2] - value![1];
|
const durationInMs = value![2] - value![1];
|
||||||
const formattedDuration = `${this.hass.localize(
|
const formattedDuration = `${this.hass.localize(
|
||||||
"ui.components.history_charts.duration"
|
"ui.components.history_charts.duration"
|
||||||
@ -281,8 +283,9 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
let prevState: string | null = null;
|
let prevState: string | null = null;
|
||||||
let locState: string | null = null;
|
let locState: string | null = null;
|
||||||
let prevLastChanged = startTime;
|
let prevLastChanged = startTime;
|
||||||
const entityDisplay: string =
|
const entityDisplay: string = this.showNames
|
||||||
names[stateInfo.entity_id] || stateInfo.name;
|
? names[stateInfo.entity_id] || stateInfo.name
|
||||||
|
: "";
|
||||||
|
|
||||||
const dataRow: unknown[] = [];
|
const dataRow: unknown[] = [];
|
||||||
stateInfo.data.forEach((entityState) => {
|
stateInfo.data.forEach((entityState) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user