cx 26.1.13 → 26.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/charts/Marker.d.ts +1 -1
- package/build/charts/Marker.d.ts.map +1 -1
- package/build/charts/Marker.js +16 -6
- package/build/charts/MouseTracker.d.ts +2 -0
- package/build/charts/MouseTracker.d.ts.map +1 -1
- package/build/charts/helpers/PointReducer.d.ts +2 -2
- package/build/charts/helpers/PointReducer.d.ts.map +1 -1
- package/build/data/View.d.ts +5 -3
- package/build/data/View.d.ts.map +1 -1
- package/build/data/View.js +3 -1
- package/build/data/ops/findTreeNode.d.ts +20 -1
- package/build/data/ops/findTreeNode.d.ts.map +1 -1
- package/build/data/ops/findTreeNode.js +19 -0
- package/build/data/ops/findTreePath.d.ts +1 -1
- package/build/data/ops/findTreePath.d.ts.map +1 -1
- package/build/data/ops/findTreePath.js +1 -1
- package/build/data/ops/removeTreeNodes.d.ts +14 -1
- package/build/data/ops/removeTreeNodes.d.ts.map +1 -1
- package/build/data/ops/removeTreeNodes.js +13 -0
- package/build/data/ops/updateArray.d.ts +1 -1
- package/build/data/ops/updateArray.d.ts.map +1 -1
- package/build/data/ops/updateArray.js +1 -1
- package/build/data/ops/updateTree.d.ts +20 -1
- package/build/data/ops/updateTree.d.ts.map +1 -1
- package/build/data/ops/updateTree.js +19 -0
- package/build/jsx-runtime.d.ts +1 -0
- package/build/jsx-runtime.d.ts.map +1 -1
- package/build/jsx-runtime.js +3 -1
- package/build/svg/Rectangle.d.ts +6 -4
- package/build/svg/Rectangle.d.ts.map +1 -1
- package/build/svg/Rectangle.js +9 -7
- package/build/ui/Instance.d.ts +1 -1
- package/build/ui/Instance.d.ts.map +1 -1
- package/build/ui/Instance.js +18 -8
- package/build/ui/IsolatedScope.d.ts +2 -1
- package/build/ui/IsolatedScope.d.ts.map +1 -1
- package/build/ui/Prop.d.ts +1 -1
- package/build/ui/Prop.d.ts.map +1 -1
- package/build/ui/Widget.d.ts +2 -0
- package/build/ui/Widget.d.ts.map +1 -1
- package/build/ui/Widget.js +4 -0
- package/build/ui/adapter/GroupAdapter.d.ts +4 -4
- package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
- package/build/ui/adapter/GroupAdapter.js +4 -4
- package/build/ui/adapter/TreeAdapter.d.ts +5 -3
- package/build/ui/adapter/TreeAdapter.d.ts.map +1 -1
- package/build/ui/adapter/TreeAdapter.js +12 -5
- package/build/ui/app/startAppLoop.d.ts +2 -2
- package/build/ui/app/startAppLoop.d.ts.map +1 -1
- package/build/ui/app/startHotAppLoop.d.ts +4 -4
- package/build/ui/app/startHotAppLoop.d.ts.map +1 -1
- package/build/ui/app/startHotAppLoop.js +1 -1
- package/build/ui/batchUpdates.d.ts.map +1 -1
- package/build/ui/batchUpdates.js +3 -4
- package/build/widgets/Button.d.ts +0 -7
- package/build/widgets/Button.d.ts.map +1 -1
- package/build/widgets/HtmlElement.d.ts +2 -2
- package/build/widgets/HtmlElement.d.ts.map +1 -1
- package/build/widgets/form/Checkbox.d.ts +3 -3
- package/build/widgets/form/Checkbox.d.ts.map +1 -1
- package/build/widgets/form/Checkbox.js +11 -6
- package/build/widgets/form/DateTimeField.d.ts +4 -0
- package/build/widgets/form/DateTimeField.d.ts.map +1 -1
- package/build/widgets/form/TextField.d.ts +2 -2
- package/build/widgets/form/TextField.d.ts.map +1 -1
- package/build/widgets/grid/Grid.d.ts +20 -16
- package/build/widgets/grid/Grid.d.ts.map +1 -1
- package/build/widgets/grid/Grid.js +200 -86
- package/build/widgets/nav/Menu.d.ts +2 -0
- package/build/widgets/nav/Menu.d.ts.map +1 -1
- package/build/widgets/nav/Route.js +1 -1
- package/build/widgets/overlay/FlyweightTooltipTracker.d.ts +6 -4
- package/build/widgets/overlay/FlyweightTooltipTracker.d.ts.map +1 -1
- package/build/widgets/overlay/FlyweightTooltipTracker.js +3 -0
- package/build/widgets/overlay/Overlay.d.ts +2 -2
- package/build/widgets/overlay/Overlay.d.ts.map +1 -1
- package/dist/data.js +52 -1
- package/dist/jsx-runtime.js +4 -2
- package/dist/manifest.js +910 -904
- package/dist/svg.js +3 -0
- package/dist/ui.js +1548 -1544
- package/dist/widgets.css +1 -1
- package/dist/widgets.js +395 -4
- package/package.json +2 -2
- package/src/charts/Marker.tsx +448 -394
- package/src/charts/MouseTracker.tsx +3 -0
- package/src/charts/helpers/PointReducer.ts +2 -2
- package/src/data/View.ts +76 -19
- package/src/data/ops/findTreeNode.ts +20 -1
- package/src/data/ops/findTreePath.ts +7 -2
- package/src/data/ops/removeTreeNodes.ts +14 -1
- package/src/data/ops/updateArray.ts +4 -4
- package/src/data/ops/updateTree.ts +32 -6
- package/src/index.scss +6 -6
- package/src/jsx-runtime.spec.tsx +40 -0
- package/src/jsx-runtime.ts +87 -84
- package/src/svg/Rectangle.tsx +80 -73
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/Instance.ts +142 -45
- package/src/ui/IsolatedScope.ts +4 -2
- package/src/ui/Prop.ts +141 -141
- package/src/ui/Rescope.ts +50 -50
- package/src/ui/Widget.tsx +292 -234
- package/src/ui/adapter/ArrayAdapter.ts +229 -229
- package/src/ui/adapter/GroupAdapter.ts +8 -10
- package/src/ui/adapter/TreeAdapter.ts +75 -15
- package/src/ui/app/Url.spec.ts +1 -1
- package/src/ui/app/startAppLoop.tsx +56 -45
- package/src/ui/app/startHotAppLoop.ts +4 -4
- package/src/ui/batchUpdates.ts +16 -21
- package/src/ui/exprHelpers.ts +96 -96
- package/src/widgets/Button.tsx +0 -8
- package/src/widgets/HtmlElement.spec.tsx +100 -72
- package/src/widgets/HtmlElement.tsx +11 -10
- package/src/widgets/Sandbox.ts +104 -104
- package/src/widgets/Section.scss +55 -55
- package/src/widgets/drag-drop/DropZone.scss +74 -74
- package/src/widgets/form/Checkbox.tsx +296 -243
- package/src/widgets/form/DateTimeField.tsx +6 -0
- package/src/widgets/form/TextField.tsx +2 -2
- package/src/widgets/grid/Grid.scss +43 -10
- package/src/widgets/grid/Grid.tsx +4401 -3848
- package/src/widgets/nav/Menu.tsx +3 -0
- package/src/widgets/nav/Route.ts +1 -1
- package/src/widgets/overlay/FlyweightTooltipTracker.ts +15 -4
- package/src/widgets/overlay/Overlay.tsx +2 -1
- package/src/widgets/overlay/index.d.ts +11 -11
package/src/charts/Marker.tsx
CHANGED
|
@@ -1,372 +1,416 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
2
|
|
|
3
3
|
import { Widget, VDOM } from "../ui/Widget";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BoundedObject,
|
|
6
|
+
BoundedObjectConfig,
|
|
7
|
+
BoundedObjectInstance,
|
|
8
|
+
} from "../svg/BoundedObject";
|
|
5
9
|
import { Rect } from "../svg/util/Rect";
|
|
6
10
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
tooltipMouseMove,
|
|
12
|
+
tooltipMouseLeave,
|
|
13
|
+
tooltipParentWillUnmount,
|
|
14
|
+
tooltipParentWillReceiveProps,
|
|
15
|
+
tooltipParentDidMount,
|
|
16
|
+
tooltipParentDidUpdate,
|
|
17
|
+
TooltipParentInstance,
|
|
18
|
+
TooltipConfig,
|
|
15
19
|
} from "../widgets/overlay/tooltip-ops";
|
|
16
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
captureMouseOrTouch,
|
|
22
|
+
getCursorPos,
|
|
23
|
+
} from "../widgets/overlay/captureMouse";
|
|
17
24
|
import { closest } from "../util/DOM";
|
|
18
25
|
import { Selection } from "../ui/selection/Selection";
|
|
19
26
|
import { getShape } from "./shapes";
|
|
20
27
|
import { getTopLevelBoundingClientRect } from "../util/getTopLevelBoundingClientRect";
|
|
21
28
|
import { RenderingContext } from "../ui/RenderingContext";
|
|
22
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
NumberProp,
|
|
31
|
+
BooleanProp,
|
|
32
|
+
StringProp,
|
|
33
|
+
StructuredProp,
|
|
34
|
+
} from "../ui/Prop";
|
|
23
35
|
import { Instance } from "../ui/Instance";
|
|
24
36
|
import type { ChartRenderingContext } from "./Chart";
|
|
25
37
|
|
|
26
38
|
export interface MarkerConfig extends BoundedObjectConfig {
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
/** The `x` value binding or expression. */
|
|
40
|
+
x?: NumberProp | StringProp;
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
/** The `y` value binding or expression. */
|
|
43
|
+
y?: NumberProp | StringProp;
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
/** Used to indicate if the data should affect axis span. */
|
|
46
|
+
affectsAxes?: boolean;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
/** Shape kind. `circle`, `square`, `triangle`, etc. */
|
|
49
|
+
shape?: StringProp;
|
|
38
50
|
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
/** Disabled state. */
|
|
52
|
+
disabled?: BooleanProp;
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
/** Index of a color from the standard palette of colors. 0-15. */
|
|
55
|
+
colorIndex?: NumberProp | StringProp;
|
|
44
56
|
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
/** Used to automatically assign a color based on the `name` and the contextual `ColorMap` widget. */
|
|
58
|
+
colorMap?: StringProp;
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
/** Name used to resolve the color. If not provided, `name` is used instead. */
|
|
61
|
+
colorName?: StringProp;
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
/** Color index to use for the legend entry. */
|
|
64
|
+
legendColorIndex?: NumberProp;
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
/** Name of the item as it will appear in the legend. */
|
|
67
|
+
name?: StringProp;
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
/** Used to indicate if an item is active or not. Inactive items are shown only in the legend. */
|
|
70
|
+
active?: BooleanProp;
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
/** X offset. */
|
|
73
|
+
xOffset?: number;
|
|
62
74
|
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
/** Y offset. */
|
|
76
|
+
yOffset?: number;
|
|
65
77
|
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
/** Size of the shape in pixels. */
|
|
79
|
+
size?: NumberProp;
|
|
68
80
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Name of the horizontal axis. The value should match one of the horizontal axes set
|
|
83
|
+
* in the `axes` configuration of the parent `Chart` component. Default value is `x`.
|
|
84
|
+
*/
|
|
85
|
+
xAxis?: string;
|
|
74
86
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Name of the vertical axis. The value should match one of the vertical axes set
|
|
89
|
+
* in the `axes` configuration if the parent `Chart` component. Default value is `y`.
|
|
90
|
+
*/
|
|
91
|
+
yAxis?: string;
|
|
80
92
|
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
/** Set to `true` to make the shape draggable along the X axis. */
|
|
94
|
+
draggableX?: boolean;
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
/** Set to `true` to make the shape draggable along the Y axis. */
|
|
97
|
+
draggableY?: boolean;
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
/** Set to `true` to make the shape draggable along the X and Y axis. */
|
|
100
|
+
draggable?: boolean;
|
|
89
101
|
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
/** Constrain the marker position to min/max values of the X axis during drag operations. */
|
|
103
|
+
constrainX?: boolean;
|
|
92
104
|
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
/** Constrain the marker position to min/max values of the Y axis during drag operations. */
|
|
106
|
+
constrainY?: boolean;
|
|
95
107
|
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
/** When set to `true`, it is equivalent to setting `constrainX` and `constrainY` to true. */
|
|
109
|
+
constrain?: boolean;
|
|
98
110
|
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
/** Name of the legend to be used. Default is `legend`. */
|
|
112
|
+
legend?: string;
|
|
101
113
|
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
/** Action to perform on legend item click. Default is `auto`. */
|
|
115
|
+
legendAction?: string;
|
|
104
116
|
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
/** Tooltip configuration. For more info see Tooltips. */
|
|
118
|
+
tooltip?: StringProp | StructuredProp;
|
|
107
119
|
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
/** Set to true to hide the marker. The marker will still participate in axis range calculations. */
|
|
121
|
+
hidden?: boolean;
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
/** Indicate that markers should be stacked horizontally. Default value is `false`. */
|
|
124
|
+
stackedX?: BooleanProp;
|
|
113
125
|
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
/** Indicate that markers should be stacked vertically. Default value is `false`. */
|
|
127
|
+
stackedY?: BooleanProp;
|
|
116
128
|
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
/** Name of the stack. If multiple stacks are used, each should have a unique name. Default value is `stack`. */
|
|
130
|
+
stack?: StringProp;
|
|
119
131
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Applies to rectangular shapes. The horizontal corner radius of the rect. Defaults to ry if ry is specified.
|
|
134
|
+
* Value type: <length>|<percentage>;
|
|
135
|
+
* If unit is not specified, it defaults to `px`.
|
|
136
|
+
*/
|
|
137
|
+
rx?: StringProp | NumberProp;
|
|
126
138
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Applies to rectangular shapes. The vertical corner radius of the rect. Defaults to rx if rx is specified.
|
|
141
|
+
* Value type: <length>|<percentage>;
|
|
142
|
+
* If unit is not specified, it defaults to `px`.
|
|
143
|
+
*/
|
|
144
|
+
ry?: StringProp | NumberProp;
|
|
133
145
|
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
/** Selection configuration. */
|
|
147
|
+
selection?: any;
|
|
136
148
|
|
|
137
|
-
|
|
138
|
-
|
|
149
|
+
/** Click event handler. */
|
|
150
|
+
onClick?: (e: React.MouseEvent, instance: Instance) => void;
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
export interface MarkerInstance
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
153
|
+
export interface MarkerInstance
|
|
154
|
+
extends BoundedObjectInstance,
|
|
155
|
+
TooltipParentInstance {
|
|
156
|
+
axes: Record<string, any>;
|
|
157
|
+
xAxis: any;
|
|
158
|
+
yAxis: any;
|
|
159
|
+
colorMap: any;
|
|
146
160
|
}
|
|
147
161
|
|
|
148
162
|
export class Marker extends BoundedObject {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
163
|
+
declare baseClass: string;
|
|
164
|
+
declare xAxis: string;
|
|
165
|
+
declare yAxis: string;
|
|
166
|
+
declare xOffset: number;
|
|
167
|
+
declare yOffset: number;
|
|
168
|
+
declare size: number;
|
|
169
|
+
declare draggableX: boolean;
|
|
170
|
+
declare draggableY: boolean;
|
|
171
|
+
declare draggable: boolean;
|
|
172
|
+
declare constrainX: boolean;
|
|
173
|
+
declare constrainY: boolean;
|
|
174
|
+
declare constrain: boolean;
|
|
175
|
+
declare legend: string;
|
|
176
|
+
declare legendAction: string;
|
|
177
|
+
declare shape: string;
|
|
178
|
+
declare hidden: boolean;
|
|
179
|
+
declare affectsAxes: boolean;
|
|
180
|
+
declare stackedY: boolean;
|
|
181
|
+
declare stackedX: boolean;
|
|
182
|
+
declare stack: string;
|
|
183
|
+
declare selection: Selection;
|
|
184
|
+
declare tooltip: TooltipConfig;
|
|
185
|
+
declare onClick: MarkerConfig["onClick"];
|
|
186
|
+
|
|
187
|
+
constructor(config: MarkerConfig) {
|
|
188
|
+
super(config);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
init(): void {
|
|
192
|
+
this.selection = Selection.create(this.selection);
|
|
193
|
+
|
|
194
|
+
if (this.draggable) {
|
|
195
|
+
this.draggableX = true;
|
|
196
|
+
this.draggableY = true;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (this.constrain) {
|
|
200
|
+
this.constrainX = true;
|
|
201
|
+
this.constrainY = true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
super.init();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declareData(...args: any[]): void {
|
|
208
|
+
var selection = this.selection.configureWidget(this);
|
|
209
|
+
|
|
210
|
+
super.declareData(...args, selection, {
|
|
211
|
+
x: undefined,
|
|
212
|
+
y: undefined,
|
|
213
|
+
size: undefined,
|
|
214
|
+
shape: undefined,
|
|
215
|
+
disabled: undefined,
|
|
216
|
+
colorMap: undefined,
|
|
217
|
+
colorIndex: undefined,
|
|
218
|
+
colorName: undefined,
|
|
219
|
+
legendColorIndex: undefined,
|
|
220
|
+
name: undefined,
|
|
221
|
+
active: true,
|
|
222
|
+
stack: undefined,
|
|
223
|
+
stackedX: undefined,
|
|
224
|
+
stackedY: undefined,
|
|
225
|
+
rx: undefined,
|
|
226
|
+
ry: undefined,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
prepareData(context: RenderingContext, instance: MarkerInstance): void {
|
|
231
|
+
instance.axes = context.axes;
|
|
232
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
233
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
234
|
+
let { data } = instance;
|
|
235
|
+
data.selected = this.selection.isInstanceSelected(instance);
|
|
236
|
+
data.stateMods = {
|
|
237
|
+
selected: data.selected,
|
|
238
|
+
disabled: data.disabled,
|
|
239
|
+
selectable: !this.selection.isDummy,
|
|
240
|
+
"draggable-x": this.draggableX && !this.draggableY,
|
|
241
|
+
"draggable-y": this.draggableY && !this.draggableX,
|
|
242
|
+
"draggable-xy": this.draggableY && this.draggableX,
|
|
243
|
+
};
|
|
244
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
245
|
+
super.prepareData(context, instance);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
calculateBounds(context: RenderingContext, instance: MarkerInstance): Rect {
|
|
249
|
+
let { data, xAxis, yAxis } = instance;
|
|
250
|
+
|
|
251
|
+
let x!: number, y!: number;
|
|
252
|
+
|
|
253
|
+
if (data.x == null || data.y == null) {
|
|
254
|
+
let bounds = super.calculateBounds(context, instance);
|
|
255
|
+
x = (bounds.l + bounds.r) / 2;
|
|
256
|
+
y = (bounds.t + bounds.b) / 2;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (data.x != null)
|
|
260
|
+
x = data.stackedX
|
|
261
|
+
? xAxis.stack(data.stack, data.y, data.x)
|
|
262
|
+
: xAxis.map(data.x);
|
|
263
|
+
|
|
264
|
+
if (data.y != null)
|
|
265
|
+
y = data.stackedY
|
|
266
|
+
? yAxis.stack(data.stack, data.x, data.y)
|
|
267
|
+
: yAxis.map(data.y);
|
|
268
|
+
|
|
269
|
+
return new Rect({
|
|
270
|
+
l: x - data.size / 2,
|
|
271
|
+
r: x + data.size / 2,
|
|
272
|
+
t: y - data.size / 2,
|
|
273
|
+
b: y + data.size / 2,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
explore(context: RenderingContext, instance: MarkerInstance): void {
|
|
278
|
+
let { data, xAxis, yAxis } = instance;
|
|
279
|
+
|
|
280
|
+
instance.colorMap =
|
|
281
|
+
data.colorMap &&
|
|
282
|
+
context.getColorMap &&
|
|
283
|
+
context.getColorMap(data.colorMap);
|
|
284
|
+
if (instance.colorMap && data.colorName)
|
|
285
|
+
instance.colorMap.acknowledge(data.colorName);
|
|
286
|
+
|
|
287
|
+
if (data.active) {
|
|
288
|
+
if (this.affectsAxes) {
|
|
289
|
+
if (xAxis && data.x != null) {
|
|
290
|
+
if (data.stackedX) xAxis.stacknowledge(data.stack, data.y, data.x);
|
|
291
|
+
else xAxis.acknowledge(data.x, 0, this.xOffset);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (yAxis && data.y != null) {
|
|
295
|
+
if (data.stackedY) yAxis.stacknowledge(data.stack, data.x, data.y);
|
|
296
|
+
else yAxis.acknowledge(data.y, 0, this.yOffset);
|
|
297
|
+
}
|
|
243
298
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
299
|
+
super.explore(context, instance);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
prepare(context: RenderingContext, instance: MarkerInstance): void {
|
|
304
|
+
let { data, xAxis, yAxis, colorMap } = instance;
|
|
305
|
+
|
|
306
|
+
if (colorMap && data.colorName) {
|
|
307
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
308
|
+
if (instance.cache("colorIndex", data.colorIndex))
|
|
309
|
+
instance.markShouldUpdate(context);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (data.active) {
|
|
313
|
+
if (xAxis && xAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
314
|
+
|
|
315
|
+
if (yAxis && yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
316
|
+
|
|
317
|
+
if (context.pointReducer)
|
|
318
|
+
context.pointReducer(data.x, data.y, data.name, data);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
super.prepare(context, instance);
|
|
322
|
+
|
|
323
|
+
if (data.name && context.addLegendEntry)
|
|
324
|
+
context.addLegendEntry(this.legend, {
|
|
325
|
+
name: data.name,
|
|
326
|
+
active: data.active,
|
|
327
|
+
colorIndex: data.legendColorIndex || data.colorIndex,
|
|
328
|
+
disabled: data.disabled,
|
|
329
|
+
selected: data.selected,
|
|
330
|
+
style: data.style,
|
|
331
|
+
shape: data.shape,
|
|
332
|
+
onClick: (e: MouseEvent) => {
|
|
333
|
+
this.onLegendClick(e, instance);
|
|
334
|
+
},
|
|
254
335
|
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (instance.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if (this.draggableX || this.draggableY) {
|
|
334
|
-
let svgEl = closest(e.target as Element, (el) => el.tagName == "svg");
|
|
335
|
-
if (svgEl)
|
|
336
|
-
captureMouseOrTouch(
|
|
337
|
-
e,
|
|
338
|
-
(e, captureData) => {
|
|
339
|
-
this.handleDragMove(e, instance, captureData);
|
|
340
|
-
},
|
|
341
|
-
undefined,
|
|
342
|
-
{ svgEl, el: e.target },
|
|
343
|
-
(e.target as HTMLElement).style.cursor
|
|
344
|
-
);
|
|
345
|
-
} else {
|
|
346
|
-
if (!this.selection.isDummy) this.selection.selectInstance(instance);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
handleClick(e: React.MouseEvent, instance: MarkerInstance): void {
|
|
351
|
-
if (this.onClick) instance.invoke("onClick", e, instance);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
handleDragMove(e: MouseEvent | TouchEvent, instance: MarkerInstance, captureData: any): void {
|
|
355
|
-
let cursor = getCursorPos(e);
|
|
356
|
-
let svgBounds = getTopLevelBoundingClientRect(captureData.svgEl);
|
|
357
|
-
let { xAxis, yAxis } = instance;
|
|
358
|
-
if (this.draggableX && xAxis) {
|
|
359
|
-
let x = xAxis.trackValue(cursor.clientX - svgBounds.left, this.xOffset);
|
|
360
|
-
if (this.constrainX) x = xAxis.constrainValue(x);
|
|
361
|
-
instance.set("x", xAxis.encodeValue(x));
|
|
362
|
-
}
|
|
363
|
-
if (this.draggableY && yAxis) {
|
|
364
|
-
let y = yAxis.trackValue(cursor.clientY - svgBounds.top, this.yOffset);
|
|
365
|
-
if (this.constrainY) y = yAxis.constrainValue(y);
|
|
366
|
-
instance.set("y", yAxis.encodeValue(y));
|
|
367
|
-
}
|
|
368
|
-
tooltipMouseMove(e, instance, this.tooltip, { target: captureData.el });
|
|
369
|
-
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
onLegendClick(e: MouseEvent, instance: MarkerInstance): void {
|
|
339
|
+
let allActions = this.legendAction == "auto";
|
|
340
|
+
let { data } = instance;
|
|
341
|
+
if (allActions || this.legendAction == "toggle")
|
|
342
|
+
if (instance.set("active", !data.active)) return;
|
|
343
|
+
|
|
344
|
+
if (allActions || this.legendAction == "select")
|
|
345
|
+
this.handleClick(e as unknown as React.MouseEvent, instance);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
render(
|
|
349
|
+
context: RenderingContext,
|
|
350
|
+
instance: MarkerInstance,
|
|
351
|
+
key: string,
|
|
352
|
+
): React.ReactNode {
|
|
353
|
+
let { data } = instance;
|
|
354
|
+
|
|
355
|
+
if (!data.active || data.x === null || data.y === null) return null;
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
<MarkerComponent
|
|
359
|
+
key={key}
|
|
360
|
+
instance={instance}
|
|
361
|
+
data={instance.data}
|
|
362
|
+
shouldUpdate={instance.shouldUpdate}
|
|
363
|
+
>
|
|
364
|
+
{this.renderChildren(context, instance)}
|
|
365
|
+
</MarkerComponent>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
handleMouseDown(
|
|
370
|
+
e: React.MouseEvent | React.TouchEvent,
|
|
371
|
+
instance: MarkerInstance,
|
|
372
|
+
): void {
|
|
373
|
+
if (this.draggableX || this.draggableY) {
|
|
374
|
+
let svgEl = closest(e.target as Element, (el) => el.tagName == "svg");
|
|
375
|
+
if (svgEl)
|
|
376
|
+
captureMouseOrTouch(
|
|
377
|
+
e,
|
|
378
|
+
(e, captureData) => {
|
|
379
|
+
this.handleDragMove(e, instance, captureData);
|
|
380
|
+
},
|
|
381
|
+
undefined,
|
|
382
|
+
{ svgEl, el: e.target },
|
|
383
|
+
(e.target as HTMLElement).style.cursor,
|
|
384
|
+
);
|
|
385
|
+
} else {
|
|
386
|
+
if (!this.selection.isDummy) this.selection.selectInstance(instance);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
handleClick(e: React.MouseEvent, instance: MarkerInstance): void {
|
|
391
|
+
if (this.onClick) instance.invoke("onClick", e, instance);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
handleDragMove(
|
|
395
|
+
e: MouseEvent | TouchEvent,
|
|
396
|
+
instance: MarkerInstance,
|
|
397
|
+
captureData: any,
|
|
398
|
+
): void {
|
|
399
|
+
let cursor = getCursorPos(e);
|
|
400
|
+
let svgBounds = getTopLevelBoundingClientRect(captureData.svgEl);
|
|
401
|
+
let { xAxis, yAxis } = instance;
|
|
402
|
+
if (this.draggableX && xAxis) {
|
|
403
|
+
let x = xAxis.trackValue(cursor.clientX - svgBounds.left, this.xOffset);
|
|
404
|
+
if (this.constrainX) x = xAxis.constrainValue(x);
|
|
405
|
+
instance.set("x", xAxis.encodeValue(x));
|
|
406
|
+
}
|
|
407
|
+
if (this.draggableY && yAxis) {
|
|
408
|
+
let y = yAxis.trackValue(cursor.clientY - svgBounds.top, this.yOffset);
|
|
409
|
+
if (this.constrainY) y = yAxis.constrainValue(y);
|
|
410
|
+
instance.set("y", yAxis.encodeValue(y));
|
|
411
|
+
}
|
|
412
|
+
tooltipMouseMove(e, instance, this.tooltip, { target: captureData.el });
|
|
413
|
+
}
|
|
370
414
|
}
|
|
371
415
|
|
|
372
416
|
Marker.prototype.xOffset = 0;
|
|
@@ -397,87 +441,97 @@ Marker.prototype.stack = "stack";
|
|
|
397
441
|
BoundedObject.alias("marker", Marker);
|
|
398
442
|
|
|
399
443
|
interface MarkerComponentProps {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
444
|
+
instance: MarkerInstance;
|
|
445
|
+
data: any;
|
|
446
|
+
shouldUpdate?: boolean;
|
|
447
|
+
children?: React.ReactNode;
|
|
404
448
|
}
|
|
405
449
|
|
|
406
450
|
class MarkerComponent extends VDOM.Component<MarkerComponentProps> {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
451
|
+
declare el: SVGElement | null;
|
|
452
|
+
|
|
453
|
+
shouldComponentUpdate(props: MarkerComponentProps): boolean {
|
|
454
|
+
return props.shouldUpdate ?? true;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
render(): React.ReactNode {
|
|
458
|
+
let { instance, children, data } = this.props;
|
|
459
|
+
let widget = instance.widget as Marker;
|
|
460
|
+
let { CSS, baseClass } = widget;
|
|
461
|
+
let { bounds, shape } = data;
|
|
462
|
+
let shapeRenderer = getShape(shape);
|
|
463
|
+
let shapeProps: Record<string, any> = {
|
|
464
|
+
className: CSS.element(baseClass, "shape", {
|
|
465
|
+
["color-" + data.colorIndex]: data.colorIndex != null,
|
|
466
|
+
selected: data.selected,
|
|
467
|
+
}),
|
|
468
|
+
style: data.style,
|
|
469
|
+
cx: (bounds.l + bounds.r) / 2,
|
|
470
|
+
cy: (bounds.t + bounds.b) / 2,
|
|
471
|
+
r: data.size / 2,
|
|
472
|
+
onMouseMove: (e: React.MouseEvent) => {
|
|
473
|
+
tooltipMouseMove(e, instance, widget.tooltip);
|
|
474
|
+
},
|
|
475
|
+
onMouseLeave: (e: React.MouseEvent) => {
|
|
476
|
+
tooltipMouseLeave(e, instance, widget.tooltip);
|
|
477
|
+
},
|
|
478
|
+
onMouseDown: (e: React.MouseEvent) => {
|
|
479
|
+
widget.handleMouseDown(e, instance);
|
|
480
|
+
},
|
|
481
|
+
onTouchStart: (e: React.TouchEvent) => {
|
|
482
|
+
widget.handleMouseDown(e, instance);
|
|
483
|
+
},
|
|
484
|
+
onClick: (e: React.MouseEvent) => {
|
|
485
|
+
widget.handleClick(e, instance);
|
|
486
|
+
},
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
if (
|
|
490
|
+
shape == "rect" ||
|
|
491
|
+
shape == "square" ||
|
|
492
|
+
shape == "bar" ||
|
|
493
|
+
shape == "column"
|
|
494
|
+
) {
|
|
495
|
+
shapeProps.rx = data.rx;
|
|
496
|
+
shapeProps.ry = data.ry;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (widget.tooltip) {
|
|
500
|
+
shapeProps.ref = (c: SVGElement | null) => {
|
|
501
|
+
this.el = c;
|
|
443
502
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
componentDidUpdate(): void {
|
|
480
|
-
let widget = this.props.instance.widget as Marker;
|
|
481
|
-
tooltipParentDidUpdate(this.el!, this.props.instance, widget.tooltip);
|
|
482
|
-
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return (
|
|
506
|
+
<g className={data.classNames}>
|
|
507
|
+
{!widget.hidden &&
|
|
508
|
+
shapeRenderer(
|
|
509
|
+
(bounds.l + bounds.r) / 2,
|
|
510
|
+
(bounds.t + bounds.b) / 2,
|
|
511
|
+
data.size,
|
|
512
|
+
shapeProps,
|
|
513
|
+
)}
|
|
514
|
+
{children}
|
|
515
|
+
</g>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
componentWillUnmount(): void {
|
|
520
|
+
tooltipParentWillUnmount(this.props.instance);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
UNSAFE_componentWillReceiveProps(props: MarkerComponentProps): void {
|
|
524
|
+
let widget = props.instance.widget as Marker;
|
|
525
|
+
tooltipParentWillReceiveProps(this.el!, props.instance, widget.tooltip);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
componentDidMount(): void {
|
|
529
|
+
let widget = this.props.instance.widget as Marker;
|
|
530
|
+
tooltipParentDidMount(this.el!, this.props.instance, widget.tooltip);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
componentDidUpdate(): void {
|
|
534
|
+
let widget = this.props.instance.widget as Marker;
|
|
535
|
+
tooltipParentDidUpdate(this.el!, this.props.instance, widget.tooltip);
|
|
536
|
+
}
|
|
483
537
|
}
|