@pie-lib/charting 8.0.3-next.20261007175429 → 8.0.3-next.20261007181944
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/dist/axes.d.ts +1 -0
- package/dist/axes.js +82 -75
- package/dist/mark-label.js +1 -0
- package/package.json +3 -3
package/dist/axes.d.ts
CHANGED
package/dist/axes.js
CHANGED
|
@@ -14,22 +14,22 @@ import _ from "@mui/material/Checkbox";
|
|
|
14
14
|
import { renderMath as v } from "@pie-element/shared-math-rendering-mathjax";
|
|
15
15
|
import y from "@pie-lib/translator";
|
|
16
16
|
//#region src/axes.tsx
|
|
17
|
-
var { translator: b } = y, x = /* @__PURE__ */ new Set(),
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}),
|
|
17
|
+
var { translator: b } = y, x = 24, S = /* @__PURE__ */ new Set(), C = null;
|
|
18
|
+
function w(e) {
|
|
19
|
+
S.add(e), !C && typeof document < "u" && (C = new MutationObserver(() => {
|
|
20
|
+
S.forEach((e) => e());
|
|
21
|
+
}), C.observe(document.body, {
|
|
22
22
|
childList: !0,
|
|
23
23
|
subtree: !0
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
26
|
+
function T(e) {
|
|
27
|
+
S.delete(e), S.size === 0 && C && (C.disconnect(), C = null);
|
|
28
28
|
}
|
|
29
|
-
var
|
|
29
|
+
var E = d("text")(({ theme: e }) => ({
|
|
30
30
|
fontSize: e.typography.fontSize - 2,
|
|
31
31
|
fill: e.palette.error.main
|
|
32
|
-
})),
|
|
32
|
+
})), D = d(_)(() => ({ color: `${m.tertiary()} !important` })), O = d("g")(({ theme: e }) => ({
|
|
33
33
|
"& .vx-axis-line": {
|
|
34
34
|
stroke: m.visualElementsColors.AXIS_LINE_COLOR,
|
|
35
35
|
strokeWidth: 2
|
|
@@ -44,7 +44,7 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
44
44
|
fontSize: e.typography.fontSize,
|
|
45
45
|
textAnchor: "middle"
|
|
46
46
|
}
|
|
47
|
-
})),
|
|
47
|
+
})), k = (e) => ({
|
|
48
48
|
borderRadius: e.spacing(2),
|
|
49
49
|
color: m.defaults.WHITE,
|
|
50
50
|
fontSize: "16px",
|
|
@@ -53,7 +53,7 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
53
53
|
padding: "2px",
|
|
54
54
|
border: `1px solid ${m.defaults.WHITE}`,
|
|
55
55
|
boxSizing: "unset"
|
|
56
|
-
}),
|
|
56
|
+
}), A = { backgroundColor: m.incorrectWithIcon() }, j = { backgroundColor: m.correct() }, M = class extends l.Component {
|
|
57
57
|
static propTypes = {
|
|
58
58
|
defineChart: u.bool,
|
|
59
59
|
error: u.any
|
|
@@ -113,12 +113,12 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
113
113
|
return n;
|
|
114
114
|
};
|
|
115
115
|
render() {
|
|
116
|
-
let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate: o, top: l, graphProps: u, defineChart: d, chartingOptions: f, x: m, y: _, formattedValue: v, changeInteractiveEnabled: y, changeEditableEnabled: x, error: S, autoFocus: C, hiddenLabelRef: w, showCorrectness:
|
|
116
|
+
let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate: o, top: l, graphProps: u, defineChart: d, chartingOptions: f, x: m, y: _, formattedValue: v, changeInteractiveEnabled: y, changeEditableEnabled: x, error: S, autoFocus: C, hiddenLabelRef: w, showCorrectness: T, language: O } = this.props;
|
|
117
117
|
if (!v) return null;
|
|
118
118
|
let M = {
|
|
119
|
-
correctnessIcon:
|
|
120
|
-
incorrectIcon:
|
|
121
|
-
correctIcon:
|
|
119
|
+
correctnessIcon: k,
|
|
120
|
+
incorrectIcon: A,
|
|
121
|
+
correctIcon: j
|
|
122
122
|
}, { dialog: N } = this.state, { changeEditable: P, changeInteractive: F } = f || {}, I = parseInt(v.split("-")[0], 10), L = e[I], { editable: R, interactive: z, label: B, correctness: V } = L || {}, H = t(r({ label: B }, I)), U = (e || []).reduce((e, t) => (e && e.label ? e.label.length : 0) > (t && t.label ? t.label.length : 0) ? e : t, { label: "" }), W = S ? [...new Set(Object.values(S))].join(" ") : "";
|
|
123
123
|
return /* @__PURE__ */ g("g", { children: [
|
|
124
124
|
/* @__PURE__ */ g("foreignObject", {
|
|
@@ -149,24 +149,24 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
149
149
|
correctness: V,
|
|
150
150
|
error: S && S[I],
|
|
151
151
|
ariaLabel: b.t("charting.categoryLabel", {
|
|
152
|
-
lng:
|
|
152
|
+
lng: O,
|
|
153
153
|
index: I + 1
|
|
154
154
|
}),
|
|
155
155
|
mathAriaLabel: b.t("charting.categoryLabelValue", {
|
|
156
|
-
lng:
|
|
156
|
+
lng: O,
|
|
157
157
|
index: I + 1,
|
|
158
158
|
label: s(B),
|
|
159
159
|
interpolation: { escapeValue: !1 }
|
|
160
160
|
}),
|
|
161
161
|
limitCharacters: !0,
|
|
162
|
-
correctnessIndicator:
|
|
162
|
+
correctnessIndicator: T && V && /* @__PURE__ */ h(n, {
|
|
163
163
|
correctness: V,
|
|
164
164
|
interactive: z,
|
|
165
165
|
classes: M
|
|
166
166
|
})
|
|
167
167
|
})]
|
|
168
168
|
}),
|
|
169
|
-
S && I === 0 && /* @__PURE__ */ h(
|
|
169
|
+
S && I === 0 && /* @__PURE__ */ h(E, {
|
|
170
170
|
y: _ + 23,
|
|
171
171
|
height: 6,
|
|
172
172
|
textAnchor: "start",
|
|
@@ -218,7 +218,7 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
218
218
|
pointerEvents: "visible",
|
|
219
219
|
overflow: "visible"
|
|
220
220
|
},
|
|
221
|
-
children: /* @__PURE__ */ h(
|
|
221
|
+
children: /* @__PURE__ */ h(D, {
|
|
222
222
|
style: { position: "fixed" },
|
|
223
223
|
checked: z,
|
|
224
224
|
onChange: (e) => this.changeInteractive(I, e.target.checked)
|
|
@@ -233,7 +233,7 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
233
233
|
pointerEvents: "visible",
|
|
234
234
|
overflow: "visible"
|
|
235
235
|
},
|
|
236
|
-
children: /* @__PURE__ */ h(
|
|
236
|
+
children: /* @__PURE__ */ h(D, {
|
|
237
237
|
style: { position: "fixed" },
|
|
238
238
|
checked: R,
|
|
239
239
|
onChange: (e) => this.changeEditable(I, e.target.checked)
|
|
@@ -259,7 +259,7 @@ var T = d("text")(({ theme: e }) => ({
|
|
|
259
259
|
] });
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
|
-
|
|
262
|
+
M.propTypes = {
|
|
263
263
|
categories: u.array,
|
|
264
264
|
xBand: u.func,
|
|
265
265
|
bandWidth: u.number,
|
|
@@ -283,7 +283,7 @@ j.propTypes = {
|
|
|
283
283
|
hiddenLabelRef: u.oneOfType([u.func, u.shape({ current: u.instanceOf(Element) })]),
|
|
284
284
|
language: u.string
|
|
285
285
|
};
|
|
286
|
-
var
|
|
286
|
+
var N = class extends l.Component {
|
|
287
287
|
static propTypes = {
|
|
288
288
|
bottomScale: u.func,
|
|
289
289
|
categories: u.array,
|
|
@@ -308,7 +308,8 @@ var M = class extends l.Component {
|
|
|
308
308
|
};
|
|
309
309
|
state = {
|
|
310
310
|
height: 0,
|
|
311
|
-
width: 0
|
|
311
|
+
width: 0,
|
|
312
|
+
labelHeight: 0
|
|
312
313
|
};
|
|
313
314
|
reportedOverhang = 0;
|
|
314
315
|
labelLayout = () => {
|
|
@@ -320,24 +321,27 @@ var M = class extends l.Component {
|
|
|
320
321
|
};
|
|
321
322
|
};
|
|
322
323
|
reportLabelOverhang = () => {
|
|
323
|
-
let { onLabelOverhang: e } = this.props, { height: t, width: n } = this.state,
|
|
324
|
-
e &&
|
|
324
|
+
let { onLabelOverhang: e } = this.props, { height: t, width: n, labelHeight: r } = this.state, i = a(n, t, this.labelLayout().rotate) + Math.max(0, r - x);
|
|
325
|
+
e && i !== this.reportedOverhang && (this.reportedOverhang = i, e(i));
|
|
325
326
|
};
|
|
326
327
|
measureHiddenLabel = () => {
|
|
327
328
|
if (!this.hiddenLabelRef) return;
|
|
328
|
-
let e = this.hiddenLabelRef.querySelector("mjx-container"), t = this.hiddenLabelRef.querySelector("input"), n = (e || t || this.hiddenLabelRef).getBoundingClientRect(), r = Math.floor(n.height), i = Math.floor(n.width);
|
|
329
|
-
(
|
|
329
|
+
let e = this.hiddenLabelRef.querySelector("mjx-container"), t = this.hiddenLabelRef.querySelector("input"), n = (e || t || this.hiddenLabelRef).getBoundingClientRect(), r = Math.floor(n.height), i = Math.floor(n.width), a = this.axesNode ? [...this.axesNode.querySelectorAll("[data-math-label]")] : [];
|
|
330
|
+
a.forEach((e) => this._sizeObserver?.observe(e));
|
|
331
|
+
let o = Math.max(0, ...a.map((e) => e.offsetHeight));
|
|
332
|
+
(r !== this.state.height || i !== this.state.width || o !== this.state.labelHeight) && this.setState({
|
|
330
333
|
height: r,
|
|
331
|
-
width: i
|
|
334
|
+
width: i,
|
|
335
|
+
labelHeight: o
|
|
332
336
|
});
|
|
333
337
|
};
|
|
334
338
|
_onDocMutation = () => {
|
|
335
|
-
this.hiddenLabelRef && this.
|
|
339
|
+
this.hiddenLabelRef && this.axesNode?.querySelector("mjx-container") && this.measureHiddenLabel();
|
|
336
340
|
};
|
|
337
341
|
observeHiddenLabel = (e) => {
|
|
338
342
|
if (!e) return;
|
|
339
343
|
let t = e.querySelector("[data-latex], [data-raw]");
|
|
340
|
-
t && v(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(),
|
|
344
|
+
t && v(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(), w(this._onDocMutation), this.observeHiddenLabelSize(e);
|
|
341
345
|
};
|
|
342
346
|
observeHiddenLabelSize = (e) => {
|
|
343
347
|
e === this._sizedLabel || typeof ResizeObserver > "u" || (this._sizeObserver?.disconnect(), this._sizedLabel = e, this._sizeObserver = new ResizeObserver(() => this.measureHiddenLabel()), this._sizeObserver.observe(e));
|
|
@@ -349,59 +353,62 @@ var M = class extends l.Component {
|
|
|
349
353
|
this.hiddenLabelRef && this.observeHiddenLabel(this.hiddenLabelRef), this.reportLabelOverhang();
|
|
350
354
|
}
|
|
351
355
|
componentWillUnmount() {
|
|
352
|
-
|
|
356
|
+
T(this._onDocMutation), this._sizeObserver?.disconnect(), this._sizedLabel = null, this._updateTimer && clearTimeout(this._updateTimer);
|
|
353
357
|
}
|
|
354
358
|
componentDidUpdate(e) {
|
|
355
359
|
e.categories !== this.props.categories && (this._updateTimer && clearTimeout(this._updateTimer), this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50)), this.reportLabelOverhang();
|
|
356
360
|
}
|
|
357
361
|
render() {
|
|
358
|
-
let { graphProps: n, xBand: r, leftAxis: i, onChange: a, onChangeCategory: s, categories: c = [], top: l, defineChart: u, chartingOptions: d, changeInteractiveEnabled: f, changeEditableEnabled: p, autoFocus: m, onAutoFocusUsed: _, error: v, showCorrectness: y, language: b } = this.props, { scale: x = {}, range: S = {}, size: C = {} } = n || {}, w = r && typeof r.rangeRound == "function" && r.rangeRound([0, C.width]), { bandWidth: T, barWidth: E, rotate:
|
|
362
|
+
let { graphProps: n, xBand: r, leftAxis: i, onChange: a, onChangeCategory: s, categories: c = [], top: l, defineChart: u, chartingOptions: d, changeInteractiveEnabled: f, changeEditableEnabled: p, autoFocus: m, onAutoFocusUsed: _, error: v, showCorrectness: y, language: b } = this.props, { scale: x = {}, range: S = {}, size: C = {} } = n || {}, w = r && typeof r.rangeRound == "function" && r.rangeRound([0, C.width]), { bandWidth: T, barWidth: E, rotate: D } = this.labelLayout(), k = o({
|
|
359
363
|
...S,
|
|
360
364
|
step: S.labelStep
|
|
361
365
|
});
|
|
362
|
-
return /* @__PURE__ */ g(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
366
|
+
return /* @__PURE__ */ g(O, {
|
|
367
|
+
ref: (e) => this.axesNode = e,
|
|
368
|
+
children: [i && /* @__PURE__ */ h(e, {
|
|
369
|
+
scale: x.y,
|
|
370
|
+
tickLength: 10,
|
|
371
|
+
tickFormat: (e) => e,
|
|
372
|
+
tickValues: k,
|
|
373
|
+
tickLabelProps: (e) => ({
|
|
374
|
+
dy: 4,
|
|
375
|
+
dx: -10 - (e.toLocaleString().length || 1) * 5
|
|
376
|
+
})
|
|
377
|
+
}), /* @__PURE__ */ h(t, {
|
|
378
|
+
scale: w,
|
|
379
|
+
labelProps: { y: 60 + l },
|
|
380
|
+
top: x.y && x.y(S.min),
|
|
381
|
+
textLabelProps: () => ({ textAnchor: "middle" }),
|
|
382
|
+
tickFormat: (e) => e,
|
|
383
|
+
tickComponent: (e) => /* @__PURE__ */ h(M, {
|
|
384
|
+
hiddenLabelRef: this.setHiddenLabelRef,
|
|
385
|
+
categories: c,
|
|
386
|
+
xBand: r,
|
|
387
|
+
bandWidth: T,
|
|
388
|
+
barWidth: E,
|
|
389
|
+
rotate: D,
|
|
390
|
+
top: l,
|
|
391
|
+
defineChart: u,
|
|
392
|
+
chartingOptions: d,
|
|
393
|
+
autoFocus: m,
|
|
394
|
+
onAutoFocusUsed: _,
|
|
395
|
+
error: v,
|
|
396
|
+
onChangeCategory: s,
|
|
397
|
+
changeInteractiveEnabled: f,
|
|
398
|
+
changeEditableEnabled: p,
|
|
399
|
+
onChange: a,
|
|
400
|
+
graphProps: n,
|
|
401
|
+
x: e.x,
|
|
402
|
+
y: e.y,
|
|
403
|
+
formattedValue: e.formattedValue,
|
|
404
|
+
showCorrectness: y,
|
|
405
|
+
language: b
|
|
406
|
+
}),
|
|
387
407
|
autoFocus: m,
|
|
388
|
-
onAutoFocusUsed: _
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
changeInteractiveEnabled: f,
|
|
392
|
-
changeEditableEnabled: p,
|
|
393
|
-
onChange: a,
|
|
394
|
-
graphProps: n,
|
|
395
|
-
x: e.x,
|
|
396
|
-
y: e.y,
|
|
397
|
-
formattedValue: e.formattedValue,
|
|
398
|
-
showCorrectness: y,
|
|
399
|
-
language: b
|
|
400
|
-
}),
|
|
401
|
-
autoFocus: m,
|
|
402
|
-
onAutoFocusUsed: _
|
|
403
|
-
})] });
|
|
408
|
+
onAutoFocusUsed: _
|
|
409
|
+
})]
|
|
410
|
+
});
|
|
404
411
|
}
|
|
405
412
|
};
|
|
406
413
|
//#endregion
|
|
407
|
-
export {
|
|
414
|
+
export { N as RawChartAxes, N as default, M as TickComponent };
|
package/dist/mark-label.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/charting",
|
|
3
|
-
"version": "8.0.3-next.
|
|
3
|
+
"version": "8.0.3-next.20261007181944",
|
|
4
4
|
"description": "charting",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
16
|
"@pie-element/shared-utils": "0.1.3-next.20261007075859",
|
|
17
|
-
"@pie-lib/plot": "5.0.3-next.
|
|
17
|
+
"@pie-lib/plot": "5.0.3-next.20261007181944",
|
|
18
18
|
"@pie-lib/render-ui": "8.0.3-next.20261007175429",
|
|
19
19
|
"@pie-lib/translator": "5.0.2-next.20261006160832",
|
|
20
20
|
"@visx/axis": "^4.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"invariant": "^2.2.4",
|
|
31
31
|
"react-draggable": "^4.7.1",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
33
|
-
"@pie-lib/config-ui": "14.0.3-next.
|
|
33
|
+
"@pie-lib/config-ui": "14.0.3-next.20261007181944",
|
|
34
34
|
"@pie-element/shared-math-rendering-mathjax": "0.1.4-next.20261007175429",
|
|
35
35
|
"@pie-element/shared-lodash": "0.1.3-next.20261006160832",
|
|
36
36
|
"clsx": "^2.1.1",
|