cx 24.4.5 → 24.4.7
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/charts.js +11 -0
- package/dist/manifest.js +769 -769
- package/dist/widgets.js +1 -1
- package/package.json +1 -1
- package/src/charts/Chart.js +16 -18
- package/src/charts/ColumnBarBase.d.ts +2 -2
- package/src/charts/ColumnBarGraphBase.d.ts +2 -2
- package/src/charts/Legend.js +151 -148
- package/src/charts/LineGraph.d.ts +2 -2
- package/src/charts/ScatterGraph.d.ts +2 -2
- package/src/charts/axis/Axis.js +254 -252
- package/src/charts/axis/CategoryAxis.d.ts +11 -9
- package/src/charts/axis/CategoryAxis.js +54 -67
- package/src/data/getAccessor.spec.js +11 -0
- package/src/widgets/drag-drop/DropZone.js +214 -213
- package/src/widgets/grid/Grid.d.ts +22 -4
package/dist/widgets.js
CHANGED
|
@@ -19323,7 +19323,7 @@ var DropZoneComponent = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
19323
19323
|
var nearDistance = widget.nearDistance;
|
|
19324
19324
|
var over = rect.left <= clientX && clientX < rect.right && rect.top <= clientY && clientY < rect.bottom;
|
|
19325
19325
|
return {
|
|
19326
|
-
over: over &&
|
|
19326
|
+
over: over && Math.abs(clientX - (rect.left + rect.right) / 2) + Math.abs(clientY - (rect.top + rect.bottom) / 2),
|
|
19327
19327
|
near: nearDistance && (over || distance < nearDistance),
|
|
19328
19328
|
};
|
|
19329
19329
|
};
|
package/package.json
CHANGED
package/src/charts/Chart.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { Widget, VDOM, getContent } from
|
|
2
|
-
import { BoundedObject } from
|
|
3
|
-
import { Axis } from
|
|
1
|
+
import { Widget, VDOM, getContent } from "../ui/Widget";
|
|
2
|
+
import { BoundedObject } from "../svg/BoundedObject";
|
|
3
|
+
import { Axis } from "./axis/Axis";
|
|
4
4
|
|
|
5
5
|
export class Chart extends BoundedObject {
|
|
6
|
-
|
|
7
6
|
init() {
|
|
8
7
|
super.init();
|
|
9
8
|
|
|
10
|
-
if (!this.axes)
|
|
11
|
-
this.axes = {};
|
|
9
|
+
if (!this.axes) this.axes = {};
|
|
12
10
|
|
|
13
11
|
for (let axis in this.axes) {
|
|
14
12
|
this.axes[axis] = Axis.create(this.axes[axis]);
|
|
@@ -16,10 +14,9 @@ export class Chart extends BoundedObject {
|
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
explore(context, instance) {
|
|
19
|
-
|
|
20
17
|
instance.calculators = { ...context.axes };
|
|
21
18
|
|
|
22
|
-
context.push(
|
|
19
|
+
context.push("axes", instance.calculators);
|
|
23
20
|
instance.axes = {};
|
|
24
21
|
|
|
25
22
|
//axes need to be registered before children to be processed first
|
|
@@ -35,16 +32,20 @@ export class Chart extends BoundedObject {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
exploreCleanup(context, instance) {
|
|
38
|
-
context.pop(
|
|
35
|
+
context.pop("axes");
|
|
36
|
+
|
|
37
|
+
for (let axis in instance.axes) {
|
|
38
|
+
instance.axes[axis].widget.reportData(context, instance.axes[axis]);
|
|
39
|
+
}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
prepare(context, instance) {
|
|
42
|
-
context.push(
|
|
43
|
+
context.push("axes", instance.calculators);
|
|
43
44
|
super.prepare(context, instance);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
prepareCleanup(context, instance) {
|
|
47
|
-
context.pop(
|
|
48
|
+
context.pop("axes");
|
|
48
49
|
super.prepareCleanup(context, instance);
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -56,22 +57,19 @@ export class Chart extends BoundedObject {
|
|
|
56
57
|
|
|
57
58
|
let result = [];
|
|
58
59
|
|
|
59
|
-
if (!this.axesOnTop)
|
|
60
|
-
result.push(axes);
|
|
60
|
+
if (!this.axesOnTop) result.push(axes);
|
|
61
61
|
|
|
62
62
|
result.push(this.renderChildren(context, instance));
|
|
63
63
|
|
|
64
|
-
if (this.axesOnTop)
|
|
65
|
-
result.push(axes);
|
|
64
|
+
if (this.axesOnTop) result.push(axes);
|
|
66
65
|
|
|
67
66
|
return result;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
Chart.prototype.anchors =
|
|
70
|
+
Chart.prototype.anchors = "0 1 1 0";
|
|
72
71
|
Chart.prototype.styled = true;
|
|
73
72
|
Chart.prototype.isPureContainer = true;
|
|
74
73
|
Chart.prototype.axesOnTop = false;
|
|
75
74
|
|
|
76
|
-
Widget.alias(
|
|
77
|
-
|
|
75
|
+
Widget.alias("chart", Chart);
|
|
@@ -48,8 +48,8 @@ interface ColumnBarBaseProps extends Cx.StyledContainerProps {
|
|
|
48
48
|
*/
|
|
49
49
|
yAxis?: string;
|
|
50
50
|
|
|
51
|
-
/** Name of the legend to be used. Default is `legend`. */
|
|
52
|
-
legend?: string;
|
|
51
|
+
/** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
|
|
52
|
+
legend?: string | false;
|
|
53
53
|
|
|
54
54
|
legendAction?: string;
|
|
55
55
|
legendShape?: string;
|
|
@@ -60,8 +60,8 @@ interface ColumnBarGraphBaseProps extends Cx.WidgetProps {
|
|
|
60
60
|
|
|
61
61
|
colorIndexField?: boolean;
|
|
62
62
|
|
|
63
|
-
/** Name of the legend to be used. Default is `legend`. */
|
|
64
|
-
legend?: string;
|
|
63
|
+
/** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
|
|
64
|
+
legend?: string | false;
|
|
65
65
|
|
|
66
66
|
legendAction?: string;
|
|
67
67
|
legendShape?: string;
|
package/src/charts/Legend.js
CHANGED
|
@@ -1,148 +1,151 @@
|
|
|
1
|
-
import { Widget, VDOM } from "../ui/Widget";
|
|
2
|
-
import { HtmlElement } from "../widgets/HtmlElement";
|
|
3
|
-
import { PureContainer } from "../ui/PureContainer";
|
|
4
|
-
import { getShape } from "./shapes";
|
|
5
|
-
import { isUndefined } from "../util/isUndefined";
|
|
6
|
-
import { isArray } from "../util/isArray";
|
|
7
|
-
import { withHoverSync } from "../ui/HoverSync";
|
|
8
|
-
|
|
9
|
-
export class Legend extends HtmlElement {
|
|
10
|
-
prepareData(context, instance) {
|
|
11
|
-
let { data } = instance;
|
|
12
|
-
data.stateMods = Object.assign(data.stateMods || {}, {
|
|
13
|
-
vertical: this.vertical,
|
|
14
|
-
});
|
|
15
|
-
super.prepareData(context, instance);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declareData() {
|
|
19
|
-
super.declareData(...arguments, {
|
|
20
|
-
shape: undefined,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
isValidHtmlAttribute(attrName) {
|
|
25
|
-
switch (attrName) {
|
|
26
|
-
case "shapeSize":
|
|
27
|
-
case "svgSize":
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
list
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Legend.prototype.
|
|
123
|
-
Legend.prototype.
|
|
124
|
-
Legend.prototype.
|
|
125
|
-
Legend.prototype.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
1
|
+
import { Widget, VDOM } from "../ui/Widget";
|
|
2
|
+
import { HtmlElement } from "../widgets/HtmlElement";
|
|
3
|
+
import { PureContainer } from "../ui/PureContainer";
|
|
4
|
+
import { getShape } from "./shapes";
|
|
5
|
+
import { isUndefined } from "../util/isUndefined";
|
|
6
|
+
import { isArray } from "../util/isArray";
|
|
7
|
+
import { withHoverSync } from "../ui/HoverSync";
|
|
8
|
+
|
|
9
|
+
export class Legend extends HtmlElement {
|
|
10
|
+
prepareData(context, instance) {
|
|
11
|
+
let { data } = instance;
|
|
12
|
+
data.stateMods = Object.assign(data.stateMods || {}, {
|
|
13
|
+
vertical: this.vertical,
|
|
14
|
+
});
|
|
15
|
+
super.prepareData(context, instance);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declareData() {
|
|
19
|
+
super.declareData(...arguments, {
|
|
20
|
+
shape: undefined,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
isValidHtmlAttribute(attrName) {
|
|
25
|
+
switch (attrName) {
|
|
26
|
+
case "shapeSize":
|
|
27
|
+
case "svgSize":
|
|
28
|
+
case "shape":
|
|
29
|
+
return false;
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
return super.isValidHtmlAttribute(attrName);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
explore(context, instance) {
|
|
37
|
+
if (!context.legends) context.legends = {};
|
|
38
|
+
|
|
39
|
+
instance.legends = context.legends;
|
|
40
|
+
|
|
41
|
+
context.addLegendEntry = (legendName, entry) => {
|
|
42
|
+
if (!legendName) return;
|
|
43
|
+
|
|
44
|
+
//case when all legends are scoped and new entry is added outside the scope
|
|
45
|
+
if (!context.legends) return;
|
|
46
|
+
|
|
47
|
+
let legend = context.legends[legendName];
|
|
48
|
+
if (!legend)
|
|
49
|
+
legend = context.legends[legendName] = {
|
|
50
|
+
entries: [],
|
|
51
|
+
names: {},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (!legend.names[entry.name]) {
|
|
55
|
+
legend.entries.push(entry);
|
|
56
|
+
legend.names[entry.name] = entry;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
super.explore(context, instance);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
renderChildren(context, instance) {
|
|
64
|
+
const CSS = this.CSS;
|
|
65
|
+
|
|
66
|
+
let entries = instance.legends[this.name] && instance.legends[this.name].entries,
|
|
67
|
+
list;
|
|
68
|
+
|
|
69
|
+
if (isArray(entries) && entries.length > 0) {
|
|
70
|
+
list = (
|
|
71
|
+
<div key="wrap" className={CSS.element(this.baseClass, "wrap")}>
|
|
72
|
+
{entries.map((e, i) =>
|
|
73
|
+
withHoverSync(i, e.hoverSync, e.hoverChannel, e.hoverId, ({ onMouseMove, onMouseLeave, hover }) => (
|
|
74
|
+
<div
|
|
75
|
+
key={i}
|
|
76
|
+
className={CSS.element(this.baseClass, "entry", {
|
|
77
|
+
"color-root": true,
|
|
78
|
+
hover,
|
|
79
|
+
disabled: e.disabled,
|
|
80
|
+
selected: e.selected,
|
|
81
|
+
})}
|
|
82
|
+
onClick={e.onClick}
|
|
83
|
+
onMouseMove={onMouseMove}
|
|
84
|
+
onMouseLeave={onMouseLeave}
|
|
85
|
+
>
|
|
86
|
+
{this.renderShape(e, instance.data.shape)}
|
|
87
|
+
{e.name}
|
|
88
|
+
</div>
|
|
89
|
+
)),
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return [list, super.renderChildren(context, instance)];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
renderShape(entry, legendEntriesShape) {
|
|
99
|
+
const className = this.CSS.element(this.baseClass, "shape", {
|
|
100
|
+
[`color-${entry.colorIndex}`]: entry.colorIndex != null && (isUndefined(entry.active) || entry.active),
|
|
101
|
+
});
|
|
102
|
+
const shape = getShape(legendEntriesShape || entry.shape || "square");
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<svg
|
|
106
|
+
className={this.CSS.element(this.baseClass, "svg")}
|
|
107
|
+
style={{
|
|
108
|
+
width: `${this.svgSize}px`,
|
|
109
|
+
height: `${this.svgSize}px`,
|
|
110
|
+
marginTop: `${-this.svgSize / 2}px`,
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{shape(this.svgSize / 2, this.svgSize / 2, entry.shapeSize || this.shapeSize, {
|
|
114
|
+
style: entry.style,
|
|
115
|
+
className: className,
|
|
116
|
+
})}
|
|
117
|
+
</svg>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Legend.prototype.name = "legend";
|
|
123
|
+
Legend.prototype.baseClass = "legend";
|
|
124
|
+
Legend.prototype.vertical = false;
|
|
125
|
+
Legend.prototype.memoize = false;
|
|
126
|
+
Legend.prototype.shapeSize = 18;
|
|
127
|
+
Legend.prototype.shape = null;
|
|
128
|
+
Legend.prototype.svgSize = 20;
|
|
129
|
+
|
|
130
|
+
Widget.alias("legend", Legend);
|
|
131
|
+
|
|
132
|
+
Legend.Scope = class extends PureContainer {
|
|
133
|
+
explore(context, instance) {
|
|
134
|
+
context.push("legends", (instance.legends = {}));
|
|
135
|
+
super.explore(context, instance);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
exploreCleanup(context, instance) {
|
|
139
|
+
context.pop("legends");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
prepare(context, instance) {
|
|
143
|
+
context.push("legends", instance.legends);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
prepareCleanup(context, instance) {
|
|
147
|
+
context.pop("legends");
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const LegendScope = Legend.Scope;
|
|
@@ -79,8 +79,8 @@ interface LineGraphProps extends Cx.WidgetProps {
|
|
|
79
79
|
/** Name of the property which holds the y0 value. Default value is `false`, which means y0 value is not read from the data array. */
|
|
80
80
|
y0Field?: string | false;
|
|
81
81
|
|
|
82
|
-
/** Name of the legend to be used. Default is `legend`. */
|
|
83
|
-
legend?: string;
|
|
82
|
+
/** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
|
|
83
|
+
legend?: string | false;
|
|
84
84
|
|
|
85
85
|
legendAction?: string;
|
|
86
86
|
legendShape?: string;
|
|
@@ -52,8 +52,8 @@ interface ScatterGraphProps extends Cx.StyledContainerProps {
|
|
|
52
52
|
/** Name of the property which holds the size value. Do not set if `size` is used. */
|
|
53
53
|
sizeField?: string | false;
|
|
54
54
|
|
|
55
|
-
/** Name of the legend to be used. Default is legend. */
|
|
56
|
-
legend?: string;
|
|
55
|
+
/** Name of the legend to be used. Default is `legend`. Set to `false` to hide the legend entry. */
|
|
56
|
+
legend?: string | false;
|
|
57
57
|
|
|
58
58
|
legendAction?: string;
|
|
59
59
|
|