mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-30 00:29:25 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86f1496e62 |
No files matched your search
+6
-6
@@ -51,7 +51,7 @@
|
||||
"@codemirror/lint": "6.9.8",
|
||||
"@codemirror/search": "6.7.3",
|
||||
"@codemirror/state": "6.7.6",
|
||||
"@codemirror/view": "6.44.1",
|
||||
"@codemirror/view": "6.44.0",
|
||||
"@date-fns/tz": "1.5.0",
|
||||
"@egjs/hammerjs": "2.0.17",
|
||||
"@formatjs/intl-datetimeformat": "8.0.3",
|
||||
@@ -79,12 +79,12 @@
|
||||
"@swc/helpers": "0.5.24",
|
||||
"@tsparticles/engine": "4.5.4",
|
||||
"@tsparticles/preset-links": "4.5.4",
|
||||
"@versatiles/style": "9.1.3",
|
||||
"@versatiles/style": "9.1.2",
|
||||
"@vibrant/color": "4.0.4",
|
||||
"@vvo/tzdb": "6.207.0",
|
||||
"@vvo/tzdb": "6.204.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "0.0.11",
|
||||
"barcode-detector": "3.2.4",
|
||||
"cally": "0.10.0",
|
||||
"cally": "0.9.2",
|
||||
"color-name": "2.1.1",
|
||||
"comlink": "4.4.2",
|
||||
"core-js": "3.51.0",
|
||||
@@ -210,12 +210,12 @@
|
||||
"rspack-manifest-plugin": "5.2.2",
|
||||
"serve": "14.2.8",
|
||||
"sinon": "22.1.0",
|
||||
"tar": "7.5.24",
|
||||
"tar": "7.5.23",
|
||||
"terser-webpack-plugin": "5.6.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.74.0",
|
||||
"vite": "8.4.0",
|
||||
"vite": "8.3.8",
|
||||
"vite-tsconfig-paths": "6.1.1",
|
||||
"vitest": "5.1.2",
|
||||
"webpack-stats-plugin": "1.1.3",
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@custom-elements-manifest/analyzer": "0.11.0",
|
||||
"@rslib/core": "1.1.0",
|
||||
"@rslib/core": "1.0.7",
|
||||
"lit": "3.3.3",
|
||||
"typescript": "6.0.3"
|
||||
}
|
||||
|
||||
Generated
+254
-359
File diff suppressed because it is too large.
Load diff
@@ -546,6 +546,10 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
if (changedProps.has("options")) {
|
||||
chartOptions = { ...chartOptions, ...this._createOptions() };
|
||||
this._disposeSonification();
|
||||
const [start, end] = this._zoomRange;
|
||||
if (!this._getZoomAxis() && (start !== 0 || end !== 100)) {
|
||||
this._setZoomRange(0, 100);
|
||||
}
|
||||
}
|
||||
let legendChanged = false;
|
||||
if (changedProps.has("options") || changedProps.has("data")) {
|
||||
@@ -1072,7 +1076,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
private _updateDragToZoom() {
|
||||
const active =
|
||||
!this._touchInput &&
|
||||
this._hasZoomableXAxis() &&
|
||||
this._getZoomAxis() !== undefined &&
|
||||
this.selectMode !== "range";
|
||||
if (!this.chart || active === this._dragToZoom) {
|
||||
return;
|
||||
@@ -1209,31 +1213,34 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
private _hasZoomableXAxis() {
|
||||
// Horizontal bar charts zoom their categories, which rescales the values
|
||||
private _getZoomAxis(): "x" | "y" | undefined {
|
||||
const xAxis = ensureArray(this.options?.xAxis)?.[0] as
|
||||
XAXisOption | undefined;
|
||||
const yAxis = ensureArray(this.options?.yAxis)?.[0] as
|
||||
YAXisOption | undefined;
|
||||
return Boolean(
|
||||
xAxis &&
|
||||
xAxis.show !== false &&
|
||||
!this.options?.dataZoom &&
|
||||
// vertical data zoom doesn't work well in this case and horizontal is pointless
|
||||
!(xAxis.type === "value" && yAxis?.type === "category")
|
||||
);
|
||||
if (!xAxis || xAxis.show === false || this.options?.dataZoom) {
|
||||
return undefined;
|
||||
}
|
||||
return xAxis.type === "value" && yAxis?.type === "category" ? "y" : "x";
|
||||
}
|
||||
|
||||
private _hasZoomableXAxis() {
|
||||
return this._getZoomAxis() === "x";
|
||||
}
|
||||
|
||||
private _getDataZoomConfig(): DataZoomComponentOption[] | undefined {
|
||||
if (!this._hasZoomableXAxis()) {
|
||||
const zoomAxis = this._getZoomAxis();
|
||||
if (!zoomAxis) {
|
||||
return undefined;
|
||||
}
|
||||
return [
|
||||
{
|
||||
id: "dataZoom",
|
||||
type: "inside",
|
||||
orient: "horizontal",
|
||||
filterMode: this._getDataZoomFilterMode() as any,
|
||||
xAxisIndex: 0,
|
||||
xAxisIndex: zoomAxis === "x" ? 0 : undefined,
|
||||
yAxisIndex: zoomAxis === "y" ? 0 : undefined,
|
||||
// Panning is left to the slider and horizontal scrolling
|
||||
moveOnMouseMove: false,
|
||||
preventDefaultMouseMove: false,
|
||||
@@ -1395,6 +1402,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
l.type === "custom" ? { show: false } : l
|
||||
);
|
||||
}
|
||||
const verticalZoom = this._getZoomAxis() === "y";
|
||||
const options = {
|
||||
animation: !this._reducedMotion,
|
||||
animationDuration: 500,
|
||||
@@ -1407,7 +1415,8 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
feature: {
|
||||
dataZoom: {
|
||||
show: true,
|
||||
yAxisIndex: false,
|
||||
xAxisIndex: verticalZoom ? false : undefined,
|
||||
yAxisIndex: verticalZoom ? undefined : false,
|
||||
filterMode: "none",
|
||||
showTitle: false,
|
||||
},
|
||||
@@ -1735,6 +1744,10 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
}
|
||||
|
||||
const replaceMerge = options.series ? ["series"] : [];
|
||||
// A bar chart turned into a pie drops its zoom
|
||||
if ("dataZoom" in options) {
|
||||
replaceMerge.push("dataZoom");
|
||||
}
|
||||
this.chart.setOption(options, { replaceMerge });
|
||||
}
|
||||
|
||||
@@ -1763,14 +1776,16 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!this._hasZoomableXAxis()) {
|
||||
const zoomAxis = this._getZoomAxis();
|
||||
if (!zoomAxis) {
|
||||
return;
|
||||
}
|
||||
const position =
|
||||
zoomAxis === "y"
|
||||
? e.offsetY / this.chart.getHeight()
|
||||
: e.offsetX / this.chart.getWidth();
|
||||
// Kept within the axis, as ECharts does, so the datazoom event matches it
|
||||
const start = Math.min(
|
||||
Math.max((e.offsetX / this.chart.getWidth()) * 100 - 15, 0),
|
||||
70
|
||||
);
|
||||
const start = Math.min(Math.max(position * 100 - 15, 0), 70);
|
||||
const range = this._isZoomed ? [0, 100] : [start, start + 30];
|
||||
this.chart.dispatchAction({
|
||||
type: "dataZoom",
|
||||
@@ -1798,7 +1813,11 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
ev.stopPropagation();
|
||||
// Not _isZoomed, which a Sankey roam sets without an axis to pan
|
||||
const [start, end] = this._zoomRange;
|
||||
if (!this.chart || (start === 0 && end === 100)) {
|
||||
if (
|
||||
!this.chart ||
|
||||
!this._hasZoomableXAxis() ||
|
||||
(start === 0 && end === 100)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const delta = ev.shiftKey ? ev.deltaX || ev.deltaY : ev.deltaX;
|
||||
@@ -1824,7 +1843,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
return;
|
||||
}
|
||||
const [start, end] = this._zoomRange;
|
||||
const shift = (pixels * (end - start)) / this._getXAxisPixelWidth();
|
||||
const shift = (pixels * (end - start)) / this._getZoomAxisLength();
|
||||
const clamped = Math.max(-start, Math.min(100 - end, shift));
|
||||
if (clamped) {
|
||||
this._setZoomWindow(start + clamped, end + clamped);
|
||||
@@ -2026,15 +2045,18 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
});
|
||||
}
|
||||
|
||||
private _getXAxisPixelWidth(): number {
|
||||
private _getZoomAxisLength(): number {
|
||||
const vertical = this._getZoomAxis() === "y";
|
||||
const axisModel = this.chart
|
||||
// @ts-ignore private method but no public way to get the axis extent
|
||||
?.getModel()
|
||||
.getComponent("xAxis", 0) as
|
||||
.getComponent(vertical ? "yAxis" : "xAxis", 0) as
|
||||
{ axis?: { getExtent(): [number, number] } } | undefined;
|
||||
const extent = axisModel?.axis?.getExtent();
|
||||
const width = extent ? Math.abs(extent[1] - extent[0]) : 0;
|
||||
return width || this.chart!.getWidth();
|
||||
const length = extent ? Math.abs(extent[1] - extent[0]) : 0;
|
||||
return (
|
||||
length || (vertical ? this.chart!.getHeight() : this.chart!.getWidth())
|
||||
);
|
||||
}
|
||||
|
||||
private _setZoomRange(start: number, end: number) {
|
||||
@@ -2056,7 +2078,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
|
||||
[start, end] = dataZoom?.getPercentRange() ?? [0, 100];
|
||||
const [prevStart, prevEnd] = this._zoomRange;
|
||||
const pixels =
|
||||
((end - start) / (prevEnd - prevStart)) * this._getXAxisPixelWidth();
|
||||
((end - start) / (prevEnd - prevStart)) * this._getZoomAxisLength();
|
||||
if (pixels < MIN_DRAG_ZOOM_WIDTH) {
|
||||
this.chart!.dispatchAction(
|
||||
{
|
||||
|
||||
@@ -387,7 +387,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
ha-icon-button {
|
||||
--ha-icon-button-size: 40px;
|
||||
--ha-color-on-disabled-quiet: currentColor;
|
||||
--disabled-text-color: currentColor;
|
||||
color: var(--ha-picture-icon-button-color, #a9a9a9);
|
||||
}
|
||||
ha-icon-button.state-on {
|
||||
|
||||
Reference in new issue
Block a user