mirror of
https://github.com/home-assistant/frontend.git
synced 2026-12-03 10:09:48 +00:00
Show the zoom reset after a graph center or zoom in the options
The layout controller moves the view with a series center/zoom, which fires no graphroam, so the chart base kept the zoom reset hidden. It now also checks the graph roam when a render finishes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
149f159880
commit
ca68e3a2c2
1 file changed
+10
-6
@@ -969,12 +969,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
this.chart!.dispatchAction({ type: "downplay" });
|
||||
});
|
||||
|
||||
this.chart.on("graphroam", () => {
|
||||
this._isGraphRoamed = this._getGraphRoams().some(
|
||||
({ zoom, x, y }) =>
|
||||
Math.abs(zoom - 1) > 1e-6 || Math.abs(x) > 0.5 || Math.abs(y) > 0.5
|
||||
);
|
||||
});
|
||||
this.chart.on("graphroam", this._updateGraphRoamed);
|
||||
|
||||
if (!this.options?.dataZoom) {
|
||||
this.chart.getZr().on("dblclick", this._handleClickZoom);
|
||||
@@ -2243,9 +2238,18 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
}
|
||||
|
||||
private _handleChartRenderFinished = () => {
|
||||
// Also after a center or zoom in the options, which ends without graphroam
|
||||
this._updateGraphRoamed();
|
||||
this._resizeChartIfNeeded();
|
||||
};
|
||||
|
||||
private _updateGraphRoamed = () => {
|
||||
this._isGraphRoamed = this._getGraphRoams().some(
|
||||
({ zoom, x, y }) =>
|
||||
Math.abs(zoom - 1) > 1e-6 || Math.abs(x) > 0.5 || Math.abs(y) > 0.5
|
||||
);
|
||||
};
|
||||
|
||||
private _resizeChartIfNeeded() {
|
||||
if (!this.chart || !this._shouldResizeChart) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user