victory-errorbar 36.9.1 → 36.9.2-next.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 +12 -0
- package/dist/victory-errorbar.js +3475 -4667
- package/dist/victory-errorbar.min.js +1 -1
- package/es/error-bar.d.ts +31 -31
- package/es/error-bar.js +60 -55
- package/es/helper-methods.d.ts +3 -3
- package/es/helper-methods.js +141 -153
- package/es/index.d.ts +2 -2
- package/es/victory-errorbar.d.ts +85 -85
- package/es/victory-errorbar.js +44 -83
- package/lib/error-bar.d.ts +31 -31
- package/lib/error-bar.js +61 -65
- package/lib/helper-methods.d.ts +3 -3
- package/lib/helper-methods.js +141 -171
- package/lib/index.d.ts +2 -2
- package/lib/index.js +0 -4
- package/lib/victory-errorbar.d.ts +85 -85
- package/lib/victory-errorbar.js +44 -91
- package/package.json +9 -12
- package/src/helper-methods.tsx +2 -2
package/es/error-bar.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { VictoryCommonPrimitiveProps } from "victory-core";
|
|
3
|
-
export interface ErrorBarProps extends VictoryCommonPrimitiveProps {
|
|
4
|
-
borderWidth?: number;
|
|
5
|
-
datum?: any;
|
|
6
|
-
errorX?: number | any[] | boolean;
|
|
7
|
-
errorY?: number | any[] | boolean;
|
|
8
|
-
groupComponent?: React.ReactElement;
|
|
9
|
-
lineComponent?: React.ReactElement;
|
|
10
|
-
x?: number;
|
|
11
|
-
y?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface ErrorProps {
|
|
14
|
-
right?: {
|
|
15
|
-
error: any;
|
|
16
|
-
errorIndex: number;
|
|
17
|
-
};
|
|
18
|
-
left?: {
|
|
19
|
-
error: any;
|
|
20
|
-
errorIndex: number;
|
|
21
|
-
};
|
|
22
|
-
bottom?: {
|
|
23
|
-
error: any;
|
|
24
|
-
errorIndex: number;
|
|
25
|
-
};
|
|
26
|
-
top?: {
|
|
27
|
-
error: any;
|
|
28
|
-
errorIndex: number;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export declare const ErrorBar: any;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { VictoryCommonPrimitiveProps } from "victory-core";
|
|
3
|
+
export interface ErrorBarProps extends VictoryCommonPrimitiveProps {
|
|
4
|
+
borderWidth?: number;
|
|
5
|
+
datum?: any;
|
|
6
|
+
errorX?: number | any[] | boolean;
|
|
7
|
+
errorY?: number | any[] | boolean;
|
|
8
|
+
groupComponent?: React.ReactElement;
|
|
9
|
+
lineComponent?: React.ReactElement;
|
|
10
|
+
x?: number;
|
|
11
|
+
y?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ErrorProps {
|
|
14
|
+
right?: {
|
|
15
|
+
error: any;
|
|
16
|
+
errorIndex: number;
|
|
17
|
+
};
|
|
18
|
+
left?: {
|
|
19
|
+
error: any;
|
|
20
|
+
errorIndex: number;
|
|
21
|
+
};
|
|
22
|
+
bottom?: {
|
|
23
|
+
error: any;
|
|
24
|
+
errorIndex: number;
|
|
25
|
+
};
|
|
26
|
+
top?: {
|
|
27
|
+
error: any;
|
|
28
|
+
errorIndex: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export declare const ErrorBar: any;
|
|
32
32
|
//# sourceMappingURL=error-bar.d.ts.map
|
package/es/error-bar.js
CHANGED
|
@@ -1,51 +1,46 @@
|
|
|
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-disable max-statements */
|
|
8
2
|
import React from "react";
|
|
9
3
|
import { Helpers, Line, UserProps } from "victory-core";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const renderBorder = (props, error, type) => {
|
|
5
|
+
const vertical = type === "right" || type === "left";
|
|
6
|
+
return /*#__PURE__*/React.cloneElement(props.lineComponent, {
|
|
7
|
+
...props.events,
|
|
14
8
|
role: props.role,
|
|
15
9
|
shapeRendering: props.shapeRendering,
|
|
16
10
|
className: props.className,
|
|
17
11
|
style: props.style,
|
|
18
12
|
transform: props.transform,
|
|
19
|
-
key:
|
|
13
|
+
key: `${props.id}-border-${type}`,
|
|
20
14
|
x1: vertical ? error[type] : props.x - props.borderWidth,
|
|
21
15
|
x2: vertical ? error[type] : props.x + props.borderWidth,
|
|
22
16
|
y1: vertical ? props.y - props.borderWidth : error[type],
|
|
23
17
|
y2: vertical ? props.y + props.borderWidth : error[type],
|
|
24
|
-
"data-type":
|
|
25
|
-
})
|
|
18
|
+
"data-type": `border-${type}`
|
|
19
|
+
});
|
|
26
20
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const renderCross = (props, error, type) => {
|
|
22
|
+
const vertical = type === "top" || type === "bottom";
|
|
23
|
+
return /*#__PURE__*/React.cloneElement(props.lineComponent, {
|
|
24
|
+
...props.events,
|
|
31
25
|
role: props.role,
|
|
32
26
|
shapeRendering: props.shapeRendering,
|
|
33
27
|
className: props.className,
|
|
34
28
|
style: props.style,
|
|
35
29
|
transform: props.transform,
|
|
36
|
-
key:
|
|
30
|
+
key: `${props.id}-cross-${type}`,
|
|
37
31
|
x1: props.x,
|
|
38
32
|
x2: vertical ? props.x : error[type],
|
|
39
33
|
y1: props.y,
|
|
40
34
|
y2: vertical ? error[type] : props.y,
|
|
41
|
-
"data-type":
|
|
42
|
-
})
|
|
35
|
+
"data-type": `cross-${type}`
|
|
36
|
+
});
|
|
43
37
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
const calculateError = props => {
|
|
39
|
+
const {
|
|
40
|
+
errorX,
|
|
41
|
+
errorY
|
|
42
|
+
} = props;
|
|
43
|
+
const settings = {
|
|
49
44
|
right: {
|
|
50
45
|
error: errorX,
|
|
51
46
|
errorIndex: 0
|
|
@@ -63,22 +58,20 @@ var calculateError = function (props) {
|
|
|
63
58
|
errorIndex: 0
|
|
64
59
|
}
|
|
65
60
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
const getError = direction => {
|
|
62
|
+
const {
|
|
63
|
+
error,
|
|
64
|
+
errorIndex
|
|
65
|
+
} = settings[direction];
|
|
71
66
|
return error ? error[errorIndex] : undefined;
|
|
72
67
|
};
|
|
73
|
-
|
|
74
|
-
var result = ["right", "left", "top", "bottom"].reduce(function (memo, dir) {
|
|
68
|
+
const result = ["right", "left", "top", "bottom"].reduce((memo, dir) => {
|
|
75
69
|
memo[dir] = getError(dir);
|
|
76
70
|
return memo;
|
|
77
71
|
}, {});
|
|
78
72
|
return result;
|
|
79
73
|
};
|
|
80
|
-
|
|
81
|
-
var evaluateProps = function (props) {
|
|
74
|
+
const evaluateProps = props => {
|
|
82
75
|
/**
|
|
83
76
|
* Potential evaluated props are:
|
|
84
77
|
* `ariaLabel`
|
|
@@ -86,36 +79,48 @@ var evaluateProps = function (props) {
|
|
|
86
79
|
* `style`
|
|
87
80
|
* `tabIndex`
|
|
88
81
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
const ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
|
|
83
|
+
const id = Helpers.evaluateProp(props.id, props);
|
|
84
|
+
const style = Helpers.evaluateStyle(Object.assign({
|
|
92
85
|
stroke: "black"
|
|
93
86
|
}, props.style), props);
|
|
94
|
-
|
|
87
|
+
const tabIndex = Helpers.evaluateProp(props.tabIndex, props);
|
|
95
88
|
return Object.assign({}, props, {
|
|
96
|
-
ariaLabel
|
|
97
|
-
id
|
|
98
|
-
style
|
|
99
|
-
tabIndex
|
|
89
|
+
ariaLabel,
|
|
90
|
+
id,
|
|
91
|
+
style,
|
|
92
|
+
tabIndex
|
|
100
93
|
});
|
|
101
94
|
};
|
|
102
95
|
|
|
103
|
-
|
|
96
|
+
// ErrorProps for calculateError
|
|
97
|
+
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
99
|
+
|
|
100
|
+
const defaultProps = {
|
|
104
101
|
groupComponent: /*#__PURE__*/React.createElement("g", null),
|
|
105
102
|
lineComponent: /*#__PURE__*/React.createElement(Line, null),
|
|
106
103
|
role: "presentation",
|
|
107
104
|
shapeRendering: "auto"
|
|
108
105
|
};
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
export const ErrorBar = initialProps => {
|
|
107
|
+
const props = evaluateProps({
|
|
108
|
+
...defaultProps,
|
|
109
|
+
...initialProps
|
|
110
|
+
});
|
|
111
|
+
const {
|
|
112
|
+
groupComponent
|
|
113
|
+
} = props;
|
|
114
|
+
const userProps = UserProps.getSafeUserProps(props);
|
|
115
|
+
const {
|
|
116
|
+
tabIndex,
|
|
117
|
+
ariaLabel
|
|
118
|
+
} = props;
|
|
119
|
+
const error = calculateError(props);
|
|
120
|
+
const children = [error.right ? renderBorder(props, error, "right") : null, error.left ? renderBorder(props, error, "left") : null, error.bottom ? renderBorder(props, error, "bottom") : null, error.top ? renderBorder(props, error, "top") : null, error.right ? renderCross(props, error, "right") : null, error.left ? renderCross(props, error, "left") : null, error.bottom ? renderCross(props, error, "bottom") : null, error.top ? renderCross(props, error, "top") : null].filter(Boolean);
|
|
121
|
+
return /*#__PURE__*/React.cloneElement(groupComponent, {
|
|
122
|
+
tabIndex,
|
|
123
|
+
"aria-label": ariaLabel,
|
|
124
|
+
...userProps
|
|
125
|
+
}, children);
|
|
121
126
|
};
|
package/es/helper-methods.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const getData: (props: any) => any;
|
|
2
|
-
export declare const getDomain: (props: any, axis: any) => any;
|
|
3
|
-
export declare const getBaseProps: (initialProps: any, fallbackProps: any) => any;
|
|
1
|
+
export declare const getData: (props: any) => any;
|
|
2
|
+
export declare const getDomain: (props: any, axis: any) => any;
|
|
3
|
+
export declare const getBaseProps: (initialProps: any, fallbackProps: any) => any;
|
|
4
4
|
//# sourceMappingURL=helper-methods.d.ts.map
|
package/es/helper-methods.js
CHANGED
|
@@ -1,236 +1,224 @@
|
|
|
1
|
-
import _isNil from "lodash/isNil";
|
|
2
1
|
import _assign from "lodash/assign";
|
|
3
2
|
import _defaults from "lodash/defaults";
|
|
4
3
|
import { Helpers, LabelHelpers, Scale, Domain, Data, Collection } from "victory-core";
|
|
5
|
-
|
|
6
|
-
var getErrors = function (props, datum, axis) {
|
|
4
|
+
const getErrors = (props, datum, axis) => {
|
|
7
5
|
/**
|
|
8
6
|
* check if it is asymmetric error or symmetric error, asymmetric error should be an array
|
|
9
7
|
* and the first value is the positive error, the second is the negative error
|
|
10
8
|
* @param {Boolean} isArray(errorX)
|
|
11
9
|
* @return {String or Array}
|
|
12
10
|
*/
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
const errorNames = {
|
|
14
13
|
x: "_errorX",
|
|
15
14
|
y: "_errorY"
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const errors = datum[errorNames[axis]];
|
|
19
17
|
if (errors === 0) {
|
|
20
18
|
return false;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return Array.isArray(errors) ? [errors[0] === 0 ? false : scale(errors[0] + datum["_".concat(axis)]), errors[1] === 0 ? false : scale(datum["_".concat(axis)] - errors[1])] : [scale(errors + datum["_".concat(axis)]), scale(datum["_".concat(axis)] - errors)];
|
|
20
|
+
const scale = props.scale[axis];
|
|
21
|
+
return Array.isArray(errors) ? [errors[0] === 0 ? false : scale(errors[0] + datum[`_${axis}`]), errors[1] === 0 ? false : scale(datum[`_${axis}`] - errors[1])] : [scale(errors + datum[`_${axis}`]), scale(datum[`_${axis}`] - errors)];
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var accessorTypes = ["x", "y", "errorX", "errorY"];
|
|
29
|
-
|
|
23
|
+
export const getData = props => {
|
|
24
|
+
const accessorTypes = ["x", "y", "errorX", "errorY"];
|
|
30
25
|
if (props.data) {
|
|
31
26
|
return Data.formatData(props.data, props, accessorTypes);
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
var generatedData = props.errorX || props.errorY ? Data.generateData(props) : [];
|
|
28
|
+
const generatedData = props.errorX || props.errorY ? Data.generateData(props) : [];
|
|
35
29
|
return Data.formatData(generatedData, props, accessorTypes);
|
|
36
30
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var dataset = getData(props);
|
|
42
|
-
|
|
31
|
+
const getDomainFromData = (props, axis) => {
|
|
32
|
+
const minDomain = Domain.getMinFromProps(props, axis);
|
|
33
|
+
const maxDomain = Domain.getMaxFromProps(props, axis);
|
|
34
|
+
const dataset = getData(props);
|
|
43
35
|
if (dataset.length < 1) {
|
|
44
36
|
return minDomain !== undefined && maxDomain !== undefined ? Domain.getDomainFromMinMax(minDomain, maxDomain) : undefined;
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var currentError = Array.isArray(datum[error]) ? datum[error][errorIndex] : datum[error];
|
|
55
|
-
var current = datum["_".concat(axis)] + sign * (currentError || 0);
|
|
38
|
+
const error = axis === "x" ? "_errorX" : "_errorY";
|
|
39
|
+
const reduceErrorData = type => {
|
|
40
|
+
const baseCondition = type === "min" ? Infinity : -Infinity;
|
|
41
|
+
const errorIndex = type === "min" ? 1 : 0;
|
|
42
|
+
const sign = type === "min" ? -1 : 1;
|
|
43
|
+
return dataset.reduce((memo, datum) => {
|
|
44
|
+
const currentError = Array.isArray(datum[error]) ? datum[error][errorIndex] : datum[error];
|
|
45
|
+
const current = datum[`_${axis}`] + sign * (currentError || 0);
|
|
56
46
|
return memo < current && type === "min" || memo > current && type === "max" ? memo : current;
|
|
57
47
|
}, baseCondition);
|
|
58
48
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var max = maxDomain !== undefined ? maxDomain : reduceErrorData("max");
|
|
49
|
+
const min = minDomain !== undefined ? minDomain : reduceErrorData("min");
|
|
50
|
+
const max = maxDomain !== undefined ? maxDomain : reduceErrorData("max");
|
|
62
51
|
return Domain.getDomainFromMinMax(min, max);
|
|
63
52
|
};
|
|
64
|
-
|
|
65
|
-
export var getDomain = function (props, axis) {
|
|
53
|
+
export const getDomain = (props, axis) => {
|
|
66
54
|
return Domain.createDomainFunction(getDomainFromData)(props, axis);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var formatDataFromDomain = function (datum, domain) {
|
|
70
|
-
var minDomainX = Collection.getMinValue(domain.x);
|
|
71
|
-
var maxDomainX = Collection.getMaxValue(domain.x);
|
|
72
|
-
var minDomainY = Collection.getMinValue(domain.y);
|
|
73
|
-
var maxDomainY = Collection.getMaxValue(domain.y);
|
|
74
|
-
var _x = datum._x,
|
|
75
|
-
_y = datum._y; // if either x or y center point is outside of the domain, null the entire data point
|
|
55
|
+
};
|
|
76
56
|
|
|
57
|
+
// This method will edit or remove errorbar data points that fall outside of the desired domain
|
|
58
|
+
const formatDataFromDomain = (datum, domain) => {
|
|
59
|
+
const minDomainX = Collection.getMinValue(domain.x);
|
|
60
|
+
const maxDomainX = Collection.getMaxValue(domain.x);
|
|
61
|
+
const minDomainY = Collection.getMinValue(domain.y);
|
|
62
|
+
const maxDomainY = Collection.getMaxValue(domain.y);
|
|
63
|
+
let {
|
|
64
|
+
_x,
|
|
65
|
+
_y
|
|
66
|
+
} = datum;
|
|
67
|
+
|
|
68
|
+
// if either x or y center point is outside of the domain, null the entire data point
|
|
77
69
|
if (_x < minDomainX || _x > maxDomainX || _y < minDomainY || _y > maxDomainY) _x = _y = null;
|
|
78
70
|
return Object.assign({}, datum, {
|
|
79
|
-
_x
|
|
80
|
-
_y
|
|
71
|
+
_x,
|
|
72
|
+
_y
|
|
81
73
|
});
|
|
82
74
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var range = {
|
|
75
|
+
const getCalculatedValues = props => {
|
|
76
|
+
const defaultStyles = Helpers.getDefaultStyles(props, "errorbar");
|
|
77
|
+
const style = Helpers.getStyles(props.style, defaultStyles) || {};
|
|
78
|
+
const data = getData(props);
|
|
79
|
+
const range = {
|
|
89
80
|
x: Helpers.getRange(props, "x"),
|
|
90
81
|
y: Helpers.getRange(props, "y")
|
|
91
82
|
};
|
|
92
|
-
|
|
83
|
+
const domain = {
|
|
93
84
|
x: getDomain(props, "x"),
|
|
94
85
|
y: getDomain(props, "y")
|
|
95
86
|
};
|
|
96
|
-
|
|
87
|
+
const scale = {
|
|
97
88
|
x: Scale.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
|
|
98
89
|
y: Scale.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
|
|
99
90
|
};
|
|
100
|
-
|
|
91
|
+
const origin = props.polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
|
|
101
92
|
return {
|
|
102
|
-
domain
|
|
103
|
-
data
|
|
104
|
-
scale
|
|
105
|
-
style
|
|
106
|
-
origin
|
|
93
|
+
domain,
|
|
94
|
+
data,
|
|
95
|
+
scale,
|
|
96
|
+
style,
|
|
97
|
+
origin
|
|
107
98
|
};
|
|
108
99
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
100
|
+
const getLabelProps = (dataProps, text, style) => {
|
|
101
|
+
const {
|
|
102
|
+
x,
|
|
103
|
+
y,
|
|
104
|
+
index,
|
|
105
|
+
scale,
|
|
106
|
+
errorY,
|
|
107
|
+
errorX,
|
|
108
|
+
horizontal,
|
|
109
|
+
labelComponent,
|
|
110
|
+
theme,
|
|
111
|
+
disableInlineStyles
|
|
112
|
+
} = dataProps;
|
|
113
|
+
const getError = function (type) {
|
|
114
|
+
if (type === void 0) {
|
|
115
|
+
type = "x";
|
|
116
|
+
}
|
|
117
|
+
const baseError = type === "y" ? errorY : errorX;
|
|
118
|
+
const error = baseError && Array.isArray(baseError) ? baseError[0] : baseError;
|
|
126
119
|
return error || dataProps[type];
|
|
127
120
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var labelProps = {
|
|
121
|
+
const labelStyle = style.labels || {};
|
|
122
|
+
const padding = labelStyle.padding || 0;
|
|
123
|
+
const textAnchor = horizontal ? "start" : "middle";
|
|
124
|
+
const verticalAnchor = horizontal ? "middle" : "end";
|
|
125
|
+
const labelProps = {
|
|
134
126
|
style: labelStyle,
|
|
135
127
|
y: horizontal ? y : getError("y"),
|
|
136
128
|
x: horizontal ? getError("x") : x,
|
|
137
129
|
dy: horizontal ? 0 : -padding,
|
|
138
130
|
dx: horizontal ? padding : 0,
|
|
139
|
-
text
|
|
140
|
-
index
|
|
141
|
-
scale
|
|
131
|
+
text,
|
|
132
|
+
index,
|
|
133
|
+
scale,
|
|
142
134
|
datum: dataProps.datum,
|
|
143
135
|
data: dataProps.data,
|
|
144
136
|
textAnchor: labelStyle.textAnchor || textAnchor,
|
|
145
137
|
verticalAnchor: labelStyle.verticalAnchor || verticalAnchor,
|
|
146
138
|
angle: labelStyle.angle,
|
|
147
|
-
horizontal
|
|
148
|
-
disableInlineStyles
|
|
139
|
+
horizontal,
|
|
140
|
+
disableInlineStyles
|
|
149
141
|
};
|
|
150
|
-
|
|
151
142
|
if (!Helpers.isTooltip(labelComponent)) {
|
|
152
143
|
return labelProps;
|
|
153
144
|
}
|
|
154
|
-
|
|
155
|
-
var tooltipTheme = theme && theme.tooltip || {};
|
|
145
|
+
const tooltipTheme = theme && theme.tooltip || {};
|
|
156
146
|
return _defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
|
|
157
147
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
148
|
+
export const getBaseProps = (initialProps, fallbackProps) => {
|
|
149
|
+
const modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "errorbar");
|
|
150
|
+
const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
|
|
151
|
+
const {
|
|
152
|
+
borderWidth,
|
|
153
|
+
data,
|
|
154
|
+
domain,
|
|
155
|
+
events,
|
|
156
|
+
groupComponent,
|
|
157
|
+
height,
|
|
158
|
+
horizontal,
|
|
159
|
+
labels,
|
|
160
|
+
name,
|
|
161
|
+
origin,
|
|
162
|
+
padding,
|
|
163
|
+
polar,
|
|
164
|
+
scale,
|
|
165
|
+
sharedEvents,
|
|
166
|
+
standalone,
|
|
167
|
+
style,
|
|
168
|
+
theme,
|
|
169
|
+
width,
|
|
170
|
+
disableInlineStyles
|
|
171
|
+
} = props;
|
|
172
|
+
const initialChildProps = {
|
|
182
173
|
parent: {
|
|
183
|
-
data
|
|
184
|
-
domain
|
|
185
|
-
height
|
|
186
|
-
horizontal
|
|
187
|
-
name
|
|
188
|
-
origin
|
|
189
|
-
padding
|
|
190
|
-
polar
|
|
191
|
-
scale
|
|
192
|
-
standalone
|
|
174
|
+
data,
|
|
175
|
+
domain,
|
|
176
|
+
height,
|
|
177
|
+
horizontal,
|
|
178
|
+
name,
|
|
179
|
+
origin,
|
|
180
|
+
padding,
|
|
181
|
+
polar,
|
|
182
|
+
scale,
|
|
183
|
+
standalone,
|
|
193
184
|
style: style.parent,
|
|
194
|
-
theme
|
|
195
|
-
width
|
|
185
|
+
theme,
|
|
186
|
+
width
|
|
196
187
|
}
|
|
197
188
|
};
|
|
198
|
-
return data.reduce(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
data: data,
|
|
189
|
+
return data.reduce((childProps, datum, index) => {
|
|
190
|
+
const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
|
|
191
|
+
const {
|
|
192
|
+
x,
|
|
193
|
+
y
|
|
194
|
+
} = Helpers.scalePoint(_assign({}, props, {
|
|
195
|
+
scale
|
|
196
|
+
}), datum);
|
|
197
|
+
const formattedDatum = formatDataFromDomain(datum, domain);
|
|
198
|
+
const errorX = getErrors(props, formattedDatum, "x");
|
|
199
|
+
const errorY = getErrors(props, formattedDatum, "y");
|
|
200
|
+
const dataProps = {
|
|
201
|
+
borderWidth,
|
|
202
|
+
data,
|
|
213
203
|
datum: formattedDatum,
|
|
214
204
|
errorX: horizontal ? errorY : errorX,
|
|
215
205
|
errorY: horizontal ? errorX : errorY,
|
|
216
|
-
groupComponent
|
|
217
|
-
horizontal
|
|
218
|
-
index
|
|
219
|
-
scale
|
|
206
|
+
groupComponent,
|
|
207
|
+
horizontal,
|
|
208
|
+
index,
|
|
209
|
+
scale,
|
|
220
210
|
style: disableInlineStyles ? {} : style.data,
|
|
221
|
-
x
|
|
222
|
-
y
|
|
223
|
-
disableInlineStyles
|
|
211
|
+
x,
|
|
212
|
+
y,
|
|
213
|
+
disableInlineStyles
|
|
224
214
|
};
|
|
225
215
|
childProps[eventKey] = {
|
|
226
216
|
data: dataProps
|
|
227
217
|
};
|
|
228
|
-
|
|
229
|
-
|
|
218
|
+
const text = LabelHelpers.getText(props, datum, index);
|
|
230
219
|
if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
|
|
231
220
|
childProps[eventKey].labels = getLabelProps(Object.assign({}, props, dataProps), text, style);
|
|
232
221
|
}
|
|
233
|
-
|
|
234
222
|
return childProps;
|
|
235
223
|
}, initialChildProps);
|
|
236
224
|
};
|
package/es/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./victory-errorbar";
|
|
2
|
-
export * from "./error-bar";
|
|
1
|
+
export * from "./victory-errorbar";
|
|
2
|
+
export * from "./error-bar";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|