@pie-lib/charting 8.0.8-next.20261102134752 → 8.0.8-next.20261102164954
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__/drag-handle-props.test.d.ts +1 -0
- package/dist/__tests__/drag-hover.test.d.ts +1 -0
- package/dist/bars/common/bars.d.ts +4 -2
- package/dist/bars/common/bars.js +69 -65
- package/dist/common/drag-handle.d.ts +7 -5
- package/dist/common/drag-handle.js +5 -5
- package/dist/common/drag-hover.d.ts +34 -0
- package/dist/common/drag-hover.js +44 -0
- package/dist/line/common/drag-handle.d.ts +2 -4
- package/dist/line/common/line.d.ts +1 -0
- package/dist/line/common/line.js +8 -2
- package/dist/line/line-cross.js +31 -30
- package/dist/line/line-dot.js +52 -53
- package/dist/plot/common/plot.d.ts +4 -0
- package/dist/plot/common/plot.js +98 -90
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -44,11 +44,13 @@ export declare class RawBar extends React.Component {
|
|
|
44
44
|
};
|
|
45
45
|
constructor(props: any);
|
|
46
46
|
componentDidMount(): void;
|
|
47
|
+
componentDidUpdate(prevProps: any): void;
|
|
47
48
|
componentWillUnmount(): void;
|
|
48
49
|
handleMouseMove: any;
|
|
49
50
|
isMouseInsideSvgElement: any;
|
|
50
|
-
handleMouseEnter: () =>
|
|
51
|
-
handleMouseLeave: () =>
|
|
51
|
+
handleMouseEnter: () => any;
|
|
52
|
+
handleMouseLeave: () => any;
|
|
53
|
+
dragStart: any;
|
|
52
54
|
setDragValue: (dragValue: any) => void;
|
|
53
55
|
changeValue: any;
|
|
54
56
|
dragStop: any;
|
package/dist/bars/common/bars.js
CHANGED
|
@@ -2,17 +2,18 @@ import e from "../../node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_m
|
|
|
2
2
|
import t from "../../node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Bar.js";
|
|
3
3
|
import { bandKey as n } from "../../utils.js";
|
|
4
4
|
import { D as r, DragHandle as i } from "../../common/drag-handle.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import s from "
|
|
8
|
-
import c from "
|
|
9
|
-
import
|
|
10
|
-
import u from "
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
5
|
+
import { DragHover as a } from "../../common/drag-hover.js";
|
|
6
|
+
import { MarkSlider as o } from "../../common/mark-slider.js";
|
|
7
|
+
import { CorrectCheckIcon as s } from "./correct-check-icon.js";
|
|
8
|
+
import c from "react";
|
|
9
|
+
import l from "prop-types";
|
|
10
|
+
import { styled as u } from "@mui/material/styles";
|
|
11
|
+
import d from "debug";
|
|
12
|
+
import { types as f } from "@pie-lib/plot";
|
|
13
|
+
import { color as p } from "@pie-lib/render-ui";
|
|
14
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
14
15
|
//#region src/bars/common/bars.tsx
|
|
15
|
-
var
|
|
16
|
+
var _ = d("pie-lib:chart:bars"), v = [
|
|
16
17
|
"#006699",
|
|
17
18
|
"#F59B00",
|
|
18
19
|
"#08916D",
|
|
@@ -25,7 +26,7 @@ var g = u("pie-lib:chart:bars"), _ = [
|
|
|
25
26
|
"#4FD2D2",
|
|
26
27
|
"#F0E442",
|
|
27
28
|
"#E287B2"
|
|
28
|
-
],
|
|
29
|
+
], y = [
|
|
29
30
|
"#003754",
|
|
30
31
|
"#975616",
|
|
31
32
|
"#00503B",
|
|
@@ -38,48 +39,50 @@ var g = u("pie-lib:chart:bars"), _ = [
|
|
|
38
39
|
"#167A7A",
|
|
39
40
|
"#91862D",
|
|
40
41
|
"#894A65"
|
|
41
|
-
],
|
|
42
|
+
], b = (e, t, n, r, i) => e && t && i ? r[n % r.length] : e && i ? p.visualElementsColors.ROLLOVER_FILL_BAR_COLOR : t || null, x = u(t)(() => ({ fill: p.defaults.TERTIARY })), S = 10, C = class extends c.Component {
|
|
42
43
|
static propTypes = {
|
|
43
|
-
barColor:
|
|
44
|
-
onChangeCategory:
|
|
45
|
-
value:
|
|
46
|
-
label:
|
|
47
|
-
xBand:
|
|
48
|
-
index:
|
|
49
|
-
graphProps:
|
|
50
|
-
interactive:
|
|
51
|
-
disabled:
|
|
52
|
-
correctness:
|
|
53
|
-
value:
|
|
54
|
-
label:
|
|
44
|
+
barColor: l.string,
|
|
45
|
+
onChangeCategory: l.func,
|
|
46
|
+
value: l.number,
|
|
47
|
+
label: l.string,
|
|
48
|
+
xBand: l.func,
|
|
49
|
+
index: l.number.isRequired,
|
|
50
|
+
graphProps: f.GraphPropsType.isRequired,
|
|
51
|
+
interactive: l.bool,
|
|
52
|
+
disabled: l.bool,
|
|
53
|
+
correctness: l.shape({
|
|
54
|
+
value: l.string,
|
|
55
|
+
label: l.string
|
|
55
56
|
}),
|
|
56
|
-
correctData:
|
|
57
|
-
defineChart:
|
|
58
|
-
language:
|
|
57
|
+
correctData: l.array,
|
|
58
|
+
defineChart: l.bool,
|
|
59
|
+
language: l.string
|
|
59
60
|
};
|
|
60
61
|
constructor(e) {
|
|
61
62
|
super(e), this.state = {
|
|
62
63
|
dragValue: void 0,
|
|
63
64
|
isHovered: !1
|
|
64
|
-
}, this.mouseX = 0, this.mouseY = 0;
|
|
65
|
+
}, this.hover = new a((e) => this.setState({ isHovered: e })), this.mouseX = 0, this.mouseY = 0;
|
|
65
66
|
}
|
|
66
67
|
componentDidMount() {
|
|
67
|
-
window.addEventListener("mousemove", this.handleMouseMove);
|
|
68
|
+
this.hover.attach(), window.addEventListener("mousemove", this.handleMouseMove);
|
|
69
|
+
}
|
|
70
|
+
componentDidUpdate(e) {
|
|
71
|
+
this.props.disabled && !e.disabled && (this.hover.stop(), this.setDragValue(void 0));
|
|
68
72
|
}
|
|
69
73
|
componentWillUnmount() {
|
|
70
|
-
window.removeEventListener("mousemove", this.handleMouseMove);
|
|
74
|
+
window.removeEventListener("mousemove", this.handleMouseMove), this.hover.dispose();
|
|
71
75
|
}
|
|
72
76
|
handleMouseMove = (e) => {
|
|
73
|
-
this.mouseX = e.clientX, this.mouseY = e.clientY;
|
|
74
|
-
let t = this.isMouseInsideSvgElement();
|
|
75
|
-
this.setState({ isHovered: t });
|
|
77
|
+
this.mouseX = e.clientX, this.mouseY = e.clientY, this.hover.setInside(this.isMouseInsideSvgElement());
|
|
76
78
|
};
|
|
77
79
|
isMouseInsideSvgElement = () => {
|
|
78
80
|
let e = this.gRef.getBoundingClientRect();
|
|
79
81
|
return this.mouseX >= e.left && this.mouseX <= e.right && this.mouseY >= e.top && this.mouseY <= e.bottom;
|
|
80
82
|
};
|
|
81
|
-
handleMouseEnter = () => this.
|
|
82
|
-
handleMouseLeave = () => this.
|
|
83
|
+
handleMouseEnter = () => this.hover.setInside(!0);
|
|
84
|
+
handleMouseLeave = () => this.hover.setInside(!1);
|
|
85
|
+
dragStart = () => this.hover.start();
|
|
83
86
|
setDragValue = (e) => this.setState({ dragValue: e });
|
|
84
87
|
changeValue = (e) => {
|
|
85
88
|
let { label: t, onChangeCategory: n } = this.props;
|
|
@@ -89,48 +92,48 @@ var g = u("pie-lib:chart:bars"), _ = [
|
|
|
89
92
|
});
|
|
90
93
|
};
|
|
91
94
|
dragStop = () => {
|
|
92
|
-
let { dragValue: e } = this.state;
|
|
93
|
-
|
|
95
|
+
let { dragValue: e } = this.state, { disabled: t } = this.props;
|
|
96
|
+
_("[dragStop]", e), e !== void 0 && !t && this.changeValue(e), this.setDragValue(void 0), this.hover.stop();
|
|
94
97
|
};
|
|
95
98
|
dragValue = (e, t) => {
|
|
96
|
-
|
|
99
|
+
_("[dragValue] next:", t), this.setDragValue(t);
|
|
97
100
|
};
|
|
98
101
|
render() {
|
|
99
|
-
let { graphProps: e, value: t, label:
|
|
100
|
-
return /* @__PURE__ */
|
|
102
|
+
let { graphProps: e, value: t, label: a, xBand: c, index: l, interactive: u, disabled: d, correctness: f, barColor: _, defineChart: v, correctData: C, language: w } = this.props, { scale: T, range: E } = e, { dragValue: D, isHovered: O } = this.state, k = b(O, _, l, y, u && !f), A = Number.isFinite(D) ? D : t, j = c.bandwidth(), M = T.y(E.max - A), N = c(n({ label: a }, l)), P = E.max - A, F = E.max - P, I = C ? C.find((e) => e.label === a) : null, L = u ? r : i, R = !!_;
|
|
103
|
+
return /* @__PURE__ */ g(o, {
|
|
101
104
|
ref: (e) => this.gRef = e,
|
|
102
105
|
onMouseEnter: this.handleMouseEnter,
|
|
103
106
|
onMouseLeave: this.handleMouseLeave,
|
|
104
107
|
onTouchStart: this.handleMouseEnter,
|
|
105
108
|
onTouchEnd: this.handleMouseLeave,
|
|
106
109
|
enabled: u && !d,
|
|
107
|
-
label:
|
|
110
|
+
label: a,
|
|
108
111
|
index: l,
|
|
109
112
|
value: A,
|
|
110
113
|
graphProps: e,
|
|
111
114
|
language: w,
|
|
112
115
|
focusBox: {
|
|
113
116
|
x: N,
|
|
114
|
-
y: T.y(F) -
|
|
117
|
+
y: T.y(F) - S,
|
|
115
118
|
width: j,
|
|
116
|
-
height: Math.max(0, M) +
|
|
119
|
+
height: Math.max(0, M) + S
|
|
117
120
|
},
|
|
118
121
|
onChange: this.changeValue,
|
|
119
122
|
children: [
|
|
120
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ h(x, {
|
|
121
124
|
x: N,
|
|
122
125
|
y: T.y(F),
|
|
123
126
|
width: j,
|
|
124
127
|
height: M,
|
|
125
128
|
style: { fill: k }
|
|
126
129
|
}),
|
|
127
|
-
|
|
130
|
+
f && f.value === "incorrect" && (() => {
|
|
128
131
|
let e = parseFloat(I && I.value);
|
|
129
132
|
if (isNaN(e)) return null;
|
|
130
|
-
let t = T.y(E.max - e), n = M, r = Math.abs(t - n), i = T.y(e), a = t > n ?
|
|
131
|
-
return /* @__PURE__ */
|
|
133
|
+
let t = T.y(E.max - e), n = M, r = Math.abs(t - n), i = T.y(e), a = t > n ? p.borderGray() : p.defaults.WHITE, o = t > n ? i : i - r;
|
|
134
|
+
return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(x, {
|
|
132
135
|
x: N + 2,
|
|
133
|
-
y:
|
|
136
|
+
y: o,
|
|
134
137
|
width: j - 4,
|
|
135
138
|
height: r,
|
|
136
139
|
style: {
|
|
@@ -139,45 +142,46 @@ var g = u("pie-lib:chart:bars"), _ = [
|
|
|
139
142
|
strokeDasharray: "5,2",
|
|
140
143
|
fill: "none"
|
|
141
144
|
}
|
|
142
|
-
}), /* @__PURE__ */
|
|
145
|
+
}), /* @__PURE__ */ h("foreignObject", {
|
|
143
146
|
x: N + j - (R ? 24 : 14),
|
|
144
147
|
y: i - 12,
|
|
145
148
|
width: 24,
|
|
146
149
|
height: 24,
|
|
147
|
-
children: /* @__PURE__ */
|
|
150
|
+
children: /* @__PURE__ */ h(s, { dashColor: a })
|
|
148
151
|
})] });
|
|
149
152
|
})(),
|
|
150
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ h(L, {
|
|
151
154
|
x: N,
|
|
152
155
|
y: A,
|
|
153
|
-
defineChart:
|
|
156
|
+
defineChart: v,
|
|
154
157
|
interactive: u,
|
|
155
158
|
disabled: d,
|
|
156
159
|
width: j,
|
|
160
|
+
onDragStart: this.dragStart,
|
|
157
161
|
onDrag: (e) => this.dragValue(t, e),
|
|
158
162
|
onDragStop: this.dragStop,
|
|
159
163
|
graphProps: e,
|
|
160
|
-
correctness:
|
|
164
|
+
correctness: f,
|
|
161
165
|
isHovered: O,
|
|
162
166
|
color: k
|
|
163
167
|
})
|
|
164
168
|
]
|
|
165
169
|
});
|
|
166
170
|
}
|
|
167
|
-
},
|
|
171
|
+
}, w = C, T = class extends c.Component {
|
|
168
172
|
static propTypes = {
|
|
169
|
-
data:
|
|
170
|
-
correctData:
|
|
171
|
-
onChangeCategory:
|
|
172
|
-
defineChart:
|
|
173
|
-
xBand:
|
|
174
|
-
graphProps:
|
|
175
|
-
histogram:
|
|
176
|
-
language:
|
|
173
|
+
data: l.array,
|
|
174
|
+
correctData: l.array,
|
|
175
|
+
onChangeCategory: l.func,
|
|
176
|
+
defineChart: l.bool,
|
|
177
|
+
xBand: l.func,
|
|
178
|
+
graphProps: f.GraphPropsType.isRequired,
|
|
179
|
+
histogram: l.bool,
|
|
180
|
+
language: l.string
|
|
177
181
|
};
|
|
178
182
|
render() {
|
|
179
183
|
let { data: t, graphProps: n, xBand: r, onChangeCategory: i, defineChart: a, histogram: o, correctData: s, disabled: c, language: l } = this.props;
|
|
180
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ h(e, { children: (t || []).map((e, t) => /* @__PURE__ */ h(w, {
|
|
181
185
|
value: e.value,
|
|
182
186
|
interactive: a || e.interactive,
|
|
183
187
|
defineChart: a,
|
|
@@ -190,9 +194,9 @@ var g = u("pie-lib:chart:bars"), _ = [
|
|
|
190
194
|
correctness: e.correctness,
|
|
191
195
|
correctData: s,
|
|
192
196
|
language: l,
|
|
193
|
-
barColor: o && (
|
|
197
|
+
barColor: o && (v[t] ? v[t] : v[t % v.length])
|
|
194
198
|
}, `bar-${e.label}-${t}`)) });
|
|
195
199
|
}
|
|
196
200
|
};
|
|
197
201
|
//#endregion
|
|
198
|
-
export {
|
|
202
|
+
export { T as Bars, T as default, C as RawBar };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
export declare const DragHandle: {
|
|
4
|
-
({ x, y, width, graphProps, interactive, isHovered, correctness, isPlot, ...rest }: {
|
|
4
|
+
({ x, y, width, graphProps, interactive, isHovered, correctness, isPlot, isDragging, onDragStart, onDrag, onDragStop, ...rest }: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
x: any;
|
|
7
7
|
y: any;
|
|
@@ -11,6 +11,10 @@ export declare const DragHandle: {
|
|
|
11
11
|
isHovered: any;
|
|
12
12
|
correctness: any;
|
|
13
13
|
isPlot: any;
|
|
14
|
+
isDragging: any;
|
|
15
|
+
onDragStart: any;
|
|
16
|
+
onDrag: any;
|
|
17
|
+
onDragStop: any;
|
|
14
18
|
}): React.JSX.Element;
|
|
15
19
|
propTypes: {
|
|
16
20
|
x: PropTypes.Validator<number>;
|
|
@@ -52,13 +56,11 @@ export declare const DragHandle: {
|
|
|
52
56
|
export declare const D: {
|
|
53
57
|
new (props: any): {
|
|
54
58
|
nodeRef: React.RefObject<unknown>;
|
|
59
|
+
isLocked: any;
|
|
55
60
|
grid: any;
|
|
56
61
|
onStart: any;
|
|
57
62
|
position: any;
|
|
58
|
-
tiny: any;
|
|
59
63
|
getScaledBounds: any;
|
|
60
|
-
getClientPoint: any;
|
|
61
|
-
skipDragOutsideOfBounds: any;
|
|
62
64
|
onDrag: any;
|
|
63
65
|
getDelta: any;
|
|
64
66
|
applyDelta: any;
|
|
@@ -85,6 +87,7 @@ export declare const D: {
|
|
|
85
87
|
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
86
88
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
87
89
|
};
|
|
90
|
+
contextType: React.Context<boolean>;
|
|
88
91
|
propTypes: {
|
|
89
92
|
disabled: PropTypes.Requireable<boolean>;
|
|
90
93
|
onDragStart: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -117,6 +120,5 @@ export declare const D: {
|
|
|
117
120
|
}>>>;
|
|
118
121
|
}>>>;
|
|
119
122
|
};
|
|
120
|
-
contextType?: React.Context<any> | undefined;
|
|
121
123
|
};
|
|
122
124
|
export default D;
|
|
@@ -32,17 +32,17 @@ var f = r("svg")(() => ({ overflow: "visible !important" })), p = r("ellipse")((
|
|
|
32
32
|
width: "16px",
|
|
33
33
|
height: "16px",
|
|
34
34
|
boxSizing: "unset"
|
|
35
|
-
})), g = ({ x: n, y: r, width: i, graphProps: a, interactive: o, isHovered: u, correctness: d, isPlot: g,
|
|
36
|
-
let { scale:
|
|
35
|
+
})), g = ({ x: n, y: r, width: i, graphProps: a, interactive: o, isHovered: u, correctness: d, isPlot: g, isDragging: _, onDragStart: v, onDrag: y, onDragStop: b, ...x }) => {
|
|
36
|
+
let { scale: S } = a, C = e(i)?.scale;
|
|
37
37
|
return /* @__PURE__ */ l(f, {
|
|
38
38
|
x: n,
|
|
39
|
-
y:
|
|
39
|
+
y: S.y(r) - 10,
|
|
40
40
|
width: i,
|
|
41
41
|
overflow: "visible",
|
|
42
42
|
children: [
|
|
43
43
|
u && !d && o && /* @__PURE__ */ c(t, {
|
|
44
44
|
width: i,
|
|
45
|
-
scaleValue:
|
|
45
|
+
scaleValue: C,
|
|
46
46
|
color: s.defaults.BORDER_GRAY
|
|
47
47
|
}),
|
|
48
48
|
o && !d && /* @__PURE__ */ c(p, {
|
|
@@ -50,7 +50,7 @@ var f = r("svg")(() => ({ overflow: "visible !important" })), p = r("ellipse")((
|
|
|
50
50
|
cy: 10,
|
|
51
51
|
rx: i / 2,
|
|
52
52
|
ry: 66,
|
|
53
|
-
...
|
|
53
|
+
...x
|
|
54
54
|
}),
|
|
55
55
|
d && o && !g && /* @__PURE__ */ c("foreignObject", {
|
|
56
56
|
x: i / 2 - 14,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hover of one mark. It knows whether the pointer is over the mark and whether the mark is being
|
|
3
|
+
* dragged, and reports `hovered` through `onChange` whenever that changes. It is the one place the rule
|
|
4
|
+
* lives, for function components (`useDragHover`) and class components alike:
|
|
5
|
+
* - a dragged mark is hovered wherever the pointer is
|
|
6
|
+
* - no other mark is hovered while one is dragged
|
|
7
|
+
* - when the drag ends, every mark the pointer is over is hovered again, the dragged one included
|
|
8
|
+
*/
|
|
9
|
+
export declare class DragHover {
|
|
10
|
+
private onChange;
|
|
11
|
+
hovered: boolean;
|
|
12
|
+
private inside;
|
|
13
|
+
private dragging;
|
|
14
|
+
private alive;
|
|
15
|
+
constructor(onChange: (hovered: boolean) => void);
|
|
16
|
+
/** Starts listening for other marks' drags. Call it once the mark is mounted. */
|
|
17
|
+
attach(): void;
|
|
18
|
+
/** Stops listening, and ends the drag if the mark is unmounted in the middle of one. */
|
|
19
|
+
dispose(): void;
|
|
20
|
+
/** Whether the pointer is over the mark. Keep it current while dragging: the drop reads it. */
|
|
21
|
+
setInside(inside: boolean): void;
|
|
22
|
+
start(): void;
|
|
23
|
+
stop(): void;
|
|
24
|
+
update(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Hover state for a function-component mark. `isDragging` is the flag gridDraggable passes to the mark
|
|
28
|
+
* it wraps; pass false for a mark that cannot be dragged, so pressing it does not count as a drag.
|
|
29
|
+
*/
|
|
30
|
+
export declare const useDragHover: (isDragging: boolean) => {
|
|
31
|
+
hovered: boolean;
|
|
32
|
+
onEnter: () => void;
|
|
33
|
+
onLeave: () => void;
|
|
34
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
//#region src/common/drag-hover.ts
|
|
3
|
+
var t = null, n = /* @__PURE__ */ new Set(), r = class {
|
|
4
|
+
onChange;
|
|
5
|
+
hovered = !1;
|
|
6
|
+
inside = !1;
|
|
7
|
+
dragging = !1;
|
|
8
|
+
alive = !1;
|
|
9
|
+
constructor(e) {
|
|
10
|
+
this.onChange = e;
|
|
11
|
+
}
|
|
12
|
+
attach() {
|
|
13
|
+
this.alive = !0, n.add(this);
|
|
14
|
+
}
|
|
15
|
+
dispose() {
|
|
16
|
+
this.stop(), this.alive = !1, n.delete(this);
|
|
17
|
+
}
|
|
18
|
+
setInside(e) {
|
|
19
|
+
this.inside = e, this.update();
|
|
20
|
+
}
|
|
21
|
+
start() {
|
|
22
|
+
this.dragging || (this.dragging = !0, t = this, i());
|
|
23
|
+
}
|
|
24
|
+
stop() {
|
|
25
|
+
this.dragging && (this.dragging = !1, t === this && (t = null), i());
|
|
26
|
+
}
|
|
27
|
+
update() {
|
|
28
|
+
let e = this.dragging || this.inside && (t === null || t === this);
|
|
29
|
+
this.alive && e !== this.hovered && (this.hovered = e, this.onChange(e));
|
|
30
|
+
}
|
|
31
|
+
}, i = () => n.forEach((e) => e.update()), a = (t) => {
|
|
32
|
+
let [n, i] = e.useState(!1), a = e.useRef(null);
|
|
33
|
+
a.current ||= new r(i);
|
|
34
|
+
let o = a.current;
|
|
35
|
+
return e.useEffect(() => (o.attach(), () => o.dispose()), [o]), e.useEffect(() => {
|
|
36
|
+
if (t) return o.start(), () => o.stop();
|
|
37
|
+
}, [t, o]), {
|
|
38
|
+
hovered: t || n,
|
|
39
|
+
onEnter: () => o.setInside(!0),
|
|
40
|
+
onLeave: () => o.setInside(!1)
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { r as DragHover, a as useDragHover };
|
|
@@ -43,13 +43,11 @@ export declare const DragHandle: typeof RawDragHandle;
|
|
|
43
43
|
declare const DraggableHandle: {
|
|
44
44
|
new (props: any): {
|
|
45
45
|
nodeRef: React.RefObject<unknown>;
|
|
46
|
+
isLocked: any;
|
|
46
47
|
grid: any;
|
|
47
48
|
onStart: any;
|
|
48
49
|
position: any;
|
|
49
|
-
tiny: any;
|
|
50
50
|
getScaledBounds: any;
|
|
51
|
-
getClientPoint: any;
|
|
52
|
-
skipDragOutsideOfBounds: any;
|
|
53
51
|
onDrag: any;
|
|
54
52
|
getDelta: any;
|
|
55
53
|
applyDelta: any;
|
|
@@ -76,6 +74,7 @@ declare const DraggableHandle: {
|
|
|
76
74
|
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
77
75
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
78
76
|
};
|
|
77
|
+
contextType: React.Context<boolean>;
|
|
79
78
|
propTypes: {
|
|
80
79
|
disabled: PropTypes.Requireable<boolean>;
|
|
81
80
|
onDragStart: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -108,6 +107,5 @@ declare const DraggableHandle: {
|
|
|
108
107
|
}>>>;
|
|
109
108
|
}>>>;
|
|
110
109
|
};
|
|
111
|
-
contextType?: React.Context<any> | undefined;
|
|
112
110
|
};
|
|
113
111
|
export default DraggableHandle;
|
|
@@ -46,6 +46,7 @@ export declare class RawLine extends React.Component {
|
|
|
46
46
|
};
|
|
47
47
|
constructor(props: any);
|
|
48
48
|
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
49
|
+
componentDidUpdate(prevProps: any): void;
|
|
49
50
|
setDragValue: (line: any) => void;
|
|
50
51
|
dragStop: any;
|
|
51
52
|
changeValue: any;
|
package/dist/line/common/line.js
CHANGED
|
@@ -50,11 +50,17 @@ var p = (e, t) => {
|
|
|
50
50
|
UNSAFE_componentWillReceiveProps(e) {
|
|
51
51
|
c(this.props.data, e.data) || this.setState({ line: p(e.data, e.graphProps.domain) });
|
|
52
52
|
}
|
|
53
|
+
componentDidUpdate(e) {
|
|
54
|
+
this.props.disabled && !e.disabled && this.state.dragging && this.setState({
|
|
55
|
+
dragging: !1,
|
|
56
|
+
line: p(this.props.data, this.props.graphProps.domain)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
53
59
|
setDragValue = (e) => this.setState({ line: e });
|
|
54
60
|
dragStop = (e) => {
|
|
55
|
-
let { onChange: t } = this.props;
|
|
61
|
+
let { onChange: t, disabled: n } = this.props;
|
|
56
62
|
this.setState({ dragging: !1 }, () => {
|
|
57
|
-
t(e, this.state.line[e]);
|
|
63
|
+
n || t(e, this.state.line[e]);
|
|
58
64
|
});
|
|
59
65
|
};
|
|
60
66
|
changeValue = (e, t, n) => {
|
package/dist/line/line-cross.js
CHANGED
|
@@ -2,8 +2,9 @@ import e from "../node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_modu
|
|
|
2
2
|
import t from "../node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/LinePath.js";
|
|
3
3
|
import { CorrectnessIndicator as n, SmallCorrectPointIndicator as r } from "../common/correctness-indicators.js";
|
|
4
4
|
import { dataToXBand as i } from "../utils.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { useDragHover as a } from "../common/drag-hover.js";
|
|
6
|
+
import { Line as o } from "./common/line.js";
|
|
7
|
+
import s from "react";
|
|
7
8
|
import c from "prop-types";
|
|
8
9
|
import { styled as l } from "@mui/material/styles";
|
|
9
10
|
import { types as u } from "@pie-lib/plot";
|
|
@@ -14,7 +15,7 @@ var m = l(t)(() => ({
|
|
|
14
15
|
stroke: d.defaults.TEXT,
|
|
15
16
|
transition: "fill 200ms linear, height 200ms linear",
|
|
16
17
|
"&.non-interactive": { stroke: d.disabled?.() || "#ccc" }
|
|
17
|
-
})), h = l(e)(({ correctness: e, interactive: t }) => ({
|
|
18
|
+
})), h = l(e, { shouldForwardProp: (e) => e !== "correctness" && e !== "interactive" })(({ correctness: e, interactive: t }) => ({
|
|
18
19
|
stroke: d.defaults.TEXT,
|
|
19
20
|
transition: "fill 200ms linear, height 200ms linear",
|
|
20
21
|
...e && !t && {
|
|
@@ -27,7 +28,7 @@ var m = l(t)(() => ({
|
|
|
27
28
|
fill: "transparent",
|
|
28
29
|
stroke: "transparent"
|
|
29
30
|
})), _ = (e) => {
|
|
30
|
-
let { className: t, scale: i, x:
|
|
31
|
+
let { className: t, scale: i, x: o, y: s, r: c, correctness: l, interactive: u, correctData: _, label: v, isDragging: y, disabled: b, onDragStart: x, onDrag: S, onDragStop: C, ...w } = e, { hovered: T, onEnter: E, onLeave: D } = a(!!y && !b), O = c * 4, k = O / 2, A = i.x(o), j = i.y(s);
|
|
31
32
|
return /* @__PURE__ */ p(h, {
|
|
32
33
|
className: t,
|
|
33
34
|
correctness: l,
|
|
@@ -35,59 +36,59 @@ var m = l(t)(() => ({
|
|
|
35
36
|
children: [
|
|
36
37
|
/* @__PURE__ */ f(m, {
|
|
37
38
|
data: [{
|
|
38
|
-
x: i.x(
|
|
39
|
-
y: i.y(
|
|
39
|
+
x: i.x(o) - c,
|
|
40
|
+
y: i.y(s) + c
|
|
40
41
|
}, {
|
|
41
|
-
x: i.x(
|
|
42
|
-
y: i.y(
|
|
42
|
+
x: i.x(o) + c,
|
|
43
|
+
y: i.y(s) - c
|
|
43
44
|
}],
|
|
44
45
|
x: (e) => e.x,
|
|
45
46
|
y: (e) => e.y,
|
|
46
47
|
strokeWidth: 5,
|
|
47
48
|
style: { pointerEvents: "none" }
|
|
48
|
-
}, `point-${
|
|
49
|
+
}, `point-${o}-${s}-1`),
|
|
49
50
|
/* @__PURE__ */ f(m, {
|
|
50
51
|
data: [{
|
|
51
|
-
x: i.x(
|
|
52
|
-
y: i.y(
|
|
52
|
+
x: i.x(o) - c,
|
|
53
|
+
y: i.y(s) - c
|
|
53
54
|
}, {
|
|
54
|
-
x: i.x(
|
|
55
|
-
y: i.y(
|
|
55
|
+
x: i.x(o) + c,
|
|
56
|
+
y: i.y(s) + c
|
|
56
57
|
}],
|
|
57
58
|
x: (e) => e.x,
|
|
58
59
|
y: (e) => e.y,
|
|
59
60
|
strokeWidth: 5,
|
|
60
61
|
style: { pointerEvents: "none" }
|
|
61
|
-
}, `point-${
|
|
62
|
-
|
|
63
|
-
x:
|
|
64
|
-
y:
|
|
65
|
-
width:
|
|
66
|
-
height:
|
|
62
|
+
}, `point-${o}-${s}-2`),
|
|
63
|
+
T && /* @__PURE__ */ f("rect", {
|
|
64
|
+
x: A - k,
|
|
65
|
+
y: j - k,
|
|
66
|
+
width: O,
|
|
67
|
+
height: O,
|
|
67
68
|
stroke: d.defaults.BORDER_GRAY,
|
|
68
69
|
fill: "none",
|
|
69
70
|
strokeWidth: 2,
|
|
70
71
|
pointerEvents: "none"
|
|
71
72
|
}),
|
|
72
73
|
/* @__PURE__ */ f(g, {
|
|
73
|
-
cx:
|
|
74
|
-
cy:
|
|
74
|
+
cx: A,
|
|
75
|
+
cy: j,
|
|
75
76
|
r: c * 2,
|
|
76
|
-
onMouseEnter:
|
|
77
|
-
onMouseLeave:
|
|
78
|
-
...
|
|
77
|
+
onMouseEnter: E,
|
|
78
|
+
onMouseLeave: D,
|
|
79
|
+
...w
|
|
79
80
|
}),
|
|
80
81
|
/* @__PURE__ */ f(n, {
|
|
81
82
|
scale: i,
|
|
82
|
-
x:
|
|
83
|
-
y:
|
|
83
|
+
x: o,
|
|
84
|
+
y: s,
|
|
84
85
|
r: c,
|
|
85
86
|
correctness: l,
|
|
86
87
|
interactive: u
|
|
87
88
|
}),
|
|
88
89
|
/* @__PURE__ */ f(r, {
|
|
89
90
|
scale: i,
|
|
90
|
-
x:
|
|
91
|
+
x: o,
|
|
91
92
|
r: c,
|
|
92
93
|
correctness: l,
|
|
93
94
|
correctData: _,
|
|
@@ -110,15 +111,15 @@ _.propTypes = {
|
|
|
110
111
|
correctData: c.array,
|
|
111
112
|
label: c.string
|
|
112
113
|
};
|
|
113
|
-
var v = class extends
|
|
114
|
+
var v = class extends s.Component {
|
|
114
115
|
static propTypes = {
|
|
115
116
|
data: c.array,
|
|
116
117
|
onChange: c.func,
|
|
117
118
|
graphProps: u.GraphPropsType.isRequired
|
|
118
119
|
};
|
|
119
120
|
render() {
|
|
120
|
-
let e = this.props, { data: t, graphProps: n } = e, { scale: r = {}, size:
|
|
121
|
-
return /* @__PURE__ */ f(
|
|
121
|
+
let e = this.props, { data: t, graphProps: n } = e, { scale: r = {}, size: a = {} } = n || {}, s = i(r.x, t, a.width, "lineCross");
|
|
122
|
+
return /* @__PURE__ */ f(o, {
|
|
122
123
|
...e,
|
|
123
124
|
xBand: s,
|
|
124
125
|
CustomDraggableComponent: _
|
package/dist/line/line-dot.js
CHANGED
|
@@ -1,101 +1,100 @@
|
|
|
1
1
|
import { CorrectnessIndicator as e, SmallCorrectPointIndicator as t } from "../common/correctness-indicators.js";
|
|
2
2
|
import { dataToXBand as n } from "../utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import i from "
|
|
5
|
-
import a from "
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { useDragHover as r } from "../common/drag-hover.js";
|
|
4
|
+
import { Line as i } from "./common/line.js";
|
|
5
|
+
import a from "react";
|
|
6
|
+
import o from "prop-types";
|
|
7
|
+
import { styled as s } from "@mui/material/styles";
|
|
8
|
+
import { types as c } from "@pie-lib/plot";
|
|
9
|
+
import { color as l } from "@pie-lib/render-ui";
|
|
10
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
10
11
|
//#region src/line/line-dot.tsx
|
|
11
|
-
var
|
|
12
|
+
var f = s("circle", { shouldForwardProp: (e) => e !== "correctness" && e !== "interactive" })(() => ({})), p = s("circle")(() => ({
|
|
12
13
|
height: "20px",
|
|
13
14
|
fill: "transparent",
|
|
14
15
|
stroke: "none",
|
|
15
16
|
pointerEvents: "auto"
|
|
16
|
-
})),
|
|
17
|
-
let
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
onMouseEnter:
|
|
20
|
-
onMouseLeave:
|
|
21
|
-
onTouchStart:
|
|
22
|
-
onTouchEnd:
|
|
17
|
+
})), m = ({ scale: n, x: i, y: a, r: o, correctness: s, interactive: c, correctData: m, label: h, isDragging: g, disabled: _, onDragStart: v, onDrag: y, onDragStop: b, ...x }) => {
|
|
18
|
+
let { hovered: S, onEnter: C, onLeave: w } = r(!!g && !_), T = !s && c;
|
|
19
|
+
return /* @__PURE__ */ d("g", {
|
|
20
|
+
onMouseEnter: C,
|
|
21
|
+
onMouseLeave: w,
|
|
22
|
+
onTouchStart: C,
|
|
23
|
+
onTouchEnd: w,
|
|
23
24
|
children: [
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
cx: n.x(
|
|
25
|
+
/* @__PURE__ */ u(p, {
|
|
26
|
+
cx: n.x(i),
|
|
26
27
|
cy: n.y(a),
|
|
27
28
|
r: o * 3,
|
|
28
|
-
|
|
29
|
-
onMouseLeave: () => v(!1),
|
|
30
|
-
...g
|
|
29
|
+
...x
|
|
31
30
|
}),
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
cx: n.x(
|
|
31
|
+
/* @__PURE__ */ u(f, {
|
|
32
|
+
cx: n.x(i),
|
|
34
33
|
cy: n.y(a),
|
|
35
34
|
r: o,
|
|
36
35
|
correctness: s,
|
|
37
|
-
interactive:
|
|
38
|
-
...
|
|
36
|
+
interactive: c,
|
|
37
|
+
...x
|
|
39
38
|
}),
|
|
40
|
-
/* @__PURE__ */
|
|
39
|
+
/* @__PURE__ */ u(e, {
|
|
41
40
|
scale: n,
|
|
42
|
-
x:
|
|
41
|
+
x: i,
|
|
43
42
|
y: a,
|
|
44
43
|
r: o,
|
|
45
44
|
correctness: s,
|
|
46
|
-
interactive:
|
|
45
|
+
interactive: c
|
|
47
46
|
}),
|
|
48
|
-
/* @__PURE__ */
|
|
47
|
+
/* @__PURE__ */ u(t, {
|
|
49
48
|
scale: n,
|
|
50
|
-
x:
|
|
49
|
+
x: i,
|
|
51
50
|
r: o,
|
|
52
51
|
correctness: s,
|
|
53
52
|
correctData: m,
|
|
54
53
|
label: h
|
|
55
54
|
}),
|
|
56
|
-
|
|
57
|
-
x: n.x(
|
|
55
|
+
S && T && /* @__PURE__ */ u("rect", {
|
|
56
|
+
x: n.x(i) - o * 2,
|
|
58
57
|
y: n.y(a) - o * 2,
|
|
59
58
|
width: o * 4,
|
|
60
59
|
height: o * 4,
|
|
61
|
-
stroke:
|
|
60
|
+
stroke: l.defaults.BORDER_GRAY,
|
|
62
61
|
strokeWidth: "1",
|
|
63
62
|
fill: "none"
|
|
64
63
|
})
|
|
65
64
|
]
|
|
66
65
|
});
|
|
67
66
|
};
|
|
68
|
-
|
|
69
|
-
scale:
|
|
70
|
-
x:
|
|
71
|
-
y:
|
|
72
|
-
r:
|
|
73
|
-
correctness:
|
|
74
|
-
value:
|
|
75
|
-
label:
|
|
67
|
+
m.propTypes = {
|
|
68
|
+
scale: o.object,
|
|
69
|
+
x: o.number,
|
|
70
|
+
y: o.number,
|
|
71
|
+
r: o.number,
|
|
72
|
+
correctness: o.shape({
|
|
73
|
+
value: o.string,
|
|
74
|
+
label: o.string
|
|
76
75
|
}),
|
|
77
|
-
interactive:
|
|
78
|
-
correctData:
|
|
79
|
-
label:
|
|
76
|
+
interactive: o.bool,
|
|
77
|
+
correctData: o.array,
|
|
78
|
+
label: o.string
|
|
80
79
|
};
|
|
81
|
-
var
|
|
80
|
+
var h = class extends a.Component {
|
|
82
81
|
static propTypes = {
|
|
83
|
-
data:
|
|
84
|
-
onChange:
|
|
85
|
-
graphProps:
|
|
82
|
+
data: o.array,
|
|
83
|
+
onChange: o.func,
|
|
84
|
+
graphProps: c.GraphPropsType.isRequired
|
|
86
85
|
};
|
|
87
86
|
render() {
|
|
88
|
-
let e = this.props, { data: t, graphProps:
|
|
89
|
-
return /* @__PURE__ */
|
|
87
|
+
let e = this.props, { data: t, graphProps: r } = e, { scale: a = {}, size: o = {} } = r || {}, s = n(a.x, t, o.width, "lineDot");
|
|
88
|
+
return /* @__PURE__ */ u(i, {
|
|
90
89
|
...e,
|
|
91
90
|
xBand: s,
|
|
92
|
-
CustomDraggableComponent:
|
|
91
|
+
CustomDraggableComponent: m
|
|
93
92
|
});
|
|
94
93
|
}
|
|
95
|
-
},
|
|
94
|
+
}, g = () => ({
|
|
96
95
|
type: "lineDot",
|
|
97
|
-
Component:
|
|
96
|
+
Component: h,
|
|
98
97
|
name: "Line Dot"
|
|
99
98
|
});
|
|
100
99
|
//#endregion
|
|
101
|
-
export {
|
|
100
|
+
export { h as LineDot, g as default };
|
|
@@ -47,8 +47,12 @@ export declare class RawPlot extends React.Component {
|
|
|
47
47
|
language: PropTypes.Requireable<string>;
|
|
48
48
|
};
|
|
49
49
|
constructor(props: any);
|
|
50
|
+
componentDidMount(): void;
|
|
51
|
+
componentDidUpdate(prevProps: any): void;
|
|
52
|
+
componentWillUnmount(): void;
|
|
50
53
|
handleMouseEnter: any;
|
|
51
54
|
handleMouseLeave: any;
|
|
55
|
+
dragStart: any;
|
|
52
56
|
setDragValue: (dragValue: any) => void;
|
|
53
57
|
changeValue: any;
|
|
54
58
|
dragStop: any;
|
package/dist/plot/common/plot.js
CHANGED
|
@@ -2,51 +2,58 @@ import e from "../../node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_m
|
|
|
2
2
|
import { bandKey as t } from "../../utils.js";
|
|
3
3
|
import { correct as n, incorrect as r } from "../../common/styles.js";
|
|
4
4
|
import { D as i, DragHandle as a } from "../../common/drag-handle.js";
|
|
5
|
-
import {
|
|
6
|
-
import s from "
|
|
7
|
-
import c from "
|
|
8
|
-
import
|
|
9
|
-
import u from "
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import g from "
|
|
5
|
+
import { DragHover as o } from "../../common/drag-hover.js";
|
|
6
|
+
import { MarkSlider as s } from "../../common/mark-slider.js";
|
|
7
|
+
import c from "react";
|
|
8
|
+
import l from "prop-types";
|
|
9
|
+
import { styled as u } from "@mui/material/styles";
|
|
10
|
+
import d from "debug";
|
|
11
|
+
import { types as f } from "@pie-lib/plot";
|
|
12
|
+
import { color as p } from "@pie-lib/render-ui";
|
|
13
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
14
|
+
import _ from "@mui/icons-material/Check";
|
|
14
15
|
//#region src/plot/common/plot.tsx
|
|
15
|
-
var
|
|
16
|
+
var v = d("pie-lib:chart:bars"), y = 16, b = 10, x = class extends c.Component {
|
|
16
17
|
static propTypes = {
|
|
17
|
-
onChangeCategory:
|
|
18
|
-
value:
|
|
19
|
-
label:
|
|
20
|
-
xBand:
|
|
21
|
-
index:
|
|
22
|
-
graphProps:
|
|
23
|
-
CustomBarElement:
|
|
24
|
-
interactive:
|
|
25
|
-
disabled:
|
|
26
|
-
correctness:
|
|
27
|
-
value:
|
|
28
|
-
label:
|
|
18
|
+
onChangeCategory: l.func,
|
|
19
|
+
value: l.number,
|
|
20
|
+
label: l.string,
|
|
21
|
+
xBand: l.func,
|
|
22
|
+
index: l.number.isRequired,
|
|
23
|
+
graphProps: f.GraphPropsType.isRequired,
|
|
24
|
+
CustomBarElement: l.func,
|
|
25
|
+
interactive: l.bool,
|
|
26
|
+
disabled: l.bool,
|
|
27
|
+
correctness: l.shape({
|
|
28
|
+
value: l.string,
|
|
29
|
+
label: l.string
|
|
29
30
|
}),
|
|
30
|
-
defineChart:
|
|
31
|
-
correctData:
|
|
32
|
-
value:
|
|
33
|
-
label:
|
|
31
|
+
defineChart: l.bool,
|
|
32
|
+
correctData: l.arrayOf(l.shape({
|
|
33
|
+
value: l.oneOfType([l.string, l.number]),
|
|
34
|
+
label: l.string
|
|
34
35
|
})),
|
|
35
|
-
className:
|
|
36
|
-
language:
|
|
36
|
+
className: l.string,
|
|
37
|
+
language: l.string
|
|
37
38
|
};
|
|
38
39
|
constructor(e) {
|
|
39
40
|
super(e), this.state = {
|
|
40
41
|
dragValue: void 0,
|
|
41
42
|
isHovered: !1
|
|
42
|
-
};
|
|
43
|
+
}, this.hover = new o((e) => this.setState({ isHovered: e }));
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.
|
|
49
|
-
}
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
this.hover.attach();
|
|
47
|
+
}
|
|
48
|
+
componentDidUpdate(e) {
|
|
49
|
+
this.props.disabled && !e.disabled && (this.hover.stop(), this.setDragValue(void 0));
|
|
50
|
+
}
|
|
51
|
+
componentWillUnmount() {
|
|
52
|
+
this.hover.dispose();
|
|
53
|
+
}
|
|
54
|
+
handleMouseEnter = () => this.hover.setInside(!0);
|
|
55
|
+
handleMouseLeave = () => this.hover.setInside(!1);
|
|
56
|
+
dragStart = () => this.hover.start();
|
|
50
57
|
setDragValue = (e) => this.setState({ dragValue: e });
|
|
51
58
|
changeValue = (e) => {
|
|
52
59
|
let { label: t, onChangeCategory: n } = this.props;
|
|
@@ -56,43 +63,43 @@ var _ = u("pie-lib:chart:bars"), v = 16, y = 10, b = class extends s.Component {
|
|
|
56
63
|
});
|
|
57
64
|
};
|
|
58
65
|
dragStop = () => {
|
|
59
|
-
let { dragValue: e } = this.state;
|
|
60
|
-
|
|
66
|
+
let { dragValue: e } = this.state, { disabled: t } = this.props;
|
|
67
|
+
v("[dragStop]", e), e !== void 0 && !t && this.changeValue(e), this.setDragValue(void 0), this.hover.stop();
|
|
61
68
|
};
|
|
62
69
|
dragValue = (e, t) => {
|
|
63
|
-
|
|
70
|
+
v("[dragValue] next:", t), this.setDragValue(t);
|
|
64
71
|
};
|
|
65
72
|
renderCorrectnessIcon = (e, t, n, r, i, a, o) => {
|
|
66
73
|
let s;
|
|
67
|
-
if (n === 0) s = i.y(0) -
|
|
74
|
+
if (n === 0) s = i.y(0) - y / 2;
|
|
68
75
|
else {
|
|
69
76
|
let e = n - 1;
|
|
70
|
-
s = i.y(e) - (a - o) / 2 - o / 2 -
|
|
77
|
+
s = i.y(e) - (a - o) / 2 - o / 2 - y / 2;
|
|
71
78
|
}
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
x: e + t / 2 -
|
|
79
|
+
return /* @__PURE__ */ h("foreignObject", {
|
|
80
|
+
x: e + t / 2 - y / 2,
|
|
74
81
|
y: s,
|
|
75
|
-
width:
|
|
76
|
-
height:
|
|
77
|
-
children: /* @__PURE__ */
|
|
82
|
+
width: y,
|
|
83
|
+
height: y,
|
|
84
|
+
children: /* @__PURE__ */ h(_, {
|
|
78
85
|
className: "correctnessIcon correctIcon smallIcon",
|
|
79
86
|
title: r.label
|
|
80
87
|
})
|
|
81
88
|
});
|
|
82
89
|
};
|
|
83
90
|
render() {
|
|
84
|
-
let { graphProps: e, value: n, label: r, xBand:
|
|
85
|
-
|
|
91
|
+
let { graphProps: e, value: n, label: r, xBand: o, index: l, CustomBarElement: u, interactive: d, disabled: f, correctness: _, defineChart: y, correctData: x, className: S, language: C } = this.props, { scale: w, range: T, size: E } = e, { max: D } = T || {}, { dragValue: O, isHovered: k } = this.state, A = Number.isFinite(O) ? O : n, j = o.bandwidth(), M = w.y(T.max - A), N = o(t({ label: r }, l));
|
|
92
|
+
v("label:", r, "barX:", N, "v: ", A, "barHeight:", M, "barWidth: ", j);
|
|
86
93
|
let P = [];
|
|
87
94
|
for (let e = 0; e < A; e++) P.push(e);
|
|
88
|
-
let F = E.height / D, I = (F > j ? j : F) * .8, L = d ? i : a, R = d && !
|
|
89
|
-
return /* @__PURE__ */
|
|
95
|
+
let F = E.height / D, I = (F > j ? j : F) * .8, L = d ? i : a, R = d && !_;
|
|
96
|
+
return /* @__PURE__ */ h(c.Fragment, { children: /* @__PURE__ */ g(s, {
|
|
90
97
|
className: S,
|
|
91
98
|
onMouseEnter: this.handleMouseEnter,
|
|
92
99
|
onMouseLeave: this.handleMouseLeave,
|
|
93
100
|
onTouchStart: this.handleMouseEnter,
|
|
94
101
|
onTouchEnd: this.handleMouseLeave,
|
|
95
|
-
enabled: d && !
|
|
102
|
+
enabled: d && !f,
|
|
96
103
|
label: r,
|
|
97
104
|
index: l,
|
|
98
105
|
value: A,
|
|
@@ -100,18 +107,18 @@ var _ = u("pie-lib:chart:bars"), v = 16, y = 10, b = class extends s.Component {
|
|
|
100
107
|
language: C,
|
|
101
108
|
focusBox: {
|
|
102
109
|
x: N,
|
|
103
|
-
y: w.y(A) -
|
|
110
|
+
y: w.y(A) - b,
|
|
104
111
|
width: j,
|
|
105
|
-
height: F * P.length +
|
|
112
|
+
height: F * P.length + b
|
|
106
113
|
},
|
|
107
114
|
onChange: this.changeValue,
|
|
108
115
|
children: [
|
|
109
|
-
k && R && /* @__PURE__ */
|
|
116
|
+
k && R && /* @__PURE__ */ h("rect", {
|
|
110
117
|
x: N,
|
|
111
118
|
y: w.y(A),
|
|
112
119
|
width: j,
|
|
113
120
|
height: P?.length ? F * P.length : 0,
|
|
114
|
-
stroke:
|
|
121
|
+
stroke: p.defaults.BORDER_GRAY,
|
|
115
122
|
strokeWidth: "4px",
|
|
116
123
|
fill: "transparent"
|
|
117
124
|
}),
|
|
@@ -125,30 +132,30 @@ var _ = u("pie-lib:chart:bars"), v = 16, y = 10, b = class extends s.Component {
|
|
|
125
132
|
value: n,
|
|
126
133
|
scale: w
|
|
127
134
|
})),
|
|
128
|
-
|
|
135
|
+
_ && _.value === "incorrect" && (() => {
|
|
129
136
|
let e = parseFloat(x[l] && x[l].value);
|
|
130
137
|
if (isNaN(e)) return null;
|
|
131
138
|
let i = A;
|
|
132
|
-
if (e === 0) return this.renderCorrectnessIcon(N, j, e,
|
|
139
|
+
if (e === 0) return this.renderCorrectnessIcon(N, j, e, _, w, F, I);
|
|
133
140
|
if (i > e) {
|
|
134
141
|
let i = [];
|
|
135
142
|
for (let t = 0; t < e; t++) i.push(t);
|
|
136
|
-
let a = i[i.length - 1],
|
|
137
|
-
return /* @__PURE__ */
|
|
143
|
+
let a = i[i.length - 1], s = o(t({ label: r }, l)), c = o.bandwidth(), d = E.height / D, f = (d > c ? c : d) * .8;
|
|
144
|
+
return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(u, {
|
|
138
145
|
index: a,
|
|
139
146
|
pointDiameter: f + 10,
|
|
140
|
-
barX:
|
|
141
|
-
barWidth:
|
|
147
|
+
barX: s,
|
|
148
|
+
barWidth: c,
|
|
142
149
|
pointHeight: d,
|
|
143
150
|
label: r,
|
|
144
151
|
value: n,
|
|
145
152
|
scale: w,
|
|
146
153
|
dottedOverline: !0
|
|
147
|
-
}), this.renderCorrectnessIcon(
|
|
154
|
+
}), this.renderCorrectnessIcon(s, c, e, _, w, d, f)] });
|
|
148
155
|
}
|
|
149
156
|
let a = [];
|
|
150
157
|
for (let t = i; t < e; t++) a.push(t);
|
|
151
|
-
return /* @__PURE__ */
|
|
158
|
+
return /* @__PURE__ */ g(m, { children: [a.map((e) => u({
|
|
152
159
|
index: e,
|
|
153
160
|
pointDiameter: I,
|
|
154
161
|
barX: N,
|
|
@@ -158,52 +165,53 @@ var _ = u("pie-lib:chart:bars"), v = 16, y = 10, b = class extends s.Component {
|
|
|
158
165
|
value: n,
|
|
159
166
|
scale: w,
|
|
160
167
|
dottedOverline: !0
|
|
161
|
-
})), this.renderCorrectnessIcon(N, j, e,
|
|
168
|
+
})), this.renderCorrectnessIcon(N, j, e, _, w, F, I)] });
|
|
162
169
|
})(),
|
|
163
|
-
/* @__PURE__ */
|
|
170
|
+
/* @__PURE__ */ h(L, {
|
|
164
171
|
x: N,
|
|
165
172
|
y: A,
|
|
166
173
|
interactive: d,
|
|
167
|
-
disabled:
|
|
174
|
+
disabled: f,
|
|
168
175
|
width: j,
|
|
176
|
+
onDragStart: this.dragStart,
|
|
169
177
|
onDrag: (e) => this.dragValue(n, e),
|
|
170
178
|
onDragStop: this.dragStop,
|
|
171
179
|
graphProps: e,
|
|
172
|
-
correctness:
|
|
180
|
+
correctness: _,
|
|
173
181
|
isHovered: k,
|
|
174
|
-
defineChart:
|
|
175
|
-
color:
|
|
182
|
+
defineChart: y,
|
|
183
|
+
color: p.primaryDark(),
|
|
176
184
|
isPlot: !0
|
|
177
185
|
})
|
|
178
186
|
]
|
|
179
187
|
}) });
|
|
180
188
|
}
|
|
181
|
-
},
|
|
189
|
+
}, S = u(x)(({ theme: e }) => ({
|
|
182
190
|
"& .dot": {
|
|
183
|
-
fill:
|
|
191
|
+
fill: p.visualElementsColors.PLOT_FILL_COLOR,
|
|
184
192
|
"&.correct": n("stroke"),
|
|
185
193
|
"&.incorrect": r("stroke")
|
|
186
194
|
},
|
|
187
195
|
"& .dotColor": {
|
|
188
|
-
fill:
|
|
196
|
+
fill: p.visualElementsColors.PLOT_FILL_COLOR,
|
|
189
197
|
"&.correct": n("fill"),
|
|
190
198
|
"&.incorrect": r("fill")
|
|
191
199
|
},
|
|
192
200
|
"& .line": {
|
|
193
|
-
stroke:
|
|
201
|
+
stroke: p.visualElementsColors.PLOT_FILL_COLOR,
|
|
194
202
|
"&.correct": n("stroke"),
|
|
195
203
|
"&.incorrect": r("stroke")
|
|
196
204
|
},
|
|
197
|
-
"& .correctIcon": { backgroundColor:
|
|
198
|
-
"& .incorrectIcon": { backgroundColor:
|
|
205
|
+
"& .correctIcon": { backgroundColor: p.correct() },
|
|
206
|
+
"& .incorrectIcon": { backgroundColor: p.incorrectWithIcon() },
|
|
199
207
|
"& .correctnessIcon": {
|
|
200
208
|
borderRadius: e.spacing(2),
|
|
201
|
-
color:
|
|
209
|
+
color: p.defaults.WHITE,
|
|
202
210
|
fontSize: "16px",
|
|
203
211
|
width: "16px",
|
|
204
212
|
height: "16px",
|
|
205
213
|
padding: "2px",
|
|
206
|
-
border: `1px solid ${
|
|
214
|
+
border: `1px solid ${p.defaults.WHITE}`,
|
|
207
215
|
stroke: "initial",
|
|
208
216
|
boxSizing: "unset",
|
|
209
217
|
display: "block"
|
|
@@ -213,24 +221,24 @@ var _ = u("pie-lib:chart:bars"), v = 16, y = 10, b = class extends s.Component {
|
|
|
213
221
|
width: "10px",
|
|
214
222
|
height: "10px"
|
|
215
223
|
}
|
|
216
|
-
})),
|
|
224
|
+
})), C = class extends c.Component {
|
|
217
225
|
static propTypes = {
|
|
218
|
-
data:
|
|
219
|
-
onChangeCategory:
|
|
220
|
-
xBand:
|
|
221
|
-
graphProps:
|
|
222
|
-
defineChart:
|
|
223
|
-
CustomBarElement:
|
|
224
|
-
correctData:
|
|
225
|
-
value:
|
|
226
|
-
label:
|
|
226
|
+
data: l.array,
|
|
227
|
+
onChangeCategory: l.func,
|
|
228
|
+
xBand: l.func,
|
|
229
|
+
graphProps: f.GraphPropsType.isRequired,
|
|
230
|
+
defineChart: l.bool,
|
|
231
|
+
CustomBarElement: l.func,
|
|
232
|
+
correctData: l.arrayOf(l.shape({
|
|
233
|
+
value: l.oneOfType([l.string, l.number]),
|
|
234
|
+
label: l.string
|
|
227
235
|
})),
|
|
228
|
-
className:
|
|
229
|
-
language:
|
|
236
|
+
className: l.string,
|
|
237
|
+
language: l.string
|
|
230
238
|
};
|
|
231
239
|
render() {
|
|
232
240
|
let { data: t, graphProps: n, xBand: r, CustomBarElement: i, onChangeCategory: a, defineChart: o, correctData: s, disabled: c, language: l } = this.props;
|
|
233
|
-
return /* @__PURE__ */
|
|
241
|
+
return /* @__PURE__ */ h(e, { children: (t || []).map((e, t) => /* @__PURE__ */ h(S, {
|
|
234
242
|
value: e.value,
|
|
235
243
|
label: e.label,
|
|
236
244
|
interactive: o || e.interactive,
|
|
@@ -248,4 +256,4 @@ var _ = u("pie-lib:chart:bars"), v = 16, y = 10, b = class extends s.Component {
|
|
|
248
256
|
}
|
|
249
257
|
};
|
|
250
258
|
//#endregion
|
|
251
|
-
export {
|
|
259
|
+
export { C as Plot, C as default, x as RawPlot };
|
package/dist/utils.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const getGridLinesAndAxisByChartType: (range: any, chartType: any
|
|
|
25
25
|
};
|
|
26
26
|
export declare const getRotateAngle: (fontSize: any, height: any) => 0 | 25;
|
|
27
27
|
export declare const getRotatedLabelOverhang: (width: any, height: any, angle: any) => number;
|
|
28
|
-
export declare const getTopPadding: (barWidth: any) => 0 |
|
|
28
|
+
export declare const getTopPadding: (barWidth: any) => 0 | 50 | 15 | 30;
|
|
29
29
|
export declare const getScale: (width: any) => {
|
|
30
30
|
scale: number;
|
|
31
31
|
deltay: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/charting",
|
|
3
|
-
"version": "8.0.8-next.
|
|
3
|
+
"version": "8.0.8-next.20261102164954",
|
|
4
4
|
"description": "charting",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
16
|
"@pie-element/shared-utils": "0.1.7-next.20261027193325",
|
|
17
|
-
"@pie-lib/plot": "5.0.8-next.
|
|
18
|
-
"@pie-lib/render-ui": "8.0.8-next.
|
|
17
|
+
"@pie-lib/plot": "5.0.8-next.20261102164954",
|
|
18
|
+
"@pie-lib/render-ui": "8.0.8-next.20261102164954",
|
|
19
19
|
"@pie-lib/translator": "5.0.3-next.20261027184745",
|
|
20
20
|
"@visx/axis": "^4.0.0",
|
|
21
21
|
"@visx/event": "^4.0.0",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"invariant": "^2.2.4",
|
|
31
31
|
"react-draggable": "^4.7.2",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
33
|
-
"@pie-lib/config-ui": "14.0.8-next.
|
|
34
|
-
"@pie-element/shared-math-rendering-mathjax": "0.1.9-next.
|
|
33
|
+
"@pie-lib/config-ui": "14.0.8-next.20261102164954",
|
|
34
|
+
"@pie-element/shared-math-rendering-mathjax": "0.1.9-next.20261102164954",
|
|
35
35
|
"@pie-element/shared-lodash": "0.1.4-next.20261026212738",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"d3-time": "^3.1.0",
|