mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Fix touch control of chart zoom (#23302)
* Fix touch control of chart zoom * fix
This commit is contained in:
parent
da7d3e118c
commit
7370d1e0dd
@ -67,6 +67,8 @@ export class HaChartBase extends LitElement {
|
|||||||
|
|
||||||
@state() private _showZoomHint = false;
|
@state() private _showZoomHint = false;
|
||||||
|
|
||||||
|
@state() private _isZoomed = false;
|
||||||
|
|
||||||
private _paddingUpdateCount = 0;
|
private _paddingUpdateCount = 0;
|
||||||
|
|
||||||
private _paddingUpdateLock = false;
|
private _paddingUpdateLock = false;
|
||||||
@ -266,7 +268,11 @@ export class HaChartBase extends LitElement {
|
|||||||
})}
|
})}
|
||||||
@wheel=${this._handleChartScroll}
|
@wheel=${this._handleChartScroll}
|
||||||
>
|
>
|
||||||
<canvas></canvas>
|
<canvas
|
||||||
|
class=${classMap({
|
||||||
|
"not-zoomed": !this._isZoomed,
|
||||||
|
})}
|
||||||
|
></canvas>
|
||||||
<div
|
<div
|
||||||
class="zoom-hint ${classMap({
|
class="zoom-hint ${classMap({
|
||||||
visible: this._showZoomHint,
|
visible: this._showZoomHint,
|
||||||
@ -396,11 +402,14 @@ export class HaChartBase extends LitElement {
|
|||||||
modifierKey,
|
modifierKey,
|
||||||
},
|
},
|
||||||
mode: "x",
|
mode: "x",
|
||||||
|
onZoomComplete: () => {
|
||||||
|
this._isZoomed = this.chart?.isZoomedOrPanned() ?? false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
limits: {
|
limits: {
|
||||||
x: {
|
x: {
|
||||||
min: "original",
|
min: "original",
|
||||||
max: "original",
|
max: (this.options?.scales?.x as any)?.max ?? "original",
|
||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
min: "original",
|
min: "original",
|
||||||
@ -516,6 +525,10 @@ export class HaChartBase extends LitElement {
|
|||||||
canvas {
|
canvas {
|
||||||
max-height: var(--chart-max-height, 400px);
|
max-height: var(--chart-max-height, 400px);
|
||||||
}
|
}
|
||||||
|
canvas.not-zoomed {
|
||||||
|
/* allow scrolling if the chart is not zoomed */
|
||||||
|
touch-action: pan-y !important;
|
||||||
|
}
|
||||||
.chartLegend {
|
.chartLegend {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
min: this.startTime,
|
min: this.startTime,
|
||||||
suggestedMax: this.endTime,
|
max: this.endTime,
|
||||||
ticks: {
|
ticks: {
|
||||||
maxRotation: 0,
|
maxRotation: 0,
|
||||||
sampleSize: 5,
|
sampleSize: 5,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user