mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 10:16:46 +00:00
Improve chart zoom (#23326)
This commit is contained in:
parent
ba3d37b550
commit
8a46ef6168
@ -372,6 +372,9 @@ export class HaChartBase extends LitElement {
|
|||||||
const modifierKey = isMac ? "meta" : "ctrl";
|
const modifierKey = isMac ? "meta" : "ctrl";
|
||||||
return {
|
return {
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
|
animation: {
|
||||||
|
duration: 500,
|
||||||
|
},
|
||||||
...this.options,
|
...this.options,
|
||||||
plugins: {
|
plugins: {
|
||||||
...this.options?.plugins,
|
...this.options?.plugins,
|
||||||
@ -396,14 +399,24 @@ export class HaChartBase extends LitElement {
|
|||||||
drag: {
|
drag: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
modifierKey,
|
modifierKey,
|
||||||
|
threshold: 2,
|
||||||
},
|
},
|
||||||
wheel: {
|
wheel: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
modifierKey,
|
modifierKey,
|
||||||
|
speed: 0.05,
|
||||||
},
|
},
|
||||||
mode: "x",
|
mode: "x",
|
||||||
onZoomComplete: () => {
|
onZoomComplete: () => {
|
||||||
this._isZoomed = this.chart?.isZoomedOrPanned() ?? false;
|
const isZoomed = this.chart?.isZoomedOrPanned() ?? false;
|
||||||
|
if (this._isZoomed && !isZoomed) {
|
||||||
|
setTimeout(() => {
|
||||||
|
// make sure the scales are properly reset after full zoom out
|
||||||
|
// they get bugged when zooming in/out multiple times and panning
|
||||||
|
this.chart?.resetZoom();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this._isZoomed = isZoomed;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
limits: {
|
limits: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user