@pie-lib/charting 8.0.1-next.20261004200555 → 8.0.1-next.20261004212815
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/__tests__/label-rotation.test.d.ts +1 -0
- package/dist/__tests__/page-unique-ids.test.d.ts +1 -0
- package/dist/actions-button.js +8 -8
- package/dist/axes.d.ts +5 -0
- package/dist/axes.js +154 -137
- package/dist/bars/common/bars.js +11 -11
- package/dist/bars/common/correct-check-icon.js +46 -42
- package/dist/chart-setup.js +19 -19
- package/dist/chart-type.js +55 -51
- package/dist/chart.d.ts +1 -0
- package/dist/chart.js +27 -24
- package/dist/common/correctness-indicators.js +18 -18
- package/dist/common/drag-handle.js +14 -38
- package/dist/grid.js +9 -9
- package/dist/key-legend.js +13 -13
- package/dist/line/common/drag-handle.js +12 -12
- package/dist/line/common/line.js +8 -8
- package/dist/line/line-cross.js +17 -17
- package/dist/line/line-dot.js +10 -10
- package/dist/mark-label.js +9 -9
- package/dist/plot/common/plot.js +22 -22
- package/dist/plot/dot.js +7 -7
- package/dist/plot/line.js +8 -8
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +7 -3
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/actions-button.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import e from "react";
|
|
2
2
|
import t from "prop-types";
|
|
3
3
|
import { styled as n } from "@mui/material/styles";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { color as r } from "@pie-lib/render-ui";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
6
|
import o from "@pie-lib/translator";
|
|
7
7
|
import s from "@mui/material/Button";
|
|
8
8
|
import c from "@mui/material/Popover";
|
|
@@ -11,7 +11,7 @@ import l from "@mui/material/Paper";
|
|
|
11
11
|
var { translator: u } = o, d = n("div")(() => ({ alignSelf: "flex-end" })), f = n("div")(({ theme: e }) => ({
|
|
12
12
|
cursor: "pointer",
|
|
13
13
|
fontSize: e.typography.fontSize,
|
|
14
|
-
color:
|
|
14
|
+
color: r.tertiary(),
|
|
15
15
|
padding: e.spacing(1)
|
|
16
16
|
})), p = n(l)(({ theme: e }) => ({
|
|
17
17
|
padding: e.spacing(1),
|
|
@@ -21,7 +21,7 @@ var { translator: u } = o, d = n("div")(() => ({ alignSelf: "flex-end" })), f =
|
|
|
21
21
|
"& button": {
|
|
22
22
|
textTransform: "none",
|
|
23
23
|
fontSize: e.typography.fontSize,
|
|
24
|
-
color:
|
|
24
|
+
color: r.text(),
|
|
25
25
|
justifyContent: "flex-start"
|
|
26
26
|
}
|
|
27
27
|
})), m = class extends e.Component {
|
|
@@ -53,12 +53,12 @@ var { translator: u } = o, d = n("div")(() => ({ alignSelf: "flex-end" })), f =
|
|
|
53
53
|
};
|
|
54
54
|
render() {
|
|
55
55
|
let { categories: e, language: t } = this.props, { actionsAnchorEl: n } = this.state;
|
|
56
|
-
return /* @__PURE__ */
|
|
56
|
+
return /* @__PURE__ */ a(d, { children: [/* @__PURE__ */ i(f, {
|
|
57
57
|
role: "button",
|
|
58
58
|
tabIndex: 0,
|
|
59
59
|
onClick: this.handleActionsClick,
|
|
60
60
|
children: "Actions"
|
|
61
|
-
}), /* @__PURE__ */
|
|
61
|
+
}), /* @__PURE__ */ i(c, {
|
|
62
62
|
open: !!n,
|
|
63
63
|
anchorEl: n,
|
|
64
64
|
onClose: this.handleActionsClose,
|
|
@@ -70,10 +70,10 @@ var { translator: u } = o, d = n("div")(() => ({ alignSelf: "flex-end" })), f =
|
|
|
70
70
|
vertical: "top",
|
|
71
71
|
horizontal: "left"
|
|
72
72
|
},
|
|
73
|
-
children: /* @__PURE__ */
|
|
73
|
+
children: /* @__PURE__ */ a(p, { children: [/* @__PURE__ */ a(s, {
|
|
74
74
|
onClick: () => this.handleAddCategory(),
|
|
75
75
|
children: ["+ ", u.t("charting.add", { lng: t })]
|
|
76
|
-
}), e.length > 0 && e.map((e, n) => e.deletable && !e.correctness && /* @__PURE__ */
|
|
76
|
+
}), e.length > 0 && e.map((e, n) => e.deletable && !e.correctness && /* @__PURE__ */ i(s, {
|
|
77
77
|
onClick: () => this.handleDeleteCategory(n),
|
|
78
78
|
children: `${u.t("charting.delete", { lng: t })} <${e.label || u.t("charting.newLabel", { lng: t })}>`
|
|
79
79
|
}, n))] })
|
package/dist/axes.d.ts
CHANGED
|
@@ -60,14 +60,19 @@ export declare class RawChartAxes extends React.Component {
|
|
|
60
60
|
current: PropTypes.Requireable<Element>;
|
|
61
61
|
}> | null | undefined>>;
|
|
62
62
|
language: PropTypes.Requireable<string>;
|
|
63
|
+
onLabelOverhang: PropTypes.Requireable<(...args: any[]) => any>;
|
|
63
64
|
};
|
|
64
65
|
state: {
|
|
65
66
|
height: number;
|
|
66
67
|
width: number;
|
|
67
68
|
};
|
|
69
|
+
reportedOverhang: number;
|
|
70
|
+
labelLayout: any;
|
|
71
|
+
reportLabelOverhang: any;
|
|
68
72
|
measureHiddenLabel: any;
|
|
69
73
|
_onDocMutation: any;
|
|
70
74
|
observeHiddenLabel: any;
|
|
75
|
+
observeHiddenLabelSize: any;
|
|
71
76
|
setHiddenLabelRef: any;
|
|
72
77
|
componentDidMount(): void;
|
|
73
78
|
componentWillUnmount(): void;
|
package/dist/axes.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
import e from "./node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisLeft.js";
|
|
2
2
|
import t from "./node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisBottom.js";
|
|
3
3
|
import { TickCorrectnessIndicator as n } from "./common/correctness-indicators.js";
|
|
4
|
-
import { bandKey as r, getRotateAngle as i,
|
|
5
|
-
import { MarkLabel as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { styled as
|
|
9
|
-
import { types as
|
|
10
|
-
import { AlertDialog as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import { renderMath as
|
|
15
|
-
import
|
|
4
|
+
import { bandKey as r, getRotateAngle as i, getRotatedLabelOverhang as a, getTickValues as o } from "./utils.js";
|
|
5
|
+
import { MarkLabel as s } from "./mark-label.js";
|
|
6
|
+
import c from "react";
|
|
7
|
+
import l from "prop-types";
|
|
8
|
+
import { styled as u } from "@mui/material/styles";
|
|
9
|
+
import { types as d } from "@pie-lib/plot";
|
|
10
|
+
import { AlertDialog as f } from "@pie-lib/config-ui";
|
|
11
|
+
import { color as p } from "@pie-lib/render-ui";
|
|
12
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
13
|
+
import g from "@mui/material/Checkbox";
|
|
14
|
+
import { renderMath as _ } from "@pie-element/shared-math-rendering-mathjax";
|
|
15
|
+
import v from "@pie-lib/translator";
|
|
16
16
|
//#region src/axes.tsx
|
|
17
|
-
var { translator:
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}),
|
|
17
|
+
var { translator: y } = v, b = /* @__PURE__ */ new Set(), x = null;
|
|
18
|
+
function S(e) {
|
|
19
|
+
b.add(e), !x && typeof document < "u" && (x = new MutationObserver(() => {
|
|
20
|
+
b.forEach((e) => e());
|
|
21
|
+
}), x.observe(document.body, {
|
|
22
22
|
childList: !0,
|
|
23
23
|
subtree: !0
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
26
|
+
function C(e) {
|
|
27
|
+
b.delete(e), b.size === 0 && x && (x.disconnect(), x = null);
|
|
28
28
|
}
|
|
29
|
-
var
|
|
29
|
+
var w = u("text")(({ theme: e }) => ({
|
|
30
30
|
fontSize: e.typography.fontSize - 2,
|
|
31
31
|
fill: e.palette.error.main
|
|
32
|
-
})),
|
|
32
|
+
})), T = u(g)(() => ({ color: `${p.tertiary()} !important` })), E = u("g")(({ theme: e }) => ({
|
|
33
33
|
"& .vx-axis-line": {
|
|
34
|
-
stroke:
|
|
34
|
+
stroke: p.visualElementsColors.AXIS_LINE_COLOR,
|
|
35
35
|
strokeWidth: 2
|
|
36
36
|
},
|
|
37
37
|
"& .vx-axis-tick": {
|
|
38
|
-
fill:
|
|
38
|
+
fill: p.visualElementsColors.AXIS_TICK_COLOR,
|
|
39
39
|
"& line": {
|
|
40
|
-
stroke:
|
|
40
|
+
stroke: p.visualElementsColors.AXIS_TICK_COLOR,
|
|
41
41
|
strokeWidth: 2
|
|
42
42
|
},
|
|
43
43
|
fontFamily: e.typography.body1?.fontFamily,
|
|
44
44
|
fontSize: e.typography.fontSize,
|
|
45
45
|
textAnchor: "middle"
|
|
46
46
|
}
|
|
47
|
-
})),
|
|
47
|
+
})), D = (e) => ({
|
|
48
48
|
borderRadius: e.spacing(2),
|
|
49
|
-
color:
|
|
49
|
+
color: p.defaults.WHITE,
|
|
50
50
|
fontSize: "16px",
|
|
51
51
|
width: "16px",
|
|
52
52
|
height: "16px",
|
|
53
53
|
padding: "2px",
|
|
54
|
-
border: `1px solid ${
|
|
54
|
+
border: `1px solid ${p.defaults.WHITE}`,
|
|
55
55
|
boxSizing: "unset"
|
|
56
|
-
}),
|
|
56
|
+
}), O = { backgroundColor: p.incorrectWithIcon() }, k = { backgroundColor: p.correct() }, A = class extends c.Component {
|
|
57
57
|
static propTypes = {
|
|
58
|
-
defineChart:
|
|
59
|
-
error:
|
|
58
|
+
defineChart: l.bool,
|
|
59
|
+
error: l.any
|
|
60
60
|
};
|
|
61
61
|
constructor(e) {
|
|
62
62
|
super(e), this.state = { dialog: { open: !1 } };
|
|
@@ -113,16 +113,16 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
113
113
|
return n;
|
|
114
114
|
};
|
|
115
115
|
render() {
|
|
116
|
-
let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate:
|
|
116
|
+
let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate: o, top: c, graphProps: l, defineChart: u, chartingOptions: d, x: p, y: g, formattedValue: _, changeInteractiveEnabled: v, changeEditableEnabled: b, error: x, autoFocus: S, hiddenLabelRef: C, showCorrectness: E, language: A } = this.props;
|
|
117
117
|
if (!_) return null;
|
|
118
118
|
let j = {
|
|
119
|
-
correctnessIcon:
|
|
120
|
-
incorrectIcon:
|
|
121
|
-
correctIcon:
|
|
122
|
-
}, { dialog: M } = this.state, { changeEditable: N, changeInteractive: P } =
|
|
123
|
-
return /* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
x: i ? V :
|
|
119
|
+
correctnessIcon: D,
|
|
120
|
+
incorrectIcon: O,
|
|
121
|
+
correctIcon: k
|
|
122
|
+
}, { dialog: M } = this.state, { changeEditable: N, changeInteractive: P } = d || {}, F = parseInt(_.split("-")[0], 10), I = e[F], { editable: L, interactive: R, label: z, correctness: B } = I || {}, V = t(r({ label: z }, F)), H = (e || []).reduce((e, t) => (e && e.label ? e.label.length : 0) > (t && t.label ? t.label.length : 0) ? e : t, { label: "" }), U = x ? [...new Set(Object.values(x))].join(" ") : "";
|
|
123
|
+
return /* @__PURE__ */ h("g", { children: [
|
|
124
|
+
/* @__PURE__ */ h("foreignObject", {
|
|
125
|
+
x: i ? V : p - a / 2,
|
|
126
126
|
y: 18,
|
|
127
127
|
width: a,
|
|
128
128
|
height: 4,
|
|
@@ -130,14 +130,14 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
130
130
|
pointerEvents: "none",
|
|
131
131
|
overflow: "visible"
|
|
132
132
|
},
|
|
133
|
-
children: [F === 0 && /* @__PURE__ */
|
|
133
|
+
children: [F === 0 && /* @__PURE__ */ m(s, {
|
|
134
134
|
isHiddenLabel: !0,
|
|
135
|
-
inputRef:
|
|
135
|
+
inputRef: C,
|
|
136
136
|
disabled: !0,
|
|
137
137
|
mark: H,
|
|
138
138
|
graphProps: l,
|
|
139
139
|
barWidth: a
|
|
140
|
-
}), /* @__PURE__ */
|
|
140
|
+
}), /* @__PURE__ */ m(s, {
|
|
141
141
|
autoFocus: u && S,
|
|
142
142
|
inputRef: (e) => this.input = e,
|
|
143
143
|
disabled: !u && !L,
|
|
@@ -145,31 +145,31 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
145
145
|
graphProps: l,
|
|
146
146
|
onChange: (e) => this.changeCategory(F, e),
|
|
147
147
|
barWidth: a,
|
|
148
|
-
rotate:
|
|
148
|
+
rotate: o,
|
|
149
149
|
correctness: B,
|
|
150
150
|
error: x && x[F],
|
|
151
|
-
ariaLabel:
|
|
151
|
+
ariaLabel: y.t("charting.categoryLabel", {
|
|
152
152
|
lng: A,
|
|
153
153
|
index: F + 1
|
|
154
154
|
}),
|
|
155
155
|
limitCharacters: !0,
|
|
156
|
-
correctnessIndicator:
|
|
156
|
+
correctnessIndicator: E && B && /* @__PURE__ */ m(n, {
|
|
157
157
|
correctness: B,
|
|
158
158
|
interactive: R,
|
|
159
159
|
classes: j
|
|
160
160
|
})
|
|
161
161
|
})]
|
|
162
162
|
}),
|
|
163
|
-
x && F === 0 && /* @__PURE__ */
|
|
163
|
+
x && F === 0 && /* @__PURE__ */ m(w, {
|
|
164
164
|
y: g + 23,
|
|
165
165
|
height: 6,
|
|
166
166
|
textAnchor: "start",
|
|
167
167
|
children: U
|
|
168
168
|
}),
|
|
169
|
-
u && F === 0 && /* @__PURE__ */
|
|
169
|
+
u && F === 0 && /* @__PURE__ */ h("svg", {
|
|
170
170
|
x: -55,
|
|
171
171
|
style: { overflow: "visible" },
|
|
172
|
-
children: [
|
|
172
|
+
children: [v && /* @__PURE__ */ m("text", {
|
|
173
173
|
y: g + 90 + c,
|
|
174
174
|
width: a,
|
|
175
175
|
height: 4,
|
|
@@ -180,12 +180,12 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
180
180
|
maxWidth: a,
|
|
181
181
|
display: "inline-block"
|
|
182
182
|
},
|
|
183
|
-
children: this.splitText(P?.authoringLabel, 20).map((e, t) => /* @__PURE__ */
|
|
183
|
+
children: this.splitText(P?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ m("tspan", {
|
|
184
184
|
x: "0",
|
|
185
185
|
dy: `${t > 0 ? "1.2em" : ".6em"}`,
|
|
186
186
|
children: e
|
|
187
187
|
}, t))
|
|
188
|
-
}), b && /* @__PURE__ */
|
|
188
|
+
}), b && /* @__PURE__ */ m("text", {
|
|
189
189
|
y: g + 145 + c,
|
|
190
190
|
width: a,
|
|
191
191
|
height: 4,
|
|
@@ -196,15 +196,15 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
196
196
|
maxWidth: a,
|
|
197
197
|
display: "inline-block"
|
|
198
198
|
},
|
|
199
|
-
children: this.splitText(N?.authoringLabel, 20).map((e, t) => /* @__PURE__ */
|
|
199
|
+
children: this.splitText(N?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ m("tspan", {
|
|
200
200
|
x: "0",
|
|
201
201
|
dy: `${t > 0 ? "1.2em" : ".6em"}`,
|
|
202
202
|
children: e
|
|
203
203
|
}, t))
|
|
204
204
|
})]
|
|
205
205
|
}),
|
|
206
|
-
u &&
|
|
207
|
-
x:
|
|
206
|
+
u && v && /* @__PURE__ */ m("foreignObject", {
|
|
207
|
+
x: p - 24,
|
|
208
208
|
y: g + 80 + c,
|
|
209
209
|
width: a,
|
|
210
210
|
height: 4,
|
|
@@ -212,14 +212,14 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
212
212
|
pointerEvents: "visible",
|
|
213
213
|
overflow: "visible"
|
|
214
214
|
},
|
|
215
|
-
children: /* @__PURE__ */
|
|
215
|
+
children: /* @__PURE__ */ m(T, {
|
|
216
216
|
style: { position: "fixed" },
|
|
217
217
|
checked: R,
|
|
218
218
|
onChange: (e) => this.changeInteractive(F, e.target.checked)
|
|
219
219
|
})
|
|
220
220
|
}),
|
|
221
|
-
u && b && /* @__PURE__ */
|
|
222
|
-
x:
|
|
221
|
+
u && b && /* @__PURE__ */ m("foreignObject", {
|
|
222
|
+
x: p - 24,
|
|
223
223
|
y: g + 130 + c,
|
|
224
224
|
width: a,
|
|
225
225
|
height: 4,
|
|
@@ -227,14 +227,14 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
227
227
|
pointerEvents: "visible",
|
|
228
228
|
overflow: "visible"
|
|
229
229
|
},
|
|
230
|
-
children: /* @__PURE__ */
|
|
230
|
+
children: /* @__PURE__ */ m(T, {
|
|
231
231
|
style: { position: "fixed" },
|
|
232
232
|
checked: L,
|
|
233
233
|
onChange: (e) => this.changeEditable(F, e.target.checked)
|
|
234
234
|
})
|
|
235
235
|
}),
|
|
236
|
-
/* @__PURE__ */
|
|
237
|
-
x:
|
|
236
|
+
/* @__PURE__ */ m("foreignObject", {
|
|
237
|
+
x: p - 24,
|
|
238
238
|
y: g + 100 + c,
|
|
239
239
|
width: a,
|
|
240
240
|
height: 4,
|
|
@@ -242,7 +242,7 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
242
242
|
pointerEvents: "visible",
|
|
243
243
|
overflow: "visible"
|
|
244
244
|
},
|
|
245
|
-
children: /* @__PURE__ */ f
|
|
245
|
+
children: /* @__PURE__ */ m(f, {
|
|
246
246
|
open: M.open,
|
|
247
247
|
title: M.title,
|
|
248
248
|
text: M.text,
|
|
@@ -253,56 +253,70 @@ var C = l("text")(({ theme: e }) => ({
|
|
|
253
253
|
] });
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
|
-
|
|
257
|
-
categories:
|
|
258
|
-
xBand:
|
|
259
|
-
bandWidth:
|
|
260
|
-
barWidth:
|
|
261
|
-
rotate:
|
|
262
|
-
top:
|
|
263
|
-
x:
|
|
264
|
-
y:
|
|
265
|
-
graphProps:
|
|
266
|
-
formattedValue:
|
|
267
|
-
onChangeCategory:
|
|
268
|
-
onChange:
|
|
269
|
-
error:
|
|
270
|
-
defineChart:
|
|
271
|
-
chartingOptions:
|
|
272
|
-
changeInteractiveEnabled:
|
|
273
|
-
changeEditableEnabled:
|
|
274
|
-
autoFocus:
|
|
275
|
-
onAutoFocusUsed:
|
|
276
|
-
showCorrectness:
|
|
277
|
-
hiddenLabelRef:
|
|
278
|
-
language:
|
|
256
|
+
A.propTypes = {
|
|
257
|
+
categories: l.array,
|
|
258
|
+
xBand: l.func,
|
|
259
|
+
bandWidth: l.number,
|
|
260
|
+
barWidth: l.number,
|
|
261
|
+
rotate: l.number,
|
|
262
|
+
top: l.number,
|
|
263
|
+
x: l.number,
|
|
264
|
+
y: l.number,
|
|
265
|
+
graphProps: l.object,
|
|
266
|
+
formattedValue: l.string,
|
|
267
|
+
onChangeCategory: l.func,
|
|
268
|
+
onChange: l.func,
|
|
269
|
+
error: l.object,
|
|
270
|
+
defineChart: l.bool,
|
|
271
|
+
chartingOptions: l.object,
|
|
272
|
+
changeInteractiveEnabled: l.bool,
|
|
273
|
+
changeEditableEnabled: l.bool,
|
|
274
|
+
autoFocus: l.bool,
|
|
275
|
+
onAutoFocusUsed: l.func,
|
|
276
|
+
showCorrectness: l.bool,
|
|
277
|
+
hiddenLabelRef: l.oneOfType([l.func, l.shape({ current: l.instanceOf(Element) })]),
|
|
278
|
+
language: l.string
|
|
279
279
|
};
|
|
280
|
-
var
|
|
280
|
+
var j = class extends c.Component {
|
|
281
281
|
static propTypes = {
|
|
282
|
-
bottomScale:
|
|
283
|
-
categories:
|
|
284
|
-
defineChart:
|
|
285
|
-
error:
|
|
286
|
-
graphProps:
|
|
287
|
-
xBand:
|
|
288
|
-
leftAxis:
|
|
289
|
-
onChange:
|
|
290
|
-
onChangeCategory:
|
|
291
|
-
top:
|
|
292
|
-
theme:
|
|
293
|
-
chartingOptions:
|
|
294
|
-
changeInteractiveEnabled:
|
|
295
|
-
changeEditableEnabled:
|
|
296
|
-
autoFocus:
|
|
297
|
-
onAutoFocusUsed:
|
|
298
|
-
showCorrectness:
|
|
299
|
-
hiddenLabelRef:
|
|
300
|
-
language:
|
|
282
|
+
bottomScale: l.func,
|
|
283
|
+
categories: l.array,
|
|
284
|
+
defineChart: l.bool,
|
|
285
|
+
error: l.any,
|
|
286
|
+
graphProps: d.GraphPropsType.isRequired,
|
|
287
|
+
xBand: l.func,
|
|
288
|
+
leftAxis: l.bool,
|
|
289
|
+
onChange: l.func,
|
|
290
|
+
onChangeCategory: l.func,
|
|
291
|
+
top: l.number,
|
|
292
|
+
theme: l.object,
|
|
293
|
+
chartingOptions: l.object,
|
|
294
|
+
changeInteractiveEnabled: l.bool,
|
|
295
|
+
changeEditableEnabled: l.bool,
|
|
296
|
+
autoFocus: l.bool,
|
|
297
|
+
onAutoFocusUsed: l.func,
|
|
298
|
+
showCorrectness: l.bool,
|
|
299
|
+
hiddenLabelRef: l.oneOfType([l.func, l.shape({ current: l.instanceOf(Element) })]),
|
|
300
|
+
language: l.string,
|
|
301
|
+
onLabelOverhang: l.func
|
|
301
302
|
};
|
|
302
303
|
state = {
|
|
303
304
|
height: 0,
|
|
304
305
|
width: 0
|
|
305
306
|
};
|
|
307
|
+
reportedOverhang = 0;
|
|
308
|
+
labelLayout = () => {
|
|
309
|
+
let { graphProps: e, xBand: t, categories: n = [], theme: r } = this.props, { scale: a = {}, domain: o = {} } = e || {}, { height: s, width: c } = this.state, l = t && typeof t.bandwidth == "function" && t.bandwidth(), u = l || a.x && a.x(o.max) / n.length;
|
|
310
|
+
return {
|
|
311
|
+
bandWidth: l,
|
|
312
|
+
barWidth: u,
|
|
313
|
+
rotate: i(r && r.typography ? r.typography.fontSize : 14, s) || (c > u ? 25 : 0)
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
reportLabelOverhang = () => {
|
|
317
|
+
let { onLabelOverhang: e } = this.props, { height: t, width: n } = this.state, r = a(n, t, this.labelLayout().rotate);
|
|
318
|
+
e && r !== this.reportedOverhang && (this.reportedOverhang = r, e(r));
|
|
319
|
+
};
|
|
306
320
|
measureHiddenLabel = () => {
|
|
307
321
|
if (!this.hiddenLabelRef) return;
|
|
308
322
|
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);
|
|
@@ -317,68 +331,71 @@ var A = class extends s.Component {
|
|
|
317
331
|
observeHiddenLabel = (e) => {
|
|
318
332
|
if (!e) return;
|
|
319
333
|
let t = e.querySelector("[data-latex], [data-raw]");
|
|
320
|
-
t &&
|
|
334
|
+
t && _(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(), S(this._onDocMutation), this.observeHiddenLabelSize(e);
|
|
335
|
+
};
|
|
336
|
+
observeHiddenLabelSize = (e) => {
|
|
337
|
+
e === this._sizedLabel || typeof ResizeObserver > "u" || (this._sizeObserver?.disconnect(), this._sizedLabel = e, this._sizeObserver = new ResizeObserver(() => this.measureHiddenLabel()), this._sizeObserver.observe(e));
|
|
321
338
|
};
|
|
322
339
|
setHiddenLabelRef = (e) => {
|
|
323
340
|
e && e !== this.hiddenLabelRef && (this.hiddenLabelRef = e, this.observeHiddenLabel(e));
|
|
324
341
|
};
|
|
325
342
|
componentDidMount() {
|
|
326
|
-
this.hiddenLabelRef && this.observeHiddenLabel(this.hiddenLabelRef);
|
|
343
|
+
this.hiddenLabelRef && this.observeHiddenLabel(this.hiddenLabelRef), this.reportLabelOverhang();
|
|
327
344
|
}
|
|
328
345
|
componentWillUnmount() {
|
|
329
|
-
|
|
346
|
+
C(this._onDocMutation), this._sizeObserver?.disconnect(), this._sizedLabel = null, this._updateTimer && clearTimeout(this._updateTimer);
|
|
330
347
|
}
|
|
331
348
|
componentDidUpdate(e) {
|
|
332
|
-
e.categories !== this.props.categories && (this._updateTimer && clearTimeout(this._updateTimer), this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50));
|
|
349
|
+
e.categories !== this.props.categories && (this._updateTimer && clearTimeout(this._updateTimer), this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50)), this.reportLabelOverhang();
|
|
333
350
|
}
|
|
334
351
|
render() {
|
|
335
|
-
let { graphProps: n, xBand: r, leftAxis:
|
|
336
|
-
...
|
|
337
|
-
step:
|
|
338
|
-
})
|
|
339
|
-
return /* @__PURE__ */
|
|
340
|
-
scale:
|
|
352
|
+
let { graphProps: n, xBand: r, leftAxis: i, onChange: a, onChangeCategory: s, categories: c = [], top: l, defineChart: u, chartingOptions: d, changeInteractiveEnabled: f, changeEditableEnabled: p, autoFocus: g, 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: D, rotate: O } = this.labelLayout(), k = o({
|
|
353
|
+
...S,
|
|
354
|
+
step: S.labelStep
|
|
355
|
+
});
|
|
356
|
+
return /* @__PURE__ */ h(E, { children: [i && /* @__PURE__ */ m(e, {
|
|
357
|
+
scale: x.y,
|
|
341
358
|
tickLength: 10,
|
|
342
359
|
tickFormat: (e) => e,
|
|
343
|
-
tickValues:
|
|
360
|
+
tickValues: k,
|
|
344
361
|
tickLabelProps: (e) => ({
|
|
345
362
|
dy: 4,
|
|
346
363
|
dx: -10 - (e.toLocaleString().length || 1) * 5
|
|
347
364
|
})
|
|
348
|
-
}), /* @__PURE__ */
|
|
349
|
-
scale:
|
|
350
|
-
labelProps: { y: 60 +
|
|
351
|
-
top:
|
|
365
|
+
}), /* @__PURE__ */ m(t, {
|
|
366
|
+
scale: w,
|
|
367
|
+
labelProps: { y: 60 + l },
|
|
368
|
+
top: x.y && x.y(S.min),
|
|
352
369
|
textLabelProps: () => ({ textAnchor: "middle" }),
|
|
353
370
|
tickFormat: (e) => e,
|
|
354
|
-
tickComponent: (e) => /* @__PURE__ */
|
|
371
|
+
tickComponent: (e) => /* @__PURE__ */ m(A, {
|
|
355
372
|
hiddenLabelRef: this.setHiddenLabelRef,
|
|
356
|
-
categories:
|
|
373
|
+
categories: c,
|
|
357
374
|
xBand: r,
|
|
358
|
-
bandWidth:
|
|
359
|
-
barWidth:
|
|
360
|
-
rotate:
|
|
361
|
-
top:
|
|
362
|
-
defineChart:
|
|
363
|
-
chartingOptions:
|
|
364
|
-
autoFocus:
|
|
365
|
-
onAutoFocusUsed:
|
|
366
|
-
error:
|
|
367
|
-
onChangeCategory:
|
|
368
|
-
changeInteractiveEnabled:
|
|
369
|
-
changeEditableEnabled:
|
|
370
|
-
onChange:
|
|
375
|
+
bandWidth: T,
|
|
376
|
+
barWidth: D,
|
|
377
|
+
rotate: O,
|
|
378
|
+
top: l,
|
|
379
|
+
defineChart: u,
|
|
380
|
+
chartingOptions: d,
|
|
381
|
+
autoFocus: g,
|
|
382
|
+
onAutoFocusUsed: _,
|
|
383
|
+
error: v,
|
|
384
|
+
onChangeCategory: s,
|
|
385
|
+
changeInteractiveEnabled: f,
|
|
386
|
+
changeEditableEnabled: p,
|
|
387
|
+
onChange: a,
|
|
371
388
|
graphProps: n,
|
|
372
389
|
x: e.x,
|
|
373
390
|
y: e.y,
|
|
374
391
|
formattedValue: e.formattedValue,
|
|
375
|
-
showCorrectness:
|
|
376
|
-
language:
|
|
392
|
+
showCorrectness: y,
|
|
393
|
+
language: b
|
|
377
394
|
}),
|
|
378
|
-
autoFocus:
|
|
379
|
-
onAutoFocusUsed:
|
|
395
|
+
autoFocus: g,
|
|
396
|
+
onAutoFocusUsed: _
|
|
380
397
|
})] });
|
|
381
398
|
}
|
|
382
399
|
};
|
|
383
400
|
//#endregion
|
|
384
|
-
export {
|
|
401
|
+
export { j as RawChartAxes, j as default, A as TickComponent };
|
package/dist/bars/common/bars.js
CHANGED
|
@@ -8,8 +8,8 @@ import s from "prop-types";
|
|
|
8
8
|
import { styled as c } from "@mui/material/styles";
|
|
9
9
|
import l from "debug";
|
|
10
10
|
import { types as u } from "@pie-lib/plot";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { color as d } from "@pie-lib/render-ui";
|
|
12
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
13
13
|
//#region src/bars/common/bars.tsx
|
|
14
14
|
var h = l("pie-lib:chart:bars"), g = [
|
|
15
15
|
"#006699",
|
|
@@ -37,7 +37,7 @@ var h = l("pie-lib:chart:bars"), g = [
|
|
|
37
37
|
"#167A7A",
|
|
38
38
|
"#91862D",
|
|
39
39
|
"#894A65"
|
|
40
|
-
], v = (e, t, n, r, i) => e && t && i ? r[n % r.length] : e && i ?
|
|
40
|
+
], v = (e, t, n, r, i) => e && t && i ? r[n % r.length] : e && i ? d.visualElementsColors.ROLLOVER_FILL_BAR_COLOR : t || null, y = c(t)(() => ({ fill: d.defaults.TERTIARY })), b = class extends o.Component {
|
|
41
41
|
static propTypes = {
|
|
42
42
|
barColor: s.string,
|
|
43
43
|
onChangeCategory: s.func,
|
|
@@ -90,14 +90,14 @@ var h = l("pie-lib:chart:bars"), g = [
|
|
|
90
90
|
};
|
|
91
91
|
render() {
|
|
92
92
|
let { graphProps: e, value: t, label: o, xBand: s, index: c, interactive: l, correctness: u, barColor: h, defineChart: g, correctData: b } = this.props, { scale: x, range: S } = e, { dragValue: C, isHovered: w } = this.state, T = v(w, h, c, _, l && !u), E = Number.isFinite(C) ? C : t, D = s.bandwidth(), O = x.y(S.max - E), k = s(n({ label: o }, c)), A = S.max - E, j = S.max - A, M = b ? b.find((e) => e.label === o) : null, N = l ? r : i, P = !!h;
|
|
93
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ m("g", {
|
|
94
94
|
ref: (e) => this.gRef = e,
|
|
95
95
|
onMouseEnter: this.handleMouseEnter,
|
|
96
96
|
onMouseLeave: this.handleMouseLeave,
|
|
97
97
|
onTouchStart: this.handleMouseEnter,
|
|
98
98
|
onTouchEnd: this.handleMouseLeave,
|
|
99
99
|
children: [
|
|
100
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ p(y, {
|
|
101
101
|
x: k,
|
|
102
102
|
y: x.y(j),
|
|
103
103
|
width: D,
|
|
@@ -107,8 +107,8 @@ var h = l("pie-lib:chart:bars"), g = [
|
|
|
107
107
|
u && u.value === "incorrect" && (() => {
|
|
108
108
|
let e = parseFloat(M && M.value);
|
|
109
109
|
if (isNaN(e)) return null;
|
|
110
|
-
let t = x.y(S.max - e), n = O, r = Math.abs(t - n), i = x.y(e), o = t > n ?
|
|
111
|
-
return /* @__PURE__ */
|
|
110
|
+
let t = x.y(S.max - e), n = O, r = Math.abs(t - n), i = x.y(e), o = t > n ? d.borderGray() : d.defaults.WHITE, s = t > n ? i : i - r;
|
|
111
|
+
return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(y, {
|
|
112
112
|
x: k + 2,
|
|
113
113
|
y: s,
|
|
114
114
|
width: D - 4,
|
|
@@ -119,15 +119,15 @@ var h = l("pie-lib:chart:bars"), g = [
|
|
|
119
119
|
strokeDasharray: "5,2",
|
|
120
120
|
fill: "none"
|
|
121
121
|
}
|
|
122
|
-
}), /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ p("foreignObject", {
|
|
123
123
|
x: k + D - (P ? 24 : 14),
|
|
124
124
|
y: i - 12,
|
|
125
125
|
width: 24,
|
|
126
126
|
height: 24,
|
|
127
|
-
children: /* @__PURE__ */
|
|
127
|
+
children: /* @__PURE__ */ p(a, { dashColor: o })
|
|
128
128
|
})] });
|
|
129
129
|
})(),
|
|
130
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ p(N, {
|
|
131
131
|
x: k,
|
|
132
132
|
y: E,
|
|
133
133
|
defineChart: g,
|
|
@@ -155,7 +155,7 @@ var h = l("pie-lib:chart:bars"), g = [
|
|
|
155
155
|
};
|
|
156
156
|
render() {
|
|
157
157
|
let { data: t, graphProps: n, xBand: r, onChangeCategory: i, defineChart: a, histogram: o, correctData: s } = this.props;
|
|
158
|
-
return /* @__PURE__ */
|
|
158
|
+
return /* @__PURE__ */ p(e, { children: (t || []).map((e, t) => /* @__PURE__ */ p(x, {
|
|
159
159
|
value: e.value,
|
|
160
160
|
interactive: a || e.interactive,
|
|
161
161
|
defineChart: a,
|