pivotkit-react 0.0.0-stage → 0.2.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/CHANGELOG.md +442 -0
- package/LICENSE +21 -0
- package/README.md +77 -2
- package/dist/chunks/chunk-53ZMK4BH.js +177 -0
- package/dist/chunks/chunk-F6MVUAQD.js +741 -0
- package/dist/chunks/chunk-LQCWFJBS.js +310 -0
- package/dist/chunks/chunk-OYY4BKIL.js +93 -0
- package/dist/chunks/chunk-QBD4FOBB.js +254 -0
- package/dist/chunks/chunk-X7H7BAVT.js +1752 -0
- package/dist/chunks/unused-texts-YTNJCFFC.js +10 -0
- package/dist/chunks/unused-texts-de-SGOHV4N7.js +6 -0
- package/dist/echarts.js +347 -0
- package/dist/index.js +3482 -0
- package/dist/labels.js +21 -0
- package/dist/menu-texts-de.js +6 -0
- package/dist/menus.js +1681 -0
- package/dist/styles.css +2529 -0
- package/package.json +70 -4
- package/types/PivotReport.d.ts +20 -0
- package/types/all-labels.d.ts +5 -0
- package/types/chart-decorate.d.ts +16 -0
- package/types/chart-layout.d.ts +111 -0
- package/types/chart-options.d.ts +23 -0
- package/types/chart-summary.d.ts +12 -0
- package/types/chart-tooltip.d.ts +38 -0
- package/types/chart-types.d.ts +61 -0
- package/types/chart.d.ts +39 -0
- package/types/chip-menus.d.ts +32 -0
- package/types/clear-input.d.ts +20 -0
- package/types/dnd-moves.d.ts +45 -0
- package/types/dnd.d.ts +101 -0
- package/types/dom.d.ts +52 -0
- package/types/drill-export.d.ts +42 -0
- package/types/drill-panel.d.ts +22 -0
- package/types/drill-table.d.ts +71 -0
- package/types/drill.d.ts +26 -0
- package/types/echarts.d.ts +4 -0
- package/types/export-run.d.ts +59 -0
- package/types/field-info.d.ts +34 -0
- package/types/fields.d.ts +32 -0
- package/types/files.d.ts +27 -0
- package/types/filter.d.ts +21 -0
- package/types/help.d.ts +21 -0
- package/types/icons.d.ts +80 -0
- package/types/index.d.ts +536 -0
- package/types/info.d.ts +34 -0
- package/types/iso.d.ts +2 -0
- package/types/labels.d.ts +663 -0
- package/types/lazy-menus.d.ts +28 -0
- package/types/menu-labels-de.d.ts +2 -0
- package/types/menu-labels.d.ts +317 -0
- package/types/menu-ops.d.ts +145 -0
- package/types/menu-texts.d.ts +2 -0
- package/types/menus.d.ts +7 -0
- package/types/names.d.ts +80 -0
- package/types/numbers.d.ts +13 -0
- package/types/overflow.d.ts +62 -0
- package/types/place.d.ts +43 -0
- package/types/popover.d.ts +93 -0
- package/types/rove.d.ts +20 -0
- package/types/section.d.ts +25 -0
- package/types/sections.d.ts +2 -0
- package/types/share-actions.d.ts +99 -0
- package/types/share.d.ts +114 -0
- package/types/skeleton.d.ts +9 -0
- package/types/storage.d.ts +24 -0
- package/types/table.d.ts +29 -0
- package/types/templates.d.ts +46 -0
- package/types/theme.d.ts +24 -0
- package/types/tip-list.d.ts +20 -0
- package/types/tips.d.ts +300 -0
- package/types/toasts.d.ts +26 -0
- package/types/toolbar-panels.d.ts +93 -0
- package/types/toolbar.d.ts +5 -0
- package/types/unused-load.d.ts +23 -0
- package/types/unused-texts-de.d.ts +2 -0
- package/types/unused-texts.d.ts +130 -0
- package/types/unused.d.ts +22 -0
- package/types/use-big-result.d.ts +29 -0
- package/types/use-export.d.ts +7 -0
- package/types/use-theme.d.ts +11 -0
- package/types/use-view-history.d.ts +37 -0
- package/types/version.d.ts +2 -0
- package/types/view-history.d.ts +106 -0
- package/types/view-ops.d.ts +293 -0
- package/types/view-save.d.ts +76 -0
- package/types/view-store.d.ts +59 -0
- package/types/virtual.d.ts +44 -0
- package/types/zones.d.ts +42 -0
package/dist/echarts.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// src/echarts.js
|
|
2
|
+
import { init, use as register } from "echarts/core";
|
|
3
|
+
import { BarChart, HeatmapChart, LineChart, PieChart } from "echarts/charts";
|
|
4
|
+
import { GridComponent, LegendComponent, TitleComponent, TooltipComponent, VisualMapComponent } from "echarts/components";
|
|
5
|
+
import { CanvasRenderer } from "echarts/renderers";
|
|
6
|
+
|
|
7
|
+
// src/chart-options.js
|
|
8
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["rich", "link", "sublink", "target", "subtarget", "linkTarget", "image", "extraCssText", "className", "appendTo", "appendToBody", "renderMode"]);
|
|
9
|
+
var TEMPLATE_KEYS = /* @__PURE__ */ new Set(["formatter", "content"]);
|
|
10
|
+
var CHART_OPTIONS_CAPS = Object.freeze({ depth: 12, entries: 2e3 });
|
|
11
|
+
var FORBIDDEN = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
12
|
+
var isPlain = (v) => v !== null && typeof v === "object" && !Array.isArray(v) && (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);
|
|
13
|
+
function cleanChartOptions(value) {
|
|
14
|
+
if (value === void 0 || value === null) {
|
|
15
|
+
return { options: null, problems: [] };
|
|
16
|
+
}
|
|
17
|
+
if (!isPlain(value)) {
|
|
18
|
+
return { options: null, problems: ["chartOptions: not a plain object"] };
|
|
19
|
+
}
|
|
20
|
+
const problems = [];
|
|
21
|
+
let entries = 0;
|
|
22
|
+
const clean = (v, path, depth) => {
|
|
23
|
+
if (typeof v === "string" && /^\s*image:\/\//i.test(v)) {
|
|
24
|
+
problems.push(`${path}: an image address, not allowed`);
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
if (v === null || typeof v === "string" || typeof v === "boolean") {
|
|
28
|
+
return v;
|
|
29
|
+
}
|
|
30
|
+
if (typeof v === "number") {
|
|
31
|
+
if (Number.isFinite(v)) {
|
|
32
|
+
return v;
|
|
33
|
+
}
|
|
34
|
+
problems.push(`${path}: not a finite number`);
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(v) || isPlain(v)) {
|
|
38
|
+
if (depth >= CHART_OPTIONS_CAPS.depth) {
|
|
39
|
+
problems.push(`${path}: nested deeper than ${CHART_OPTIONS_CAPS.depth} levels`);
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(v)) {
|
|
43
|
+
const out2 = [];
|
|
44
|
+
for (let i = 0; i < v.length; i++) {
|
|
45
|
+
if (++entries > CHART_OPTIONS_CAPS.entries) {
|
|
46
|
+
problems.push(`${path}: more than ${CHART_OPTIONS_CAPS.entries} entries in all`);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
const c = clean(v[i], `${path}[${i}]`, depth + 1);
|
|
50
|
+
out2.push(c === void 0 ? null : c);
|
|
51
|
+
}
|
|
52
|
+
return out2;
|
|
53
|
+
}
|
|
54
|
+
const out = {};
|
|
55
|
+
for (const key of Object.keys(v)) {
|
|
56
|
+
if (FORBIDDEN.has(key)) {
|
|
57
|
+
problems.push(`${path}.${key}: not allowed`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (UNSAFE_KEYS.has(key)) {
|
|
61
|
+
problems.push(`${path}.${key}: markup, an address or the tooltip's element, not allowed`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (TEMPLATE_KEYS.has(key) && typeof v[key] === "string") {
|
|
65
|
+
problems.push(`${path}.${key}: a text template (written as markup), not allowed`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (++entries > CHART_OPTIONS_CAPS.entries) {
|
|
69
|
+
problems.push(`${path}: more than ${CHART_OPTIONS_CAPS.entries} entries in all`);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
const c = clean(v[key], `${path}.${key}`, depth + 1);
|
|
73
|
+
if (c !== void 0) {
|
|
74
|
+
out[key] = c;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
problems.push(`${path}: ${typeof v === "function" ? "a function" : typeof v === "object" ? "not plain JSON" : `a ${typeof v}`}, not allowed`);
|
|
80
|
+
return void 0;
|
|
81
|
+
};
|
|
82
|
+
return { options: (
|
|
83
|
+
/** @type {Record<string, unknown>} */
|
|
84
|
+
clean(value, "chartOptions", 0)
|
|
85
|
+
), problems };
|
|
86
|
+
}
|
|
87
|
+
function mergeChartOptions(base, over) {
|
|
88
|
+
if (over === void 0) {
|
|
89
|
+
return base;
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(base)) {
|
|
92
|
+
if (Array.isArray(over)) {
|
|
93
|
+
const length = Math.max(base.length, over.length);
|
|
94
|
+
return Array.from({ length }, (_, i) => i < over.length ? mergeChartOptions(base[i], over[i]) : base[i]);
|
|
95
|
+
}
|
|
96
|
+
if (isPlain(over)) {
|
|
97
|
+
return base.map((entry) => mergeChartOptions(entry, over));
|
|
98
|
+
}
|
|
99
|
+
return over;
|
|
100
|
+
}
|
|
101
|
+
if (isPlain(base) && isPlain(over)) {
|
|
102
|
+
const b = (
|
|
103
|
+
/** @type {Record<string, unknown>} */
|
|
104
|
+
base
|
|
105
|
+
);
|
|
106
|
+
const o = (
|
|
107
|
+
/** @type {Record<string, unknown>} */
|
|
108
|
+
over
|
|
109
|
+
);
|
|
110
|
+
const out = { ...b };
|
|
111
|
+
for (const key of Object.keys(o)) {
|
|
112
|
+
out[key] = mergeChartOptions(b[key], o[key]);
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
return over;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/chart-tooltip.js
|
|
120
|
+
function tooltipContent(params, { valueFormatter = (v) => String(v ?? ""), xNames = [], yNames = [], categoryNames = [] } = {}) {
|
|
121
|
+
const color = (p) => typeof p.color === "string" ? p.color : null;
|
|
122
|
+
const text = (v) => v === null || v === void 0 ? "" : String(v);
|
|
123
|
+
if (Array.isArray(params)) {
|
|
124
|
+
const first = params[0];
|
|
125
|
+
return {
|
|
126
|
+
title: first ? text(categoryNames[first.dataIndex] ?? first.axisValueLabel ?? first.name) : "",
|
|
127
|
+
lines: params.map((p) => ({ color: color(p), name: text(p.seriesName), value: valueFormatter(p.value) }))
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (params && params.seriesType === "heatmap" && Array.isArray(params.value)) {
|
|
131
|
+
const [x, y, v] = params.value;
|
|
132
|
+
return {
|
|
133
|
+
title: text(params.seriesName),
|
|
134
|
+
lines: [{ color: color(params), name: [yNames[y], xNames[x]].filter((n) => n !== void 0).map(text).join(", "), value: valueFormatter(v) }]
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
title: text(params?.seriesName),
|
|
139
|
+
lines: params ? [{ color: color(params), name: text(params.name), value: valueFormatter(params.value) }] : []
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function tooltipFormatter(doc, options) {
|
|
143
|
+
return (params) => {
|
|
144
|
+
const { title, lines } = tooltipContent(params, options);
|
|
145
|
+
const box = doc.createElement("div");
|
|
146
|
+
if (title) {
|
|
147
|
+
const head = doc.createElement("div");
|
|
148
|
+
head.textContent = title;
|
|
149
|
+
head.style.fontWeight = "600";
|
|
150
|
+
head.style.marginBottom = "2px";
|
|
151
|
+
box.append(head);
|
|
152
|
+
}
|
|
153
|
+
for (const line of lines) {
|
|
154
|
+
const row = doc.createElement("div");
|
|
155
|
+
row.style.display = "flex";
|
|
156
|
+
row.style.alignItems = "center";
|
|
157
|
+
row.style.gap = "8px";
|
|
158
|
+
const marker = doc.createElement("span");
|
|
159
|
+
marker.style.display = "inline-block";
|
|
160
|
+
marker.style.width = "10px";
|
|
161
|
+
marker.style.height = "10px";
|
|
162
|
+
marker.style.borderRadius = "50%";
|
|
163
|
+
marker.style.flex = "none";
|
|
164
|
+
if (line.color) {
|
|
165
|
+
marker.style.backgroundColor = line.color;
|
|
166
|
+
}
|
|
167
|
+
const name = doc.createElement("span");
|
|
168
|
+
name.textContent = line.name;
|
|
169
|
+
name.style.flex = "1";
|
|
170
|
+
const value = doc.createElement("span");
|
|
171
|
+
value.textContent = line.value;
|
|
172
|
+
value.style.fontWeight = "600";
|
|
173
|
+
value.style.marginLeft = "12px";
|
|
174
|
+
row.append(marker, name, value);
|
|
175
|
+
box.append(row);
|
|
176
|
+
}
|
|
177
|
+
return box;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/chart-layout.js
|
|
182
|
+
function pieLabelRoom(height) {
|
|
183
|
+
return Math.round(Math.min(24, Math.max(0, height) * 0.05));
|
|
184
|
+
}
|
|
185
|
+
var RIGHT_LEGEND_MIN_WIDTH = 480;
|
|
186
|
+
var BOTTOM_LEGEND_ROOM = 32;
|
|
187
|
+
var labelWidth = (text) => String(text).length * 7;
|
|
188
|
+
function ringLabelsFit(radius, box, texts) {
|
|
189
|
+
const half = Math.max(0, Math.min(box.width, box.height)) / 2;
|
|
190
|
+
const px = (r) => typeof r === "number" ? r : /%$/.test(String(r)) ? parseFloat(String(r)) / 100 * half : parseFloat(String(r)) || 0;
|
|
191
|
+
const inner = px(radius[0]);
|
|
192
|
+
if (inner <= 0) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
const ring = px(radius[1]) - inner;
|
|
196
|
+
return texts.every((t) => labelWidth(t) + 6 <= ring);
|
|
197
|
+
}
|
|
198
|
+
var SLANTED_LABEL_WIDTH = 120;
|
|
199
|
+
var HEATMAP_FRAME = { x: 80, y: 120 };
|
|
200
|
+
var LABEL_LINE = 16;
|
|
201
|
+
var LABEL_PAD = 4;
|
|
202
|
+
function columnLabelLayout(names, width, fontSize = 12) {
|
|
203
|
+
if (names.length === 0) {
|
|
204
|
+
return { rotate: 0 };
|
|
205
|
+
}
|
|
206
|
+
const slot = Math.max(0, width - HEATMAP_FRAME.x) / names.length;
|
|
207
|
+
const longest = Math.max(...names.map((n) => String(n).length)) * fontSize * 0.55;
|
|
208
|
+
return longest <= slot ? { rotate: 0 } : { rotate: 45, width: SLANTED_LABEL_WIDTH, overflow: "truncate" };
|
|
209
|
+
}
|
|
210
|
+
function heatmapCellLabels(columns, rows, width, height, texts, fontSize = 12) {
|
|
211
|
+
const w = Math.max(0, width - HEATMAP_FRAME.x) / Math.max(1, columns);
|
|
212
|
+
const h = Math.max(0, height - HEATMAP_FRAME.y) / Math.max(1, rows);
|
|
213
|
+
const longest = texts.reduce((m, t) => Math.max(m, String(t).length), 0) * fontSize * 0.55;
|
|
214
|
+
return w >= longest + 2 * LABEL_PAD && h >= LABEL_LINE;
|
|
215
|
+
}
|
|
216
|
+
function rowLabelInterval(rows, height) {
|
|
217
|
+
const h = Math.max(0, height - HEATMAP_FRAME.y) / Math.max(1, rows);
|
|
218
|
+
return h >= LABEL_LINE ? 0 : Math.ceil(LABEL_LINE / Math.max(h, 0.1)) - 1;
|
|
219
|
+
}
|
|
220
|
+
var CATEGORY_LABEL_WIDTH = 120;
|
|
221
|
+
var AXIS_FRAME = { x: 80, y: 60 };
|
|
222
|
+
function categoryLabelLayout(names, { width, height, horizontal = false, mode = "auto", fontSize = 12 }) {
|
|
223
|
+
const n = Math.max(1, names.length);
|
|
224
|
+
const cut = { width: CATEGORY_LABEL_WIDTH, overflow: (
|
|
225
|
+
/** @type {const} */
|
|
226
|
+
"truncate"
|
|
227
|
+
) };
|
|
228
|
+
const every = (slot2, need) => Math.max(1, Math.ceil(need / Math.max(slot2, 0.1)));
|
|
229
|
+
const result = (rotate, step) => ({ rotate, interval: step - 1, every: step, ...cut });
|
|
230
|
+
if (horizontal) {
|
|
231
|
+
const slot2 = Math.max(0, height - AXIS_FRAME.y) / n;
|
|
232
|
+
return result(0, mode === "all" ? 1 : every(slot2, fontSize + 1));
|
|
233
|
+
}
|
|
234
|
+
const slot = Math.max(0, width - AXIS_FRAME.x) / n;
|
|
235
|
+
const longest = Math.min(CATEGORY_LABEL_WIDTH, Math.max(0, ...names.map((t) => String(t).length)) * fontSize * 0.55);
|
|
236
|
+
if (mode === "nth") {
|
|
237
|
+
return result(0, every(slot, longest + 8));
|
|
238
|
+
}
|
|
239
|
+
if (longest + 8 <= slot) {
|
|
240
|
+
return result(0, 1);
|
|
241
|
+
}
|
|
242
|
+
return result(45, mode === "all" ? 1 : every(slot, LABEL_LINE));
|
|
243
|
+
}
|
|
244
|
+
var GROUP_LABEL_ROOM = Object.freeze({ along: 56, across: 28, width: 420, height: 260 });
|
|
245
|
+
function groupLabelsFit(count, groupSize, { width, height, horizontal = false }) {
|
|
246
|
+
if (width < GROUP_LABEL_ROOM.width || height < GROUP_LABEL_ROOM.height) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
const n = Math.max(1, count);
|
|
250
|
+
const slot = horizontal ? Math.max(0, height - AXIS_FRAME.y) / n : Math.max(0, width - AXIS_FRAME.x) / n;
|
|
251
|
+
return slot * Math.max(1, groupSize) >= (horizontal ? GROUP_LABEL_ROOM.across : GROUP_LABEL_ROOM.along);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// src/chart-decorate.js
|
|
255
|
+
var without = (obj, keys) => Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k)));
|
|
256
|
+
function decorate(option, style, height = 480, doc = void 0, width = 800, extra = {}) {
|
|
257
|
+
const first = (a) => Array.isArray(a) ? a[0] : a;
|
|
258
|
+
const v = (name) => style.getPropertyValue(name).trim();
|
|
259
|
+
const rightLegend = option.legend?.orient === "vertical" && typeof option.legend.right === "number";
|
|
260
|
+
const legendDown = rightLegend && width < RIGHT_LEGEND_MIN_WIDTH;
|
|
261
|
+
if (legendDown) {
|
|
262
|
+
option = {
|
|
263
|
+
...option,
|
|
264
|
+
legend: { ...without(option.legend, ["orient", "right", "top"]), bottom: 0 },
|
|
265
|
+
series: (option.series || []).map((s) => s.type === "pie" ? { ...without(s, ["right"]), bottom: (typeof s.bottom === "number" ? s.bottom : 0) + BOTTOM_LEGEND_ROOM } : s),
|
|
266
|
+
...option.grid ? { grid: { ...without(option.grid, ["right"]), bottom: BOTTOM_LEGEND_ROOM + 8 } } : {}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
const surface = v("--pk-surface") || void 0;
|
|
270
|
+
const tooltip = {
|
|
271
|
+
...option.tooltip,
|
|
272
|
+
backgroundColor: v("--pk-surface-raised") || surface,
|
|
273
|
+
borderColor: v("--pk-border") || void 0,
|
|
274
|
+
textStyle: { color: v("--pk-text") || void 0, fontFamily: style.getPropertyValue("font-family") || void 0 },
|
|
275
|
+
extraCssText: `box-shadow: ${v("--pk-shadow") || "none"}; border-radius: 8px;`,
|
|
276
|
+
...doc ? { formatter: tooltipFormatter(doc, { valueFormatter: option.tooltip?.valueFormatter, xNames: first(option.xAxis)?.data, yNames: first(option.yAxis)?.data, categoryNames: extra.categoryNames }) } : {}
|
|
277
|
+
};
|
|
278
|
+
const series = (option.series || []).map((s) => {
|
|
279
|
+
if (s.type === "bar") {
|
|
280
|
+
const horizontal = first(option.yAxis)?.type === "category";
|
|
281
|
+
const r = horizontal ? [0, 4, 4, 0] : [4, 4, 0, 0];
|
|
282
|
+
return { ...s, barMaxWidth: 48, itemStyle: { borderRadius: s.stack ? 0 : r, borderColor: s.stack ? surface : void 0, borderWidth: s.stack ? 1 : 0 }, emphasis: { focus: "series" } };
|
|
283
|
+
}
|
|
284
|
+
if (s.type === "line") {
|
|
285
|
+
return { ...s, lineStyle: { width: 2 }, symbolSize: 7, smooth: Boolean(s.smooth), areaStyle: s.areaStyle ? { opacity: 0.18 } : void 0, emphasis: { focus: "series" } };
|
|
286
|
+
}
|
|
287
|
+
if (s.type === "pie") {
|
|
288
|
+
const room = pieLabelRoom(height);
|
|
289
|
+
const top = (typeof s.top === "number" ? s.top : 0) + room;
|
|
290
|
+
const bottom = (typeof s.bottom === "number" ? s.bottom : 0) + room;
|
|
291
|
+
let label = s.label;
|
|
292
|
+
let line = s.labelLine;
|
|
293
|
+
if (label?.position === "inside" && label.show !== false && Array.isArray(s.radius)) {
|
|
294
|
+
const box = { width: width - (typeof s.right === "number" ? s.right : 0), height: height - top - bottom };
|
|
295
|
+
const total = (s.data || []).reduce((sum, d) => sum + (typeof d.value === "number" ? d.value : 0), 0);
|
|
296
|
+
const texts = typeof label.formatter === "function" ? (s.data || []).map((d) => label.formatter({ name: d.name, value: d.value, percent: total ? d.value / total * 100 : 0 })) : [];
|
|
297
|
+
if (!ringLabelsFit(s.radius, box, texts)) {
|
|
298
|
+
label = without(label, ["position"]);
|
|
299
|
+
line = { show: true };
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return { ...s, top, bottom, labelLine: line, itemStyle: { borderColor: surface, borderWidth: 2, borderRadius: 4 }, label: { ...label, color: label?.position === "inside" ? void 0 : v("--pk-text") || void 0 } };
|
|
303
|
+
}
|
|
304
|
+
if (s.type === "heatmap") {
|
|
305
|
+
const texts = typeof s.label?.formatter === "function" ? s.data.map((d) => s.label.formatter({ value: d })) : [];
|
|
306
|
+
const fits = heatmapCellLabels(option.xAxis?.data?.length ?? 1, option.yAxis?.data?.length ?? 1, width, height, texts);
|
|
307
|
+
return { ...s, itemStyle: { borderColor: surface, borderWidth: 2, borderRadius: 3 }, label: { ...s.label, show: Boolean(s.label?.show) && fits, color: v("--pk-text") || void 0 } };
|
|
308
|
+
}
|
|
309
|
+
return s;
|
|
310
|
+
});
|
|
311
|
+
const legend = option.legend ? { ...option.legend, icon: "roundRect", itemWidth: 12, itemHeight: 12, textStyle: { ...option.legend.textStyle, color: v("--pk-text") || void 0 } } : void 0;
|
|
312
|
+
const grid = option.grid ? { left: 12, right: 24, bottom: option.visualMap ? 64 : 12, containLabel: true, ...option.grid } : void 0;
|
|
313
|
+
const heatmap = series.some((s) => s.type === "heatmap") && option.xAxis?.axisLabel;
|
|
314
|
+
const xAxis = heatmap ? { ...option.xAxis, axisLabel: { ...option.xAxis.axisLabel, ...columnLabelLayout(option.xAxis.data ?? [], width) } } : option.xAxis;
|
|
315
|
+
const yAxis = heatmap && option.yAxis ? { ...option.yAxis, axisLabel: { ...option.yAxis.axisLabel, interval: rowLabelInterval(option.yAxis.data?.length ?? 0, height) } } : option.yAxis;
|
|
316
|
+
const title = option.title ? { title: { ...option.title, textStyle: { ...option.title.textStyle, width: Math.max(40, width - 32), overflow: "truncate" } } } : {};
|
|
317
|
+
let axes = { xAxis, yAxis };
|
|
318
|
+
let axisEvery = 1;
|
|
319
|
+
const along = !heatmap && series.some((s) => s.type === "bar" || s.type === "line") ? first(option.yAxis)?.type === "category" ? "yAxis" : first(option.xAxis)?.type === "category" ? "xAxis" : null : null;
|
|
320
|
+
if (along) {
|
|
321
|
+
let list = Array.isArray(axes[along]) ? axes[along] : [axes[along]];
|
|
322
|
+
const group = list[1]?.groups ? list[1] : null;
|
|
323
|
+
if (group && group.groupsAuto && !groupLabelsFit(list[0].data?.length ?? 0, group.groupSize ?? 1, { width, height, horizontal: along === "yAxis" })) {
|
|
324
|
+
list = [{ ...list[0], data: extra.categoryNames ?? list[0].data }];
|
|
325
|
+
}
|
|
326
|
+
const names = list[0].data ?? [];
|
|
327
|
+
const layout = categoryLabelLayout(names, { width, height, horizontal: along === "yAxis", mode: extra.axisLabels });
|
|
328
|
+
axisEvery = layout.every;
|
|
329
|
+
const longest = Math.min(CATEGORY_LABEL_WIDTH, Math.max(0, ...names.map((t) => String(t).length)) * 12 * 0.55);
|
|
330
|
+
const offset = along === "yAxis" ? Math.round(longest) + 16 : layout.rotate ? Math.round(longest * 0.71) + 14 : 24;
|
|
331
|
+
const main = { ...list[0], axisLabel: { ...list[0].axisLabel, rotate: layout.rotate, interval: layout.interval, width: layout.width, overflow: layout.overflow } };
|
|
332
|
+
const slot = (along === "yAxis" ? Math.max(0, height - 60) : Math.max(0, width - 80)) / Math.max(1, names.length);
|
|
333
|
+
const groupWidth = along === "yAxis" ? CATEGORY_LABEL_WIDTH : Math.max(24, Math.round(slot * (list[1]?.groupSize ?? 1)) - 8);
|
|
334
|
+
const rest = list.slice(1).map((a) => a.groups ? { ...a, offset, axisTick: { ...a.axisTick, length: offset }, axisLabel: { ...a.axisLabel, width: groupWidth, overflow: "truncate" } } : a);
|
|
335
|
+
axes = { ...axes, [along]: rest.length ? [main, ...rest] : main };
|
|
336
|
+
}
|
|
337
|
+
return { ...option, ...title, tooltip, series, ...axes.xAxis ? { xAxis: axes.xAxis } : {}, ...axes.yAxis ? { yAxis: axes.yAxis } : {}, ...legend ? { legend } : {}, ...grid ? { grid } : {}, animationDuration: style.getPropertyValue("--pk-duration").trim() === "0ms" ? 0 : 400, axisEvery };
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/echarts.js
|
|
341
|
+
register([BarChart, LineChart, PieChart, HeatmapChart, GridComponent, TooltipComponent, LegendComponent, TitleComponent, VisualMapComponent, CanvasRenderer]);
|
|
342
|
+
export {
|
|
343
|
+
cleanChartOptions,
|
|
344
|
+
decorate,
|
|
345
|
+
init,
|
|
346
|
+
mergeChartOptions
|
|
347
|
+
};
|