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