victory-bar 36.4.1 → 36.5.2
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/victory-bar.js +748 -706
- package/dist/victory-bar.min.js +1 -1
- package/es/bar-helper-methods.js +2 -1
- package/es/bar.js +2 -1
- package/es/geometry-helper-methods.js +2 -1
- package/es/helper-methods.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +2 -1
- package/es/path-helper-methods.js +2 -1
- package/es/v37/victory-bar.d.ts +23 -0
- package/es/v37/victory-bar.js +98 -0
- package/es/v37/victory-bar.stories.d.ts +13 -0
- package/es/v37/victory-bar.stories.js +18 -0
- package/es/victory-bar-beta.d.ts +23 -0
- package/es/victory-bar-beta.js +102 -0
- package/es/victory-bar.js +20 -27
- package/lib/bar-helper-methods.js +2 -1
- package/lib/bar.js +2 -1
- package/lib/geometry-helper-methods.js +2 -1
- package/lib/helper-methods.js +2 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/path-helper-methods.js +2 -1
- package/lib/v37/victory-bar.d.ts +23 -0
- package/lib/v37/victory-bar.js +115 -0
- package/lib/v37/victory-bar.stories.d.ts +13 -0
- package/lib/v37/victory-bar.stories.js +41 -0
- package/lib/victory-bar-beta.d.ts +23 -0
- package/lib/victory-bar-beta.js +122 -0
- package/lib/victory-bar.js +20 -26
- package/package.json +5 -5
- package/src/bar-helper-methods.js +4 -4
- package/src/bar.js +7 -7
- package/src/geometry-helper-methods.js +5 -5
- package/src/helper-methods.js +9 -9
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/path-helper-methods.js +18 -18
- package/src/v37/victory-bar.stories.tsx +25 -0
- package/src/v37/victory-bar.tsx +96 -0
- package/src/victory-bar-beta.tsx +127 -0
- package/src/victory-bar.js +13 -13
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithChart = exports.Demo = void 0;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _victoryBar = _interopRequireDefault(require("./victory-bar"));
|
|
11
|
+
|
|
12
|
+
var _victoryChart = _interopRequireDefault(require("victory-chart/lib/v37/victory-chart"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
/* eslint-disable react/no-multi-comp */
|
|
21
|
+
var _default = {
|
|
22
|
+
title: "v37/VictoryBar",
|
|
23
|
+
component: _victoryBar.default
|
|
24
|
+
};
|
|
25
|
+
exports.default = _default;
|
|
26
|
+
|
|
27
|
+
var Demo = function (props) {
|
|
28
|
+
return /*#__PURE__*/React.createElement(_victoryBar.default, props);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.Demo = Demo;
|
|
32
|
+
Demo.args = {
|
|
33
|
+
barRatio: 0.5
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var WithChart = function (props) {
|
|
37
|
+
return /*#__PURE__*/React.createElement(_victoryChart.default, props, /*#__PURE__*/React.createElement(_victoryBar.default, null));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.WithChart = WithChart;
|
|
41
|
+
//# sourceMappingURL=victory-bar.stories.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { NumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryProviderProps } from "victory-core";
|
|
3
|
+
export declare type VictoryBarAlignmentType = "start" | "middle" | "end";
|
|
4
|
+
export interface VictoryBarProps extends VictoryCommonProps, VictoryDatableProps {
|
|
5
|
+
alignment?: VictoryBarAlignmentType;
|
|
6
|
+
barRatio?: number;
|
|
7
|
+
barWidth?: NumberOrCallback;
|
|
8
|
+
cornerRadius?: NumberOrCallback | {
|
|
9
|
+
top?: NumberOrCallback;
|
|
10
|
+
topLeft?: NumberOrCallback;
|
|
11
|
+
topRight?: NumberOrCallback;
|
|
12
|
+
bottom?: NumberOrCallback;
|
|
13
|
+
bottomLeft?: NumberOrCallback;
|
|
14
|
+
bottomRight?: NumberOrCallback;
|
|
15
|
+
};
|
|
16
|
+
dataComponent?: React.ReactElement;
|
|
17
|
+
groupComponent?: React.ReactElement;
|
|
18
|
+
horizontal?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent: (props: Props) => React.ReactElement, initialProviderProps?: Partial<VictoryProviderProps>): (props: Props) => JSX.Element;
|
|
21
|
+
declare const _default: (props: VictoryBarProps) => JSX.Element;
|
|
22
|
+
export default _default;
|
|
23
|
+
//# sourceMappingURL=victory-bar-beta.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.withContainer = withContainer;
|
|
8
|
+
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
|
|
11
|
+
var _victoryCore = require("victory-core");
|
|
12
|
+
|
|
13
|
+
var _bar = _interopRequireDefault(require("./bar"));
|
|
14
|
+
|
|
15
|
+
var _helperMethods = require("./helper-methods");
|
|
16
|
+
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
+
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
29
|
+
// This is a demo component that uses VictoryProvider to access calculated props and state.
|
|
30
|
+
// This component does not include events, animations, or styling.
|
|
31
|
+
// To test this out, swap out the VictoryBar export in ./index.js and run `yarn storybook`.
|
|
32
|
+
var defaultProps = {
|
|
33
|
+
data: [{
|
|
34
|
+
x: 1,
|
|
35
|
+
y: 1
|
|
36
|
+
}, {
|
|
37
|
+
x: 2,
|
|
38
|
+
y: 2
|
|
39
|
+
}, {
|
|
40
|
+
x: 3,
|
|
41
|
+
y: 3
|
|
42
|
+
}, {
|
|
43
|
+
x: 4,
|
|
44
|
+
y: 4
|
|
45
|
+
}],
|
|
46
|
+
height: 300,
|
|
47
|
+
includeZero: true,
|
|
48
|
+
padding: 50,
|
|
49
|
+
sortOrder: "ascending",
|
|
50
|
+
width: 450
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// TODO: This would be a shared helper that allows us to access context values in the base component
|
|
54
|
+
function withContainer(WrappedComponent) {
|
|
55
|
+
var initialProviderProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
56
|
+
return function (props) {
|
|
57
|
+
var providerProps = _objectSpread(_objectSpread({}, initialProviderProps), props);
|
|
58
|
+
|
|
59
|
+
var _props$standalone = props.standalone,
|
|
60
|
+
standalone = _props$standalone === void 0 ? true : _props$standalone,
|
|
61
|
+
_props$containerCompo = props.containerComponent,
|
|
62
|
+
containerComponent = _props$containerCompo === void 0 ? /*#__PURE__*/React.createElement(_victoryCore.VictoryContainer, null) : _props$containerCompo;
|
|
63
|
+
|
|
64
|
+
if (standalone) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(_victoryCore.VictoryProvider, providerProps, /*#__PURE__*/React.cloneElement(containerComponent, providerProps, /*#__PURE__*/React.createElement(WrappedComponent, props)));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return /*#__PURE__*/React.createElement(_victoryCore.VictoryProvider, providerProps, /*#__PURE__*/React.createElement(WrappedComponent, props));
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function VictoryBar(_ref) {
|
|
73
|
+
var _ref$dataComponent = _ref.dataComponent,
|
|
74
|
+
dataComponent = _ref$dataComponent === void 0 ? /*#__PURE__*/React.createElement(_bar.default, null) : _ref$dataComponent,
|
|
75
|
+
_ref$groupComponent = _ref.groupComponent,
|
|
76
|
+
groupComponent = _ref$groupComponent === void 0 ? /*#__PURE__*/React.createElement("g", {
|
|
77
|
+
role: "presentation"
|
|
78
|
+
}) : _ref$groupComponent,
|
|
79
|
+
alignment = _ref.alignment,
|
|
80
|
+
barRatio = _ref.barRatio,
|
|
81
|
+
barWidth = _ref.barWidth,
|
|
82
|
+
cornerRadius = _ref.cornerRadius,
|
|
83
|
+
_ref$horizontal = _ref.horizontal,
|
|
84
|
+
horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal;
|
|
85
|
+
var scale = (0, _victoryCore.useScale)();
|
|
86
|
+
var data = (0, _victoryCore.useData)();
|
|
87
|
+
var domain = (0, _victoryCore.useDomain)();
|
|
88
|
+
var children = data.map(function (datum, i) {
|
|
89
|
+
var _getBarPosition = (0, _helperMethods.getBarPosition)({
|
|
90
|
+
domain: domain,
|
|
91
|
+
scale: scale,
|
|
92
|
+
horizontal: horizontal
|
|
93
|
+
}, datum),
|
|
94
|
+
x = _getBarPosition.x,
|
|
95
|
+
y = _getBarPosition.y,
|
|
96
|
+
x0 = _getBarPosition.x0,
|
|
97
|
+
y0 = _getBarPosition.y0;
|
|
98
|
+
|
|
99
|
+
var dataProps = {
|
|
100
|
+
index: i,
|
|
101
|
+
key: "bar-".concat(i),
|
|
102
|
+
alignment: alignment,
|
|
103
|
+
barRatio: barRatio,
|
|
104
|
+
barWidth: barWidth,
|
|
105
|
+
cornerRadius: cornerRadius,
|
|
106
|
+
scale: scale,
|
|
107
|
+
data: data,
|
|
108
|
+
x: x,
|
|
109
|
+
y: y,
|
|
110
|
+
x0: x0,
|
|
111
|
+
y0: y0,
|
|
112
|
+
datum: datum
|
|
113
|
+
};
|
|
114
|
+
return /*#__PURE__*/React.cloneElement(dataComponent, dataProps);
|
|
115
|
+
});
|
|
116
|
+
return /*#__PURE__*/React.cloneElement(groupComponent, {}, children);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
var _default = withContainer(VictoryBar, defaultProps);
|
|
120
|
+
|
|
121
|
+
exports.default = _default;
|
|
122
|
+
//# sourceMappingURL=victory-bar-beta.js.map
|
package/lib/victory-bar.js
CHANGED
|
@@ -21,6 +21,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
21
21
|
|
|
22
22
|
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; }
|
|
23
23
|
|
|
24
|
+
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; }
|
|
25
|
+
|
|
24
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
27
|
|
|
26
28
|
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); } }
|
|
@@ -29,7 +31,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
29
31
|
|
|
30
32
|
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); }
|
|
31
33
|
|
|
32
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
35
|
|
|
34
36
|
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); }; }
|
|
35
37
|
|
|
@@ -39,9 +41,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
39
41
|
|
|
40
42
|
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; } }
|
|
41
43
|
|
|
42
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
|
-
|
|
44
|
-
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; }
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
45
|
|
|
46
46
|
var fallbackProps = {
|
|
47
47
|
width: 450,
|
|
@@ -100,13 +100,10 @@ var VictoryBar = /*#__PURE__*/function (_React$Component) {
|
|
|
100
100
|
return VictoryBar;
|
|
101
101
|
}(_react.default.Component);
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
_defineProperty(VictoryBar, "role", "bar");
|
|
108
|
-
|
|
109
|
-
_defineProperty(VictoryBar, "defaultTransitions", {
|
|
103
|
+
VictoryBar.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
|
|
104
|
+
VictoryBar.displayName = "VictoryBar";
|
|
105
|
+
VictoryBar.role = "bar";
|
|
106
|
+
VictoryBar.defaultTransitions = {
|
|
110
107
|
onLoad: {
|
|
111
108
|
duration: 2000,
|
|
112
109
|
before: function () {
|
|
@@ -150,9 +147,8 @@ _defineProperty(VictoryBar, "defaultTransitions", {
|
|
|
150
147
|
};
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
_defineProperty(VictoryBar, "propTypes", _objectSpread(_objectSpread(_objectSpread({}, _victoryCore.CommonProps.baseProps), _victoryCore.CommonProps.dataProps), {}, {
|
|
150
|
+
};
|
|
151
|
+
VictoryBar.propTypes = _objectSpread(_objectSpread(_objectSpread({}, _victoryCore.CommonProps.baseProps), _victoryCore.CommonProps.dataProps), {}, {
|
|
156
152
|
alignment: _propTypes.default.oneOf(["start", "middle", "end"]),
|
|
157
153
|
barRatio: _propTypes.default.number,
|
|
158
154
|
barWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.func]),
|
|
@@ -166,9 +162,8 @@ _defineProperty(VictoryBar, "propTypes", _objectSpread(_objectSpread(_objectSpre
|
|
|
166
162
|
})]),
|
|
167
163
|
getPath: _propTypes.default.func,
|
|
168
164
|
horizontal: _propTypes.default.bool
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
_defineProperty(VictoryBar, "defaultProps", {
|
|
165
|
+
});
|
|
166
|
+
VictoryBar.defaultProps = {
|
|
172
167
|
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
|
|
173
168
|
data: defaultData,
|
|
174
169
|
dataComponent: /*#__PURE__*/_react.default.createElement(_bar.default, null),
|
|
@@ -180,18 +175,17 @@ _defineProperty(VictoryBar, "defaultProps", {
|
|
|
180
175
|
sortOrder: "ascending",
|
|
181
176
|
standalone: true,
|
|
182
177
|
theme: _victoryCore.VictoryTheme.grayscale
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
_defineProperty(VictoryBar, "getData", _victoryCore.Data.getData);
|
|
178
|
+
};
|
|
179
|
+
VictoryBar.getDomain = _victoryCore.Domain.getDomainWithZero;
|
|
180
|
+
VictoryBar.getData = _victoryCore.Data.getData;
|
|
188
181
|
|
|
189
|
-
|
|
182
|
+
VictoryBar.getBaseProps = function (props) {
|
|
190
183
|
return (0, _helperMethods.getBaseProps)(props, fallbackProps);
|
|
191
|
-
}
|
|
184
|
+
};
|
|
192
185
|
|
|
193
|
-
|
|
186
|
+
VictoryBar.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
|
|
194
187
|
|
|
195
188
|
var _default = (0, _victoryCore.addEvents)(VictoryBar);
|
|
196
189
|
|
|
197
|
-
exports.default = _default;
|
|
190
|
+
exports.default = _default;
|
|
191
|
+
//# sourceMappingURL=victory-bar.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-bar",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.5.2",
|
|
4
4
|
"description": "Bar Component for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"lodash": "^4.17.19",
|
|
23
23
|
"prop-types": "^15.8.1",
|
|
24
|
-
"victory-core": "^36.
|
|
25
|
-
"victory-vendor": "^36.
|
|
24
|
+
"victory-core": "^36.5.2",
|
|
25
|
+
"victory-vendor": "^36.5.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"react": "
|
|
28
|
+
"react": ">=16.6.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"version": "yarn run nps build-libs && nps build-dists"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "def218e9749ecafc159ef458dd03a8b92e227666"
|
|
35
35
|
}
|
|
@@ -22,18 +22,18 @@ const getCornerRadiusFromObject = (cornerRadius, props) => {
|
|
|
22
22
|
topLeft: 0,
|
|
23
23
|
topRight: 0,
|
|
24
24
|
bottomLeft: 0,
|
|
25
|
-
bottomRight: 0
|
|
25
|
+
bottomRight: 0,
|
|
26
26
|
};
|
|
27
27
|
const updateCornerRadius = (corner, fallback) => {
|
|
28
28
|
if (!isNil(cornerRadius[corner])) {
|
|
29
29
|
realCornerRadius[corner] = Helpers.evaluateProp(
|
|
30
30
|
cornerRadius[corner],
|
|
31
|
-
props
|
|
31
|
+
props,
|
|
32
32
|
);
|
|
33
33
|
} else if (!isNil(cornerRadius[fallback])) {
|
|
34
34
|
realCornerRadius[corner] = Helpers.evaluateProp(
|
|
35
35
|
cornerRadius[fallback],
|
|
36
|
-
props
|
|
36
|
+
props,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
@@ -49,7 +49,7 @@ export const getCornerRadius = (cornerRadius, props) => {
|
|
|
49
49
|
topLeft: 0,
|
|
50
50
|
topRight: 0,
|
|
51
51
|
bottomLeft: 0,
|
|
52
|
-
bottomRight: 0
|
|
52
|
+
bottomRight: 0,
|
|
53
53
|
};
|
|
54
54
|
if (!cornerRadius) {
|
|
55
55
|
return realCornerRadius;
|
package/src/bar.js
CHANGED
|
@@ -22,7 +22,7 @@ const evaluateProps = (props) => {
|
|
|
22
22
|
const barWidth = getBarWidth(props.barWidth, assign({}, props, { style }));
|
|
23
23
|
const cornerRadius = getCornerRadius(
|
|
24
24
|
props.cornerRadius,
|
|
25
|
-
assign({}, props, { style, barWidth })
|
|
25
|
+
assign({}, props, { style, barWidth }),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
|
|
@@ -37,7 +37,7 @@ const evaluateProps = (props) => {
|
|
|
37
37
|
cornerRadius,
|
|
38
38
|
desc,
|
|
39
39
|
id,
|
|
40
|
-
tabIndex
|
|
40
|
+
tabIndex,
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -62,7 +62,7 @@ const Bar = (props) => {
|
|
|
62
62
|
role: props.role,
|
|
63
63
|
shapeRendering: props.shapeRendering,
|
|
64
64
|
transform: props.transform || defaultTransform,
|
|
65
|
-
tabIndex: props.tabIndex
|
|
65
|
+
tabIndex: props.tabIndex,
|
|
66
66
|
});
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -80,8 +80,8 @@ Bar.propTypes = {
|
|
|
80
80
|
topRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
81
81
|
bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
82
82
|
bottomLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
83
|
-
bottomRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
|
|
84
|
-
})
|
|
83
|
+
bottomRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
84
|
+
}),
|
|
85
85
|
]),
|
|
86
86
|
datum: PropTypes.object,
|
|
87
87
|
getPath: PropTypes.func,
|
|
@@ -90,14 +90,14 @@ Bar.propTypes = {
|
|
|
90
90
|
width: PropTypes.number,
|
|
91
91
|
x: PropTypes.number,
|
|
92
92
|
y: PropTypes.number,
|
|
93
|
-
y0: PropTypes.number
|
|
93
|
+
y0: PropTypes.number,
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
Bar.defaultProps = {
|
|
97
97
|
defaultBarWidth: 8,
|
|
98
98
|
pathComponent: <Path />,
|
|
99
99
|
role: "presentation",
|
|
100
|
-
shapeRendering: "auto"
|
|
100
|
+
shapeRendering: "auto",
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
export default Bar;
|
|
@@ -32,7 +32,7 @@ const point = function (x, y) {
|
|
|
32
32
|
},
|
|
33
33
|
equals(p1) {
|
|
34
34
|
return this.x === p1.x && this.y === p1.y;
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -90,23 +90,23 @@ const circle = function (center, radius) {
|
|
|
90
90
|
const { x: x2, y: y2 } = P2;
|
|
91
91
|
const P3s = [
|
|
92
92
|
point(x2 - (h * (y1 - y0)) / d, y2 + (h * (x1 - x0)) / d),
|
|
93
|
-
point(x2 + (h * (y1 - y0)) / d, y2 - (h * (x1 - x0)) / d)
|
|
93
|
+
point(x2 + (h * (y1 - y0)) / d, y2 - (h * (x1 - x0)) / d),
|
|
94
94
|
];
|
|
95
95
|
P3s.sort((Point1, Point2) => Point1.x - Point2.x);
|
|
96
96
|
return P3s;
|
|
97
97
|
},
|
|
98
98
|
solveX(y) {
|
|
99
99
|
const sqrt = Math.sqrt(
|
|
100
|
-
Math.pow(this.radius, 2) - Math.pow(y - this.center.y, 2)
|
|
100
|
+
Math.pow(this.radius, 2) - Math.pow(y - this.center.y, 2),
|
|
101
101
|
);
|
|
102
102
|
return [this.center.x - sqrt, this.center.x + sqrt];
|
|
103
103
|
},
|
|
104
104
|
solveY(x) {
|
|
105
105
|
const sqrt = Math.sqrt(
|
|
106
|
-
Math.pow(this.radius, 2) - Math.pow(x - this.center.x, 2)
|
|
106
|
+
Math.pow(this.radius, 2) - Math.pow(x - this.center.x, 2),
|
|
107
107
|
);
|
|
108
108
|
return [this.center.y - sqrt, this.center.y + sqrt];
|
|
109
|
-
}
|
|
109
|
+
},
|
|
110
110
|
};
|
|
111
111
|
};
|
|
112
112
|
|
package/src/helper-methods.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
Domain,
|
|
6
6
|
Helpers,
|
|
7
7
|
LabelHelpers,
|
|
8
|
-
Scale
|
|
8
|
+
Scale,
|
|
9
9
|
} from "victory-core";
|
|
10
10
|
|
|
11
11
|
export const getBarPosition = (props, datum) => {
|
|
@@ -41,11 +41,11 @@ const getCalculatedValues = (props) => {
|
|
|
41
41
|
: {};
|
|
42
42
|
const range = props.range || {
|
|
43
43
|
x: Helpers.getRange(props, "x"),
|
|
44
|
-
y: Helpers.getRange(props, "y")
|
|
44
|
+
y: Helpers.getRange(props, "y"),
|
|
45
45
|
};
|
|
46
46
|
const domain = {
|
|
47
47
|
x: Domain.getDomainWithZero(props, "x"),
|
|
48
|
-
y: Domain.getDomainWithZero(props, "y")
|
|
48
|
+
y: Domain.getDomainWithZero(props, "y"),
|
|
49
49
|
};
|
|
50
50
|
const scale = {
|
|
51
51
|
x: Scale.getBaseScale(props, "x")
|
|
@@ -53,7 +53,7 @@ const getCalculatedValues = (props) => {
|
|
|
53
53
|
.range(props.horizontal ? range.y : range.x),
|
|
54
54
|
y: Scale.getBaseScale(props, "y")
|
|
55
55
|
.domain(domain.y)
|
|
56
|
-
.range(props.horizontal ? range.x : range.y)
|
|
56
|
+
.range(props.horizontal ? range.x : range.y),
|
|
57
57
|
};
|
|
58
58
|
const origin = polar
|
|
59
59
|
? props.origin || Helpers.getPolarOrigin(props)
|
|
@@ -90,7 +90,7 @@ export const getBaseProps = (props, fallbackProps) => {
|
|
|
90
90
|
labels,
|
|
91
91
|
name,
|
|
92
92
|
barWidth,
|
|
93
|
-
getPath
|
|
93
|
+
getPath,
|
|
94
94
|
} = props;
|
|
95
95
|
const initialChildProps = {
|
|
96
96
|
parent: {
|
|
@@ -106,8 +106,8 @@ export const getBaseProps = (props, fallbackProps) => {
|
|
|
106
106
|
polar,
|
|
107
107
|
origin,
|
|
108
108
|
padding,
|
|
109
|
-
style: style.parent
|
|
110
|
-
}
|
|
109
|
+
style: style.parent,
|
|
110
|
+
},
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
return data.reduce((childProps, datum, index) => {
|
|
@@ -134,11 +134,11 @@ export const getBaseProps = (props, fallbackProps) => {
|
|
|
134
134
|
x,
|
|
135
135
|
y,
|
|
136
136
|
y0,
|
|
137
|
-
x0
|
|
137
|
+
x0,
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
childProps[eventKey] = {
|
|
141
|
-
data: dataProps
|
|
141
|
+
data: dataProps,
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
const text = LabelHelpers.getText(props, datum, index);
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const getPosition = (props, width) => {
|
|
|
12
12
|
x0,
|
|
13
13
|
x1: x,
|
|
14
14
|
y0: alignment === "start" ? y : y - sign * size,
|
|
15
|
-
y1: alignment === "end" ? y : y + sign * size
|
|
15
|
+
y1: alignment === "end" ? y : y + sign * size,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ const getPosition = (props, width) => {
|
|
|
20
20
|
x0: alignment === "start" ? x : x - sign * size,
|
|
21
21
|
x1: alignment === "end" ? x : x + sign * size,
|
|
22
22
|
y0,
|
|
23
|
-
y1: y
|
|
23
|
+
y1: y,
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -100,7 +100,7 @@ const mapPointsToPath = (coords, cornerRadius, direction) => {
|
|
|
100
100
|
"L",
|
|
101
101
|
`A ${topRightPath},`,
|
|
102
102
|
"L",
|
|
103
|
-
`A ${bottomRightPath}
|
|
103
|
+
`A ${bottomRightPath},`,
|
|
104
104
|
];
|
|
105
105
|
const path = commands.reduce((acc, command, i) => {
|
|
106
106
|
acc += `${command} ${coords[i].x}, ${coords[i].y} \n`;
|
|
@@ -128,12 +128,12 @@ const getVerticalBarPoints = (position, sign, cr) => {
|
|
|
128
128
|
if (hasIntersection) {
|
|
129
129
|
const topCenter = point(
|
|
130
130
|
x + signL * cr[`top${side}`],
|
|
131
|
-
y1 + sign * cr[`top${side}`]
|
|
131
|
+
y1 + sign * cr[`top${side}`],
|
|
132
132
|
);
|
|
133
133
|
const topCircle = circle(topCenter, cr[`top${side}`]);
|
|
134
134
|
const bottomCenter = point(
|
|
135
135
|
x + signL * cr[`bottom${side}`],
|
|
136
|
-
y0 - sign * cr[`bottom${side}`]
|
|
136
|
+
y0 - sign * cr[`bottom${side}`],
|
|
137
137
|
);
|
|
138
138
|
const bottomCircle = circle(bottomCenter, cr[`bottom${side}`]);
|
|
139
139
|
const circleIntersection = topCircle.intersection(bottomCircle);
|
|
@@ -183,12 +183,12 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
183
183
|
if (hasIntersection) {
|
|
184
184
|
const leftCenter = point(
|
|
185
185
|
x0 + cr[`${side}Left`],
|
|
186
|
-
y - signL * cr[`${side}Left`]
|
|
186
|
+
y - signL * cr[`${side}Left`],
|
|
187
187
|
);
|
|
188
188
|
const leftCircle = circle(leftCenter, cr[`${side}Left`]);
|
|
189
189
|
const rightCenter = point(
|
|
190
190
|
x1 - cr[`${side}Right`],
|
|
191
|
-
y - signL * cr[`${side}Right`]
|
|
191
|
+
y - signL * cr[`${side}Right`],
|
|
192
192
|
);
|
|
193
193
|
const rightCircle = circle(rightCenter, cr[`${side}Right`]);
|
|
194
194
|
const circleIntersection = leftCircle.intersection(rightCircle);
|
|
@@ -223,7 +223,7 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
223
223
|
...topPoints,
|
|
224
224
|
// eslint-disable-next-line no-magic-numbers
|
|
225
225
|
bottomPoints[3],
|
|
226
|
-
bottomPoints[2]
|
|
226
|
+
bottomPoints[2],
|
|
227
227
|
];
|
|
228
228
|
};
|
|
229
229
|
|
|
@@ -247,7 +247,7 @@ export const getHorizontalBarPath = (props, width, cornerRadius) => {
|
|
|
247
247
|
topRight: sign > 0 ? cornerRadius.topLeft : cornerRadius.bottomLeft,
|
|
248
248
|
bottomRight: sign > 0 ? cornerRadius.topRight : cornerRadius.bottomRight,
|
|
249
249
|
bottomLeft: sign > 0 ? cornerRadius.bottomRight : cornerRadius.topRight,
|
|
250
|
-
topLeft: sign > 0 ? cornerRadius.bottomLeft : cornerRadius.topLeft
|
|
250
|
+
topLeft: sign > 0 ? cornerRadius.bottomLeft : cornerRadius.topLeft,
|
|
251
251
|
};
|
|
252
252
|
const points = getHorizontalBarPoints(position, sign, cr);
|
|
253
253
|
return mapPointsToPath(points, cr, direction);
|
|
@@ -296,7 +296,7 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
296
296
|
rightMiddle,
|
|
297
297
|
leftMoves,
|
|
298
298
|
leftCoords,
|
|
299
|
-
leftMiddle
|
|
299
|
+
leftMiddle,
|
|
300
300
|
};
|
|
301
301
|
};
|
|
302
302
|
|
|
@@ -310,7 +310,7 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
310
310
|
rightMiddle,
|
|
311
311
|
leftMoves,
|
|
312
312
|
leftCoords,
|
|
313
|
-
leftMiddle
|
|
313
|
+
leftMiddle,
|
|
314
314
|
} = getPathData("top");
|
|
315
315
|
let moves;
|
|
316
316
|
let coords;
|
|
@@ -333,11 +333,11 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
333
333
|
}
|
|
334
334
|
moves = [
|
|
335
335
|
...rightMoves.slice(0, rightOffset),
|
|
336
|
-
...leftMoves.slice(leftOffset)
|
|
336
|
+
...leftMoves.slice(leftOffset),
|
|
337
337
|
];
|
|
338
338
|
coords = [
|
|
339
339
|
...rightCoords.slice(0, rightOffset),
|
|
340
|
-
...leftCoords.slice(leftOffset)
|
|
340
|
+
...leftCoords.slice(leftOffset),
|
|
341
341
|
];
|
|
342
342
|
}
|
|
343
343
|
|
|
@@ -346,7 +346,7 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
346
346
|
const subCoords = coords.slice(0, middle);
|
|
347
347
|
return subMoves.map((m, i) => ({
|
|
348
348
|
command: m,
|
|
349
|
-
coords: subCoords[i].split(",")
|
|
349
|
+
coords: subCoords[i].split(","),
|
|
350
350
|
}));
|
|
351
351
|
};
|
|
352
352
|
|
|
@@ -360,7 +360,7 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
360
360
|
rightMiddle,
|
|
361
361
|
leftMoves,
|
|
362
362
|
leftCoords,
|
|
363
|
-
leftMiddle
|
|
363
|
+
leftMiddle,
|
|
364
364
|
} = getPathData("bottom");
|
|
365
365
|
let moves;
|
|
366
366
|
let coords;
|
|
@@ -382,11 +382,11 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
382
382
|
|
|
383
383
|
moves = [
|
|
384
384
|
...leftMoves.slice(0, leftMiddle + 2),
|
|
385
|
-
...rightMoves.slice(rightOffset)
|
|
385
|
+
...rightMoves.slice(rightOffset),
|
|
386
386
|
];
|
|
387
387
|
coords = [
|
|
388
388
|
...leftCoords.slice(0, leftMiddle + 2),
|
|
389
|
-
...rightCoords.slice(rightOffset)
|
|
389
|
+
...rightCoords.slice(rightOffset),
|
|
390
390
|
];
|
|
391
391
|
}
|
|
392
392
|
const middle = moves.indexOf("L");
|
|
@@ -394,7 +394,7 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
394
394
|
const subCoords = coords.slice(middle, -1);
|
|
395
395
|
return subMoves.map((m, i) => ({
|
|
396
396
|
command: m,
|
|
397
|
-
coords: subCoords[i].split(",")
|
|
397
|
+
coords: subCoords[i].split(","),
|
|
398
398
|
}));
|
|
399
399
|
};
|
|
400
400
|
|