mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-05 23:47:54 +00:00
Fix network graph not rendering (#26396)
This commit is contained in:
parent
53497aa632
commit
c363995718
@ -168,14 +168,16 @@ export class HaChartBase extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated() {
|
protected firstUpdated() {
|
||||||
this._setupChart();
|
if (this.isConnected) {
|
||||||
|
this._setupChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public willUpdate(changedProps: PropertyValues): void {
|
public willUpdate(changedProps: PropertyValues): void {
|
||||||
if (!this.chart) {
|
if (!this.chart) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (changedProps.has("_themes")) {
|
if (changedProps.has("_themes") && this.hasUpdated) {
|
||||||
this._setupChart();
|
this._setupChart();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -802,6 +804,7 @@ export class HaChartBase extends LitElement {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const replaceMerge = options.series ? ["series"] : [];
|
const replaceMerge = options.series ? ["series"] : [];
|
||||||
this.chart.setOption(options, { replaceMerge });
|
this.chart.setOption(options, { replaceMerge });
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,14 @@ export class HaNetworkGraph extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!GraphChart) {
|
if (!GraphChart || !this.data.nodes?.length) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isMobile = window.matchMedia(
|
const isMobile = window.matchMedia(
|
||||||
"all and (max-width: 450px), all and (max-height: 500px)"
|
"all and (max-width: 450px), all and (max-height: 500px)"
|
||||||
).matches;
|
).matches;
|
||||||
|
|
||||||
return html`<ha-chart-base
|
return html`<ha-chart-base
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.data=${this._getSeries(
|
.data=${this._getSeries(
|
||||||
@ -243,6 +245,7 @@ export class HaNetworkGraph extends SubscribeMixin(LitElement) {
|
|||||||
) {
|
) {
|
||||||
const containerWidth = this.clientWidth;
|
const containerWidth = this.clientWidth;
|
||||||
const containerHeight = this.clientHeight;
|
const containerHeight = this.clientHeight;
|
||||||
|
|
||||||
const positionedNodes: NetworkNode[] = nodes.map((node) => ({ ...node }));
|
const positionedNodes: NetworkNode[] = nodes.map((node) => ({ ...node }));
|
||||||
positionedNodes.forEach((node) => {
|
positionedNodes.forEach((node) => {
|
||||||
if (nodePositions[node.id]) {
|
if (nodePositions[node.id]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user