pivotkit-react 0.1.0 → 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 +143 -1
- package/README.md +48 -298
- package/dist/chunks/chunk-53ZMK4BH.js +177 -0
- package/dist/chunks/{chunk-ILHFIV2P.js → chunk-F6MVUAQD.js} +35 -78
- 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-KKJO36W5.js → chunk-X7H7BAVT.js} +243 -324
- package/dist/chunks/unused-texts-YTNJCFFC.js +10 -0
- package/dist/chunks/unused-texts-de-SGOHV4N7.js +6 -0
- package/dist/echarts.js +96 -11
- package/dist/index.js +619 -527
- package/dist/labels.js +13 -4
- package/dist/menu-texts-de.js +6 -0
- package/dist/menus.js +787 -191
- package/dist/styles.css +113 -31
- package/package.json +2 -2
- package/types/chart-layout.d.ts +111 -0
- package/types/chart-types.d.ts +0 -91
- package/types/drill-panel.d.ts +5 -22
- package/types/drill-table.d.ts +71 -0
- package/types/drill.d.ts +0 -36
- package/types/help.d.ts +21 -0
- package/types/icons.d.ts +4 -0
- package/types/labels.d.ts +43 -101
- package/types/lazy-menus.d.ts +16 -4
- package/types/menu-labels-de.d.ts +2 -0
- package/types/menu-labels.d.ts +71 -9
- package/types/menu-ops.d.ts +145 -0
- package/types/menu-texts.d.ts +2 -0
- package/types/menus.d.ts +1 -1
- package/types/names.d.ts +19 -19
- package/types/overflow.d.ts +4 -1
- package/types/popover.d.ts +10 -6
- package/types/section.d.ts +7 -24
- package/types/sections.d.ts +2 -0
- package/types/share-actions.d.ts +99 -0
- package/types/share.d.ts +0 -9
- package/types/table.d.ts +9 -3
- package/types/templates.d.ts +7 -1
- package/types/tips.d.ts +9 -7
- package/types/toolbar-panels.d.ts +8 -5
- 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-view-history.d.ts +7 -4
- package/types/view-history.d.ts +23 -6
- package/types/view-ops.d.ts +72 -123
- package/types/view-save.d.ts +76 -0
- package/types/view-store.d.ts +13 -6
- package/dist/chunks/chunk-C32TYSHG.js +0 -441
- package/dist/chunks/chunk-XYP47DJ3.js +0 -123
package/dist/echarts.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CATEGORY_LABEL_WIDTH,
|
|
3
|
-
categoryLabelLayout,
|
|
4
|
-
columnLabelLayout,
|
|
5
|
-
groupLabelsFit,
|
|
6
|
-
heatmapCellLabels,
|
|
7
|
-
pieLabelRoom,
|
|
8
|
-
rowLabelInterval
|
|
9
|
-
} from "./chunks/chunk-XYP47DJ3.js";
|
|
10
|
-
|
|
11
1
|
// src/echarts.js
|
|
12
2
|
import { init, use as register } from "echarts/core";
|
|
13
3
|
import { BarChart, HeatmapChart, LineChart, PieChart } from "echarts/charts";
|
|
@@ -188,10 +178,94 @@ function tooltipFormatter(doc, options) {
|
|
|
188
178
|
};
|
|
189
179
|
}
|
|
190
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
|
+
|
|
191
254
|
// src/chart-decorate.js
|
|
255
|
+
var without = (obj, keys) => Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k)));
|
|
192
256
|
function decorate(option, style, height = 480, doc = void 0, width = 800, extra = {}) {
|
|
193
257
|
const first = (a) => Array.isArray(a) ? a[0] : a;
|
|
194
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
|
+
}
|
|
195
269
|
const surface = v("--pk-surface") || void 0;
|
|
196
270
|
const tooltip = {
|
|
197
271
|
...option.tooltip,
|
|
@@ -214,7 +288,18 @@ function decorate(option, style, height = 480, doc = void 0, width = 800, extra
|
|
|
214
288
|
const room = pieLabelRoom(height);
|
|
215
289
|
const top = (typeof s.top === "number" ? s.top : 0) + room;
|
|
216
290
|
const bottom = (typeof s.bottom === "number" ? s.bottom : 0) + room;
|
|
217
|
-
|
|
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 } };
|
|
218
303
|
}
|
|
219
304
|
if (s.type === "heatmap") {
|
|
220
305
|
const texts = typeof s.label?.formatter === "function" ? s.data.map((d) => s.label.formatter({ value: d })) : [];
|