@cpsoft13/z-agent-ui 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lines-baseline.json +1 -15
- package/bin/text-baseline.json +1 -2
- package/dist/build-info.json +2 -2
- package/dist/components/context-menu/ContextMenu.js +7 -7
- package/dist/components/context-menu/ContextMenu.js.map +1 -1
- package/dist/components/date-range/DateRange.js +4 -4
- package/dist/components/date-range/DateRange.js.map +1 -1
- package/dist/components/datepicker/Datepicker.js +207 -332
- package/dist/components/datepicker/Datepicker.js.map +1 -1
- package/dist/components/datepicker/datepicker-keyboard.js +66 -0
- package/dist/components/datepicker/datepicker-keyboard.js.map +1 -0
- package/dist/components/datepicker/datepicker-panel-render.js +78 -0
- package/dist/components/datepicker/datepicker-panel-render.js.map +1 -0
- package/dist/components/form/Form.js +69 -47
- package/dist/components/form/Form.js.map +1 -1
- package/dist/components/form/form-context.js +9 -0
- package/dist/components/form/form-context.js.map +1 -0
- package/dist/components/form.js +2 -0
- package/dist/components/form.js.map +1 -1
- package/dist/components/menu/Menu.js +27 -27
- package/dist/components/menu/Menu.js.map +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/select/Select.js +235 -351
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/select/option-search.js +49 -0
- package/dist/components/select/option-search.js.map +1 -0
- package/dist/components/select/select-render.js +75 -0
- package/dist/components/select/select-render.js.map +1 -0
- package/dist/components/select/selection-strategy.js +151 -0
- package/dist/components/select/selection-strategy.js.map +1 -0
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/time-picker/TimePicker.js.map +1 -1
- package/dist/components/tooltip/Tooltip.js +16 -16
- package/dist/components/tooltip/Tooltip.js.map +1 -1
- package/dist/core/BaseElement.js +96 -77
- package/dist/core/BaseElement.js.map +1 -1
- package/dist/core/context.js +68 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/controller.js +2 -0
- package/dist/core/controller.js.map +1 -0
- package/dist/core/public.js +35 -30
- package/dist/core/public.js.map +1 -1
- package/dist/core.js +95 -90
- package/dist/core.js.map +1 -1
- package/dist/doc/doc-template-editor-core.js +12 -11
- package/dist/doc/doc-template-editor-core.js.map +1 -1
- package/dist/doc/doc-template-editor-panel.css.js +202 -0
- package/dist/doc/doc-template-editor-panel.css.js.map +1 -0
- package/dist/doc/doc-template-editor.css.js +1 -200
- package/dist/doc/doc-template-editor.css.js.map +1 -1
- package/dist/flow/Flow.js +104 -195
- package/dist/flow/Flow.js.map +1 -1
- package/dist/flow/flow-keyboard-controller.js +101 -0
- package/dist/flow/flow-keyboard-controller.js.map +1 -0
- package/dist/primitives/overlay/floatingPanel.js +6 -2
- package/dist/primitives/overlay/floatingPanel.js.map +1 -1
- package/dist/report/chart/Chart.js +271 -761
- package/dist/report/chart/Chart.js.map +1 -1
- package/dist/report/chart/chart-brush-controller.js +187 -0
- package/dist/report/chart/chart-brush-controller.js.map +1 -0
- package/dist/report/chart/chart-layout-pipeline.js +158 -0
- package/dist/report/chart/chart-layout-pipeline.js.map +1 -0
- package/dist/report/chart/chart-zoom.js +79 -0
- package/dist/report/chart/chart-zoom.js.map +1 -0
- package/dist/report/chart/geometry/build.js +41 -26
- package/dist/report/chart/geometry/build.js.map +1 -1
- package/dist/report/chart/geometry/extra-flow-dist.js +283 -0
- package/dist/report/chart/geometry/extra-flow-dist.js.map +1 -0
- package/dist/report/chart/geometry/extra-radial-grid.js +280 -0
- package/dist/report/chart/geometry/extra-radial-grid.js.map +1 -0
- package/dist/report/chart/geometry/extra-shared.js +36 -0
- package/dist/report/chart/geometry/extra-shared.js.map +1 -0
- package/dist/report/chart/geometry/extra.js +20 -583
- package/dist/report/chart/geometry/extra.js.map +1 -1
- package/dist/report/chart/geometry/registry.js +20 -0
- package/dist/report/chart/geometry/registry.js.map +1 -0
- package/dist/report/chart.js +12 -6
- package/dist/report/chart.js.map +1 -1
- package/dist/report/gantt/Gantt.js +199 -308
- package/dist/report/gantt/Gantt.js.map +1 -1
- package/dist/report/gantt/gantt-bars.css.js +247 -0
- package/dist/report/gantt/gantt-bars.css.js.map +1 -0
- package/dist/report/gantt/gantt-edit-controller.js +94 -0
- package/dist/report/gantt/gantt-edit-controller.js.map +1 -0
- package/dist/report/gantt/gantt.css.js +0 -272
- package/dist/report/gantt/gantt.css.js.map +1 -1
- package/dist/report/table/ReportTable.js +336 -493
- package/dist/report/table/ReportTable.js.map +1 -1
- package/dist/report/table/report-table-config.css.js +172 -0
- package/dist/report/table/report-table-config.css.js.map +1 -0
- package/dist/report/table/report-table-types.js.map +1 -1
- package/dist/report/table/report-table.css.js +0 -176
- package/dist/report/table/report-table.css.js.map +1 -1
- package/dist/report/table/table-cell-registry.js +29 -0
- package/dist/report/table/table-cell-registry.js.map +1 -0
- package/dist/report/table/table-keyboard-controller.js +96 -0
- package/dist/report/table/table-keyboard-controller.js.map +1 -0
- package/dist/report/table/table-pipeline.js +36 -0
- package/dist/report/table/table-pipeline.js.map +1 -0
- package/dist/report/table/table-render.js +97 -96
- package/dist/report/table/table-render.js.map +1 -1
- package/dist/report/table/table-scroll-controller.js +33 -0
- package/dist/report/table/table-scroll-controller.js.map +1 -0
- package/dist/report/table.js +7 -2
- package/dist/report/table.js.map +1 -1
- package/dist/report.js +39 -28
- package/dist/report.js.map +1 -1
- package/dist/types/components/datepicker/Datepicker.d.ts +1 -109
- package/dist/types/components/datepicker/datepicker-keyboard.d.ts +21 -0
- package/dist/types/components/datepicker/datepicker-panel-render.d.ts +25 -0
- package/dist/types/components/form/Form.d.ts +7 -2
- package/dist/types/components/form/form-context.d.ts +11 -0
- package/dist/types/components/form/index.d.ts +1 -1
- package/dist/types/components/select/Select.d.ts +7 -110
- package/dist/types/components/select/option-search.d.ts +38 -0
- package/dist/types/components/select/select-render.d.ts +39 -0
- package/dist/types/components/select/selection-strategy.d.ts +86 -0
- package/dist/types/core/BaseElement.d.ts +7 -1
- package/dist/types/core/context.d.ts +66 -0
- package/dist/types/core/controller.d.ts +22 -0
- package/dist/types/core/public.d.ts +2 -0
- package/dist/types/flow/Flow.d.ts +3 -76
- package/dist/types/flow/flow-keyboard-controller.d.ts +35 -0
- package/dist/types/primitives/overlay/floatingPanel.d.ts +2 -0
- package/dist/types/report/chart/Chart.d.ts +2 -245
- package/dist/types/report/chart/chart-brush-controller.d.ts +59 -0
- package/dist/types/report/chart/chart-layout-pipeline.d.ts +42 -0
- package/dist/types/report/chart/chart-zoom.d.ts +12 -0
- package/dist/types/report/chart/geometry/build.d.ts +2 -0
- package/dist/types/report/chart/geometry/extra-flow-dist.d.ts +6 -0
- package/dist/types/report/chart/geometry/extra-radial-grid.d.ts +6 -0
- package/dist/types/report/chart/geometry/extra-shared.d.ts +24 -0
- package/dist/types/report/chart/geometry/extra.d.ts +2 -34
- package/dist/types/report/chart/geometry/registry.d.ts +26 -0
- package/dist/types/report/chart/index.d.ts +1 -0
- package/dist/types/report/gantt/Gantt.d.ts +7 -97
- package/dist/types/report/gantt/gantt-edit-controller.d.ts +34 -0
- package/dist/types/report/table/ReportTable.d.ts +9 -180
- package/dist/types/report/table/index.d.ts +1 -0
- package/dist/types/report/table/report-table-types.d.ts +2 -0
- package/dist/types/report/table/table-cell-registry.d.ts +17 -0
- package/dist/types/report/table/table-keyboard-controller.d.ts +30 -0
- package/dist/types/report/table/table-pipeline.d.ts +33 -0
- package/dist/types/report/table/table-scroll-controller.d.ts +25 -0
- package/dist/z-agent-ui.js +35 -30
- package/dist/z-agent-ui.js.map +1 -1
- package/package.json +1 -1
- package/registry/component-manifest.json +39 -7
- package/src/components/context-menu/ContextMenu.ts +1 -1
- package/src/components/date-range/DateRange.ts +1 -1
- package/src/components/datepicker/Datepicker.ts +99 -417
- package/src/components/datepicker/datepicker-keyboard.ts +94 -0
- package/src/components/datepicker/datepicker-panel-render.ts +169 -0
- package/src/components/form/Form.ts +39 -11
- package/src/components/form/form-context.ts +11 -0
- package/src/components/form/index.ts +1 -1
- package/src/components/menu/Menu.ts +1 -1
- package/src/components/popover/Popover.ts +1 -1
- package/src/components/select/Select.ts +140 -525
- package/src/components/select/option-search.ts +114 -0
- package/src/components/select/select-render.ts +161 -0
- package/src/components/select/selection-strategy.ts +245 -0
- package/src/components/time-picker/TimePicker.ts +1 -1
- package/src/components/tooltip/Tooltip.ts +1 -1
|
@@ -1,66 +1,36 @@
|
|
|
1
|
-
import { BaseElement as
|
|
2
|
-
import { property as
|
|
3
|
-
import { escapeAttr as
|
|
4
|
-
import
|
|
1
|
+
import { BaseElement as $ } from "../../core/BaseElement.js";
|
|
2
|
+
import { property as r } from "../../core/decorators.js";
|
|
3
|
+
import { escapeAttr as _, html as H } from "../../core/template.js";
|
|
4
|
+
import "../../core/i18n.js";
|
|
5
5
|
import "../../core/date/presets.js";
|
|
6
|
-
import { COPY as
|
|
7
|
-
import { defineElement as
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var mt = Object.defineProperty, p = (v, t, e, i) => {
|
|
24
|
-
for (var s = void 0, o = v.length - 1, r; o >= 0; o--)
|
|
25
|
-
(r = v[o]) && (s = r(t, e, s) || s);
|
|
26
|
-
return s && mt(t, e, s), s;
|
|
6
|
+
import { COPY as I } from "../../core/copy.js";
|
|
7
|
+
import { defineElement as N } from "../../core/define.js";
|
|
8
|
+
import R from "./chart.css.js";
|
|
9
|
+
import { resolveRenderer as E } from "./renderer/renderer.js";
|
|
10
|
+
import { buildGeometry as M } from "./geometry/build.js";
|
|
11
|
+
import { normalizeSeries as O } from "./data/normalize.js";
|
|
12
|
+
import { resolveSeriesColors as B } from "./palette.js";
|
|
13
|
+
import { Animator as F, prefersReducedMotion as j } from "./animator/animator.js";
|
|
14
|
+
import { TooltipManager as q } from "./interaction/tooltip.js";
|
|
15
|
+
import { nextTargetIndex as D } from "./interaction/hit.js";
|
|
16
|
+
import { resolveChartTheme as L, buildAxisSlots as P, parseHeatmapClamp as U, normalizeMapValues as G, computeChartFrameAndDomains as Z, paintChartSurfaces as V, renderChartTooltipHtml as W } from "./chart-layout-pipeline.js";
|
|
17
|
+
import { parseZoomAttr as J, MIN_ZOOM_CATEGORIES as Q, ZOOM_HEIGHT as Y, applyCategoryZoom as X, renderZoomBar as tt, stepZoomRange as et } from "./chart-zoom.js";
|
|
18
|
+
import { ChartBrushController as it } from "./chart-brush-controller.js";
|
|
19
|
+
var st = Object.defineProperty, a = (d, t, e, i) => {
|
|
20
|
+
for (var s = void 0, n = d.length - 1, m; n >= 0; n--)
|
|
21
|
+
(m = d[n]) && (s = m(t, e, s) || s);
|
|
22
|
+
return s && st(t, e, s), s;
|
|
27
23
|
};
|
|
28
|
-
const
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
for (const e of v.composedPath())
|
|
24
|
+
const ot = 400, rt = 320, at = 48;
|
|
25
|
+
let nt = 0;
|
|
26
|
+
function c(d, t) {
|
|
27
|
+
for (const e of d.composedPath())
|
|
33
28
|
if (e instanceof Element && e.matches(t)) return e;
|
|
34
29
|
return null;
|
|
35
30
|
}
|
|
36
|
-
|
|
37
|
-
const t = /^#([0-9a-f]{6})$/i.exec(v.trim());
|
|
38
|
-
if (!t) return null;
|
|
39
|
-
const e = parseInt(t[1], 16);
|
|
40
|
-
return [e >> 16 & 255, e >> 8 & 255, e & 255];
|
|
41
|
-
}
|
|
42
|
-
function vt(v) {
|
|
43
|
-
const [t, e, i] = v.map((s) => {
|
|
44
|
-
const o = s / 255;
|
|
45
|
-
return o <= 0.03928 ? o / 12.92 : Math.pow((o + 0.055) / 1.055, 2.4);
|
|
46
|
-
});
|
|
47
|
-
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
48
|
-
}
|
|
49
|
-
function bt(v, t, e) {
|
|
50
|
-
if (!v || typeof v != "object") return [];
|
|
51
|
-
const i = v, s = Array.isArray(i) ? i : Array.isArray(i.features) ? i.features : [], o = [];
|
|
52
|
-
for (const r of s) {
|
|
53
|
-
const n = r == null ? void 0 : r.geometry;
|
|
54
|
-
if (!n || n.type !== "Polygon" && n.type !== "MultiPolygon") continue;
|
|
55
|
-
const a = (r == null ? void 0 : r.properties) ?? {}, c = String(a[t] ?? (r == null ? void 0 : r.id) ?? ""), u = String(a[e] ?? c), l = n.type === "Polygon" ? n.coordinates : n.coordinates.flat();
|
|
56
|
-
l.length > 0 && o.push({ id: c, name: u, rings: l });
|
|
57
|
-
}
|
|
58
|
-
return o;
|
|
59
|
-
}
|
|
60
|
-
const N = class N extends j {
|
|
31
|
+
const f = class f extends $ {
|
|
61
32
|
constructor() {
|
|
62
|
-
super(
|
|
63
|
-
// [WHY] 默认主题对齐 slate 色板(REQ-010)
|
|
33
|
+
super(), this.type = "bar", this.direction = "vertical", this.heatmapClamp = "", this.zoomable = !1, this.zoom = "", this.brushable = !1, this.stack = "none", this.renderer = "svg", this.width = "auto", this.height = "auto", this.legend = !0, this.tooltip = !0, this.animation = !0, this.showGrid = !0, this.locale = "en-US", this.projection = "auto", this.mapIdKey = "id", this.mapNameKey = "name", this.markline = "", this.marklineLabel = "", this.markpoint = "", this.markgap = !1, this.labels = !1, this.colors = null, this.geojson = null, this.values = null, this._engine = "svg", this._engineKey = "", this._model = null, this._theme = {
|
|
64
34
|
text: "#0f172a",
|
|
65
35
|
textSecondary: "#64748b",
|
|
66
36
|
grid: "#e2e8f0",
|
|
@@ -69,116 +39,117 @@ const N = class N extends j {
|
|
|
69
39
|
fontFamily: "sans-serif",
|
|
70
40
|
labelFontSize: "12px",
|
|
71
41
|
titleFontSize: "16px"
|
|
72
|
-
}, this._lastKey = "", this._lastSizeKey = "", this._chromeH = -1, this._chromeKey = "", this._readyEmitted = !1, this._suppressAnim = !1, this._animator = new
|
|
42
|
+
}, this._lastKey = "", this._lastSizeKey = "", this._chromeH = -1, this._chromeKey = "", this._readyEmitted = !1, this._suppressAnim = !1, this._animator = new F(), this._tooltip = null, this._activeTarget = -1, this._uid = `z-chart-${++nt}`, this._columns = 1, this._zoom = null, this._zoomOffset = 0, this._zoomFocus = null, this._ro = null, this._mo = null, this.onSeriesChange = () => {
|
|
73
43
|
this.requestUpdate();
|
|
74
|
-
}, this.onPointerMove = (
|
|
75
|
-
if (this.
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
44
|
+
}, this.onPointerMove = (e) => {
|
|
45
|
+
if (this._brushCtrl.isDragging) return;
|
|
46
|
+
const i = c(e, "[data-m]");
|
|
47
|
+
if (!i) {
|
|
78
48
|
this.hideTooltip();
|
|
79
49
|
return;
|
|
80
50
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (e) {
|
|
87
|
-
const a = this.zoomNorm() ?? [0, 1];
|
|
88
|
-
this._drag = {
|
|
89
|
-
handle: e.getAttribute("data-handle") ?? "window",
|
|
90
|
-
startX: t.clientX,
|
|
91
|
-
start: [a[0], a[1]]
|
|
92
|
-
}, this._beginSession(t, 0);
|
|
51
|
+
this.showTarget(Number(i.getAttribute("data-m")), i);
|
|
52
|
+
}, this.onPointerDown = (e) => {
|
|
53
|
+
const i = c(e, "[data-handle]");
|
|
54
|
+
if (i) {
|
|
55
|
+
this._brushCtrl.startZoomDrag(e, i.getAttribute("data-handle") ?? "window");
|
|
93
56
|
return;
|
|
94
57
|
}
|
|
95
|
-
|
|
96
|
-
const i = (r = this.shadowRoot) == null ? void 0 : r.querySelector(".z-chart__plot");
|
|
97
|
-
if (!i) return;
|
|
98
|
-
const s = i.getBoundingClientRect();
|
|
99
|
-
if (t.clientX < s.left || t.clientX > s.right || t.clientY < s.top || t.clientY > s.bottom) return;
|
|
100
|
-
const o = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".z-chart__brush");
|
|
101
|
-
o && (o.hidden = !0), this._brush = {
|
|
102
|
-
active: !1,
|
|
103
|
-
x0: t.clientX - s.left,
|
|
104
|
-
y0: t.clientY - s.top,
|
|
105
|
-
x1: 0,
|
|
106
|
-
y1: 0
|
|
107
|
-
}, this._beginSession(t);
|
|
108
|
-
}, this.onPointerUp = () => {
|
|
109
|
-
this._session = null, this._drag = null;
|
|
110
|
-
const t = this._brush;
|
|
111
|
-
this._brush = null, t != null && t.active ? (this.commitBrush(t), this.paintBrushRect(t)) : this.clearBrush();
|
|
58
|
+
this._brushCtrl.startBrush(e);
|
|
112
59
|
}, this.onPointerLeave = () => {
|
|
113
60
|
this.hideTooltip();
|
|
114
|
-
}, this.onClick = (
|
|
115
|
-
var
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
61
|
+
}, this.onClick = (e) => {
|
|
62
|
+
var n;
|
|
63
|
+
const i = c(e, "[data-m]");
|
|
64
|
+
if (i) {
|
|
65
|
+
const m = (n = this._model) == null ? void 0 : n.tooltipTargets[Number(i.getAttribute("data-m"))];
|
|
66
|
+
if (m) {
|
|
67
|
+
const h = m.values[0];
|
|
121
68
|
this.emit("z-marker-click", {
|
|
122
|
-
seriesIndex:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
value: n == null ? void 0 : n.value,
|
|
127
|
-
formatted: n == null ? void 0 : n.formatted
|
|
69
|
+
seriesIndex: m.seriesIndex,
|
|
70
|
+
dataIndex: m.dataIndex + this._zoomOffset,
|
|
71
|
+
value: h == null ? void 0 : h.value,
|
|
72
|
+
formatted: h == null ? void 0 : h.formatted
|
|
128
73
|
});
|
|
129
74
|
}
|
|
130
75
|
return;
|
|
131
76
|
}
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
136
|
-
|
|
137
|
-
index:
|
|
138
|
-
name:
|
|
139
|
-
visible:
|
|
140
|
-
hidden: this.seriesConfigs().map((
|
|
77
|
+
const s = c(e, "[data-legend-index]");
|
|
78
|
+
if (s) {
|
|
79
|
+
const m = Number(s.getAttribute("data-legend-index")), h = this.seriesConfigs()[m];
|
|
80
|
+
if (!h) return;
|
|
81
|
+
h.visible = !h.visible, this.emit("z-series-toggle", {
|
|
82
|
+
index: m,
|
|
83
|
+
name: h.name,
|
|
84
|
+
visible: h.visible,
|
|
85
|
+
hidden: this.seriesConfigs().map((p, g) => ({ s: p, i: g })).filter(({ s: p }) => !p.visible).map(({ i: p }) => p)
|
|
141
86
|
});
|
|
142
87
|
}
|
|
143
|
-
}, this.onKeyDown = (
|
|
144
|
-
var
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.hideTooltip(), this._kbdSel && (this._kbdSel = null, this.clearBrush());
|
|
88
|
+
}, this.onKeyDown = (e) => {
|
|
89
|
+
var h;
|
|
90
|
+
if (c(e, "[data-handle]") && this.zoomKey(e)) return;
|
|
91
|
+
if (e.key === "Escape") {
|
|
92
|
+
this.hideTooltip(), this._brushCtrl.cancelKbdSel();
|
|
149
93
|
return;
|
|
150
94
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
95
|
+
if (e.key === "Enter" && this._brushCtrl.hasKbdSel) {
|
|
96
|
+
e.preventDefault(), this._brushCtrl.commitKbdSel();
|
|
153
97
|
return;
|
|
154
98
|
}
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
if (
|
|
159
|
-
|
|
99
|
+
if (e.shiftKey && this.brushable && this._brushCtrl.kbdBrushKey(e)) return;
|
|
100
|
+
const i = ((h = this._model) == null ? void 0 : h.tooltipTargets.length) ?? 0;
|
|
101
|
+
if (e.key === "Home" || e.key === "End") {
|
|
102
|
+
if (i <= 0) return;
|
|
103
|
+
e.preventDefault(), this.moveTarget(e.key === "Home" ? 0 : i - 1);
|
|
160
104
|
return;
|
|
161
105
|
}
|
|
162
|
-
const
|
|
106
|
+
const n = {
|
|
163
107
|
ArrowLeft: "left",
|
|
164
108
|
ArrowRight: "right",
|
|
165
109
|
ArrowUp: "up",
|
|
166
110
|
ArrowDown: "down"
|
|
167
|
-
}[
|
|
168
|
-
if (!
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
111
|
+
}[e.key];
|
|
112
|
+
if (!n) return;
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
const m = D(this._activeTarget, n, i, this._columns);
|
|
115
|
+
m >= 0 && this.moveTarget(m);
|
|
172
116
|
};
|
|
117
|
+
const t = this;
|
|
118
|
+
this._brushCtrl = this.addController(
|
|
119
|
+
new it({
|
|
120
|
+
get shadowRoot() {
|
|
121
|
+
return t.shadowRoot;
|
|
122
|
+
},
|
|
123
|
+
get brushable() {
|
|
124
|
+
return t.brushable;
|
|
125
|
+
},
|
|
126
|
+
getTargets: () => {
|
|
127
|
+
var e;
|
|
128
|
+
return ((e = t._model) == null ? void 0 : e.tooltipTargets) ?? [];
|
|
129
|
+
},
|
|
130
|
+
getColumns: () => t._columns,
|
|
131
|
+
getActiveTarget: () => t._activeTarget,
|
|
132
|
+
getZoomOffset: () => t._zoomOffset,
|
|
133
|
+
getZoomNorm: () => t.zoomNorm(),
|
|
134
|
+
setZoom: (e) => {
|
|
135
|
+
t._zoom = e, t._suppressAnim = !0, t.requestUpdate();
|
|
136
|
+
},
|
|
137
|
+
moveTarget: (e) => t.moveTarget(e),
|
|
138
|
+
hideTooltip: () => t.hideTooltip(),
|
|
139
|
+
emitBrush: (e) => {
|
|
140
|
+
t.emit("z-brush", e);
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
);
|
|
173
144
|
}
|
|
174
145
|
connectedCallback() {
|
|
175
|
-
super.connectedCallback(), this.setAttribute("tabindex", "0"), this.
|
|
146
|
+
super.connectedCallback(), this.setAttribute("tabindex", "0"), this.listen(this, "pointermove", this.onPointerMove), this.listen(this, "pointerdown", this.onPointerDown), this.listen(this, "pointerup", this._brushCtrl.onPointerUp), this.listen(this, "pointercancel", this._brushCtrl.onPointerUp), this.listen(this, "pointerleave", this.onPointerLeave), this.listen(this, "click", this.onClick), this.listen(this, "keydown", this.onKeyDown), this.listen(this, "z-series-change", this.onSeriesChange), this._mo = new MutationObserver(() => this.requestUpdate()), this._mo.observe(this, { childList: !0 }), typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => {
|
|
176
147
|
this._suppressAnim = !0, this.requestUpdate();
|
|
177
148
|
}), this._ro.observe(this));
|
|
178
149
|
}
|
|
179
150
|
disconnectedCallback() {
|
|
180
151
|
var t, e, i;
|
|
181
|
-
|
|
152
|
+
(t = this._mo) == null || t.disconnect(), (e = this._ro) == null || e.disconnect(), this._animator.cancel(), (i = this._tooltip) == null || i.destroy(), this._tooltip = null, super.disconnectedCallback();
|
|
182
153
|
}
|
|
183
154
|
willUpdate() {
|
|
184
155
|
this._engine = this.resolveEngine();
|
|
@@ -189,10 +160,10 @@ const N = class N extends j {
|
|
|
189
160
|
const t = this.title || `${this.type} chart`;
|
|
190
161
|
this.setAttribute("role", "group"), this.setAttribute("aria-label", t);
|
|
191
162
|
const e = this.legend ? '<div class="z-chart__legend" part="legend"></div>' : "";
|
|
192
|
-
return
|
|
193
|
-
${this.title ? `<div class="z-chart__title" part="title">${
|
|
163
|
+
return H`
|
|
164
|
+
${this.title ? `<div class="z-chart__title" part="title">${_(this.title)}</div>` : ""}
|
|
194
165
|
${e}
|
|
195
|
-
<div class="z-chart__plot" part="plot" role="img" aria-label="${
|
|
166
|
+
<div class="z-chart__plot" part="plot" role="img" aria-label="${_(t)}"
|
|
196
167
|
aria-describedby="${this._uid}-hint">
|
|
197
168
|
${this._engine === "svg" ? '<svg class="z-chart__svg" aria-hidden="true"></svg>' : '<canvas class="z-chart__canvas" aria-hidden="true"></canvas>'}
|
|
198
169
|
<svg class="z-chart__overlay" aria-hidden="true"></svg>
|
|
@@ -200,7 +171,7 @@ const N = class N extends j {
|
|
|
200
171
|
<div class="z-chart__focus-ring" hidden></div>
|
|
201
172
|
</div>
|
|
202
173
|
${this.zoomVisible() ? '<div class="z-chart__zoom" part="zoom"></div>' : ""}
|
|
203
|
-
<span class="z-chart__sr-only" id="${this._uid}-hint">${
|
|
174
|
+
<span class="z-chart__sr-only" id="${this._uid}-hint">${_(I.chartKeyboardHint)}</span>
|
|
204
175
|
<span class="z-chart__sr-only" role="status" id="${this._uid}-live"></span>
|
|
205
176
|
`;
|
|
206
177
|
}
|
|
@@ -208,158 +179,49 @@ const N = class N extends j {
|
|
|
208
179
|
const t = this.resolveSize(), e = `${t.w}x${t.h}`;
|
|
209
180
|
e !== this._lastSizeKey && (this._lastSizeKey !== "" && this.emit("z-resize", { width: t.w, height: t.h }), this._lastSizeKey = e);
|
|
210
181
|
const i = this.drawKey(t);
|
|
211
|
-
if (i !== this._lastKey && (this._lastKey = i, !this._suppressAnim && this.animation && !
|
|
182
|
+
if (i !== this._lastKey && (this._lastKey = i, !this._suppressAnim && this.animation && !j())) {
|
|
212
183
|
this._animator.play(400, (s) => this.draw(s, t));
|
|
213
184
|
return;
|
|
214
185
|
}
|
|
215
186
|
this._suppressAnim = !1, this._animator.cancel(), this.draw(1, t);
|
|
216
187
|
}
|
|
217
|
-
/** 属性值来自 attribute,可能是任意字符串。非法值一律当 none —— 与 type 的
|
|
218
|
-
* 「未知就回落」策略一致:渲染层不抛错,宁可少一个视觉效果,也不让整张图消失。 */
|
|
219
188
|
stackMode() {
|
|
220
189
|
const t = this.stack;
|
|
221
190
|
return t === "stacked" || t === "percent" ? t : "none";
|
|
222
191
|
}
|
|
223
|
-
/**
|
|
224
|
-
* 是否为条形图(横向)。
|
|
225
|
-
*
|
|
226
|
-
* [WHY 只认显式 horizontal] 与 stack 同一策略:属性来自 attribute,可能是任意字符串。
|
|
227
|
-
* 拼错的 `direction=horizonal` 回落竖向 —— 图照常画出来,只是方向没变,比空白图好排查。
|
|
228
|
-
*/
|
|
229
|
-
horizontalMode() {
|
|
230
|
-
return this.direction === "horizontal";
|
|
231
|
-
}
|
|
232
|
-
/** 解析 `heatmap-clamp`。非法或上下限颠倒时返回空对象(= 按本图极值,与没写一样)。 */
|
|
233
|
-
clampRange() {
|
|
234
|
-
const t = this.heatmapClamp;
|
|
235
|
-
if (!t) return {};
|
|
236
|
-
const [e, i] = t.split(",").map((o) => Number(o.trim())), s = {};
|
|
237
|
-
return Number.isFinite(e) && (s.clampMin = e), Number.isFinite(i) && (s.clampMax = i), s.clampMin !== void 0 && s.clampMax !== void 0 && s.clampMax <= s.clampMin ? {} : s;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* 归一化的可视区间(0..1)。null = 全量。
|
|
241
|
-
*
|
|
242
|
-
* [WHY 内部状态优先于属性] `zoom` 只是初值:用户拖过之后 `_zoom` 接管。
|
|
243
|
-
* 反过来(每次 draw 都从属性重新解析)的症状是「拖到一半弹回去」——
|
|
244
|
-
* 任何一次无关的重渲染都会重置,而且看起来像拖拽失灵。
|
|
245
|
-
*
|
|
246
|
-
* 非法输入("abc" / "0.5" / "0.8,0.2")一律回 null 走全量:与 stack 的
|
|
247
|
-
* 「未知回落」同策略,宁可少一个交互,不让整张图消失。
|
|
248
|
-
*/
|
|
249
192
|
zoomNorm() {
|
|
250
|
-
|
|
251
|
-
const t = (this.zoom ?? "").trim();
|
|
252
|
-
if (!t) return null;
|
|
253
|
-
const e = t.split(",").map((o) => Number(o.trim()));
|
|
254
|
-
if (e.length !== 2 || !e.every((o) => Number.isFinite(o))) return null;
|
|
255
|
-
const i = Math.min(Math.max(e[0], 0), 1), s = Math.min(Math.max(e[1], 0), 1);
|
|
256
|
-
return s > i ? [i, s] : null;
|
|
193
|
+
return this._zoom ?? J(this.zoom);
|
|
257
194
|
}
|
|
258
|
-
/** 是否显示缩放条:显式开启且分类足够多。 */
|
|
259
195
|
zoomVisible() {
|
|
260
196
|
if (!this.zoomable) return !1;
|
|
261
197
|
const t = this.seriesConfigs()[0];
|
|
262
|
-
return (Array.isArray(t == null ? void 0 : t.data) ? t.data.length : 0) >=
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* 按可视区间切片分类轴数据。
|
|
266
|
-
*
|
|
267
|
-
* [WHY 切片而不是「只画区间内的柱」] 柱宽、轴刻度、并排槽位都是按**分类数**算的。
|
|
268
|
-
* 若保留全量数据只在几何里跳过区间外的下标,画出来是「柱子挤在左边一小条、右边全是
|
|
269
|
-
* 空轴」—— 图看着像数据缺了一大半。切片后分类数变小,柱宽与刻度自动铺满,这才是缩放。
|
|
270
|
-
*
|
|
271
|
-
* 代价是 `dataIndex` 变成本地下标,所以记下 `_zoomOffset`,事件上报时还原。
|
|
272
|
-
*
|
|
273
|
-
* [WHY 只对分类轴生效] 时间/数值轴的区间裁剪要同时改值域并过滤出界点(否则点被画到
|
|
274
|
-
* 轴外),是另一套几何。当前先收口在分类轴 —— 报表里的维度列(日期、门店、渠道)
|
|
275
|
-
* 落到 `z-chart` 时基本都是分类。
|
|
276
|
-
*/
|
|
277
|
-
applyZoom(t, e) {
|
|
278
|
-
var a;
|
|
279
|
-
this._zoomOffset = 0;
|
|
280
|
-
const i = this.zoomNorm();
|
|
281
|
-
if (!i || rt(
|
|
282
|
-
t.map((c) => c.data),
|
|
283
|
-
((a = e.x) == null ? void 0 : a.type) ?? "auto"
|
|
284
|
-
) !== "category") return t;
|
|
285
|
-
const o = Math.max(...t.map((c) => c.data.length), 1), r = Math.min(Math.max(Math.floor(i[0] * o), 0), o - 1), n = Math.min(o - 1, Math.max(r + 1, Math.ceil(i[1] * o) - 1));
|
|
286
|
-
return this._zoomOffset = r, t.map((c) => ({ ...c, data: c.data.slice(r, n + 1) }));
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* 数值 / 时间轴缩放:按 `zoom` 比例收窄 x 值域(原地改 domains)。
|
|
290
|
-
*
|
|
291
|
-
* [WHY 不能像分类轴那样切片] 这正是 `applyZoom` 注释里留下的那个缺口。分类轴切的是
|
|
292
|
-
* **点**,切完分类数变少、柱宽与刻度自动铺满,所以要记 `_zoomOffset` 把 `dataIndex`
|
|
293
|
-
* 还原。数值轴切的是**值** —— 被排除的点数量与位置都不规则,数组下标一旦错位,
|
|
294
|
-
* tooltip 与点选就会指到相邻的另一行数据,而且看不出错。所以这里反过来做:
|
|
295
|
-
* 数据一根不动,只把值域收窄,域外的点由几何层跳过(`build.ts` 的 `xInDomain`)。
|
|
296
|
-
*
|
|
297
|
-
* [WHY 收窄后不必重算 ticks] `computeFrame` 是按 `domains.xDomain` 算刻度的 ——
|
|
298
|
-
* 改在它之前,轴刻度自然跟着变,不会出现「柱子缩了、刻度还是全量」的错位。
|
|
299
|
-
*
|
|
300
|
-
* 横向柱不受影响:它要求 xKind 是 category(值走 leftDomain、映射到水平方向),
|
|
301
|
-
* 在这条判断的第一行就返回了。
|
|
302
|
-
*/
|
|
303
|
-
narrowValueDomain(t) {
|
|
304
|
-
if (t.xKind !== "value" && t.xKind !== "time") return;
|
|
305
|
-
const e = this.zoomNorm();
|
|
306
|
-
if (!e) return;
|
|
307
|
-
const [i, s] = t.xDomain, o = s - i;
|
|
308
|
-
!Number.isFinite(o) || o <= 0 || (t.xDomain = [i + o * e[0], i + o * e[1]]);
|
|
198
|
+
return (Array.isArray(t == null ? void 0 : t.data) ? t.data.length : 0) >= Q;
|
|
309
199
|
}
|
|
310
200
|
resolveEngine() {
|
|
311
201
|
const t = `${this.type}|${this.renderer}`;
|
|
312
|
-
return t !== this._engineKey && (this._engineKey = t, this._engine =
|
|
202
|
+
return t !== this._engineKey && (this._engineKey = t, this._engine = E(this.type, this.renderer)), this._engine;
|
|
313
203
|
}
|
|
314
204
|
resolveSize() {
|
|
315
|
-
const t = this.width !== "auto" ? parseFloat(this.width) || 0 : this.clientWidth || 0, e = this.
|
|
316
|
-
return {
|
|
317
|
-
w: t > 0 ? t : dt,
|
|
318
|
-
h: r > 0 ? r : n
|
|
319
|
-
};
|
|
205
|
+
const t = this.width !== "auto" ? parseFloat(this.width) || 0 : this.clientWidth || 0, e = this.height !== "auto" ? parseFloat(this.height) || 0 : this.clientHeight || 0, i = this._chromeH >= 0 ? this._chromeH : this.chromeHeight(), s = this.zoomVisible() ? Y : 0, n = Math.max(0, e - i - s), m = this.type === "sparkline" ? at : rt;
|
|
206
|
+
return { w: t > 0 ? t : ot, h: n > 0 ? n : m };
|
|
320
207
|
}
|
|
321
|
-
/**
|
|
322
|
-
* chrome = 画布之上的一切:title / legend 以及它们的 margin。
|
|
323
|
-
* [为什么用矩形差而不是 offsetHeight 相加] offsetHeight 不含 margin:本组件 legend 有
|
|
324
|
-
* `margin-top: 8px`、title 有 `margin-bottom: 8px`,相加只有 21,实际占位 29 ——
|
|
325
|
-
* 少算 8px 就把画布往下推 8px,底部横轴标签仍然被裁(改了等于没改)。
|
|
326
|
-
* 直接量「宿主顶 → 画布顶」的距离,以后 CSS 怎么加间距都不会再漏。
|
|
327
|
-
*/
|
|
328
208
|
chromeHeight() {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (!e) return 0;
|
|
333
|
-
const i = this.getBoundingClientRect().top, s = e.getBoundingClientRect().top;
|
|
334
|
-
return Math.max(0, Math.round(s - i));
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* [WHY] 不能直接用 chromeHeight():render() 每次都把 shadow 整体重建(BaseElement
|
|
338
|
-
* 用 `shadow.innerHTML = styles + rendered`),legend 节点刚建出来是空的 —— 于是
|
|
339
|
-
* **每一轮 updated() 里实测到的 chrome 都是 0**,`_chromeH` 记下的真值从来没人读回来。
|
|
340
|
-
* 症状:SVG 高度恒等于宿主高度,再叠上图例 ⇒ 总高溢出宿主一个图例高,
|
|
341
|
-
* 卡片高度固定时底部横轴标签被 overflow:hidden 裁掉(卡面底部多出一条空白)。
|
|
342
|
-
* 只有 draw() 填完 legend 之后测得的值才是真值,优先用它。
|
|
343
|
-
*/
|
|
344
|
-
resolvedChromeH() {
|
|
345
|
-
return this._chromeH >= 0 ? this._chromeH : this.chromeHeight();
|
|
209
|
+
var e;
|
|
210
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".z-chart__plot");
|
|
211
|
+
return t ? Math.max(0, Math.round(t.getBoundingClientRect().top - this.getBoundingClientRect().top)) : 0;
|
|
346
212
|
}
|
|
347
|
-
/** markline 属性来自 attribute(任意字符串),只在是有限数字时生效。 */
|
|
348
213
|
marklineValue() {
|
|
349
214
|
if (!this.markline && this.markline !== "0") return;
|
|
350
215
|
const t = Number(this.markline);
|
|
351
216
|
return Number.isFinite(t) ? t : void 0;
|
|
352
217
|
}
|
|
353
218
|
drawKey(t) {
|
|
354
|
-
const e = this.seriesConfigs()
|
|
219
|
+
const e = this.seriesConfigs();
|
|
355
220
|
return JSON.stringify({
|
|
356
221
|
type: this.type,
|
|
357
222
|
stack: this.stack,
|
|
358
|
-
// 方向必须进 key:否则改 direction 后图不重画,属性面板改了半天「没反应」
|
|
359
223
|
direction: this.direction,
|
|
360
|
-
// 色阶上下限同理:不进 key 就是「改了 clamp 图不变色」
|
|
361
224
|
heatmapClamp: this.heatmapClamp,
|
|
362
|
-
// 缩放区间同理:不进 key 就是「拖了滑块柱子不动」
|
|
363
225
|
zoom: this._zoom ? this._zoom.join(",") : this.zoom,
|
|
364
226
|
zoomable: this.zoomable,
|
|
365
227
|
engine: this._engine,
|
|
@@ -373,15 +235,20 @@ const N = class N extends j {
|
|
|
373
235
|
mapNameKey: this.mapNameKey,
|
|
374
236
|
geojson: this.geojson,
|
|
375
237
|
values: this.values,
|
|
376
|
-
// 标注属性进 drawKey:改 markline/markpoint/markgap 必须重画,
|
|
377
|
-
// 不进 key 的后果是「改了属性、图不动」(与改 stack 不重画同病)
|
|
378
238
|
markline: this.marklineValue(),
|
|
379
239
|
marklineLabel: this.marklineLabel,
|
|
380
240
|
markpoint: this.markpoint,
|
|
381
241
|
markgap: this.markgap,
|
|
382
242
|
labels: this.labels,
|
|
383
|
-
series: e.map((
|
|
384
|
-
|
|
243
|
+
series: e.map((i) => ({
|
|
244
|
+
name: i.name,
|
|
245
|
+
type: i.type,
|
|
246
|
+
color: i.color,
|
|
247
|
+
yAxis: i.yAxis,
|
|
248
|
+
format: i.format,
|
|
249
|
+
data: i.data
|
|
250
|
+
})),
|
|
251
|
+
axes: this.axisConfigs()
|
|
385
252
|
});
|
|
386
253
|
}
|
|
387
254
|
seriesConfigs() {
|
|
@@ -390,467 +257,110 @@ const N = class N extends j {
|
|
|
390
257
|
axisConfigs() {
|
|
391
258
|
return Array.from(this.querySelectorAll("z-chart-axis"));
|
|
392
259
|
}
|
|
393
|
-
resolveTheme() {
|
|
394
|
-
const t = typeof getComputedStyle == "function" ? getComputedStyle(document.documentElement) : null, e = (o, r) => (t == null ? void 0 : t.getPropertyValue(o).trim()) || r, i = e("--z-color-bg", "#ffffff"), s = _t(i);
|
|
395
|
-
return {
|
|
396
|
-
text: e("--z-color-text", "#0f172a"),
|
|
397
|
-
textSecondary: e("--z-chart-label-color", e("--z-color-text-secondary", "#64748b")),
|
|
398
|
-
grid: e("--z-chart-grid-color", e("--z-color-border", "#e2e8f0")),
|
|
399
|
-
bg: i,
|
|
400
|
-
dark: s ? vt(s) < 0.35 : !1,
|
|
401
|
-
fontFamily: e("--z-chart-font-family", e("--z-font-sans", "sans-serif")),
|
|
402
|
-
labelFontSize: e("--z-chart-label-font-size", "12px"),
|
|
403
|
-
titleFontSize: e("--z-chart-title-font-size", "16px")
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
260
|
draw(t, e) {
|
|
407
|
-
var
|
|
408
|
-
this._theme =
|
|
409
|
-
const i = this.type, s = this.seriesConfigs(),
|
|
410
|
-
s.map((
|
|
411
|
-
name:
|
|
412
|
-
type:
|
|
413
|
-
data:
|
|
414
|
-
color:
|
|
415
|
-
yAxis:
|
|
416
|
-
format:
|
|
417
|
-
visible:
|
|
418
|
-
index:
|
|
419
|
-
|
|
420
|
-
...f.sizeTitle ? { sizeTitle: f.sizeTitle } : {}
|
|
261
|
+
var A, K;
|
|
262
|
+
this._theme = L();
|
|
263
|
+
const i = this.type, s = this.seriesConfigs(), m = i === "pie" || i === "donut" || i === "funnel" || i === "treemap" || i === "sankey" ? Math.max(1, ...s.map((l) => Array.isArray(l.data) ? l.data.length : 0)) : s.length, h = B(m, this.colors), p = this.marklineValue(), g = O(
|
|
264
|
+
s.map((l, y) => ({
|
|
265
|
+
name: l.name,
|
|
266
|
+
type: l.type,
|
|
267
|
+
data: l.data,
|
|
268
|
+
color: l.color || h[y % h.length],
|
|
269
|
+
yAxis: l.yAxis,
|
|
270
|
+
format: l.format,
|
|
271
|
+
visible: l.visible,
|
|
272
|
+
index: y,
|
|
273
|
+
...l.sizeTitle ? { sizeTitle: l.sizeTitle } : {}
|
|
421
274
|
})),
|
|
422
275
|
i,
|
|
423
276
|
{ markgap: this.markgap }
|
|
424
|
-
),
|
|
277
|
+
), u = P(this.axisConfigs()), b = X(g, u, this.zoomNorm());
|
|
278
|
+
this._zoomOffset = b.offset;
|
|
279
|
+
const v = b.series, x = parseFloat(this._theme.labelFontSize) || 12, z = {
|
|
425
280
|
showGrid: this.showGrid,
|
|
426
281
|
stack: this.stackMode(),
|
|
427
|
-
markline:
|
|
282
|
+
markline: p,
|
|
428
283
|
marklineLabel: this.marklineLabel || void 0,
|
|
429
284
|
markpoint: this.markpoint || void 0,
|
|
430
285
|
markgap: this.markgap,
|
|
431
286
|
labels: this.labels,
|
|
432
|
-
sliceColors:
|
|
287
|
+
sliceColors: h,
|
|
433
288
|
regions: [],
|
|
434
|
-
values: this.
|
|
289
|
+
values: G(this.values),
|
|
435
290
|
mapIdKey: this.mapIdKey,
|
|
436
291
|
mapNameKey: this.mapNameKey,
|
|
437
292
|
projection: this.projection,
|
|
438
|
-
locale:
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
y = E(e.w, e.h, 4);
|
|
459
|
-
else if (i === "radar")
|
|
460
|
-
y = E(e.w, e.h, 30);
|
|
461
|
-
else if (i === "waterfall")
|
|
462
|
-
h = it(g), y = I(e.w, e.h, h, l, b, T);
|
|
463
|
-
else if (i === "map")
|
|
464
|
-
y = E(e.w, e.h, 8), R.regions = bt(this.geojson, this.mapIdKey, this.mapNameKey);
|
|
465
|
-
else if (i === "funnel" || i === "treemap" || i === "sankey" || i === "heatmap" || i === "gauge")
|
|
466
|
-
y = E(e.w, e.h, i === "gauge" ? 12 : 10);
|
|
467
|
-
else {
|
|
468
|
-
h = st(g, l, this.stackMode(), c, {
|
|
469
|
-
horizontal: $,
|
|
470
|
-
// 散点的 label 只是 tooltip 文案,不构成分类轴 —— 不强制的话所有点会等距排在
|
|
471
|
-
// 一条线上,看着像「只有一个维度」。
|
|
472
|
-
xKind: i === "scatter" ? "value" : void 0
|
|
473
|
-
}), this.narrowValueDomain(h);
|
|
474
|
-
let f = null;
|
|
475
|
-
if (i === "scatter" && g.some((_) => _.data.some((z) => z.r !== void 0)) && (f = 22), f !== null) {
|
|
476
|
-
const _ = I(e.w, e.h, h, l, b, T, {
|
|
477
|
-
topPad: 0,
|
|
478
|
-
rightPad: S
|
|
479
|
-
}), z = f / Math.max(_.plot.height, 1) * (h.leftDomain[1] - h.leftDomain[0]), K = f / Math.max(_.plot.width, 1) * (h.xDomain[1] - h.xDomain[0]);
|
|
480
|
-
h.leftDomain = [h.leftDomain[0] - z, h.leftDomain[1] + z], h.hasRight && (h.rightDomain = [h.rightDomain[0] - z, h.rightDomain[1] + z]), h.xDomain = [h.xDomain[0] - K, h.xDomain[1] + K];
|
|
481
|
-
}
|
|
482
|
-
y = I(e.w, e.h, h, l, b, T, {
|
|
483
|
-
// 横向参考线的标签画在绘图区上方,需要额外上边距(见 FrameOptions.topPad)
|
|
484
|
-
topPad: $ && c !== void 0 ? 14 : 0,
|
|
485
|
-
rightPad: S
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
this._model = tt(i, g, y, h, this._theme, t, R), this._columns = this.computeColumns();
|
|
489
|
-
const M = this.shadowRoot, k = M.querySelector(".z-chart__svg");
|
|
490
|
-
k && (k.setAttribute("width", String(e.w)), k.setAttribute("height", String(e.h)), k.setAttribute("viewBox", `0 0 ${e.w} ${e.h}`), k.innerHTML = Y(this._model, y, this._theme));
|
|
491
|
-
const w = M.querySelector(".z-chart__canvas");
|
|
492
|
-
if (w) {
|
|
493
|
-
const f = typeof devicePixelRatio == "number" ? devicePixelRatio : 1;
|
|
494
|
-
w.width = e.w * f, w.height = e.h * f, w.style.width = `${e.w}px`, w.style.height = `${e.h}px`;
|
|
495
|
-
const _ = w.getContext("2d");
|
|
496
|
-
_ && (_.scale(f, f), Q(_, this._model, y, this._theme));
|
|
497
|
-
}
|
|
498
|
-
const C = M.querySelector(".z-chart__overlay");
|
|
499
|
-
C && (C.setAttribute("width", String(e.w)), C.setAttribute("height", String(e.h)), C.setAttribute("viewBox", `0 0 ${e.w} ${e.h}`), C.innerHTML = J(this._model));
|
|
500
|
-
const P = M.querySelector(".z-chart__legend");
|
|
501
|
-
P && (P.innerHTML = this.legendHtml(this._model)), this.renderZoom(e);
|
|
502
|
-
const B = this.chromeHeight();
|
|
503
|
-
B !== this._chromeH && (this._chromeH = B, this.requestUpdate()), this._readyEmitted || (this._readyEmitted = !0, this.emit("z-ready", { type: this.type, width: e.w, height: e.h }));
|
|
504
|
-
}
|
|
505
|
-
buildAxisSlots(t) {
|
|
506
|
-
const e = {};
|
|
507
|
-
for (const i of t) {
|
|
508
|
-
const s = i.position, o = {
|
|
509
|
-
position: s,
|
|
510
|
-
type: i.type,
|
|
511
|
-
title: i.title,
|
|
512
|
-
format: i.format,
|
|
513
|
-
min: i.minValue,
|
|
514
|
-
max: i.maxValue,
|
|
515
|
-
tickCount: i.tickCount,
|
|
516
|
-
grid: i.gridOverride,
|
|
517
|
-
...i.scale === "log" ? { scale: "log" } : {}
|
|
518
|
-
};
|
|
519
|
-
(s === "bottom" || s === "top") && !e.x ? e.x = o : s === "left" && !e.left ? e.left = o : s === "right" && !e.right && (e.right = o);
|
|
520
|
-
}
|
|
521
|
-
return e;
|
|
522
|
-
}
|
|
523
|
-
normalizeValues() {
|
|
524
|
-
const t = this.values;
|
|
525
|
-
return t ? Array.isArray(t) ? t.map((e) => ({ id: String(e.id), value: Number(e.value) })) : Object.entries(t).map(([e, i]) => ({ id: e, value: Number(i) })) : null;
|
|
526
|
-
}
|
|
527
|
-
computeColumns() {
|
|
528
|
-
var i;
|
|
529
|
-
const t = ((i = this._model) == null ? void 0 : i.tooltipTargets) ?? [], e = new Set(t.map((s) => s.dataIndex)).size;
|
|
530
|
-
return Math.max(1, e);
|
|
531
|
-
}
|
|
532
|
-
legendHtml(t) {
|
|
533
|
-
return t.legend.map(
|
|
534
|
-
(e) => `<button type="button" class="z-chart__legend-item${e.visible ? "" : " z-chart__legend-item--hidden"}" data-legend-index="${e.index}" part="legend-item">
|
|
535
|
-
<span class="z-chart__legend-swatch" style="background:${e.color}"></span>
|
|
536
|
-
<span>${x(e.name)}</span>
|
|
537
|
-
</button>`
|
|
538
|
-
).join("");
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* 画底部缩放条:缩略趋势 + 两个可聚焦手柄 + 可拖窗口。
|
|
542
|
-
*
|
|
543
|
-
* [WHY 手柄用 div 而不是 SVG rect] 手柄要能 Tab 聚焦、要用 `role="slider"` 播报当前
|
|
544
|
-
* 百分比。SVG 图形做这两件事要靠 foreignObject 兜,shadow 内兼容性差。缩略趋势本身
|
|
545
|
-
* 是纯装饰(aria-hidden),才用 SVG。
|
|
546
|
-
*
|
|
547
|
-
* [WHY 必须有缩略趋势] 只有两个手柄的话,用户看不出「现在看的是整段里的哪一截」——
|
|
548
|
-
* 手柄位置是相对全长的,而全长的形状不在视野里。缩略线是这两个手柄的唯一参照物。
|
|
549
|
-
*/
|
|
550
|
-
renderZoom(t) {
|
|
551
|
-
var y;
|
|
552
|
-
const e = (y = this.shadowRoot) == null ? void 0 : y.querySelector(".z-chart__zoom");
|
|
553
|
-
if (!e) return;
|
|
554
|
-
const i = this.seriesConfigs()[0], s = Array.isArray(i == null ? void 0 : i.data) ? i.data : [], o = s.length, r = this.zoomNorm() ?? [0, 1], n = Math.max(Math.round(e.clientWidth || t.w), 40), a = 22, c = Math.round(r[0] * n), u = Math.round(r[1] * n), l = s.map((h) => Number(h == null ? void 0 : h.value)), g = l.filter((h) => Number.isFinite(h)), b = g.length ? Math.min(...g) : 0, R = (g.length ? Math.max(...g) : 1) - b || 1;
|
|
555
|
-
let $ = "";
|
|
556
|
-
l.forEach((h, M) => {
|
|
557
|
-
const k = o === 1 ? n / 2 : M / (o - 1) * n, w = a - 3 - ((Number.isFinite(h) ? h : b) - b) / R * (a - 6);
|
|
558
|
-
$ += `${M === 0 ? "M" : "L"} ${k.toFixed(1)} ${w.toFixed(1)}`;
|
|
559
|
-
});
|
|
560
|
-
const S = (h) => Math.round(h * 100);
|
|
561
|
-
if (e.innerHTML = `
|
|
562
|
-
<svg class="z-chart__zoom-svg" width="${n}" height="${a}" aria-hidden="true">
|
|
563
|
-
<path d="${$}" fill="none" stroke-width="1.5" class="z-chart__zoom-track"/>
|
|
564
|
-
<rect class="z-chart__zoom-mask" x="0" y="0" width="${c}" height="${a}"/>
|
|
565
|
-
<rect class="z-chart__zoom-mask" x="${u}" y="0" width="${Math.max(n - u, 0)}" height="${a}"/>
|
|
566
|
-
</svg>
|
|
567
|
-
<div class="z-chart__zoom-window" data-handle="window" role="slider" tabindex="0"
|
|
568
|
-
aria-label="${x(D.chartZoomWindow)}"
|
|
569
|
-
aria-valuemin="0" aria-valuemax="100" aria-valuenow="${S(r[0])}"
|
|
570
|
-
style="left:${c}px;width:${Math.max(u - c, 8)}px"></div>
|
|
571
|
-
<div class="z-chart__zoom-handle" data-handle="start" role="slider" tabindex="0"
|
|
572
|
-
aria-label="${x(D.chartZoomStart)}"
|
|
573
|
-
aria-valuemin="0" aria-valuemax="100" aria-valuenow="${S(r[0])}"
|
|
574
|
-
style="left:${c - 4}px"></div>
|
|
575
|
-
<div class="z-chart__zoom-handle" data-handle="end" role="slider" tabindex="0"
|
|
576
|
-
aria-label="${x(D.chartZoomEnd)}"
|
|
577
|
-
aria-valuemin="0" aria-valuemax="100" aria-valuenow="${S(r[1])}"
|
|
578
|
-
style="left:${u - 4}px"></div>
|
|
579
|
-
`, this._zoomFocus) {
|
|
580
|
-
const h = e.querySelector(`[data-handle="${this._zoomFocus}"]`);
|
|
581
|
-
h == null || h.focus(), this._zoomFocus = null;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
tooltipHtml(t) {
|
|
585
|
-
const e = t.values.map(
|
|
586
|
-
(i) => `<div class="z-chart__tooltip-row">
|
|
587
|
-
<span class="z-chart__tooltip-swatch" style="background:${i.color}"></span>
|
|
588
|
-
<span class="z-chart__tooltip-label">${x(i.name)}</span>
|
|
589
|
-
<span class="z-chart__tooltip-value">${x(i.formatted)}</span>
|
|
590
|
-
</div>`
|
|
591
|
-
).join("");
|
|
592
|
-
return `<div class="z-chart__tooltip-title">${x(t.label)}</div>${e}`;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* 建手势会话:起手 / 阈值 / cancel / Esc / user-select / 吞 click 归 `primitives/pointer-drag`;
|
|
596
|
-
* 捕获显式打开(原语默认不捕获),保证拖到图表外松手也收得到 up。
|
|
597
|
-
*/
|
|
598
|
-
_beginSession(t, e) {
|
|
599
|
-
var i;
|
|
600
|
-
(i = this._session) == null || i.dispose(), this._session = new W(
|
|
601
|
-
{
|
|
602
|
-
onMove: (s) => this._onDragMove(s),
|
|
603
|
-
onEnd: () => this.onPointerUp(),
|
|
604
|
-
// 触屏按住后一滚页面:复位,不提交框选
|
|
605
|
-
onCancel: () => {
|
|
606
|
-
this._drag = null, this._brush = null, this.clearBrush();
|
|
607
|
-
}
|
|
608
|
-
},
|
|
609
|
-
e === void 0 ? { captureTarget: t.target } : { captureTarget: t.target, threshold: e }
|
|
610
|
-
), this._session.begin(t), t.preventDefault();
|
|
611
|
-
}
|
|
612
|
-
_onDragMove(t) {
|
|
613
|
-
if (this._drag) {
|
|
614
|
-
this.dragTo(t.x);
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
const e = this._brush;
|
|
618
|
-
if (e) {
|
|
619
|
-
if (!e.active) {
|
|
620
|
-
if (!t.moved) return;
|
|
621
|
-
e.active = !0, this.hideTooltip();
|
|
622
|
-
}
|
|
623
|
-
this.brushTo(t.x, t.y);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* 把指针位置换算成选区并重画那圈框。
|
|
628
|
-
*
|
|
629
|
-
* 框只在**超过阈值**后才出现 —— 见 BRUSH_THRESHOLD 的注释。选区元素的样式直接改,
|
|
630
|
-
* 不走 `requestUpdate`:那是整图重绘(几何 + 动画),每帧一次会明显卡。
|
|
631
|
-
*/
|
|
632
|
-
/**
|
|
633
|
-
* 把指针位置换算成选区并重画那圈框(只在已越过阈值后调用)。
|
|
634
|
-
*
|
|
635
|
-
* 选区元素的样式直接改,不走 `requestUpdate`:那是整图重绘(几何 + 动画),
|
|
636
|
-
* 每帧一次会明显卡。
|
|
637
|
-
*/
|
|
638
|
-
brushTo(t, e) {
|
|
639
|
-
var a;
|
|
640
|
-
const i = this._brush, s = (a = this.shadowRoot) == null ? void 0 : a.querySelector(".z-chart__plot");
|
|
641
|
-
if (!i || !s) return;
|
|
642
|
-
const o = s.getBoundingClientRect(), r = Math.min(Math.max(t - o.left, 0), o.width), n = Math.min(Math.max(e - o.top, 0), o.height);
|
|
643
|
-
i.x1 = r, i.y1 = n, this.paintBrush();
|
|
644
|
-
}
|
|
645
|
-
paintBrush() {
|
|
646
|
-
var i;
|
|
647
|
-
const t = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".z-chart__brush"), e = this._brush;
|
|
648
|
-
if (t) {
|
|
649
|
-
if (!(e != null && e.active)) {
|
|
650
|
-
t.hidden = !0;
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
t.hidden = !1, t.style.left = `${Math.min(e.x0, e.x1)}px`, t.style.top = `${Math.min(e.y0, e.y1)}px`, t.style.width = `${Math.abs(e.x1 - e.x0)}px`, t.style.height = `${Math.abs(e.y1 - e.y0)}px`;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* 框选结束:算出选区内的数据点并上报。
|
|
658
|
-
*
|
|
659
|
-
* 命中判据用**中心点**落在框内,不是矩形相交 —— 用相交时擦到边也算选中,
|
|
660
|
-
* 框一条窄带会把整排柱都收进来,而读者明明是照着中间那几个点框的。
|
|
661
|
-
*/
|
|
662
|
-
commitBrush(t) {
|
|
663
|
-
var c;
|
|
664
|
-
const e = Math.min(t.x0, t.x1), i = Math.min(t.y0, t.y1), s = Math.abs(t.x1 - t.x0), o = Math.abs(t.y1 - t.y0), a = (((c = this._model) == null ? void 0 : c.tooltipTargets) ?? []).filter((u) => {
|
|
665
|
-
const l = u.x + u.w / 2, g = u.y + u.h / 2;
|
|
666
|
-
return l >= e && l <= e + s && g >= i && g <= i + o;
|
|
667
|
-
}).map((u) => ({
|
|
668
|
-
seriesIndex: u.seriesIndex,
|
|
669
|
-
dataIndex: u.dataIndex + this._zoomOffset,
|
|
670
|
-
label: u.label
|
|
671
|
-
}));
|
|
672
|
-
this.emitBrush(a, { x: e, y: i, w: s, h: o });
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* 上报 `z-brush` 并播报结果。指针路径与键盘路径共用。
|
|
676
|
-
*
|
|
677
|
-
* [WHY 抽出来] 两条路径的**选区来源不同**(一个来自拖拽矩形,一个来自下标区间),
|
|
678
|
-
* 但上报的载荷结构、`_zoomOffset` 还原、读屏播报三件事必须逐字一致。各写一遍
|
|
679
|
-
* 必然漂移 —— 而漂移的表现是「键盘选的点和鼠标选的点差了一段」,只有真用键盘才发现。
|
|
680
|
-
*/
|
|
681
|
-
emitBrush(t, e) {
|
|
682
|
-
var o;
|
|
683
|
-
const i = t.map((r) => r.dataIndex);
|
|
684
|
-
this.emit("z-brush", {
|
|
685
|
-
...e,
|
|
686
|
-
points: t,
|
|
687
|
-
/** 分类下标的区间(含端点);无命中时为 null —— 别给 `[0,0]` 让人误以为选了第一个。 */
|
|
688
|
-
indexRange: i.length ? [Math.min(...i), Math.max(...i)] : null
|
|
293
|
+
locale: this.locale,
|
|
294
|
+
gaugeMin: (A = u.left) == null ? void 0 : A.min,
|
|
295
|
+
gaugeMax: (K = u.left) == null ? void 0 : K.max,
|
|
296
|
+
...U(this.heatmapClamp)
|
|
297
|
+
}, { frame: k, domains: T } = Z({
|
|
298
|
+
type: i,
|
|
299
|
+
seriesModels: v,
|
|
300
|
+
axisSlots: u,
|
|
301
|
+
size: e,
|
|
302
|
+
locale: this.locale,
|
|
303
|
+
fontSize: x,
|
|
304
|
+
stack: this.stackMode(),
|
|
305
|
+
horizontal: this.direction === "horizontal" && i === "bar",
|
|
306
|
+
labels: this.labels,
|
|
307
|
+
markline: p,
|
|
308
|
+
geojson: this.geojson,
|
|
309
|
+
mapIdKey: this.mapIdKey,
|
|
310
|
+
mapNameKey: this.mapNameKey,
|
|
311
|
+
zoomNorm: this.zoomNorm(),
|
|
312
|
+
ctx: z
|
|
689
313
|
});
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
t && (t.hidden = !0);
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* `Shift + 方向键`:以当前聚焦点为锚点扩展键盘选区。返回 true 表示这个按键已被消费。
|
|
701
|
-
*
|
|
702
|
-
* 不自动提交(见 `_kbdSel` 的注释):键盘没有「松开鼠标」那一刻,每按一次方向键
|
|
703
|
-
* 就发一次 `z-brush` 会让宿主收到一串半成品选区。
|
|
704
|
-
*/
|
|
705
|
-
kbdBrushKey(t) {
|
|
706
|
-
var o;
|
|
707
|
-
const i = {
|
|
708
|
-
ArrowLeft: "left",
|
|
709
|
-
ArrowRight: "right",
|
|
710
|
-
ArrowUp: "up",
|
|
711
|
-
ArrowDown: "down"
|
|
712
|
-
}[t.key];
|
|
713
|
-
if (!i) return !1;
|
|
714
|
-
const s = ((o = this._model) == null ? void 0 : o.tooltipTargets.length) ?? 0;
|
|
715
|
-
if (s <= 0) return !1;
|
|
716
|
-
if (t.preventDefault(), !this._kbdSel) {
|
|
717
|
-
const r = this._activeTarget >= 0 && this._activeTarget < s ? this._activeTarget : 0;
|
|
718
|
-
this._kbdSel = { anchor: r, end: r };
|
|
719
|
-
}
|
|
720
|
-
return this._kbdSel.end = U(this._kbdSel.end, i, s, this._columns), this.paintKbdSel(), !0;
|
|
721
|
-
}
|
|
722
|
-
/** 键盘选区当前覆盖的数据点(含端点)。 */
|
|
723
|
-
kbdSelHits() {
|
|
724
|
-
var o;
|
|
725
|
-
const t = this._kbdSel, e = ((o = this._model) == null ? void 0 : o.tooltipTargets) ?? [];
|
|
726
|
-
if (!t || !e.length) return [];
|
|
727
|
-
const i = Math.max(0, Math.min(t.anchor, t.end)), s = Math.min(e.length - 1, Math.max(t.anchor, t.end));
|
|
728
|
-
return e.slice(i, s + 1);
|
|
729
|
-
}
|
|
730
|
-
/** 画出键盘选区的包围盒、挪动焦点环、播报。 */
|
|
731
|
-
paintKbdSel() {
|
|
732
|
-
var c, u;
|
|
733
|
-
const t = this.kbdSelHits(), e = this._kbdSel;
|
|
734
|
-
if (!t.length || !e) return;
|
|
735
|
-
const i = Math.min(...t.map((l) => l.x)), s = Math.min(...t.map((l) => l.y)), o = Math.max(...t.map((l) => l.x + l.w)), r = Math.max(...t.map((l) => l.y + l.h));
|
|
736
|
-
this.paintBrushRect({ x0: i, y0: s, x1: o, y1: r }), this.moveTarget(e.end);
|
|
737
|
-
const n = ((c = t[t.length - 1]) == null ? void 0 : c.label) ?? "", a = (u = this.shadowRoot) == null ? void 0 : u.querySelector('[role="status"]');
|
|
738
|
-
a && (a.textContent = L("chartKeyboardBrush", { count: t.length, label: n }));
|
|
739
|
-
}
|
|
740
|
-
/** `Enter`:提交键盘选区,载荷与鼠标框选逐字一致(见 emitBrush 的注释)。 */
|
|
741
|
-
commitKbdSel() {
|
|
742
|
-
const t = this.kbdSelHits();
|
|
743
|
-
if (this._kbdSel = null, !t.length) {
|
|
744
|
-
this.clearBrush();
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
const e = Math.min(...t.map((r) => r.x)), i = Math.min(...t.map((r) => r.y)), s = Math.max(...t.map((r) => r.x + r.w)) - e, o = Math.max(...t.map((r) => r.y + r.h)) - i;
|
|
748
|
-
this.emitBrush(
|
|
749
|
-
t.map((r) => ({
|
|
750
|
-
seriesIndex: r.seriesIndex,
|
|
751
|
-
dataIndex: r.dataIndex + this._zoomOffset,
|
|
752
|
-
label: r.label
|
|
753
|
-
})),
|
|
754
|
-
{ x: e, y: i, w: s, h: o }
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
/** 把已提交的选区画出来(`paintBrush` 读的是 `_brush`,提交后它已被置空)。 */
|
|
758
|
-
paintBrushRect(t) {
|
|
759
|
-
var i;
|
|
760
|
-
this._brush = null;
|
|
761
|
-
const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".z-chart__brush");
|
|
762
|
-
e && (e.hidden = !1, e.style.left = `${Math.min(t.x0, t.x1)}px`, e.style.top = `${Math.min(t.y0, t.y1)}px`, e.style.width = `${Math.abs(t.x1 - t.x0)}px`, e.style.height = `${Math.abs(t.y1 - t.y0)}px`);
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* 把指针位移换算成新的可视区间。
|
|
766
|
-
*
|
|
767
|
-
* 拖起点只动左边界、拖终点只动右边界、拖窗口整体平移(跨度不变)。
|
|
768
|
-
* 左右边界之间保留 MIN_ZOOM_SPAN,否则两个手柄重合后区间变成 0 宽,
|
|
769
|
-
* 图里一个分类都不剩 —— 用户会以为是渲染挂了。
|
|
770
|
-
*/
|
|
771
|
-
dragTo(t) {
|
|
772
|
-
var u;
|
|
773
|
-
const e = this._drag;
|
|
774
|
-
if (!e) return;
|
|
775
|
-
const i = (u = this.shadowRoot) == null ? void 0 : u.querySelector(".z-chart__zoom"), s = (i == null ? void 0 : i.clientWidth) ?? 0;
|
|
776
|
-
if (s <= 0) return;
|
|
777
|
-
const o = (t - e.startX) / s, [r, n] = e.start;
|
|
778
|
-
let a = r, c = n;
|
|
779
|
-
if (e.handle === "start")
|
|
780
|
-
a = Math.min(Math.max(r + o, 0), n - H);
|
|
781
|
-
else if (e.handle === "end")
|
|
782
|
-
c = Math.max(Math.min(n + o, 1), r + H);
|
|
783
|
-
else {
|
|
784
|
-
const l = n - r;
|
|
785
|
-
a = Math.min(Math.max(r + o, 0), 1 - l), c = a + l;
|
|
314
|
+
this._model = M(i, v, k, T, this._theme, t, z), this._columns = Math.max(1, new Set(this._model.tooltipTargets.map((l) => l.dataIndex)).size);
|
|
315
|
+
const w = this.shadowRoot;
|
|
316
|
+
V(w, this._model, k, this._theme, e);
|
|
317
|
+
const S = w.querySelector(".z-chart__zoom");
|
|
318
|
+
if (S) {
|
|
319
|
+
const l = s[0], y = Array.isArray(l == null ? void 0 : l.data) ? l.data : [];
|
|
320
|
+
tt(S, y, this.zoomNorm() ?? [0, 1], e.w, this._zoomFocus), this._zoomFocus = null;
|
|
786
321
|
}
|
|
787
|
-
|
|
322
|
+
const C = this.chromeHeight();
|
|
323
|
+
C !== this._chromeH && (this._chromeH = C, this.requestUpdate()), this._readyEmitted || (this._readyEmitted = !0, this.emit("z-ready", { type: this.type, width: e.w, height: e.h }));
|
|
788
324
|
}
|
|
789
|
-
/**
|
|
790
|
-
* 缩放条的键盘操作。返回 true = 这个键已处理,调用方不要再当数据点导航用。
|
|
791
|
-
*
|
|
792
|
-
* 步长:方向键 1%,Shift + 方向键 10%。三个部件的语义与鼠标拖拽一致
|
|
793
|
-
* (起点只动左边界、终点只动右边界、窗口整体平移)。
|
|
794
|
-
*/
|
|
795
325
|
zoomKey(t) {
|
|
796
|
-
var
|
|
797
|
-
const e = ((
|
|
326
|
+
var n;
|
|
327
|
+
const e = ((n = c(t, "[data-handle]")) == null ? void 0 : n.getAttribute("data-handle")) ?? "", i = t.key === "ArrowLeft" ? -1 : t.key === "ArrowRight" ? 1 : 0;
|
|
798
328
|
if (!i) return !1;
|
|
799
|
-
const s = (t.shiftKey ? 0.1 : 0.01) * i
|
|
800
|
-
|
|
801
|
-
if (e === "start")
|
|
802
|
-
a = n(o + s, 0, r - H);
|
|
803
|
-
else if (e === "end")
|
|
804
|
-
c = n(r + s, o + H, 1);
|
|
805
|
-
else {
|
|
806
|
-
const l = r - o;
|
|
807
|
-
a = n(o + s, 0, 1 - l), c = a + l;
|
|
808
|
-
}
|
|
809
|
-
return t.preventDefault(), this._zoom = [a, c], this._suppressAnim = !0, this._zoomFocus = e || "window", this.requestUpdate(), !0;
|
|
329
|
+
const s = (t.shiftKey ? 0.1 : 0.01) * i;
|
|
330
|
+
return t.preventDefault(), this._zoom = et(e, this.zoomNorm() ?? [0, 1], s), this._suppressAnim = !0, this._zoomFocus = e || "window", this.requestUpdate(), !0;
|
|
810
331
|
}
|
|
811
|
-
/** 把「当前数据点」挪到 idx:焦点环 + tooltip + 读屏播报,三件事一起做。 */
|
|
812
332
|
moveTarget(t) {
|
|
813
|
-
var s,
|
|
333
|
+
var s, n;
|
|
814
334
|
const e = ((s = this._model) == null ? void 0 : s.tooltipTargets.length) ?? 0;
|
|
815
335
|
if (t < 0 || t >= e) return;
|
|
816
336
|
this._activeTarget = t;
|
|
817
|
-
const i = (
|
|
337
|
+
const i = (n = this.shadowRoot) == null ? void 0 : n.querySelector(`[data-m="${t}"]`);
|
|
818
338
|
this.showTarget(t, i ?? this);
|
|
819
339
|
}
|
|
820
340
|
showTarget(t, e) {
|
|
821
341
|
var s;
|
|
822
342
|
const i = (s = this._model) == null ? void 0 : s.tooltipTargets[t];
|
|
823
|
-
i && (this._activeTarget = t, this.tooltip && (this._tooltip || (this._tooltip = new
|
|
343
|
+
i && (this._activeTarget = t, this.tooltip && (this._tooltip || (this._tooltip = new q()), this._tooltip.show(e, W(i))), this.setFocusRing(i), this.announce(i), this.emit("z-tooltip-change", {
|
|
824
344
|
visible: !0,
|
|
825
345
|
seriesIndex: i.seriesIndex,
|
|
826
|
-
// 同 z-marker-click:还原成全量下标(见 applyZoom 的注释)
|
|
827
346
|
dataIndex: i.dataIndex + this._zoomOffset,
|
|
828
347
|
label: i.label,
|
|
829
348
|
values: i.values
|
|
830
349
|
}));
|
|
831
350
|
}
|
|
832
|
-
/**
|
|
833
|
-
* 把当前数据点念出来。
|
|
834
|
-
*
|
|
835
|
-
* [WHY 光有焦点环不够] 方向键的成功判据原先只有 `.z-chart__focus-ring` 的显隐 ——
|
|
836
|
-
* 那是**纯视觉**的。2026-11-16 实测:按方向键后 shadow 里
|
|
837
|
-
* `[aria-live]`/`[role=status]` 数量为 0,读屏用户按十下屏幕对他一动不动。
|
|
838
|
-
* tooltip 本身也不进无障碍树(`TooltipManager` 用的是 fixed 定位的浮层),
|
|
839
|
-
* 所以播报必须自己发。
|
|
840
|
-
*/
|
|
841
351
|
announce(t) {
|
|
842
352
|
var s;
|
|
843
353
|
const e = (s = this.shadowRoot) == null ? void 0 : s.querySelector(`#${this._uid}-live`);
|
|
844
354
|
if (!e) return;
|
|
845
|
-
const i = t.values.map((
|
|
355
|
+
const i = t.values.map((n) => `${n.name} ${n.formatted}`).join(",");
|
|
846
356
|
e.textContent = i ? `${t.label}:${i}` : t.label;
|
|
847
357
|
}
|
|
848
358
|
hideTooltip() {
|
|
849
|
-
var i, s,
|
|
359
|
+
var i, s, n;
|
|
850
360
|
this._activeTarget = -1, (i = this._tooltip) == null || i.hide();
|
|
851
361
|
const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".z-chart__focus-ring");
|
|
852
362
|
t && (t.hidden = !0);
|
|
853
|
-
const e = (
|
|
363
|
+
const e = (n = this.shadowRoot) == null ? void 0 : n.querySelector(`#${this._uid}-live`);
|
|
854
364
|
e && (e.textContent = ""), this.emit("z-tooltip-change", { visible: !1 });
|
|
855
365
|
}
|
|
856
366
|
setFocusRing(t) {
|
|
@@ -859,91 +369,91 @@ const N = class N extends j {
|
|
|
859
369
|
e && (e.hidden = !1, e.style.left = `${t.x}px`, e.style.top = `${t.y}px`, e.style.width = `${t.w}px`, e.style.height = `${t.h}px`);
|
|
860
370
|
}
|
|
861
371
|
};
|
|
862
|
-
|
|
863
|
-
let
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
],
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
],
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
],
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
],
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
],
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
],
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
],
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
],
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
],
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
],
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
],
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
],
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
],
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
],
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
],
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
],
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
],
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
],
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
],
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
],
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
],
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
],
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
],
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
],
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
],
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
],
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
],
|
|
945
|
-
|
|
372
|
+
f.styles = R;
|
|
373
|
+
let o = f;
|
|
374
|
+
a([
|
|
375
|
+
r({ type: String })
|
|
376
|
+
], o.prototype, "type");
|
|
377
|
+
a([
|
|
378
|
+
r({ type: String })
|
|
379
|
+
], o.prototype, "direction");
|
|
380
|
+
a([
|
|
381
|
+
r({ type: String, attribute: "heatmap-clamp" })
|
|
382
|
+
], o.prototype, "heatmapClamp");
|
|
383
|
+
a([
|
|
384
|
+
r({ type: Boolean })
|
|
385
|
+
], o.prototype, "zoomable");
|
|
386
|
+
a([
|
|
387
|
+
r({ type: String })
|
|
388
|
+
], o.prototype, "zoom");
|
|
389
|
+
a([
|
|
390
|
+
r({ type: Boolean })
|
|
391
|
+
], o.prototype, "brushable");
|
|
392
|
+
a([
|
|
393
|
+
r({ type: String })
|
|
394
|
+
], o.prototype, "stack");
|
|
395
|
+
a([
|
|
396
|
+
r({ type: String })
|
|
397
|
+
], o.prototype, "renderer");
|
|
398
|
+
a([
|
|
399
|
+
r({ type: String })
|
|
400
|
+
], o.prototype, "width");
|
|
401
|
+
a([
|
|
402
|
+
r({ type: String })
|
|
403
|
+
], o.prototype, "height");
|
|
404
|
+
a([
|
|
405
|
+
r({ type: String })
|
|
406
|
+
], o.prototype, "title");
|
|
407
|
+
a([
|
|
408
|
+
r({ type: Boolean })
|
|
409
|
+
], o.prototype, "legend");
|
|
410
|
+
a([
|
|
411
|
+
r({ type: Boolean })
|
|
412
|
+
], o.prototype, "tooltip");
|
|
413
|
+
a([
|
|
414
|
+
r({ type: Boolean })
|
|
415
|
+
], o.prototype, "animation");
|
|
416
|
+
a([
|
|
417
|
+
r({ type: Boolean, attribute: "show-grid" })
|
|
418
|
+
], o.prototype, "showGrid");
|
|
419
|
+
a([
|
|
420
|
+
r({ type: String })
|
|
421
|
+
], o.prototype, "locale");
|
|
422
|
+
a([
|
|
423
|
+
r({ type: String })
|
|
424
|
+
], o.prototype, "projection");
|
|
425
|
+
a([
|
|
426
|
+
r({ type: String, attribute: "map-id-key" })
|
|
427
|
+
], o.prototype, "mapIdKey");
|
|
428
|
+
a([
|
|
429
|
+
r({ type: String, attribute: "map-name-key" })
|
|
430
|
+
], o.prototype, "mapNameKey");
|
|
431
|
+
a([
|
|
432
|
+
r({ type: String })
|
|
433
|
+
], o.prototype, "markline");
|
|
434
|
+
a([
|
|
435
|
+
r({ type: String, attribute: "markline-label" })
|
|
436
|
+
], o.prototype, "marklineLabel");
|
|
437
|
+
a([
|
|
438
|
+
r({ type: String })
|
|
439
|
+
], o.prototype, "markpoint");
|
|
440
|
+
a([
|
|
441
|
+
r({ type: Boolean })
|
|
442
|
+
], o.prototype, "markgap");
|
|
443
|
+
a([
|
|
444
|
+
r({ type: Boolean })
|
|
445
|
+
], o.prototype, "labels");
|
|
446
|
+
a([
|
|
447
|
+
r({ type: Array, attribute: !1 })
|
|
448
|
+
], o.prototype, "colors");
|
|
449
|
+
a([
|
|
450
|
+
r({ type: Object, attribute: !1 })
|
|
451
|
+
], o.prototype, "geojson");
|
|
452
|
+
a([
|
|
453
|
+
r({ type: Array, attribute: !1 })
|
|
454
|
+
], o.prototype, "values");
|
|
455
|
+
N("z-chart", o);
|
|
946
456
|
export {
|
|
947
|
-
|
|
457
|
+
o as ZChart
|
|
948
458
|
};
|
|
949
459
|
//# sourceMappingURL=Chart.js.map
|