victory-area 36.9.2 → 37.0.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/CHANGELOG.md +6 -0
- package/dist/victory-area.js +3769 -5009
- package/dist/victory-area.min.js +1 -1
- package/es/area.js +80 -94
- package/es/helper-methods.js +81 -90
- package/es/victory-area.js +46 -85
- package/lib/area.js +83 -116
- package/lib/helper-methods.js +81 -101
- package/lib/index.js +0 -4
- package/lib/victory-area.js +46 -93
- package/package.json +3 -3
package/es/area.js
CHANGED
|
@@ -1,59 +1,43 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/
|
|
8
2
|
import React from "react";
|
|
9
3
|
import * as d3Shape from "victory-vendor/d3-shape";
|
|
10
4
|
import { Helpers, Path, UserProps, LineHelpers } from "victory-core";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var y = d._y1 !== undefined ? d._y1 : d._y;
|
|
5
|
+
const defined = d => {
|
|
6
|
+
const y = d._y1 !== undefined ? d._y1 : d._y;
|
|
14
7
|
return y !== null && y !== undefined && d._y0 !== null;
|
|
15
8
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return function (d) {
|
|
19
|
-
return scale.x(d._x1 !== undefined ? d._x1 : d._x);
|
|
20
|
-
};
|
|
9
|
+
const getXAccessor = scale => {
|
|
10
|
+
return d => scale.x(d._x1 !== undefined ? d._x1 : d._x);
|
|
21
11
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return function (d) {
|
|
25
|
-
return scale.y(d._y1 !== undefined ? d._y1 : d._y);
|
|
26
|
-
};
|
|
12
|
+
const getYAccessor = scale => {
|
|
13
|
+
return d => scale.y(d._y1 !== undefined ? d._y1 : d._y);
|
|
27
14
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return function (d) {
|
|
31
|
-
return scale.y(d._y0);
|
|
32
|
-
};
|
|
15
|
+
const getY0Accessor = scale => {
|
|
16
|
+
return d => scale.y(d._y0);
|
|
33
17
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
|
|
18
|
+
const getAngleAccessor = scale => {
|
|
19
|
+
return d => {
|
|
20
|
+
const x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
|
|
38
21
|
return -1 * x + Math.PI / 2;
|
|
39
22
|
};
|
|
40
23
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
const getCartesianArea = props => {
|
|
25
|
+
const {
|
|
26
|
+
horizontal,
|
|
27
|
+
scale
|
|
28
|
+
} = props;
|
|
29
|
+
const interpolationFunction = LineHelpers.getInterpolationFunction(props);
|
|
46
30
|
return horizontal ? d3Shape.area().defined(defined).curve(interpolationFunction).x0(getY0Accessor(scale)).x1(getYAccessor(scale)).y(getXAccessor(scale)) : d3Shape.area().defined(defined).curve(interpolationFunction).x(getXAccessor(scale)).y1(getYAccessor(scale)).y0(getY0Accessor(scale));
|
|
47
31
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
const getAreaFunction = props => {
|
|
33
|
+
const {
|
|
34
|
+
polar,
|
|
35
|
+
scale
|
|
36
|
+
} = props;
|
|
37
|
+
const interpolationFunction = LineHelpers.getInterpolationFunction(props);
|
|
53
38
|
return polar ? d3Shape.radialArea().defined(defined).curve(interpolationFunction).angle(getAngleAccessor(scale)).outerRadius(getYAccessor(scale)).innerRadius(getY0Accessor(scale)) : getCartesianArea(props);
|
|
54
39
|
};
|
|
55
|
-
|
|
56
|
-
var evaluateProps = function (props) {
|
|
40
|
+
const evaluateProps = props => {
|
|
57
41
|
/**
|
|
58
42
|
* Potential evaluated props are:
|
|
59
43
|
* `ariaLabel`
|
|
@@ -62,79 +46,81 @@ var evaluateProps = function (props) {
|
|
|
62
46
|
* `style`
|
|
63
47
|
* `tabIndex`
|
|
64
48
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
const ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
|
|
50
|
+
const desc = Helpers.evaluateProp(props.desc, props);
|
|
51
|
+
const id = Helpers.evaluateProp(props.id, props);
|
|
52
|
+
const style = Helpers.evaluateStyle(Object.assign({
|
|
69
53
|
fill: "black"
|
|
70
54
|
}, props.style), props);
|
|
71
|
-
|
|
55
|
+
const tabIndex = Helpers.evaluateProp(props.tabIndex, props);
|
|
72
56
|
return Object.assign({}, props, {
|
|
73
|
-
ariaLabel
|
|
74
|
-
desc
|
|
75
|
-
id
|
|
76
|
-
style
|
|
77
|
-
tabIndex
|
|
57
|
+
ariaLabel,
|
|
58
|
+
desc,
|
|
59
|
+
id,
|
|
60
|
+
style,
|
|
61
|
+
tabIndex
|
|
78
62
|
});
|
|
79
63
|
};
|
|
80
|
-
|
|
81
|
-
var defaultProps = {
|
|
64
|
+
const defaultProps = {
|
|
82
65
|
groupComponent: /*#__PURE__*/React.createElement("g", null),
|
|
83
66
|
pathComponent: /*#__PURE__*/React.createElement(Path, null),
|
|
84
67
|
role: "presentation",
|
|
85
68
|
shapeRendering: "auto"
|
|
86
69
|
};
|
|
70
|
+
|
|
87
71
|
/**
|
|
88
72
|
* The area primitive used by VictoryArea
|
|
89
73
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
role = props.role,
|
|
95
|
-
shapeRendering = props.shapeRendering,
|
|
96
|
-
className = props.className,
|
|
97
|
-
polar = props.polar,
|
|
98
|
-
origin = props.origin,
|
|
99
|
-
data = props.data,
|
|
100
|
-
pathComponent = props.pathComponent,
|
|
101
|
-
events = props.events,
|
|
102
|
-
groupComponent = props.groupComponent,
|
|
103
|
-
clipPath = props.clipPath,
|
|
104
|
-
id = props.id,
|
|
105
|
-
style = props.style,
|
|
106
|
-
desc = props.desc,
|
|
107
|
-
tabIndex = props.tabIndex;
|
|
108
|
-
var userProps = UserProps.getSafeUserProps(props);
|
|
109
|
-
var defaultTransform = polar && origin ? "translate(".concat(origin.x, ", ").concat(origin.y, ")") : undefined;
|
|
110
|
-
var transform = props.transform || defaultTransform;
|
|
111
|
-
var renderLine = style.stroke && style.stroke !== "none" && style.stroke !== "transparent";
|
|
112
|
-
var areaFunction = getAreaFunction(props);
|
|
113
|
-
var lineFunction = renderLine && LineHelpers.getLineFunction(props);
|
|
114
|
-
var areaStroke = style.stroke ? "none" : style.fill;
|
|
115
|
-
|
|
116
|
-
var sharedProps = _objectSpread(_objectSpread({
|
|
117
|
-
"aria-label": ariaLabel,
|
|
118
|
-
className: className,
|
|
119
|
-
role: role,
|
|
120
|
-
shapeRendering: shapeRendering,
|
|
121
|
-
transform: transform
|
|
122
|
-
}, events), {}, {
|
|
123
|
-
clipPath: clipPath,
|
|
124
|
-
tabIndex: tabIndex
|
|
74
|
+
export const Area = initialProps => {
|
|
75
|
+
const props = evaluateProps({
|
|
76
|
+
...defaultProps,
|
|
77
|
+
...initialProps
|
|
125
78
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
79
|
+
const {
|
|
80
|
+
ariaLabel,
|
|
81
|
+
role,
|
|
82
|
+
shapeRendering,
|
|
83
|
+
className,
|
|
84
|
+
polar,
|
|
85
|
+
origin,
|
|
86
|
+
data,
|
|
87
|
+
pathComponent,
|
|
88
|
+
events,
|
|
89
|
+
groupComponent,
|
|
90
|
+
clipPath,
|
|
91
|
+
id,
|
|
92
|
+
style,
|
|
93
|
+
desc,
|
|
94
|
+
tabIndex
|
|
95
|
+
} = props;
|
|
96
|
+
const userProps = UserProps.getSafeUserProps(props);
|
|
97
|
+
const defaultTransform = polar && origin ? `translate(${origin.x}, ${origin.y})` : undefined;
|
|
98
|
+
const transform = props.transform || defaultTransform;
|
|
99
|
+
const renderLine = style.stroke && style.stroke !== "none" && style.stroke !== "transparent";
|
|
100
|
+
const areaFunction = getAreaFunction(props);
|
|
101
|
+
const lineFunction = renderLine && LineHelpers.getLineFunction(props);
|
|
102
|
+
const areaStroke = style.stroke ? "none" : style.fill;
|
|
103
|
+
const sharedProps = {
|
|
104
|
+
"aria-label": ariaLabel,
|
|
105
|
+
className,
|
|
106
|
+
role,
|
|
107
|
+
shapeRendering,
|
|
108
|
+
transform,
|
|
109
|
+
...events,
|
|
110
|
+
clipPath,
|
|
111
|
+
tabIndex
|
|
112
|
+
};
|
|
113
|
+
const area = /*#__PURE__*/React.cloneElement(pathComponent, Object.assign({
|
|
114
|
+
key: `${id}-area`,
|
|
129
115
|
style: Object.assign({}, style, {
|
|
130
116
|
stroke: areaStroke
|
|
131
117
|
}),
|
|
132
118
|
d: areaFunction(data),
|
|
133
|
-
desc
|
|
134
|
-
tabIndex
|
|
119
|
+
desc,
|
|
120
|
+
tabIndex
|
|
135
121
|
}, sharedProps, userProps));
|
|
136
|
-
|
|
137
|
-
key:
|
|
122
|
+
const line = renderLine ? /*#__PURE__*/React.cloneElement(pathComponent, Object.assign({
|
|
123
|
+
key: `${id}-area-stroke`,
|
|
138
124
|
style: Object.assign({}, style, {
|
|
139
125
|
fill: "none"
|
|
140
126
|
}),
|
package/es/helper-methods.js
CHANGED
|
@@ -1,134 +1,125 @@
|
|
|
1
1
|
import { Helpers, LabelHelpers, Data, Domain, Scale, Collection } from "victory-core";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export const getDataWithBaseline = (props, scale) => {
|
|
3
|
+
let data = Data.getData(props);
|
|
5
4
|
if (data.length < 2) {
|
|
6
5
|
data = [];
|
|
7
6
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var defaultMin = defaultZero;
|
|
15
|
-
|
|
7
|
+
const getDefaultMin = axis => {
|
|
8
|
+
const defaultZero = Scale.getType(scale[axis]) === "log" ? 1 / Number.MAX_SAFE_INTEGER : 0;
|
|
9
|
+
const domain = scale[axis].domain();
|
|
10
|
+
const minY = Collection.getMinValue(domain);
|
|
11
|
+
const maxY = Collection.getMaxValue(domain);
|
|
12
|
+
let defaultMin = defaultZero;
|
|
16
13
|
if (minY < 0 && maxY <= 0) {
|
|
17
14
|
defaultMin = maxY;
|
|
18
15
|
} else if (minY >= 0 && maxY > 0) {
|
|
19
16
|
defaultMin = minY;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
return Collection.containsDates(domain) ? new Date(defaultMin) : defaultMin;
|
|
23
19
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _x1 = datum._x1 !== undefined ? datum._x1 : datum._x;
|
|
31
|
-
|
|
32
|
-
var _x0 = datum._x0 !== undefined ? datum._x0 : getDefaultMin("x");
|
|
33
|
-
|
|
20
|
+
return data.map(datum => {
|
|
21
|
+
const _y1 = datum._y1 !== undefined ? datum._y1 : datum._y;
|
|
22
|
+
const _y0 = datum._y0 !== undefined ? datum._y0 : getDefaultMin("y");
|
|
23
|
+
const _x1 = datum._x1 !== undefined ? datum._x1 : datum._x;
|
|
24
|
+
const _x0 = datum._x0 !== undefined ? datum._x0 : getDefaultMin("x");
|
|
34
25
|
return Object.assign({}, datum, {
|
|
35
|
-
_y0
|
|
36
|
-
_y1
|
|
37
|
-
_x0
|
|
38
|
-
_x1
|
|
26
|
+
_y0,
|
|
27
|
+
_y1,
|
|
28
|
+
_x0,
|
|
29
|
+
_x1
|
|
39
30
|
});
|
|
40
31
|
});
|
|
41
32
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
const getCalculatedValues = props => {
|
|
34
|
+
const {
|
|
35
|
+
polar
|
|
36
|
+
} = props;
|
|
37
|
+
const defaultStyles = Helpers.getDefaultStyles(props, "area");
|
|
38
|
+
const style = Helpers.getStyles(props.style, defaultStyles);
|
|
39
|
+
const range = {
|
|
48
40
|
x: Helpers.getRange(props, "x"),
|
|
49
41
|
y: Helpers.getRange(props, "y")
|
|
50
42
|
};
|
|
51
|
-
|
|
43
|
+
const domain = {
|
|
52
44
|
x: Domain.getDomainWithZero(props, "x"),
|
|
53
45
|
y: Domain.getDomainWithZero(props, "y")
|
|
54
46
|
};
|
|
55
|
-
|
|
47
|
+
const scale = {
|
|
56
48
|
x: Scale.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
|
|
57
49
|
y: Scale.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
|
|
58
50
|
};
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
const origin = polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
|
|
52
|
+
const data = getDataWithBaseline(props, scale);
|
|
61
53
|
return {
|
|
62
|
-
style
|
|
63
|
-
data
|
|
64
|
-
scale
|
|
65
|
-
domain
|
|
66
|
-
origin
|
|
54
|
+
style,
|
|
55
|
+
data,
|
|
56
|
+
scale,
|
|
57
|
+
domain,
|
|
58
|
+
origin
|
|
67
59
|
};
|
|
68
60
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
61
|
+
export const getBaseProps = (initialProps, fallbackProps) => {
|
|
62
|
+
const modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "area");
|
|
63
|
+
const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
|
|
64
|
+
const {
|
|
65
|
+
data,
|
|
66
|
+
domain,
|
|
67
|
+
events,
|
|
68
|
+
groupComponent,
|
|
69
|
+
height,
|
|
70
|
+
horizontal,
|
|
71
|
+
interpolation,
|
|
72
|
+
origin,
|
|
73
|
+
padding,
|
|
74
|
+
polar,
|
|
75
|
+
scale,
|
|
76
|
+
sharedEvents,
|
|
77
|
+
standalone,
|
|
78
|
+
style,
|
|
79
|
+
theme,
|
|
80
|
+
width,
|
|
81
|
+
labels,
|
|
82
|
+
name,
|
|
83
|
+
disableInlineStyles
|
|
84
|
+
} = props;
|
|
85
|
+
const initialChildProps = {
|
|
93
86
|
parent: {
|
|
94
87
|
style: style.parent,
|
|
95
|
-
width
|
|
96
|
-
height
|
|
97
|
-
scale
|
|
98
|
-
data
|
|
99
|
-
domain
|
|
100
|
-
standalone
|
|
101
|
-
theme
|
|
102
|
-
polar
|
|
103
|
-
origin
|
|
104
|
-
padding
|
|
105
|
-
name
|
|
106
|
-
horizontal
|
|
88
|
+
width,
|
|
89
|
+
height,
|
|
90
|
+
scale,
|
|
91
|
+
data,
|
|
92
|
+
domain,
|
|
93
|
+
standalone,
|
|
94
|
+
theme,
|
|
95
|
+
polar,
|
|
96
|
+
origin,
|
|
97
|
+
padding,
|
|
98
|
+
name,
|
|
99
|
+
horizontal
|
|
107
100
|
},
|
|
108
101
|
all: {
|
|
109
102
|
data: {
|
|
110
|
-
horizontal
|
|
111
|
-
polar
|
|
112
|
-
origin
|
|
113
|
-
scale
|
|
114
|
-
data
|
|
115
|
-
interpolation
|
|
116
|
-
groupComponent
|
|
103
|
+
horizontal,
|
|
104
|
+
polar,
|
|
105
|
+
origin,
|
|
106
|
+
scale,
|
|
107
|
+
data,
|
|
108
|
+
interpolation,
|
|
109
|
+
groupComponent,
|
|
117
110
|
style: disableInlineStyles ? {} : style.data,
|
|
118
|
-
disableInlineStyles
|
|
111
|
+
disableInlineStyles
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
114
|
};
|
|
122
|
-
return data.reduce(
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
return data.reduce((childProps, datum, index) => {
|
|
116
|
+
const text = LabelHelpers.getText(props, datum, index);
|
|
125
117
|
if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
|
|
126
|
-
|
|
118
|
+
const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
|
|
127
119
|
childProps[eventKey] = {
|
|
128
120
|
labels: LabelHelpers.getProps(props, index)
|
|
129
121
|
};
|
|
130
122
|
}
|
|
131
|
-
|
|
132
123
|
return childProps;
|
|
133
124
|
}, initialChildProps);
|
|
134
125
|
};
|
package/es/victory-area.js
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
-
|
|
3
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
4
|
-
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
-
|
|
7
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
|
-
|
|
9
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
-
|
|
11
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
14
|
-
|
|
15
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
-
|
|
17
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
|
|
19
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
-
|
|
21
1
|
import React from "react";
|
|
22
2
|
import { getBaseProps } from "./helper-methods";
|
|
23
3
|
import { Area } from "./area";
|
|
24
4
|
import { Helpers, VictoryLabel, VictoryContainer, DefaultTransitions, VictoryClipContainer, addEvents, VictoryTheme, Data, Domain, UserProps } from "victory-core";
|
|
25
|
-
|
|
5
|
+
const fallbackProps = {
|
|
26
6
|
width: 450,
|
|
27
7
|
height: 300,
|
|
28
8
|
padding: 50,
|
|
29
9
|
interpolation: "linear"
|
|
30
10
|
};
|
|
31
|
-
|
|
11
|
+
const options = {
|
|
32
12
|
components: [{
|
|
33
13
|
name: "parent",
|
|
34
14
|
index: "parent"
|
|
@@ -40,72 +20,53 @@ var options = {
|
|
|
40
20
|
}]
|
|
41
21
|
};
|
|
42
22
|
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
24
|
+
|
|
43
25
|
/**
|
|
44
26
|
* Draw area charts with React. VictoryArea is a composable component, so it doesn't include axes.
|
|
45
27
|
* Add VictoryArea as a child of VictoryChart for a complete chart.
|
|
46
28
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
class VictoryAreaBase extends React.Component {
|
|
30
|
+
static animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
|
|
31
|
+
static defaultProps = {
|
|
32
|
+
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
33
|
+
dataComponent: /*#__PURE__*/React.createElement(Area, null),
|
|
34
|
+
groupComponent: /*#__PURE__*/React.createElement(VictoryClipContainer, null),
|
|
35
|
+
labelComponent: /*#__PURE__*/React.createElement(VictoryLabel, {
|
|
36
|
+
renderInPortal: true
|
|
37
|
+
}),
|
|
38
|
+
samples: 50,
|
|
39
|
+
sortKey: "x",
|
|
40
|
+
sortOrder: "ascending",
|
|
41
|
+
standalone: true,
|
|
42
|
+
theme: VictoryTheme.grayscale
|
|
43
|
+
};
|
|
44
|
+
static displayName = "VictoryArea";
|
|
45
|
+
static role = "area";
|
|
46
|
+
static continuous = true;
|
|
47
|
+
static defaultTransitions = DefaultTransitions.continuousTransitions();
|
|
48
|
+
static defaultPolarTransitions = DefaultTransitions.continuousPolarTransitions();
|
|
49
|
+
static getDomain = Domain.getDomainWithZero;
|
|
50
|
+
static getData = Data.getData;
|
|
51
|
+
static getBaseProps = props => getBaseProps(props, fallbackProps);
|
|
52
|
+
static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
|
|
53
|
+
|
|
54
|
+
// Overridden in native versions
|
|
55
|
+
shouldAnimate() {
|
|
56
|
+
return !!this.props.animate;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
render() {
|
|
59
|
+
const {
|
|
60
|
+
animationWhitelist,
|
|
61
|
+
role
|
|
62
|
+
} = VictoryAreaBase;
|
|
63
|
+
const props = Helpers.modifyProps(this.props, fallbackProps, role);
|
|
64
|
+
if (this.shouldAnimate()) {
|
|
65
|
+
return this.animateComponent(props, animationWhitelist);
|
|
63
66
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (this.shouldAnimate()) {
|
|
72
|
-
return this.animateComponent(props, animationWhitelist);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var children = this.renderContinuousData(props);
|
|
76
|
-
var component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
|
|
77
|
-
return UserProps.withSafeUserProps(component, props);
|
|
78
|
-
}
|
|
79
|
-
}]);
|
|
80
|
-
|
|
81
|
-
return VictoryAreaBase;
|
|
82
|
-
}(React.Component);
|
|
83
|
-
|
|
84
|
-
VictoryAreaBase.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
|
|
85
|
-
VictoryAreaBase.defaultProps = {
|
|
86
|
-
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
87
|
-
dataComponent: /*#__PURE__*/React.createElement(Area, null),
|
|
88
|
-
groupComponent: /*#__PURE__*/React.createElement(VictoryClipContainer, null),
|
|
89
|
-
labelComponent: /*#__PURE__*/React.createElement(VictoryLabel, {
|
|
90
|
-
renderInPortal: true
|
|
91
|
-
}),
|
|
92
|
-
samples: 50,
|
|
93
|
-
sortKey: "x",
|
|
94
|
-
sortOrder: "ascending",
|
|
95
|
-
standalone: true,
|
|
96
|
-
theme: VictoryTheme.grayscale
|
|
97
|
-
};
|
|
98
|
-
VictoryAreaBase.displayName = "VictoryArea";
|
|
99
|
-
VictoryAreaBase.role = "area";
|
|
100
|
-
VictoryAreaBase.continuous = true;
|
|
101
|
-
VictoryAreaBase.defaultTransitions = DefaultTransitions.continuousTransitions();
|
|
102
|
-
VictoryAreaBase.defaultPolarTransitions = DefaultTransitions.continuousPolarTransitions();
|
|
103
|
-
VictoryAreaBase.getDomain = Domain.getDomainWithZero;
|
|
104
|
-
VictoryAreaBase.getData = Data.getData;
|
|
105
|
-
|
|
106
|
-
VictoryAreaBase.getBaseProps = function (props) {
|
|
107
|
-
return getBaseProps(props, fallbackProps);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
VictoryAreaBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
|
|
111
|
-
export var VictoryArea = addEvents(VictoryAreaBase, options);
|
|
67
|
+
const children = this.renderContinuousData(props);
|
|
68
|
+
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
|
|
69
|
+
return UserProps.withSafeUserProps(component, props);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export const VictoryArea = addEvents(VictoryAreaBase, options);
|