@pie-lib/charting 8.0.5 → 8.0.6-next.20261016071127

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/dist/axes.d.ts CHANGED
@@ -14,6 +14,18 @@ export declare class TickComponent extends React.Component {
14
14
  splitText: any;
15
15
  render(): React.JSX.Element | null;
16
16
  }
17
+ export declare const RangeTickLabel: {
18
+ ({ x, y, formattedValue }: {
19
+ x: any;
20
+ y: any;
21
+ formattedValue: any;
22
+ }): React.JSX.Element;
23
+ propTypes: {
24
+ x: PropTypes.Requireable<number>;
25
+ y: PropTypes.Requireable<number>;
26
+ formattedValue: PropTypes.Requireable<string>;
27
+ };
28
+ };
17
29
  export declare class RawChartAxes extends React.Component {
18
30
  static propTypes: {
19
31
  bottomScale: PropTypes.Requireable<(...args: any[]) => any>;
@@ -61,15 +73,19 @@ export declare class RawChartAxes extends React.Component {
61
73
  }> | null | undefined>>;
62
74
  language: PropTypes.Requireable<string>;
63
75
  onLabelOverhang: PropTypes.Requireable<(...args: any[]) => any>;
76
+ onRangeLabelOverhang: PropTypes.Requireable<(...args: any[]) => any>;
64
77
  };
65
78
  state: {
66
79
  height: number;
67
80
  width: number;
68
81
  labelHeight: number;
82
+ rangeLabelWidth: number;
69
83
  };
70
84
  reportedOverhang: number;
85
+ reportedRangeOverhang: number;
71
86
  labelLayout: any;
72
87
  reportLabelOverhang: any;
88
+ reportRangeLabelOverhang: any;
73
89
  measureHiddenLabel: any;
74
90
  _onDocMutation: any;
75
91
  observeHiddenLabel: any;
package/dist/axes.js CHANGED
@@ -3,60 +3,60 @@ import t from "./node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_module
3
3
  import { TickCorrectnessIndicator as n } from "./common/correctness-indicators.js";
4
4
  import { bandKey as r, getRotateAngle as i, getRotatedLabelOverhang as a, getTickValues as o, textOf as s } from "./utils.js";
5
5
  import { MarkLabel as c } from "./mark-label.js";
6
- import l from "react";
7
- import u from "prop-types";
8
- import { styled as d } from "@mui/material/styles";
9
- import { types as f } from "@pie-lib/plot";
10
- import { AlertDialog as p } from "@pie-lib/config-ui";
11
- import { color as m } from "@pie-lib/render-ui";
12
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
- import _ from "@mui/material/Checkbox";
14
- import { renderMath as v } from "@pie-element/shared-math-rendering-mathjax";
15
- import y from "@pie-lib/translator";
6
+ import l, { useEffect as u, useRef as d } from "react";
7
+ import f from "prop-types";
8
+ import { styled as p } from "@mui/material/styles";
9
+ import { types as m } from "@pie-lib/plot";
10
+ import { AlertDialog as h } from "@pie-lib/config-ui";
11
+ import { color as g } from "@pie-lib/render-ui";
12
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
13
+ import y from "@mui/material/Checkbox";
14
+ import { renderMath as b } from "@pie-element/shared-math-rendering-mathjax";
15
+ import x from "@pie-lib/translator";
16
16
  //#region src/axes.tsx
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, {
17
+ var { translator: S } = x, C = 24, w = -110, T = 12, E = /* @__PURE__ */ new Set(), D = null;
18
+ function O(e) {
19
+ E.add(e), !D && typeof document < "u" && (D = new MutationObserver(() => {
20
+ E.forEach((e) => e());
21
+ }), D.observe(document.body, {
22
22
  childList: !0,
23
23
  subtree: !0
24
24
  }));
25
25
  }
26
- function T(e) {
27
- S.delete(e), S.size === 0 && C && (C.disconnect(), C = null);
26
+ function k(e) {
27
+ E.delete(e), E.size === 0 && D && (D.disconnect(), D = null);
28
28
  }
29
- var E = d("text")(({ theme: e }) => ({
29
+ var A = p("text")(({ theme: e }) => ({
30
30
  fontSize: e.typography.fontSize - 2,
31
31
  fill: e.palette.error.main
32
- })), D = d(_)(() => ({ color: `${m.tertiary()} !important` })), O = d("g")(({ theme: e }) => ({
32
+ })), j = p(y)(() => ({ color: `${g.tertiary()} !important` })), M = p("g")(({ theme: e }) => ({
33
33
  "& .vx-axis-line": {
34
- stroke: m.visualElementsColors.AXIS_LINE_COLOR,
34
+ stroke: g.visualElementsColors.AXIS_LINE_COLOR,
35
35
  strokeWidth: 2
36
36
  },
37
37
  "& .vx-axis-tick": {
38
- fill: m.visualElementsColors.AXIS_TICK_COLOR,
38
+ fill: g.visualElementsColors.AXIS_TICK_COLOR,
39
39
  "& line": {
40
- stroke: m.visualElementsColors.AXIS_TICK_COLOR,
40
+ stroke: g.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
- })), k = (e) => ({
47
+ })), N = (e) => ({
48
48
  borderRadius: e.spacing(2),
49
- color: m.defaults.WHITE,
49
+ color: g.defaults.WHITE,
50
50
  fontSize: "16px",
51
51
  width: "16px",
52
52
  height: "16px",
53
53
  padding: "2px",
54
- border: `1px solid ${m.defaults.WHITE}`,
54
+ border: `1px solid ${g.defaults.WHITE}`,
55
55
  boxSizing: "unset"
56
- }), A = { backgroundColor: m.incorrectWithIcon() }, j = { backgroundColor: m.correct() }, M = class extends l.Component {
56
+ }), P = { backgroundColor: g.incorrectWithIcon() }, F = { backgroundColor: g.correct() }, I = class extends l.Component {
57
57
  static propTypes = {
58
- defineChart: u.bool,
59
- error: u.any
58
+ defineChart: f.bool,
59
+ error: f.any
60
60
  };
61
61
  constructor(e) {
62
62
  super(e), this.state = { dialog: { open: !1 } };
@@ -113,16 +113,16 @@ var E = 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: T, language: O } = this.props;
117
- if (!v) return null;
118
- let M = {
119
- correctnessIcon: k,
120
- incorrectIcon: A,
121
- correctIcon: j
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
- return /* @__PURE__ */ g("g", { children: [
124
- /* @__PURE__ */ g("foreignObject", {
125
- x: i ? H : m - a / 2,
116
+ let { categories: e, xBand: t, bandWidth: i, barWidth: a, rotate: o, top: l, graphProps: u, defineChart: d, chartingOptions: f, x: p, y: m, formattedValue: g, changeInteractiveEnabled: y, changeEditableEnabled: b, error: x, autoFocus: C, hiddenLabelRef: E, showCorrectness: D, language: O } = this.props;
117
+ if (!g) return null;
118
+ let k = {
119
+ correctnessIcon: N,
120
+ incorrectIcon: P,
121
+ correctIcon: F
122
+ }, { dialog: M } = this.state, { changeEditable: I, changeInteractive: L } = f || {}, R = parseInt(g.split("-")[0], 10), z = e[R], { editable: B, interactive: V, label: H, correctness: U } = z || {}, W = t(r({ label: H }, R)), G = (e || []).reduce((e, t) => (e && e.label ? e.label.length : 0) > (t && t.label ? t.label.length : 0) ? e : t, { label: "" }), K = x ? [...new Set(Object.values(x))].join(" ") : "";
123
+ return /* @__PURE__ */ v("g", { children: [
124
+ /* @__PURE__ */ v("foreignObject", {
125
+ x: i ? W : p - a / 2,
126
126
  y: 18,
127
127
  width: a,
128
128
  height: 4,
@@ -130,53 +130,53 @@ var E = d("text")(({ theme: e }) => ({
130
130
  pointerEvents: "none",
131
131
  overflow: "visible"
132
132
  },
133
- children: [I === 0 && /* @__PURE__ */ h(c, {
133
+ children: [R === 0 && /* @__PURE__ */ _(c, {
134
134
  isHiddenLabel: !0,
135
- inputRef: w,
135
+ inputRef: E,
136
136
  disabled: !0,
137
- mark: U,
137
+ mark: G,
138
138
  graphProps: u,
139
139
  barWidth: a
140
- }), /* @__PURE__ */ h(c, {
140
+ }), /* @__PURE__ */ _(c, {
141
141
  autoFocus: d && C,
142
142
  inputRef: (e) => this.input = e,
143
- disabled: !d && !R,
144
- mark: L,
143
+ disabled: !d && !B,
144
+ mark: z,
145
145
  graphProps: u,
146
- onChange: (e) => this.changeCategory(I, e),
146
+ onChange: (e) => this.changeCategory(R, e),
147
147
  barWidth: a,
148
148
  rotate: o,
149
- correctness: V,
150
- error: S && S[I],
151
- ariaLabel: b.t("charting.categoryLabel", {
149
+ correctness: U,
150
+ error: x && x[R],
151
+ ariaLabel: S.t("charting.categoryLabel", {
152
152
  lng: O,
153
- index: I + 1
153
+ index: R + 1
154
154
  }),
155
- mathAriaLabel: b.t("charting.categoryLabelValue", {
155
+ mathAriaLabel: S.t("charting.categoryLabelValue", {
156
156
  lng: O,
157
- index: I + 1,
158
- label: s(B),
157
+ index: R + 1,
158
+ label: s(H),
159
159
  interpolation: { escapeValue: !1 }
160
160
  }),
161
161
  limitCharacters: !0,
162
- correctnessIndicator: T && V && /* @__PURE__ */ h(n, {
163
- correctness: V,
164
- interactive: z,
165
- classes: M
162
+ correctnessIndicator: D && U && /* @__PURE__ */ _(n, {
163
+ correctness: U,
164
+ interactive: V,
165
+ classes: k
166
166
  })
167
167
  })]
168
168
  }),
169
- S && I === 0 && /* @__PURE__ */ h(E, {
170
- y: _ + 23,
169
+ x && R === 0 && /* @__PURE__ */ _(A, {
170
+ y: m + 23,
171
171
  height: 6,
172
172
  textAnchor: "start",
173
- children: W
173
+ children: K
174
174
  }),
175
- d && I === 0 && /* @__PURE__ */ g("svg", {
176
- x: -100,
175
+ d && R === 0 && /* @__PURE__ */ v("svg", {
176
+ x: w,
177
177
  style: { overflow: "visible" },
178
- children: [y && /* @__PURE__ */ h("text", {
179
- y: _ + 90 + l,
178
+ children: [y && /* @__PURE__ */ _("text", {
179
+ y: m + 90 + l,
180
180
  width: a,
181
181
  height: 4,
182
182
  style: {
@@ -186,13 +186,13 @@ var E = d("text")(({ theme: e }) => ({
186
186
  maxWidth: a,
187
187
  display: "inline-block"
188
188
  },
189
- children: this.splitText(F?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ h("tspan", {
189
+ children: this.splitText(L?.authoringLabel, T).map((e, t) => /* @__PURE__ */ _("tspan", {
190
190
  x: "0",
191
191
  dy: `${t > 0 ? "1.2em" : ".6em"}`,
192
192
  children: e
193
193
  }, t))
194
- }), x && /* @__PURE__ */ h("text", {
195
- y: _ + 145 + l,
194
+ }), b && /* @__PURE__ */ _("text", {
195
+ y: m + 145 + l,
196
196
  width: a,
197
197
  height: 4,
198
198
  style: {
@@ -202,116 +202,151 @@ var E = d("text")(({ theme: e }) => ({
202
202
  maxWidth: a,
203
203
  display: "inline-block"
204
204
  },
205
- children: this.splitText(P?.authoringLabel, 20).map((e, t) => /* @__PURE__ */ h("tspan", {
205
+ children: this.splitText(I?.authoringLabel, T).map((e, t) => /* @__PURE__ */ _("tspan", {
206
206
  x: "0",
207
207
  dy: `${t > 0 ? "1.2em" : ".6em"}`,
208
208
  children: e
209
209
  }, t))
210
210
  })]
211
211
  }),
212
- d && y && /* @__PURE__ */ h("foreignObject", {
213
- x: m - 24,
214
- y: _ + 80 + l,
212
+ d && y && /* @__PURE__ */ _("foreignObject", {
213
+ x: p - 24,
214
+ y: m + 80 + l,
215
215
  width: a,
216
216
  height: 4,
217
217
  style: {
218
218
  pointerEvents: "visible",
219
219
  overflow: "visible"
220
220
  },
221
- children: /* @__PURE__ */ h(D, {
221
+ children: /* @__PURE__ */ _(j, {
222
222
  style: { position: "fixed" },
223
- checked: z,
224
- onChange: (e) => this.changeInteractive(I, e.target.checked)
223
+ checked: V,
224
+ onChange: (e) => this.changeInteractive(R, e.target.checked)
225
225
  })
226
226
  }),
227
- d && x && /* @__PURE__ */ h("foreignObject", {
228
- x: m - 24,
229
- y: _ + 130 + l,
227
+ d && b && /* @__PURE__ */ _("foreignObject", {
228
+ x: p - 24,
229
+ y: m + 130 + l,
230
230
  width: a,
231
231
  height: 4,
232
232
  style: {
233
233
  pointerEvents: "visible",
234
234
  overflow: "visible"
235
235
  },
236
- children: /* @__PURE__ */ h(D, {
236
+ children: /* @__PURE__ */ _(j, {
237
237
  style: { position: "fixed" },
238
- checked: R,
239
- onChange: (e) => this.changeEditable(I, e.target.checked)
238
+ checked: B,
239
+ onChange: (e) => this.changeEditable(R, e.target.checked)
240
240
  })
241
241
  }),
242
- /* @__PURE__ */ h("foreignObject", {
243
- x: m - 24,
244
- y: _ + 100 + l,
242
+ /* @__PURE__ */ _("foreignObject", {
243
+ x: p - 24,
244
+ y: m + 100 + l,
245
245
  width: a,
246
246
  height: 4,
247
247
  style: {
248
248
  pointerEvents: "visible",
249
249
  overflow: "visible"
250
250
  },
251
- children: /* @__PURE__ */ h(p, {
252
- open: N.open,
253
- title: N.title,
254
- text: N.text,
255
- onClose: N.onClose,
256
- onConfirm: N.onConfirm
251
+ children: /* @__PURE__ */ _(h, {
252
+ open: M.open,
253
+ title: M.title,
254
+ text: M.text,
255
+ onClose: M.onClose,
256
+ onConfirm: M.onConfirm
257
257
  })
258
258
  })
259
259
  ] });
260
260
  }
261
261
  };
262
- M.propTypes = {
263
- categories: u.array,
264
- xBand: u.func,
265
- bandWidth: u.number,
266
- barWidth: u.number,
267
- rotate: u.number,
268
- top: u.number,
269
- x: u.number,
270
- y: u.number,
271
- graphProps: u.object,
272
- formattedValue: u.string,
273
- onChangeCategory: u.func,
274
- onChange: u.func,
275
- error: u.object,
276
- defineChart: u.bool,
277
- chartingOptions: u.object,
278
- changeInteractiveEnabled: u.bool,
279
- changeEditableEnabled: u.bool,
280
- autoFocus: u.bool,
281
- onAutoFocusUsed: u.func,
282
- showCorrectness: u.bool,
283
- hiddenLabelRef: u.oneOfType([u.func, u.shape({ current: u.instanceOf(Element) })]),
284
- language: u.string
262
+ I.propTypes = {
263
+ categories: f.array,
264
+ xBand: f.func,
265
+ bandWidth: f.number,
266
+ barWidth: f.number,
267
+ rotate: f.number,
268
+ top: f.number,
269
+ x: f.number,
270
+ y: f.number,
271
+ graphProps: f.object,
272
+ formattedValue: f.string,
273
+ onChangeCategory: f.func,
274
+ onChange: f.func,
275
+ error: f.object,
276
+ defineChart: f.bool,
277
+ chartingOptions: f.object,
278
+ changeInteractiveEnabled: f.bool,
279
+ changeEditableEnabled: f.bool,
280
+ autoFocus: f.bool,
281
+ onAutoFocusUsed: f.func,
282
+ showCorrectness: f.bool,
283
+ hiddenLabelRef: f.oneOfType([f.func, f.shape({ current: f.instanceOf(Element) })]),
284
+ language: f.string
285
285
  };
286
- var N = class extends l.Component {
286
+ var L = 80, R = 6, z = 18, B = p("div")(({ theme: e }) => ({
287
+ textAlign: "right",
288
+ fontSize: e.typography.fontSize + 2,
289
+ fontFamily: e.typography.fontFamily,
290
+ color: g.defaults.TEXT,
291
+ lineHeight: 1
292
+ })), V = ({ x: e, y: t, formattedValue: n }) => {
293
+ let r = d(null), i = `\\(${n}\\)`;
294
+ return u(() => {
295
+ let e = r.current;
296
+ e && (e.textContent = i, b(e));
297
+ }, [i]), /* @__PURE__ */ _("foreignObject", {
298
+ x: e - R - L,
299
+ y: t,
300
+ width: L,
301
+ height: 1,
302
+ style: {
303
+ pointerEvents: "none",
304
+ overflow: "visible"
305
+ },
306
+ children: /* @__PURE__ */ _(B, {
307
+ ref: r,
308
+ "data-range-label": !0,
309
+ style: { transform: "translateY(-50%)" }
310
+ })
311
+ });
312
+ };
313
+ V.propTypes = {
314
+ x: f.number,
315
+ y: f.number,
316
+ formattedValue: f.string
317
+ };
318
+ var H = class extends l.Component {
287
319
  static propTypes = {
288
- bottomScale: u.func,
289
- categories: u.array,
290
- defineChart: u.bool,
291
- error: u.any,
292
- graphProps: f.GraphPropsType.isRequired,
293
- xBand: u.func,
294
- leftAxis: u.bool,
295
- onChange: u.func,
296
- onChangeCategory: u.func,
297
- top: u.number,
298
- theme: u.object,
299
- chartingOptions: u.object,
300
- changeInteractiveEnabled: u.bool,
301
- changeEditableEnabled: u.bool,
302
- autoFocus: u.bool,
303
- onAutoFocusUsed: u.func,
304
- showCorrectness: u.bool,
305
- hiddenLabelRef: u.oneOfType([u.func, u.shape({ current: u.instanceOf(Element) })]),
306
- language: u.string,
307
- onLabelOverhang: u.func
320
+ bottomScale: f.func,
321
+ categories: f.array,
322
+ defineChart: f.bool,
323
+ error: f.any,
324
+ graphProps: m.GraphPropsType.isRequired,
325
+ xBand: f.func,
326
+ leftAxis: f.bool,
327
+ onChange: f.func,
328
+ onChangeCategory: f.func,
329
+ top: f.number,
330
+ theme: f.object,
331
+ chartingOptions: f.object,
332
+ changeInteractiveEnabled: f.bool,
333
+ changeEditableEnabled: f.bool,
334
+ autoFocus: f.bool,
335
+ onAutoFocusUsed: f.func,
336
+ showCorrectness: f.bool,
337
+ hiddenLabelRef: f.oneOfType([f.func, f.shape({ current: f.instanceOf(Element) })]),
338
+ language: f.string,
339
+ onLabelOverhang: f.func,
340
+ onRangeLabelOverhang: f.func
308
341
  };
309
342
  state = {
310
343
  height: 0,
311
344
  width: 0,
312
- labelHeight: 0
345
+ labelHeight: 0,
346
+ rangeLabelWidth: 0
313
347
  };
314
348
  reportedOverhang = 0;
349
+ reportedRangeOverhang = 0;
315
350
  labelLayout = () => {
316
351
  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;
317
352
  return {
@@ -321,18 +356,25 @@ var N = class extends l.Component {
321
356
  };
322
357
  };
323
358
  reportLabelOverhang = () => {
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);
359
+ let { onLabelOverhang: e } = this.props, { height: t, width: n, labelHeight: r } = this.state, i = a(n, t, this.labelLayout().rotate) + Math.max(0, r - C);
325
360
  e && i !== this.reportedOverhang && (this.reportedOverhang = i, e(i));
326
361
  };
362
+ reportRangeLabelOverhang = () => {
363
+ let { onRangeLabelOverhang: e } = this.props, t = Math.max(0, Math.ceil(this.state.rangeLabelWidth - z));
364
+ e && t !== this.reportedRangeOverhang && (this.reportedRangeOverhang = t, e(t));
365
+ };
327
366
  measureHiddenLabel = () => {
328
367
  if (!this.hiddenLabelRef) return;
329
368
  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
369
  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({
370
+ let o = Math.max(0, ...a.map((e) => e.offsetHeight)), s = this.axesNode ? [...this.axesNode.querySelectorAll("[data-range-label] mjx-container")] : [];
371
+ s.forEach((e) => this._sizeObserver?.observe(e));
372
+ let c = Math.max(0, ...s.map((e) => e.getBoundingClientRect().width));
373
+ (r !== this.state.height || i !== this.state.width || o !== this.state.labelHeight || c !== this.state.rangeLabelWidth) && this.setState({
333
374
  height: r,
334
375
  width: i,
335
- labelHeight: o
376
+ labelHeight: o,
377
+ rangeLabelWidth: c
336
378
  });
337
379
  };
338
380
  _onDocMutation = () => {
@@ -341,7 +383,7 @@ var N = class extends l.Component {
341
383
  observeHiddenLabel = (e) => {
342
384
  if (!e) return;
343
385
  let t = e.querySelector("[data-latex], [data-raw]");
344
- t && v(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(), w(this._onDocMutation), this.observeHiddenLabelSize(e);
386
+ t && b(e), (e.querySelector("mjx-container") || !t) && this.measureHiddenLabel(), O(this._onDocMutation), this.observeHiddenLabelSize(e);
345
387
  };
346
388
  observeHiddenLabelSize = (e) => {
347
389
  e === this._sizedLabel || typeof ResizeObserver > "u" || (this._sizeObserver?.disconnect(), this._sizedLabel = e, this._sizeObserver = new ResizeObserver(() => this.measureHiddenLabel()), this._sizeObserver.observe(e));
@@ -350,37 +392,34 @@ var N = class extends l.Component {
350
392
  e && e !== this.hiddenLabelRef && (this.hiddenLabelRef = e, this.observeHiddenLabel(e));
351
393
  };
352
394
  componentDidMount() {
353
- this.hiddenLabelRef && this.observeHiddenLabel(this.hiddenLabelRef), this.reportLabelOverhang();
395
+ this.hiddenLabelRef && this.observeHiddenLabel(this.hiddenLabelRef), this.reportLabelOverhang(), this.reportRangeLabelOverhang();
354
396
  }
355
397
  componentWillUnmount() {
356
- T(this._onDocMutation), this._sizeObserver?.disconnect(), this._sizedLabel = null, this._updateTimer && clearTimeout(this._updateTimer);
398
+ k(this._onDocMutation), this._sizeObserver?.disconnect(), this._sizedLabel = null, this._updateTimer && clearTimeout(this._updateTimer);
357
399
  }
358
400
  componentDidUpdate(e) {
359
- e.categories !== this.props.categories && (this._updateTimer && clearTimeout(this._updateTimer), this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50)), this.reportLabelOverhang();
401
+ e.categories !== this.props.categories && (this._updateTimer && clearTimeout(this._updateTimer), this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50)), this.reportLabelOverhang(), this.reportRangeLabelOverhang();
360
402
  }
361
403
  render() {
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({
404
+ 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: h, error: g, 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(), O = o({
363
405
  ...S,
364
406
  step: S.labelStep
365
407
  });
366
- return /* @__PURE__ */ g(O, {
408
+ return /* @__PURE__ */ v(M, {
367
409
  ref: (e) => this.axesNode = e,
368
- children: [i && /* @__PURE__ */ h(e, {
410
+ children: [i && /* @__PURE__ */ _(e, {
369
411
  scale: x.y,
370
412
  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, {
413
+ tickFormat: (e) => `${e}`,
414
+ tickValues: O,
415
+ tickComponent: V
416
+ }), /* @__PURE__ */ _(t, {
378
417
  scale: w,
379
418
  labelProps: { y: 60 + l },
380
419
  top: x.y && x.y(S.min),
381
420
  textLabelProps: () => ({ textAnchor: "middle" }),
382
421
  tickFormat: (e) => e,
383
- tickComponent: (e) => /* @__PURE__ */ h(M, {
422
+ tickComponent: (e) => /* @__PURE__ */ _(I, {
384
423
  hiddenLabelRef: this.setHiddenLabelRef,
385
424
  categories: c,
386
425
  xBand: r,
@@ -391,8 +430,8 @@ var N = class extends l.Component {
391
430
  defineChart: u,
392
431
  chartingOptions: d,
393
432
  autoFocus: m,
394
- onAutoFocusUsed: _,
395
- error: v,
433
+ onAutoFocusUsed: h,
434
+ error: g,
396
435
  onChangeCategory: s,
397
436
  changeInteractiveEnabled: f,
398
437
  changeEditableEnabled: p,
@@ -405,10 +444,10 @@ var N = class extends l.Component {
405
444
  language: b
406
445
  }),
407
446
  autoFocus: m,
408
- onAutoFocusUsed: _
447
+ onAutoFocusUsed: h
409
448
  })]
410
449
  });
411
450
  }
412
451
  };
413
452
  //#endregion
414
- export { N as RawChartAxes, N as default, M as TickComponent };
453
+ export { V as RangeTickLabel, H as RawChartAxes, H as default, I as TickComponent };
package/dist/chart.d.ts CHANGED
@@ -79,6 +79,7 @@ export declare class Chart extends React.Component {
79
79
  };
80
80
  generateMaskId(): string;
81
81
  setLabelOverhang: (labelOverhang: any) => void;
82
+ setRangeLabelOverhang: (rangeLabelOverhang: any) => void;
82
83
  handleAlertDialog: (open: any, callback: any) => void;
83
84
  getChart: any;
84
85
  changeData: any;
package/dist/chart.js CHANGED
@@ -41,7 +41,8 @@ var { translator: x } = b, ee = f("pie-lib:charts:chart"), te = d("div")(() => (
41
41
  super(e), this.state = {
42
42
  dialog: { open: !1 },
43
43
  actionsAnchorEl: null,
44
- labelOverhang: 0
44
+ labelOverhang: 0,
45
+ rangeLabelOverhang: 0
45
46
  }, this.maskUid = this.generateMaskId();
46
47
  }
47
48
  static propTypes = {
@@ -114,6 +115,7 @@ var { translator: x } = b, ee = f("pie-lib:charts:chart"), te = d("div")(() => (
114
115
  return _("chart");
115
116
  }
116
117
  setLabelOverhang = (e) => this.setState({ labelOverhang: e });
118
+ setRangeLabelOverhang = (e) => this.setState({ rangeLabelOverhang: e });
117
119
  handleAlertDialog = (e, t) => this.setState({ dialog: { open: e } }, t);
118
120
  getChart = () => {
119
121
  let e = this.props.charts || this.state.charts, { chartType: t } = this.props, n = null, r = null;
@@ -209,6 +211,7 @@ var { translator: x } = b, ee = f("pie-lib:charts:chart"), te = d("div")(() => (
209
211
  labelsCharactersLimit: A,
210
212
  ariaLabel: U,
211
213
  ariaDescription: W,
214
+ leftAxisOverhang: this.state.rangeLabelOverhang,
212
215
  ...$,
213
216
  children: [
214
217
  /* @__PURE__ */ v(e, {
@@ -234,7 +237,8 @@ var { translator: x } = b, ee = f("pie-lib:charts:chart"), te = d("div")(() => (
234
237
  error: D,
235
238
  showCorrectness: N === "linePlot" || N === "dotPlot",
236
239
  language: k,
237
- onLabelOverhang: this.setLabelOverhang
240
+ onLabelOverhang: this.setLabelOverhang,
241
+ onRangeLabelOverhang: this.setRangeLabelOverhang
238
242
  }),
239
243
  C ? /* @__PURE__ */ v("foreignObject", {
240
244
  x: I,
@@ -25,12 +25,17 @@ u("input")(({ theme: e }) => ({
25
25
  "&.disabledMarkLabel": { backgroundColor: "transparent !important" },
26
26
  "&.error": { border: `2px solid ${e.palette.error.main}` }
27
27
  }));
28
- var y = u("div")(({ theme: e }) => ({
28
+ var y = 24, b = u("div")(({ theme: e }) => ({
29
29
  pointerEvents: "auto",
30
+ display: "flex",
31
+ justifyContent: "center",
32
+ alignItems: "center",
33
+ minHeight: y,
30
34
  textAlign: "center",
35
+ "& mjx-container": { lineHeight: 0 },
31
36
  fontSize: e.typography.fontSize + 2,
32
37
  fontFamily: e.typography.fontFamily,
33
- color: f.defaults.PRIMARY_DARK,
38
+ color: f.defaults.TEXT,
34
39
  "&.disabledMarkLabel": {
35
40
  ...r("color"),
36
41
  color: v,
@@ -43,26 +48,24 @@ var y = u("div")(({ theme: e }) => ({
43
48
  outline: `2px solid ${f.focusOutline()}`,
44
49
  outlineOffset: "2px"
45
50
  }
46
- }));
47
- function b(e) {
48
- let t = e?.trim() || "";
49
- return (/* @__PURE__ */ new RegExp(/^[1-9]*[0-9]*\s?[1-9][0-9]*\/[1-9][0-9]*$/)).test(t);
50
- }
51
- function x(e) {
52
- let t = e?.trim() || "", n, r = "", i = t.split(" ");
53
- n = i[1] && i[1].includes("/") ? i[1].split("/") || "" : t?.split("/") || "";
54
- let a;
55
- if (b(e)) return i[0] && i[1] && (r = i[0]), a = `\\(${r}\\frac{${n[0]}}{${n[1]}}\\)`, a;
51
+ })), x = /^(-?)(?:(\d+)\s+)?(\d+)\/(\d+)$/, S = /^-?(?:\d+\.?\d*|\.\d+)$/;
52
+ function C(e) {
53
+ let t = e?.trim() || "", n = x.exec(t);
54
+ if (n) {
55
+ let [, e, t = "", r, i] = n;
56
+ return `\\(${e}${t}\\frac{${r}}{${i}}\\)`;
57
+ }
58
+ if (S.test(t)) return `\\(${t}\\)`;
56
59
  }
57
- var S = (n) => {
58
- let [r, i] = c(null), l = a((e) => i(e), null), { mark: u = {}, disabled: d, inputRef: b, barWidth: S, rotate: C, correctness: w, autoFocus: T, error: E, isHiddenLabel: D, limitCharacters: O, correctnessIndicator: k, ariaLabel: A, mathAriaLabel: j } = n, [M, N] = c(u.label), [P, F] = c(u.label), [I, L] = c(!1), R = x(P), z = s(null), B = (e) => {
60
+ var w = (n) => {
61
+ let [r, i] = c(null), l = a((e) => i(e), null), { mark: u = {}, disabled: d, inputRef: y, barWidth: x, rotate: S, correctness: w, autoFocus: T, error: E, isHiddenLabel: D, limitCharacters: O, correctnessIndicator: k, ariaLabel: A, mathAriaLabel: j } = n, [M, N] = c(u.label), [P, F] = c(u.label), [I, L] = c(!1), R = C(P), z = s(null), B = (e) => {
59
62
  O && e.target.value && e.target.value.length > 20 || N(e.target.value);
60
63
  }, V = () => I === !1 && R !== void 0, H = () => L(!0), U = (e) => {
61
64
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), H());
62
65
  }, W = (e) => {
63
66
  F(e.target.value), L(!1), n.onChange(e.target.value);
64
67
  }, G = {};
65
- return C && (G = {
68
+ return S && (G = {
66
69
  width: "unset",
67
70
  textAlign: "left"
68
71
  }), o(() => {
@@ -70,9 +73,9 @@ var S = (n) => {
70
73
  }, [u.label]), o(() => {
71
74
  let e = z.current;
72
75
  e && R && !I && (e.innerHTML = g(R), h(e));
73
- }, [R, I]), /* @__PURE__ */ m(_, { children: [k, V() ? /* @__PURE__ */ p(y, {
76
+ }, [R, I]), /* @__PURE__ */ m(_, { children: [k, V() ? /* @__PURE__ */ p(b, {
74
77
  ref: (e) => {
75
- z.current = e, typeof b == "function" && b(e);
78
+ z.current = e, typeof y == "function" && y(e);
76
79
  },
77
80
  "data-math-label": !0,
78
81
  className: e({
@@ -89,16 +92,16 @@ var S = (n) => {
89
92
  onKeyDown: U
90
93
  },
91
94
  style: {
92
- minWidth: S,
95
+ minWidth: x,
93
96
  position: "fixed",
94
97
  transformOrigin: "left",
95
- transform: `rotate(${C}deg)`,
98
+ transform: `rotate(${S}deg)`,
96
99
  visibility: D ? "hidden" : "unset",
97
100
  marginTop: k ? "24px" : "0"
98
101
  }
99
102
  }) : /* @__PURE__ */ p(t, {
100
103
  inputRef: (e) => {
101
- l(e), typeof b == "function" && b(e);
104
+ l(e), typeof y == "function" && y(e);
102
105
  },
103
106
  name: "mark-label-input",
104
107
  "aria-label": A,
@@ -106,7 +109,7 @@ var S = (n) => {
106
109
  disabled: d,
107
110
  inputClassName: e(w && u.editable ? w.label : null, d && "disabledMarkLabel", E && "error"),
108
111
  inputStyle: {
109
- minWidth: S,
112
+ minWidth: x,
110
113
  textAlign: "center",
111
114
  background: "transparent",
112
115
  boxSizing: "border-box",
@@ -128,9 +131,9 @@ var S = (n) => {
128
131
  pointerEvents: "auto",
129
132
  top: 0,
130
133
  left: 0,
131
- minWidth: S,
134
+ minWidth: x,
132
135
  transformOrigin: "left",
133
- transform: `rotate(${C}deg)`,
136
+ transform: `rotate(${S}deg)`,
134
137
  visibility: D ? "hidden" : "unset",
135
138
  marginTop: k ? "24px" : "0"
136
139
  },
@@ -138,7 +141,7 @@ var S = (n) => {
138
141
  onBlur: W
139
142
  })] });
140
143
  };
141
- S.propTypes = {
144
+ w.propTypes = {
142
145
  autoFocus: l.bool,
143
146
  disabled: l.bool,
144
147
  error: l.any,
@@ -159,4 +162,4 @@ S.propTypes = {
159
162
  mathAriaLabel: l.string
160
163
  };
161
164
  //#endregion
162
- export { S as MarkLabel, S as default };
165
+ export { w as MarkLabel, w as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/charting",
3
- "version": "8.0.5",
3
+ "version": "8.0.6-next.20261016071127",
4
4
  "description": "charting",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,10 +13,10 @@
13
13
  "@mapbox/point-geometry": "^1.1.0",
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
- "@pie-element/shared-utils": "0.1.4",
17
- "@pie-lib/plot": "5.0.5",
18
- "@pie-lib/render-ui": "8.0.5",
19
- "@pie-lib/translator": "5.0.1",
16
+ "@pie-element/shared-utils": "0.1.5-next.20261012213240",
17
+ "@pie-lib/plot": "5.0.6-next.20261016071127",
18
+ "@pie-lib/render-ui": "8.0.6-next.20261015154938",
19
+ "@pie-lib/translator": "5.0.2-next.20261006160832",
20
20
  "@visx/axis": "^4.0.0",
21
21
  "@visx/event": "^4.0.0",
22
22
  "@visx/grid": "^4.0.0",
@@ -30,9 +30,9 @@
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.5",
34
- "@pie-element/shared-math-rendering-mathjax": "0.1.6",
35
- "@pie-element/shared-lodash": "0.1.2",
33
+ "@pie-lib/config-ui": "14.0.6-next.20261015154938",
34
+ "@pie-element/shared-math-rendering-mathjax": "0.1.7-next.20261015154938",
35
+ "@pie-element/shared-lodash": "0.1.3-next.20261012213240",
36
36
  "clsx": "^2.1.1",
37
37
  "d3-time": "^3.1.0",
38
38
  "d3-interpolate": "^3.0.1",