victory-core 30.6.1 → 31.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/README.md +13 -12
- package/dist/victory-core.js +1083 -842
- package/dist/victory-core.min.js +1 -1
- package/es/victory-animation/victory-animation.js +26 -21
- package/es/victory-label/victory-label.js +8 -2
- package/es/victory-primitives/path-helpers.js +1 -1
- package/es/victory-transition/victory-transition.js +11 -6
- package/es/victory-util/add-events.js +66 -38
- package/es/victory-util/axis.js +35 -9
- package/es/victory-util/data.js +24 -9
- package/es/victory-util/domain.js +15 -7
- package/es/victory-util/events.js +1 -1
- package/es/victory-util/helpers.js +17 -5
- package/es/victory-util/label-helpers.js +3 -5
- package/es/victory-util/textsize.js +20 -20
- package/es/victory-util/transitions.js +16 -16
- package/es/victory-util/wrapper.js +56 -19
- package/lib/victory-animation/victory-animation.js +27 -21
- package/lib/victory-label/victory-label.js +8 -2
- package/lib/victory-primitives/path-helpers.js +1 -1
- package/lib/victory-transition/victory-transition.js +12 -6
- package/lib/victory-util/add-events.js +66 -38
- package/lib/victory-util/axis.js +36 -9
- package/lib/victory-util/data.js +25 -9
- package/lib/victory-util/domain.js +16 -8
- package/lib/victory-util/events.js +1 -1
- package/lib/victory-util/helpers.js +17 -5
- package/lib/victory-util/label-helpers.js +3 -5
- package/lib/victory-util/textsize.js +20 -20
- package/lib/victory-util/transitions.js +16 -16
- package/lib/victory-util/wrapper.js +56 -19
- package/package.json +1 -1
- package/src/victory-animation/util.js +47 -45
- package/src/victory-animation/victory-animation.js +66 -38
- package/src/victory-clip-container/victory-clip-container.js +44 -31
- package/src/victory-container/victory-container.js +35 -21
- package/src/victory-label/victory-label.js +55 -71
- package/src/victory-portal/portal.js +1 -1
- package/src/victory-portal/victory-portal.js +10 -7
- package/src/victory-primitives/arc.js +15 -4
- package/src/victory-primitives/border.js +26 -5
- package/src/victory-primitives/circle.js +14 -3
- package/src/victory-primitives/clip-path.js +2 -7
- package/src/victory-primitives/line-segment.js +28 -5
- package/src/victory-primitives/line.js +15 -2
- package/src/victory-primitives/path-helpers.js +6 -7
- package/src/victory-primitives/point.js +30 -11
- package/src/victory-primitives/rect.js +19 -3
- package/src/victory-primitives/text.js +21 -11
- package/src/victory-primitives/tspan.js +6 -4
- package/src/victory-primitives/whisker.js +13 -6
- package/src/victory-theme/grayscale.js +153 -128
- package/src/victory-theme/material.js +178 -149
- package/src/victory-transition/victory-transition.js +31 -25
- package/src/victory-util/add-events.js +113 -75
- package/src/victory-util/axis.js +89 -35
- package/src/victory-util/collection.js +3 -8
- package/src/victory-util/common-props.js +42 -36
- package/src/victory-util/data.js +78 -43
- package/src/victory-util/domain.js +68 -46
- package/src/victory-util/events.js +129 -112
- package/src/victory-util/helpers.js +36 -16
- package/src/victory-util/immutable.js +12 -7
- package/src/victory-util/label-helpers.js +34 -18
- package/src/victory-util/prop-types.js +11 -23
- package/src/victory-util/scale.js +2 -3
- package/src/victory-util/selection.js +4 -5
- package/src/victory-util/style.js +17 -10
- package/src/victory-util/textsize.js +35 -31
- package/src/victory-util/transitions.js +53 -35
- package/src/victory-util/wrapper.js +112 -56
|
@@ -20,32 +20,18 @@ const defaultStyles = {
|
|
|
20
20
|
export default class VictoryLabel extends React.Component {
|
|
21
21
|
static displayName = "VictoryLabel";
|
|
22
22
|
static role = "label";
|
|
23
|
+
static defaultStyles = defaultStyles;
|
|
23
24
|
static propTypes = {
|
|
24
25
|
active: PropTypes.bool,
|
|
25
|
-
angle: PropTypes.oneOfType([
|
|
26
|
-
|
|
27
|
-
PropTypes.number
|
|
28
|
-
]),
|
|
29
|
-
capHeight: PropTypes.oneOfType([
|
|
30
|
-
PropTypes.string,
|
|
31
|
-
CustomPropTypes.nonNegative,
|
|
32
|
-
PropTypes.func
|
|
33
|
-
]),
|
|
26
|
+
angle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
27
|
+
capHeight: PropTypes.oneOfType([PropTypes.string, CustomPropTypes.nonNegative, PropTypes.func]),
|
|
34
28
|
className: PropTypes.string,
|
|
35
29
|
data: PropTypes.array,
|
|
36
30
|
datum: PropTypes.any,
|
|
37
31
|
desc: PropTypes.string,
|
|
38
32
|
direction: PropTypes.oneOf(["rtl", "ltr", "inherit"]),
|
|
39
|
-
dx: PropTypes.oneOfType([
|
|
40
|
-
|
|
41
|
-
PropTypes.string,
|
|
42
|
-
PropTypes.func
|
|
43
|
-
]),
|
|
44
|
-
dy: PropTypes.oneOfType([
|
|
45
|
-
PropTypes.number,
|
|
46
|
-
PropTypes.string,
|
|
47
|
-
PropTypes.func
|
|
48
|
-
]),
|
|
33
|
+
dx: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]),
|
|
34
|
+
dy: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]),
|
|
49
35
|
events: PropTypes.object,
|
|
50
36
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
51
37
|
index: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -57,14 +43,17 @@ export default class VictoryLabel extends React.Component {
|
|
|
57
43
|
PropTypes.func,
|
|
58
44
|
PropTypes.array
|
|
59
45
|
]),
|
|
60
|
-
origin: PropTypes.shape({
|
|
46
|
+
origin: PropTypes.shape({
|
|
47
|
+
x: CustomPropTypes.nonNegative,
|
|
48
|
+
y: CustomPropTypes.nonNegative
|
|
49
|
+
}),
|
|
61
50
|
polar: PropTypes.bool,
|
|
62
51
|
renderInPortal: PropTypes.bool,
|
|
63
|
-
scale: PropTypes.shape({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
]),
|
|
52
|
+
scale: PropTypes.shape({
|
|
53
|
+
x: CustomPropTypes.scale,
|
|
54
|
+
y: CustomPropTypes.scale
|
|
55
|
+
}),
|
|
56
|
+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
68
57
|
text: PropTypes.oneOfType([
|
|
69
58
|
PropTypes.string,
|
|
70
59
|
PropTypes.number,
|
|
@@ -72,52 +61,32 @@ export default class VictoryLabel extends React.Component {
|
|
|
72
61
|
PropTypes.array
|
|
73
62
|
]),
|
|
74
63
|
textAnchor: PropTypes.oneOfType([
|
|
75
|
-
PropTypes.oneOf([
|
|
76
|
-
"start",
|
|
77
|
-
"middle",
|
|
78
|
-
"end",
|
|
79
|
-
"inherit"
|
|
80
|
-
]),
|
|
64
|
+
PropTypes.oneOf(["start", "middle", "end", "inherit"]),
|
|
81
65
|
PropTypes.func
|
|
82
66
|
]),
|
|
83
67
|
textComponent: PropTypes.element,
|
|
84
68
|
title: PropTypes.string,
|
|
85
|
-
transform: PropTypes.oneOfType([
|
|
86
|
-
PropTypes.string,
|
|
87
|
-
PropTypes.object,
|
|
88
|
-
PropTypes.func
|
|
89
|
-
]),
|
|
69
|
+
transform: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),
|
|
90
70
|
tspanComponent: PropTypes.element,
|
|
91
71
|
verticalAnchor: PropTypes.oneOfType([
|
|
92
|
-
PropTypes.oneOf([
|
|
93
|
-
"start",
|
|
94
|
-
"middle",
|
|
95
|
-
"end"
|
|
96
|
-
]),
|
|
72
|
+
PropTypes.oneOf(["start", "middle", "end"]),
|
|
97
73
|
PropTypes.func
|
|
98
74
|
]),
|
|
99
|
-
x: PropTypes.oneOfType([
|
|
100
|
-
|
|
101
|
-
PropTypes.string
|
|
102
|
-
]),
|
|
103
|
-
y: PropTypes.oneOfType([
|
|
104
|
-
PropTypes.number,
|
|
105
|
-
PropTypes.string
|
|
106
|
-
])
|
|
75
|
+
x: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
76
|
+
y: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
107
77
|
};
|
|
108
78
|
|
|
109
79
|
static defaultProps = {
|
|
110
80
|
direction: "inherit",
|
|
111
|
-
textComponent: <Text/>,
|
|
112
|
-
tspanComponent: <TSpan/>,
|
|
81
|
+
textComponent: <Text />,
|
|
82
|
+
tspanComponent: <TSpan />,
|
|
113
83
|
capHeight: 0.71, // Magic number from d3.
|
|
114
84
|
lineHeight: 1
|
|
115
85
|
};
|
|
116
86
|
|
|
117
87
|
constructor(props) {
|
|
118
88
|
super(props);
|
|
119
|
-
this.id = props.id === undefined ?
|
|
120
|
-
uniqueId("label-") : props.id;
|
|
89
|
+
this.id = props.id === undefined ? uniqueId("label-") : props.id;
|
|
121
90
|
}
|
|
122
91
|
|
|
123
92
|
getPosition(props, dimension) {
|
|
@@ -136,8 +105,9 @@ export default class VictoryLabel extends React.Component {
|
|
|
136
105
|
}
|
|
137
106
|
|
|
138
107
|
getStyles(props) {
|
|
139
|
-
return Array.isArray(props.style) && !isEmpty(props.style)
|
|
140
|
-
props.style.map((style) => this.getStyle(props, style))
|
|
108
|
+
return Array.isArray(props.style) && !isEmpty(props.style)
|
|
109
|
+
? props.style.map((style) => this.getStyle(props, style))
|
|
110
|
+
: [this.getStyle(props, props.style)];
|
|
141
111
|
}
|
|
142
112
|
|
|
143
113
|
getHeight(props, type) {
|
|
@@ -160,7 +130,8 @@ export default class VictoryLabel extends React.Component {
|
|
|
160
130
|
return `${child}`.split("\n");
|
|
161
131
|
}
|
|
162
132
|
|
|
163
|
-
|
|
133
|
+
//eslint-disable-next-line max-params
|
|
134
|
+
getDy(props, style, content, lineHeight) {
|
|
164
135
|
style = Array.isArray(style) ? style[0] : style;
|
|
165
136
|
lineHeight = this.checkLineHeight(lineHeight, lineHeight[0], 1);
|
|
166
137
|
const fontSize = style.fontSize;
|
|
@@ -169,15 +140,14 @@ export default class VictoryLabel extends React.Component {
|
|
|
169
140
|
const length = content.length;
|
|
170
141
|
const capHeight = this.getHeight(props, "capHeight");
|
|
171
142
|
const verticalAnchor = style.verticalAnchor || props.verticalAnchor;
|
|
172
|
-
const anchor = verticalAnchor ?
|
|
173
|
-
Helpers.evaluateProp(verticalAnchor, datum) : "middle";
|
|
143
|
+
const anchor = verticalAnchor ? Helpers.evaluateProp(verticalAnchor, datum) : "middle";
|
|
174
144
|
switch (anchor) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
145
|
+
case "end":
|
|
146
|
+
return dy + (capHeight / 2 + (0.5 - length) * lineHeight) * fontSize;
|
|
147
|
+
case "middle":
|
|
148
|
+
return dy + (capHeight / 2 + (0.5 - length / 2) * lineHeight) * fontSize;
|
|
149
|
+
default:
|
|
150
|
+
return dy + (capHeight / 2 + lineHeight / 2) * fontSize;
|
|
181
151
|
}
|
|
182
152
|
}
|
|
183
153
|
|
|
@@ -196,8 +166,7 @@ export default class VictoryLabel extends React.Component {
|
|
|
196
166
|
const transform = props.transform || style.transform;
|
|
197
167
|
const transformPart = transform && Helpers.evaluateProp(transform, datum, active);
|
|
198
168
|
const rotatePart = angle && { rotate: [angle, x, y] };
|
|
199
|
-
return transformPart || angle ?
|
|
200
|
-
Style.toTransformString(transformPart, rotatePart) : undefined;
|
|
169
|
+
return transformPart || angle ? Style.toTransformString(transformPart, rotatePart) : undefined;
|
|
201
170
|
}
|
|
202
171
|
|
|
203
172
|
getFontSize(style) {
|
|
@@ -222,8 +191,9 @@ export default class VictoryLabel extends React.Component {
|
|
|
222
191
|
const { datum, active, inline, className, title, desc, events, direction } = props;
|
|
223
192
|
const style = this.getStyles(props);
|
|
224
193
|
const lineHeight = this.getHeight(props, "lineHeight");
|
|
225
|
-
const textAnchor = props.textAnchor
|
|
226
|
-
Helpers.evaluateProp(props.textAnchor, datum, active)
|
|
194
|
+
const textAnchor = props.textAnchor
|
|
195
|
+
? Helpers.evaluateProp(props.textAnchor, datum, active)
|
|
196
|
+
: "start";
|
|
227
197
|
const dx = props.dx ? Helpers.evaluateProp(props.dx, datum, active) : 0;
|
|
228
198
|
const dy = this.getDy(props, style, content, lineHeight);
|
|
229
199
|
const transform = this.getTransform(props, style);
|
|
@@ -235,13 +205,15 @@ export default class VictoryLabel extends React.Component {
|
|
|
235
205
|
const lastStyle = style[i - 1] || style[0];
|
|
236
206
|
const fontSize = (currentStyle.fontSize + lastStyle.fontSize) / 2;
|
|
237
207
|
const currentLineHeight = this.checkLineHeight(
|
|
238
|
-
lineHeight,
|
|
208
|
+
lineHeight,
|
|
209
|
+
(lineHeight[i] + (lineHeight[i - 1] || lineHeight[0])) / 2,
|
|
210
|
+
1
|
|
239
211
|
);
|
|
240
212
|
const tspanProps = {
|
|
241
213
|
key: `${this.id}-key-${i}`,
|
|
242
214
|
x: !inline ? props.x : undefined,
|
|
243
215
|
dx,
|
|
244
|
-
dy: i && !inline ?
|
|
216
|
+
dy: i && !inline ? currentLineHeight * fontSize : undefined,
|
|
245
217
|
textAnchor: currentStyle.textAnchor || textAnchor,
|
|
246
218
|
style: currentStyle,
|
|
247
219
|
content: line
|
|
@@ -250,7 +222,19 @@ export default class VictoryLabel extends React.Component {
|
|
|
250
222
|
});
|
|
251
223
|
return React.cloneElement(
|
|
252
224
|
props.textComponent,
|
|
253
|
-
{
|
|
225
|
+
{
|
|
226
|
+
direction,
|
|
227
|
+
dx,
|
|
228
|
+
dy,
|
|
229
|
+
x,
|
|
230
|
+
y,
|
|
231
|
+
events,
|
|
232
|
+
transform,
|
|
233
|
+
className,
|
|
234
|
+
title,
|
|
235
|
+
desc,
|
|
236
|
+
id: this.id
|
|
237
|
+
},
|
|
254
238
|
textChildren
|
|
255
239
|
);
|
|
256
240
|
}
|
|
@@ -15,7 +15,7 @@ export default class VictoryPortal extends React.Component {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
static defaultProps = {
|
|
18
|
-
groupComponent: <g/>
|
|
18
|
+
groupComponent: <g />
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
static contextTypes = {
|
|
@@ -27,7 +27,8 @@ export default class VictoryPortal extends React.Component {
|
|
|
27
27
|
componentDidMount() {
|
|
28
28
|
if (!this.checkedContext) {
|
|
29
29
|
if (typeof this.context.portalUpdate !== "function") {
|
|
30
|
-
const msg =
|
|
30
|
+
const msg =
|
|
31
|
+
"`renderInPortal` is not supported outside of `VictoryContainer`. " +
|
|
31
32
|
"Component will be rendered in place";
|
|
32
33
|
Log.warn(msg);
|
|
33
34
|
this.renderInPlace = true;
|
|
@@ -60,16 +61,18 @@ export default class VictoryPortal extends React.Component {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
render() {
|
|
63
|
-
const children = Array.isArray(this.props.children)
|
|
64
|
-
this.props.children[0]
|
|
64
|
+
const children = Array.isArray(this.props.children)
|
|
65
|
+
? this.props.children[0]
|
|
66
|
+
: this.props.children;
|
|
65
67
|
const { groupComponent } = this.props;
|
|
66
|
-
const childProps = children && children.props || {};
|
|
68
|
+
const childProps = (children && children.props) || {};
|
|
67
69
|
const standardProps = childProps.groupComponent ? { groupComponent, standalone: false } : {};
|
|
68
70
|
const newProps = defaults(
|
|
69
|
-
standardProps,
|
|
71
|
+
standardProps,
|
|
72
|
+
childProps,
|
|
73
|
+
Helpers.omit(this.props, ["children", "groupComponent"])
|
|
70
74
|
);
|
|
71
75
|
const child = children && React.cloneElement(children, newProps);
|
|
72
76
|
return this.renderPortal(child);
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
|
|
@@ -20,7 +20,7 @@ export default class Arc extends React.Component {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
static defaultProps = {
|
|
23
|
-
pathComponent: <Path/>
|
|
23
|
+
pathComponent: <Path />
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
getStyle(props) {
|
|
@@ -31,7 +31,7 @@ export default class Arc extends React.Component {
|
|
|
31
31
|
getArcPath(props) {
|
|
32
32
|
const { cx, cy, r, startAngle, endAngle, closedPath } = props;
|
|
33
33
|
// Always draw the path as two arcs so that complete circles may be rendered.
|
|
34
|
-
const halfAngle =
|
|
34
|
+
const halfAngle = Math.abs(endAngle - startAngle) / 2 + startAngle;
|
|
35
35
|
const x1 = cx + r * Math.cos(Helpers.degreesToRadians(startAngle));
|
|
36
36
|
const y1 = cy - r * Math.sin(Helpers.degreesToRadians(startAngle));
|
|
37
37
|
const x2 = cx + r * Math.cos(Helpers.degreesToRadians(halfAngle));
|
|
@@ -49,12 +49,23 @@ export default class Arc extends React.Component {
|
|
|
49
49
|
|
|
50
50
|
render() {
|
|
51
51
|
const {
|
|
52
|
-
role,
|
|
52
|
+
role,
|
|
53
|
+
shapeRendering,
|
|
54
|
+
className,
|
|
55
|
+
events,
|
|
56
|
+
pathComponent,
|
|
57
|
+
transform,
|
|
58
|
+
clipPath
|
|
53
59
|
} = this.props;
|
|
54
60
|
return React.cloneElement(pathComponent, {
|
|
55
61
|
d: this.getArcPath(this.props),
|
|
56
62
|
style: this.getStyle(this.props),
|
|
57
|
-
className,
|
|
63
|
+
className,
|
|
64
|
+
role,
|
|
65
|
+
shapeRendering,
|
|
66
|
+
events,
|
|
67
|
+
transform,
|
|
68
|
+
clipPath
|
|
58
69
|
});
|
|
59
70
|
}
|
|
60
71
|
}
|
|
@@ -16,17 +16,38 @@ export default class Border extends React.Component {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
static defaultProps = {
|
|
19
|
-
rectComponent: <Rect/>
|
|
19
|
+
rectComponent: <Rect />
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
render() {
|
|
23
23
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
x,
|
|
25
|
+
y,
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
events,
|
|
29
|
+
datum,
|
|
30
|
+
active,
|
|
31
|
+
role,
|
|
32
|
+
clipPath,
|
|
33
|
+
className,
|
|
34
|
+
shapeRendering,
|
|
35
|
+
rectComponent,
|
|
36
|
+
transform
|
|
37
|
+
} = this.props;
|
|
27
38
|
const style = Helpers.evaluateStyle(assign({ fill: "none" }, this.props.style), datum, active);
|
|
28
39
|
return React.cloneElement(rectComponent, {
|
|
29
|
-
style,
|
|
40
|
+
style,
|
|
41
|
+
className,
|
|
42
|
+
x,
|
|
43
|
+
y,
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
46
|
+
events,
|
|
47
|
+
role,
|
|
48
|
+
shapeRendering,
|
|
49
|
+
transform,
|
|
50
|
+
clipPath
|
|
30
51
|
});
|
|
31
52
|
}
|
|
32
53
|
}
|
|
@@ -22,11 +22,22 @@ export default class Circle extends React.Component {
|
|
|
22
22
|
|
|
23
23
|
render() {
|
|
24
24
|
const {
|
|
25
|
-
cx,
|
|
26
|
-
|
|
25
|
+
cx,
|
|
26
|
+
cy,
|
|
27
|
+
r,
|
|
28
|
+
events,
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
role,
|
|
32
|
+
shapeRendering,
|
|
33
|
+
transform,
|
|
34
|
+
clipPath
|
|
35
|
+
} = this.props;
|
|
27
36
|
return (
|
|
28
37
|
<circle
|
|
29
|
-
cx={cx}
|
|
38
|
+
cx={cx}
|
|
39
|
+
cy={cy}
|
|
40
|
+
r={r}
|
|
30
41
|
className={className}
|
|
31
42
|
clipPath={clipPath}
|
|
32
43
|
transform={transform}
|
|
@@ -3,10 +3,7 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
|
|
4
4
|
export default class ClipPath extends React.Component {
|
|
5
5
|
static propTypes = {
|
|
6
|
-
children: PropTypes.oneOfType([
|
|
7
|
-
PropTypes.arrayOf(PropTypes.node),
|
|
8
|
-
PropTypes.node
|
|
9
|
-
]),
|
|
6
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
10
7
|
clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
11
8
|
};
|
|
12
9
|
|
|
@@ -14,9 +11,7 @@ export default class ClipPath extends React.Component {
|
|
|
14
11
|
const { children, clipId } = this.props;
|
|
15
12
|
return (
|
|
16
13
|
<defs>
|
|
17
|
-
<clipPath id={clipId}>
|
|
18
|
-
{children}
|
|
19
|
-
</clipPath>
|
|
14
|
+
<clipPath id={clipId}>{children}</clipPath>
|
|
20
15
|
</defs>
|
|
21
16
|
);
|
|
22
17
|
}
|
|
@@ -17,19 +17,42 @@ export default class LineSegment extends React.Component {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
static defaultProps = {
|
|
20
|
-
lineComponent: <Line/>
|
|
20
|
+
lineComponent: <Line />
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
render() {
|
|
24
24
|
const {
|
|
25
|
-
x1,
|
|
26
|
-
|
|
25
|
+
x1,
|
|
26
|
+
x2,
|
|
27
|
+
y1,
|
|
28
|
+
y2,
|
|
29
|
+
events,
|
|
30
|
+
datum,
|
|
31
|
+
active,
|
|
32
|
+
lineComponent,
|
|
33
|
+
className,
|
|
34
|
+
role,
|
|
35
|
+
shapeRendering,
|
|
36
|
+
transform,
|
|
37
|
+
clipPath
|
|
27
38
|
} = this.props;
|
|
28
39
|
const style = Helpers.evaluateStyle(
|
|
29
|
-
assign({ stroke: "black" }, this.props.style),
|
|
40
|
+
assign({ stroke: "black" }, this.props.style),
|
|
41
|
+
datum,
|
|
42
|
+
active
|
|
30
43
|
);
|
|
31
44
|
return React.cloneElement(lineComponent, {
|
|
32
|
-
style,
|
|
45
|
+
style,
|
|
46
|
+
className,
|
|
47
|
+
role,
|
|
48
|
+
shapeRendering,
|
|
49
|
+
events,
|
|
50
|
+
x1,
|
|
51
|
+
x2,
|
|
52
|
+
y1,
|
|
53
|
+
y2,
|
|
54
|
+
transform,
|
|
55
|
+
clipPath
|
|
33
56
|
});
|
|
34
57
|
}
|
|
35
58
|
}
|
|
@@ -23,11 +23,24 @@ export default class Line extends React.Component {
|
|
|
23
23
|
|
|
24
24
|
render() {
|
|
25
25
|
const {
|
|
26
|
-
x1,
|
|
26
|
+
x1,
|
|
27
|
+
x2,
|
|
28
|
+
y1,
|
|
29
|
+
y2,
|
|
30
|
+
events,
|
|
31
|
+
className,
|
|
32
|
+
clipPath,
|
|
33
|
+
transform,
|
|
34
|
+
style,
|
|
35
|
+
shapeRendering,
|
|
36
|
+
role
|
|
27
37
|
} = this.props;
|
|
28
38
|
return (
|
|
29
39
|
<line
|
|
30
|
-
x1={x1}
|
|
40
|
+
x1={x1}
|
|
41
|
+
x2={x2}
|
|
42
|
+
y1={y1}
|
|
43
|
+
y2={y2}
|
|
31
44
|
className={className}
|
|
32
45
|
clipPath={clipPath}
|
|
33
46
|
transform={transform}
|
|
@@ -9,7 +9,6 @@ export default {
|
|
|
9
9
|
a ${size}, ${size} 0 1,0 ${-size * 2},0`;
|
|
10
10
|
},
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
square(x, y, size) {
|
|
14
13
|
const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
|
|
15
14
|
const x0 = x - baseSize;
|
|
@@ -34,7 +33,7 @@ export default {
|
|
|
34
33
|
},
|
|
35
34
|
|
|
36
35
|
triangleDown(x, y, size) {
|
|
37
|
-
const height = size / 2 * Math.sqrt(3);
|
|
36
|
+
const height = (size / 2) * Math.sqrt(3);
|
|
38
37
|
const x0 = x - size;
|
|
39
38
|
const x1 = x + size;
|
|
40
39
|
const y0 = y - size;
|
|
@@ -46,7 +45,7 @@ export default {
|
|
|
46
45
|
},
|
|
47
46
|
|
|
48
47
|
triangleUp(x, y, size) {
|
|
49
|
-
const height = size / 2 * Math.sqrt(3);
|
|
48
|
+
const height = (size / 2) * Math.sqrt(3);
|
|
50
49
|
const x0 = x - size;
|
|
51
50
|
const x1 = x + size;
|
|
52
51
|
const y0 = y - height;
|
|
@@ -61,7 +60,7 @@ export default {
|
|
|
61
60
|
const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
|
|
62
61
|
const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
|
|
63
62
|
return `
|
|
64
|
-
M ${x -
|
|
63
|
+
M ${x - distance / 2}, ${y + baseSize}
|
|
65
64
|
v-${distance}
|
|
66
65
|
h-${distance}
|
|
67
66
|
v-${distance}
|
|
@@ -77,9 +76,8 @@ export default {
|
|
|
77
76
|
},
|
|
78
77
|
|
|
79
78
|
minus(x, y, size) {
|
|
80
|
-
|
|
81
79
|
const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
|
|
82
|
-
const lineHeight = baseSize - baseSize * 0.3
|
|
80
|
+
const lineHeight = baseSize - baseSize * 0.3; // eslint-disable-line no-magic-numbers
|
|
83
81
|
const x0 = x - baseSize;
|
|
84
82
|
const y1 = y + lineHeight / 2;
|
|
85
83
|
const distance = x + baseSize - x0;
|
|
@@ -93,7 +91,8 @@ export default {
|
|
|
93
91
|
star(x, y, size) {
|
|
94
92
|
const baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
|
|
95
93
|
const angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
|
|
96
|
-
|
|
94
|
+
// eslint-disable-next-line no-magic-numbers
|
|
95
|
+
const starCoords = range(10).map((index) => {
|
|
97
96
|
const length = index % 2 === 0 ? baseSize : baseSize / 2;
|
|
98
97
|
return `${length * Math.sin(angle * (index + 1)) + x},
|
|
99
98
|
${length * Math.cos(angle * (index + 1)) + y}`;
|
|
@@ -11,13 +11,17 @@ export default class Point extends React.Component {
|
|
|
11
11
|
datum: PropTypes.object,
|
|
12
12
|
getPath: PropTypes.func,
|
|
13
13
|
pathComponent: PropTypes.element,
|
|
14
|
-
size: PropTypes.oneOfType([
|
|
15
|
-
PropTypes.number,
|
|
16
|
-
PropTypes.func
|
|
17
|
-
]),
|
|
14
|
+
size: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
18
15
|
symbol: PropTypes.oneOfType([
|
|
19
16
|
PropTypes.oneOf([
|
|
20
|
-
"circle",
|
|
17
|
+
"circle",
|
|
18
|
+
"diamond",
|
|
19
|
+
"plus",
|
|
20
|
+
"minus",
|
|
21
|
+
"square",
|
|
22
|
+
"star",
|
|
23
|
+
"triangleDown",
|
|
24
|
+
"triangleUp"
|
|
21
25
|
]),
|
|
22
26
|
PropTypes.func
|
|
23
27
|
]),
|
|
@@ -46,19 +50,34 @@ export default class Point extends React.Component {
|
|
|
46
50
|
star: pathHelpers.star
|
|
47
51
|
};
|
|
48
52
|
const symbol = Helpers.evaluateProp(props.symbol, datum, active);
|
|
49
|
-
const symbolFunction =
|
|
50
|
-
pathFunctions[symbol] : pathFunctions.circle;
|
|
53
|
+
const symbolFunction =
|
|
54
|
+
typeof pathFunctions[symbol] === "function" ? pathFunctions[symbol] : pathFunctions.circle;
|
|
51
55
|
return symbolFunction(x, y, size);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
render() {
|
|
55
59
|
const {
|
|
56
|
-
active,
|
|
60
|
+
active,
|
|
61
|
+
datum,
|
|
62
|
+
role,
|
|
63
|
+
shapeRendering,
|
|
64
|
+
className,
|
|
65
|
+
events,
|
|
66
|
+
pathComponent,
|
|
67
|
+
transform,
|
|
68
|
+
clipPath
|
|
57
69
|
} = this.props;
|
|
58
70
|
const style = Helpers.evaluateStyle(this.props.style, datum, active);
|
|
59
71
|
const d = this.getPath(this.props);
|
|
60
|
-
return React.cloneElement(
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
return React.cloneElement(pathComponent, {
|
|
73
|
+
style,
|
|
74
|
+
role,
|
|
75
|
+
shapeRendering,
|
|
76
|
+
className,
|
|
77
|
+
events,
|
|
78
|
+
d,
|
|
79
|
+
transform,
|
|
80
|
+
clipPath
|
|
81
|
+
});
|
|
63
82
|
}
|
|
64
83
|
}
|
|
@@ -25,12 +25,28 @@ export default class Rect extends React.Component {
|
|
|
25
25
|
|
|
26
26
|
render() {
|
|
27
27
|
const {
|
|
28
|
-
x,
|
|
29
|
-
|
|
28
|
+
x,
|
|
29
|
+
y,
|
|
30
|
+
rx,
|
|
31
|
+
ry,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
events,
|
|
35
|
+
className,
|
|
36
|
+
clipPath,
|
|
37
|
+
style,
|
|
38
|
+
role,
|
|
39
|
+
shapeRendering,
|
|
40
|
+
transform
|
|
30
41
|
} = this.props;
|
|
31
42
|
return (
|
|
32
43
|
<rect
|
|
33
|
-
x={x}
|
|
44
|
+
x={x}
|
|
45
|
+
y={y}
|
|
46
|
+
rx={rx}
|
|
47
|
+
ry={ry}
|
|
48
|
+
width={width}
|
|
49
|
+
height={height}
|
|
34
50
|
className={className}
|
|
35
51
|
clipPath={clipPath}
|
|
36
52
|
style={style}
|