cx 24.2.0 → 24.3.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/dist/charts.js +104 -34
- package/dist/data.js +26 -15
- package/dist/manifest.js +685 -685
- package/package.json +1 -1
- package/src/charts/PieChart.d.ts +3 -0
- package/src/charts/PieChart.js +115 -36
- package/src/charts/axis/Axis.d.ts +96 -96
- package/src/charts/axis/Axis.js +252 -252
- package/src/data/Expression.js +212 -212
- package/src/data/Expression.spec.js +174 -174
- package/src/data/StringTemplate.spec.js +105 -105
- package/src/ui/Controller.d.ts +182 -182
- package/src/ui/Cx.d.ts +3 -3
- package/src/ui/FocusManager.js +171 -171
- package/src/ui/Format.js +87 -87
- package/src/ui/Instance.d.ts +72 -72
- package/src/ui/app/startAppLoop.js +3 -3
- package/src/widgets/form/ColorPicker.scss +275 -275
- package/src/widgets/form/ColorPicker.variables.scss +22 -22
- package/src/widgets/form/Label.js +88 -88
- package/src/widgets/form/UploadButton.d.ts +34 -34
- package/src/widgets/grid/Grid.js +3277 -3277
package/package.json
CHANGED
package/src/charts/PieChart.d.ts
CHANGED
|
@@ -75,6 +75,9 @@ interface PieSliceProps extends Cx.StyledContainerProps {
|
|
|
75
75
|
|
|
76
76
|
/** A value used to uniquely identify the record within the hover sync group. */
|
|
77
77
|
hoverId?: Cx.StringProp;
|
|
78
|
+
|
|
79
|
+
/** Border radius of the slice. Default is 0. */
|
|
80
|
+
borderRadius?: Cx.NumberProp;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
export class PieSlice extends Cx.Widget<PieSliceProps> {}
|
package/src/charts/PieChart.js
CHANGED
|
@@ -102,50 +102,110 @@ class PieCalculator {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function createSvgArc(x, y, r0, r,
|
|
106
|
-
if (
|
|
107
|
-
var s =
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
function createSvgArc(x, y, r0 = 0, r, startAngleRadian, endAngleRadian, br = 0) {
|
|
106
|
+
if (startAngleRadian > endAngleRadian) {
|
|
107
|
+
var s = startAngleRadian;
|
|
108
|
+
startAngleRadian = endAngleRadian;
|
|
109
|
+
endAngleRadian = s;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
let path = [];
|
|
113
|
+
// limit br size based on r and r0
|
|
114
|
+
if (br > (r - r0) / 2) br = (r - r0) / 2;
|
|
115
|
+
|
|
116
|
+
let largeArc = endAngleRadian - startAngleRadian > Math.PI ? 1 : 0;
|
|
117
|
+
|
|
118
|
+
if (br > 0) {
|
|
119
|
+
if (r0 > 0) {
|
|
120
|
+
let innerBr = br;
|
|
121
|
+
let innerSmallArcAngle = Math.asin(br / (r0 + br));
|
|
122
|
+
if (innerSmallArcAngle > (endAngleRadian - startAngleRadian) / 2) {
|
|
123
|
+
innerSmallArcAngle = (endAngleRadian - startAngleRadian) / 2;
|
|
124
|
+
let sin = Math.sin(innerSmallArcAngle);
|
|
125
|
+
// correct br according to newly calculated border radius angle
|
|
126
|
+
innerBr = (r0 * sin) / (1 - sin);
|
|
127
|
+
}
|
|
128
|
+
let innerHip = Math.cos(innerSmallArcAngle) * (r0 + innerBr);
|
|
129
|
+
|
|
130
|
+
let innerSmallArc1XFrom = x + Math.cos(endAngleRadian) * innerHip;
|
|
131
|
+
let innerSmallArc1YFrom = y - Math.sin(endAngleRadian) * innerHip;
|
|
132
|
+
|
|
133
|
+
// move from the first small inner arc
|
|
134
|
+
path.push(move(innerSmallArc1XFrom, innerSmallArc1YFrom));
|
|
135
|
+
|
|
136
|
+
let innerSmallArc1XTo = x + Math.cos(endAngleRadian - innerSmallArcAngle) * r0;
|
|
137
|
+
let innerSmallArc1YTo = y - Math.sin(endAngleRadian - innerSmallArcAngle) * r0;
|
|
113
138
|
|
|
114
|
-
|
|
139
|
+
// add first small inner arc
|
|
140
|
+
path.push(arc(innerBr, innerBr, 0, 0, 0, innerSmallArc1XTo, innerSmallArc1YTo));
|
|
115
141
|
|
|
116
|
-
|
|
142
|
+
let innerArcXTo = x + Math.cos(startAngleRadian + innerSmallArcAngle) * r0;
|
|
143
|
+
let innerArcYTo = y - Math.sin(startAngleRadian + innerSmallArcAngle) * r0;
|
|
117
144
|
|
|
118
|
-
|
|
145
|
+
// add large inner arc
|
|
146
|
+
path.push(arc(r0, r0, 0, largeArc, 1, innerArcXTo, innerArcYTo));
|
|
119
147
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
let innerSmallArc2XTo = x + Math.cos(startAngleRadian) * innerHip;
|
|
149
|
+
let innerSmallArc2YTo = y - Math.sin(startAngleRadian) * innerHip;
|
|
150
|
+
// add second small inner arc
|
|
151
|
+
path.push(arc(innerBr, innerBr, 0, 0, 0, innerSmallArc2XTo, innerSmallArc2YTo));
|
|
152
|
+
} else {
|
|
153
|
+
path.push(move(x, y));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let outerBr = br;
|
|
157
|
+
let outerSmallArcAngle = Math.asin(br / (r - br));
|
|
158
|
+
if (outerSmallArcAngle > (endAngleRadian - startAngleRadian) / 2) {
|
|
159
|
+
outerSmallArcAngle = (endAngleRadian - startAngleRadian) / 2;
|
|
160
|
+
let sin = Math.sin(outerSmallArcAngle);
|
|
161
|
+
// correct br according to newly calculated border radius angle
|
|
162
|
+
outerBr = (r * sin) / (1 + sin);
|
|
163
|
+
}
|
|
164
|
+
let outerHip = Math.cos(outerSmallArcAngle) * (r - outerBr);
|
|
124
165
|
|
|
125
|
-
|
|
166
|
+
let outerSmallArc1XFrom = x + Math.cos(startAngleRadian) * outerHip;
|
|
167
|
+
let outerSmallArc1YFrom = y - Math.sin(startAngleRadian) * outerHip;
|
|
168
|
+
|
|
169
|
+
let outerSmallArc1XTo = x + Math.cos(startAngleRadian + outerSmallArcAngle) * r;
|
|
170
|
+
let outerSmallArc1YTo = y - Math.sin(startAngleRadian + outerSmallArcAngle) * r;
|
|
171
|
+
|
|
172
|
+
let outerLargeArcXTo = x + Math.cos(endAngleRadian - outerSmallArcAngle) * r;
|
|
173
|
+
let outerLargeArcYTo = y - Math.sin(endAngleRadian - outerSmallArcAngle) * r;
|
|
174
|
+
|
|
175
|
+
let outerSmallArc2XTo = x + Math.cos(endAngleRadian) * outerHip;
|
|
176
|
+
let outerSmallArc2YTo = y - Math.sin(endAngleRadian) * outerHip;
|
|
177
|
+
|
|
178
|
+
path.push(
|
|
179
|
+
line(outerSmallArc1XFrom, outerSmallArc1YFrom),
|
|
180
|
+
arc(outerBr, outerBr, 0, 0, 0, outerSmallArc1XTo, outerSmallArc1YTo),
|
|
181
|
+
arc(r, r, 0, largeArc, 0, outerLargeArcXTo, outerLargeArcYTo),
|
|
182
|
+
arc(outerBr, outerBr, 0, 0, 0, outerSmallArc2XTo, outerSmallArc2YTo)
|
|
183
|
+
);
|
|
126
184
|
} else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
185
|
+
if (r0 > 0) {
|
|
186
|
+
let startX = x + Math.cos(endAngleRadian) * r0;
|
|
187
|
+
let startY = y - Math.sin(endAngleRadian) * r0;
|
|
188
|
+
path.push(move(startX, startY));
|
|
189
|
+
|
|
190
|
+
let innerArcToX = x + Math.cos(startAngleRadian) * r0;
|
|
191
|
+
let innerArcToY = y - Math.sin(startAngleRadian) * r0;
|
|
192
|
+
|
|
193
|
+
path.push(arc(r0, r0, 0, largeArc, 1, innerArcToX, innerArcToY));
|
|
194
|
+
} else {
|
|
195
|
+
path.push(move(x, y));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let lineToX = x + Math.cos(startAngleRadian) * r;
|
|
199
|
+
let lineToY = y - Math.sin(startAngleRadian) * r;
|
|
200
|
+
path.push(line(lineToX, lineToY));
|
|
201
|
+
|
|
202
|
+
let arcToX = x + Math.cos(endAngleRadian) * r;
|
|
203
|
+
let arcToY = y - Math.sin(endAngleRadian) * r;
|
|
204
|
+
path.push(arc(r, r, 0, largeArc, 0, arcToX, arcToY));
|
|
130
205
|
}
|
|
131
206
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
x + Math.cos(startAngle) * r,
|
|
135
|
-
y - Math.sin(startAngle) * r,
|
|
136
|
-
"A",
|
|
137
|
-
r,
|
|
138
|
-
r,
|
|
139
|
-
0,
|
|
140
|
-
largeArc,
|
|
141
|
-
0,
|
|
142
|
-
x + Math.cos(endAngle) * r,
|
|
143
|
-
y - Math.sin(endAngle) * r,
|
|
144
|
-
"L",
|
|
145
|
-
startX,
|
|
146
|
-
startY
|
|
147
|
-
);
|
|
148
|
-
return result.join(" ");
|
|
207
|
+
path.push(z());
|
|
208
|
+
return path.join(" ");
|
|
149
209
|
}
|
|
150
210
|
|
|
151
211
|
PieChart.prototype.anchors = "0 1 1 0";
|
|
@@ -155,6 +215,7 @@ Widget.alias("pie-slice");
|
|
|
155
215
|
export class PieSlice extends Container {
|
|
156
216
|
init() {
|
|
157
217
|
this.selection = Selection.create(this.selection);
|
|
218
|
+
if (this.borderRadius) this.br = this.borderRadius;
|
|
158
219
|
super.init();
|
|
159
220
|
}
|
|
160
221
|
|
|
@@ -176,6 +237,7 @@ export class PieSlice extends Container {
|
|
|
176
237
|
stack: undefined,
|
|
177
238
|
legend: undefined,
|
|
178
239
|
hoverId: undefined,
|
|
240
|
+
br: undefined,
|
|
179
241
|
});
|
|
180
242
|
}
|
|
181
243
|
|
|
@@ -307,13 +369,14 @@ export class PieSlice extends Container {
|
|
|
307
369
|
hover,
|
|
308
370
|
};
|
|
309
371
|
|
|
310
|
-
|
|
372
|
+
let d = createSvgArc(
|
|
311
373
|
segment.ox,
|
|
312
374
|
segment.oy,
|
|
313
375
|
data.r0 * segment.radiusMultiplier,
|
|
314
376
|
data.r * segment.radiusMultiplier,
|
|
315
377
|
segment.startAngle,
|
|
316
|
-
segment.endAngle
|
|
378
|
+
segment.endAngle,
|
|
379
|
+
data.br
|
|
317
380
|
);
|
|
318
381
|
|
|
319
382
|
return (
|
|
@@ -352,6 +415,22 @@ export class PieSlice extends Container {
|
|
|
352
415
|
}
|
|
353
416
|
}
|
|
354
417
|
|
|
418
|
+
function move(x, y) {
|
|
419
|
+
return `M ${x} ${y}`;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function line(x, y) {
|
|
423
|
+
return `L ${x} ${y}`;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function z() {
|
|
427
|
+
return "Z";
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function arc(rx, ry, xRotation, largeArc, sweep, x, y) {
|
|
431
|
+
return `A ${rx} ${ry} ${xRotation} ${largeArc} ${sweep} ${x} ${y}`;
|
|
432
|
+
}
|
|
433
|
+
|
|
355
434
|
PieSlice.prototype.offset = 0;
|
|
356
435
|
PieSlice.prototype.r0 = 0;
|
|
357
436
|
PieSlice.prototype.r = 50;
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { Instance } from "./../../ui/Instance.d";
|
|
2
|
-
import * as Cx from "../../core";
|
|
3
|
-
import { BoundedObject, BoundedObjectProps } from "../../svg/BoundedObject";
|
|
4
|
-
|
|
5
|
-
export interface AxisProps extends BoundedObjectProps {
|
|
6
|
-
/** Set to `true` for vertical axes. */
|
|
7
|
-
vertical?: boolean;
|
|
8
|
-
|
|
9
|
-
/** Used as a secondary axis. Displayed at the top/right. */
|
|
10
|
-
secondary?: boolean;
|
|
11
|
-
|
|
12
|
-
/** When set to `true`, the values are displayed in descending order. */
|
|
13
|
-
inverted?: Cx.BooleanProp;
|
|
14
|
-
|
|
15
|
-
/** When set to `true`, rendering of visual elements of the axis, such as ticks and labels, is skipped, but their function is preserved. */
|
|
16
|
-
hidden?: boolean;
|
|
17
|
-
|
|
18
|
-
tickSize?: number;
|
|
19
|
-
minTickDistance?: number;
|
|
20
|
-
minLabelDistanceVertical?: number;
|
|
21
|
-
minLabelDistanceHorizontal?: number;
|
|
22
|
-
|
|
23
|
-
/** Distance between labels and the axis. */
|
|
24
|
-
labelOffset?: number | string;
|
|
25
|
-
|
|
26
|
-
/** Label rotation angle in degrees. */
|
|
27
|
-
labelRotation?: Cx.Prop<number | string>;
|
|
28
|
-
|
|
29
|
-
/** Label text-anchor value. Allowed values are start, end and middle. Default value is set based on the value of vertical and secondary flags. */
|
|
30
|
-
labelAnchor?: "start" | "end" | "middle" | "auto";
|
|
31
|
-
|
|
32
|
-
/** Horizontal text offset. */
|
|
33
|
-
labelDx?: number | string;
|
|
34
|
-
|
|
35
|
-
/** Vertical text offset which can be used for vertical alignment. */
|
|
36
|
-
labelDy?: number | string;
|
|
37
|
-
|
|
38
|
-
/** Set to `true` to break long labels into multiple lines. Default value is `false`. Text is split at space characters. See also `labelMaxLineLength` and `labelLineCountDyFactor`. */
|
|
39
|
-
labelWrap?: boolean;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Used for vertical adjustment of multi-line labels. Default value is `auto` which means
|
|
43
|
-
* that value is initialized based on axis configuration. Value `0` means that label will grow towards
|
|
44
|
-
* the bottom of the screen. Value `-1` will make labels to grow towards the top of the screen.
|
|
45
|
-
* `-0.5` will make labels vertically centered.
|
|
46
|
-
*/
|
|
47
|
-
labelLineCountDyFactor?: number | string;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Used for vertical adjustment of multi-line labels. Default value is 1 which means
|
|
51
|
-
* that labels are stacked without any space between them. Value of 1.4 will add 40% of the label height as a space between labels.
|
|
52
|
-
*/
|
|
53
|
-
labelLineHeight?: number | string;
|
|
54
|
-
|
|
55
|
-
/** If `labelWrap` is on, this number is used as a measure to split labels into multiple lines. Default value is `10`. */
|
|
56
|
-
labelMaxLineLength?: number;
|
|
57
|
-
|
|
58
|
-
/** Set to true to hide the axis labels. */
|
|
59
|
-
hideLabels?: boolean;
|
|
60
|
-
|
|
61
|
-
/** Set to true to hide the axis line. */
|
|
62
|
-
hideLine?: boolean;
|
|
63
|
-
|
|
64
|
-
/** Set to true to hide the axis ticks. */
|
|
65
|
-
hideTicks?: boolean;
|
|
66
|
-
|
|
67
|
-
/** Additional CSS style to be applied to the axis line. */
|
|
68
|
-
lineStyle?: Cx.StyleProp;
|
|
69
|
-
|
|
70
|
-
/** Additional CSS style to be applied to the axis ticks. */
|
|
71
|
-
tickStyle?: Cx.StyleProp;
|
|
72
|
-
|
|
73
|
-
/** Additional CSS style to be applied to the axis labels. */
|
|
74
|
-
labelStyle?: Cx.StyleProp;
|
|
75
|
-
|
|
76
|
-
/** Additional CSS class to be applied to the axis line. */
|
|
77
|
-
lineClass?: Cx.ClassProp;
|
|
78
|
-
|
|
79
|
-
/** Additional CSS class to be applied to the axis ticks. */
|
|
80
|
-
tickClass?: Cx.ClassProp;
|
|
81
|
-
|
|
82
|
-
/** Additional CSS class to be applied to the axis labels. */
|
|
83
|
-
labelClass?: Cx.ClassProp;
|
|
84
|
-
|
|
85
|
-
onMeasured?: (info: any, instance: Instance) => void;
|
|
86
|
-
|
|
87
|
-
/** A function used to create a formatter function for axis labels. See Complex Labels example in the CxJS documentation for more info. */
|
|
88
|
-
onCreateLabelFormatter?:
|
|
89
|
-
| string
|
|
90
|
-
| ((
|
|
91
|
-
context: any,
|
|
92
|
-
instance: Instance
|
|
93
|
-
) => (formattedValue: string, value: any) => { text: string; style?: any; className?: string }[]);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export class Axis extends BoundedObject {}
|
|
1
|
+
import { Instance } from "./../../ui/Instance.d";
|
|
2
|
+
import * as Cx from "../../core";
|
|
3
|
+
import { BoundedObject, BoundedObjectProps } from "../../svg/BoundedObject";
|
|
4
|
+
|
|
5
|
+
export interface AxisProps extends BoundedObjectProps {
|
|
6
|
+
/** Set to `true` for vertical axes. */
|
|
7
|
+
vertical?: boolean;
|
|
8
|
+
|
|
9
|
+
/** Used as a secondary axis. Displayed at the top/right. */
|
|
10
|
+
secondary?: boolean;
|
|
11
|
+
|
|
12
|
+
/** When set to `true`, the values are displayed in descending order. */
|
|
13
|
+
inverted?: Cx.BooleanProp;
|
|
14
|
+
|
|
15
|
+
/** When set to `true`, rendering of visual elements of the axis, such as ticks and labels, is skipped, but their function is preserved. */
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
|
|
18
|
+
tickSize?: number;
|
|
19
|
+
minTickDistance?: number;
|
|
20
|
+
minLabelDistanceVertical?: number;
|
|
21
|
+
minLabelDistanceHorizontal?: number;
|
|
22
|
+
|
|
23
|
+
/** Distance between labels and the axis. */
|
|
24
|
+
labelOffset?: number | string;
|
|
25
|
+
|
|
26
|
+
/** Label rotation angle in degrees. */
|
|
27
|
+
labelRotation?: Cx.Prop<number | string>;
|
|
28
|
+
|
|
29
|
+
/** Label text-anchor value. Allowed values are start, end and middle. Default value is set based on the value of vertical and secondary flags. */
|
|
30
|
+
labelAnchor?: "start" | "end" | "middle" | "auto";
|
|
31
|
+
|
|
32
|
+
/** Horizontal text offset. */
|
|
33
|
+
labelDx?: number | string;
|
|
34
|
+
|
|
35
|
+
/** Vertical text offset which can be used for vertical alignment. */
|
|
36
|
+
labelDy?: number | string;
|
|
37
|
+
|
|
38
|
+
/** Set to `true` to break long labels into multiple lines. Default value is `false`. Text is split at space characters. See also `labelMaxLineLength` and `labelLineCountDyFactor`. */
|
|
39
|
+
labelWrap?: boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Used for vertical adjustment of multi-line labels. Default value is `auto` which means
|
|
43
|
+
* that value is initialized based on axis configuration. Value `0` means that label will grow towards
|
|
44
|
+
* the bottom of the screen. Value `-1` will make labels to grow towards the top of the screen.
|
|
45
|
+
* `-0.5` will make labels vertically centered.
|
|
46
|
+
*/
|
|
47
|
+
labelLineCountDyFactor?: number | string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Used for vertical adjustment of multi-line labels. Default value is 1 which means
|
|
51
|
+
* that labels are stacked without any space between them. Value of 1.4 will add 40% of the label height as a space between labels.
|
|
52
|
+
*/
|
|
53
|
+
labelLineHeight?: number | string;
|
|
54
|
+
|
|
55
|
+
/** If `labelWrap` is on, this number is used as a measure to split labels into multiple lines. Default value is `10`. */
|
|
56
|
+
labelMaxLineLength?: number;
|
|
57
|
+
|
|
58
|
+
/** Set to true to hide the axis labels. */
|
|
59
|
+
hideLabels?: boolean;
|
|
60
|
+
|
|
61
|
+
/** Set to true to hide the axis line. */
|
|
62
|
+
hideLine?: boolean;
|
|
63
|
+
|
|
64
|
+
/** Set to true to hide the axis ticks. */
|
|
65
|
+
hideTicks?: boolean;
|
|
66
|
+
|
|
67
|
+
/** Additional CSS style to be applied to the axis line. */
|
|
68
|
+
lineStyle?: Cx.StyleProp;
|
|
69
|
+
|
|
70
|
+
/** Additional CSS style to be applied to the axis ticks. */
|
|
71
|
+
tickStyle?: Cx.StyleProp;
|
|
72
|
+
|
|
73
|
+
/** Additional CSS style to be applied to the axis labels. */
|
|
74
|
+
labelStyle?: Cx.StyleProp;
|
|
75
|
+
|
|
76
|
+
/** Additional CSS class to be applied to the axis line. */
|
|
77
|
+
lineClass?: Cx.ClassProp;
|
|
78
|
+
|
|
79
|
+
/** Additional CSS class to be applied to the axis ticks. */
|
|
80
|
+
tickClass?: Cx.ClassProp;
|
|
81
|
+
|
|
82
|
+
/** Additional CSS class to be applied to the axis labels. */
|
|
83
|
+
labelClass?: Cx.ClassProp;
|
|
84
|
+
|
|
85
|
+
onMeasured?: (info: any, instance: Instance) => void;
|
|
86
|
+
|
|
87
|
+
/** A function used to create a formatter function for axis labels. See Complex Labels example in the CxJS documentation for more info. */
|
|
88
|
+
onCreateLabelFormatter?:
|
|
89
|
+
| string
|
|
90
|
+
| ((
|
|
91
|
+
context: any,
|
|
92
|
+
instance: Instance
|
|
93
|
+
) => (formattedValue: string, value: any) => { text: string; style?: any; className?: string }[]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export class Axis extends BoundedObject {}
|