victory-area 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/lib/index.js CHANGED
@@ -3,21 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Area", {
7
- enumerable: true,
8
- get: function () {
9
- return _area.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "VictoryArea", {
13
- enumerable: true,
14
- get: function () {
15
- return _victoryArea.default;
16
- }
17
- });
18
6
 
19
- var _victoryArea = _interopRequireDefault(require("./victory-area"));
7
+ var _victoryArea = require("./victory-area");
20
8
 
21
- var _area = _interopRequireDefault(require("./area"));
9
+ Object.keys(_victoryArea).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _victoryArea[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _victoryArea[key];
16
+ }
17
+ });
18
+ });
22
19
 
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ var _area = require("./area");
21
+
22
+ Object.keys(_area).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _area[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _area[key];
29
+ }
30
+ });
31
+ });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,150 @@
1
+ import PropTypes from "prop-types";
2
+ import React from "react";
3
+ import { Data, Domain, EventPropTypeInterface, InterpolationPropType, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps, VictoryStyleInterface, EventsMixinClass } from "victory-core";
4
+ export declare type VictoryAreaTTargetType = "data" | "labels" | "parent";
5
+ export interface VictoryAreaProps extends VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps {
6
+ eventKey?: string[] | number[] | StringOrNumberOrCallback;
7
+ events?: EventPropTypeInterface<VictoryAreaTTargetType, string | number>[];
8
+ interpolation?: InterpolationPropType | Function;
9
+ samples?: number;
10
+ style?: VictoryStyleInterface;
11
+ }
12
+ interface VictoryAreaBase extends EventsMixinClass<VictoryAreaProps> {
13
+ }
14
+ /**
15
+ * Draw area charts with React. VictoryArea is a composable component, so it doesn't include axes.
16
+ * Add VictoryArea as a child of VictoryChart for a complete chart.
17
+ */
18
+ declare class VictoryAreaBase extends React.Component<VictoryAreaProps> {
19
+ static animationWhitelist: string[];
20
+ static propTypes: {
21
+ interpolation: PropTypes.Requireable<string | ((...args: any[]) => any)>;
22
+ label: PropTypes.Validator<string | null | undefined>;
23
+ categories?: React.Validator<import("victory-core").CategoryPropType | null | undefined> | undefined;
24
+ data?: React.Validator<readonly any[] | null | undefined> | undefined;
25
+ dataComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
26
+ domain?: React.Validator<import("victory-core").ForAxes<import("victory-core").DomainTuple> | null | undefined> | undefined;
27
+ domainPadding?: React.Validator<import("victory-core").ForAxes<import("victory-core").PaddingType> | null | undefined> | undefined;
28
+ samples?: React.Validator<number | null | undefined> | undefined;
29
+ sortKey?: React.Validator<import("victory-core").DataGetterPropType | null | undefined> | undefined;
30
+ sortOrder?: React.Validator<import("victory-core").SortOrderPropType | null | undefined> | undefined;
31
+ x?: React.Validator<import("victory-core").DataGetterPropType | null | undefined> | undefined;
32
+ y?: React.Validator<import("victory-core").DataGetterPropType | null | undefined> | undefined;
33
+ y0?: React.Validator<import("victory-core").DataGetterPropType | null | undefined> | undefined;
34
+ theme?: React.Validator<import("victory-core").VictoryThemeDefinition | null | undefined> | undefined;
35
+ animate?: React.Validator<boolean | import("victory-core").AnimatePropTypeInterface | null | undefined> | undefined;
36
+ colorScale?: React.Validator<import("victory-core").ColorScalePropType | null | undefined> | undefined;
37
+ containerComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
38
+ externalEventMutations?: React.Validator<import("victory-core").EventCallbackInterface<string | string[], import("victory-core").StringOrNumberOrList>[] | null | undefined> | undefined;
39
+ groupComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
40
+ height?: React.Validator<number | null | undefined> | undefined;
41
+ horizontal?: React.Validator<boolean | null | undefined> | undefined;
42
+ maxDomain?: React.Validator<number | {
43
+ x?: number | undefined;
44
+ y?: number | undefined;
45
+ } | null | undefined> | undefined;
46
+ minDomain?: React.Validator<number | {
47
+ x?: number | undefined;
48
+ y?: number | undefined;
49
+ } | null | undefined> | undefined;
50
+ name?: React.Validator<string | null | undefined> | undefined;
51
+ origin?: React.Validator<import("victory-core").OriginType | null | undefined> | undefined;
52
+ padding?: React.Validator<import("victory-core").PaddingProps | null | undefined> | undefined;
53
+ polar?: React.Validator<boolean | null | undefined> | undefined;
54
+ range?: React.Validator<import("victory-core").ForAxes<import("victory-core").RangeTuple> | null | undefined> | undefined;
55
+ scale?: React.Validator<import("victory-core").D3Scale<any> | import("victory-core").ScaleName | {
56
+ x?: import("victory-core").D3Scale<any> | import("victory-core").ScaleName | undefined;
57
+ y?: import("victory-core").D3Scale<any> | import("victory-core").ScaleName | undefined;
58
+ } | null | undefined> | undefined;
59
+ sharedEvents?: React.Validator<{
60
+ events: any[];
61
+ getEventState: Function;
62
+ } | null | undefined> | undefined;
63
+ singleQuadrantDomainPadding?: React.Validator<boolean | {
64
+ x?: boolean | undefined;
65
+ y?: boolean | undefined;
66
+ } | null | undefined> | undefined;
67
+ standalone?: React.Validator<boolean | null | undefined> | undefined;
68
+ width?: React.Validator<number | null | undefined> | undefined;
69
+ };
70
+ static defaultProps: {
71
+ containerComponent: JSX.Element;
72
+ dataComponent: JSX.Element;
73
+ groupComponent: JSX.Element;
74
+ labelComponent: JSX.Element;
75
+ samples: number;
76
+ sortKey: string;
77
+ sortOrder: string;
78
+ standalone: boolean;
79
+ theme: import("victory-core").VictoryThemeDefinition;
80
+ };
81
+ static displayName: string;
82
+ static role: string;
83
+ static continuous: boolean;
84
+ static defaultTransitions: import("victory-core").AnimatePropTypeInterface;
85
+ static defaultPolarTransitions: import("victory-core").AnimatePropTypeInterface;
86
+ static getDomain: typeof Domain.getDomainWithZero;
87
+ static getData: typeof Data.getData;
88
+ static getBaseProps: (props: any) => any;
89
+ static expectedComponents: string[];
90
+ shouldAnimate(): boolean;
91
+ render(): any;
92
+ }
93
+ export declare const VictoryArea: {
94
+ new (props: import("victory-core").EventMixinCommonProps): {
95
+ state: {};
96
+ getEventState: (eventKey: string | number, namespace: string, childType?: string | undefined) => any;
97
+ getScopedEvents: (events: any, namespace: any, childType: any, baseProps: any) => {};
98
+ getEvents: (p: any, target: any, eventKey: any) => any;
99
+ externalMutations: {} | undefined;
100
+ calculatedState: {};
101
+ globalEvents: {};
102
+ prevGlobalEventKeys: string[];
103
+ boundGlobalEvents: {};
104
+ shouldComponentUpdate(nextProps: import("victory-core").EventMixinCommonProps): boolean;
105
+ componentDidMount(): void;
106
+ componentDidUpdate(prevProps: any): void;
107
+ componentWillUnmount(): void;
108
+ addGlobalListener(key: any): void;
109
+ removeGlobalListener(key: any): void;
110
+ getStateChanges(props: any): {};
111
+ applyExternalMutations(props: any, externalMutations: any): void;
112
+ getCalculatedValues(props: any): import("victory-core").EventMixinCalculatedValues;
113
+ getExternalMutations(props: import("victory-core").EventMixinCommonProps): {} | undefined;
114
+ cacheValues(obj: any): void;
115
+ getBaseProps(props: any, getSharedEventState: any): Record<string, object>;
116
+ getAllEvents(props: any): any;
117
+ getComponentProps(component: any, type: any, index: any): any;
118
+ renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
119
+ animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): JSX.Element;
120
+ renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
121
+ renderData(props: any, shouldRenderDatum?: ((datum: any) => boolean) | undefined): React.DetailedReactHTMLElement<any, HTMLElement>;
122
+ context: unknown;
123
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
124
+ forceUpdate(callback?: (() => void) | undefined): void;
125
+ render(): React.ReactNode;
126
+ readonly props: Readonly<import("victory-core").EventMixinCommonProps>;
127
+ refs: {
128
+ [key: string]: React.ReactInstance;
129
+ };
130
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
131
+ getSnapshotBeforeUpdate?(prevProps: Readonly<import("victory-core").EventMixinCommonProps>, prevState: Readonly<{}>): any;
132
+ componentWillMount?(): void;
133
+ UNSAFE_componentWillMount?(): void;
134
+ componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
135
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
136
+ componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
137
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
138
+ componentEvents: import("victory-core/lib/victory-util/events").ComponentEvent[];
139
+ getSharedEventState: (key: string, value: string) => unknown;
140
+ baseProps: Record<string, object>;
141
+ dataKeys: string[];
142
+ hasEvents: unknown;
143
+ events: unknown;
144
+ };
145
+ getBaseProps?(props: import("victory-core").EventMixinCommonProps): Record<string, object>;
146
+ role?: string | undefined;
147
+ expectedComponents?: string[] | undefined;
148
+ } & typeof VictoryAreaBase;
149
+ export {};
150
+ //# sourceMappingURL=victory-area.d.ts.map
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.VictoryArea = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
@@ -11,7 +11,7 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _helperMethods = require("./helper-methods");
13
13
 
14
- var _area = _interopRequireDefault(require("./area"));
14
+ var _area = require("./area");
15
15
 
16
16
  var _victoryCore = require("victory-core");
17
17
 
@@ -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 || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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,
@@ -61,18 +61,22 @@ var options = {
61
61
  }]
62
62
  };
63
63
 
64
- var VictoryArea = /*#__PURE__*/function (_React$Component) {
65
- _inherits(VictoryArea, _React$Component);
64
+ /**
65
+ * Draw area charts with React. VictoryArea is a composable component, so it doesn't include axes.
66
+ * Add VictoryArea as a child of VictoryChart for a complete chart.
67
+ */
68
+ var VictoryAreaBase = /*#__PURE__*/function (_React$Component) {
69
+ _inherits(VictoryAreaBase, _React$Component);
66
70
 
67
- var _super = _createSuper(VictoryArea);
71
+ var _super = _createSuper(VictoryAreaBase);
68
72
 
69
- function VictoryArea() {
70
- _classCallCheck(this, VictoryArea);
73
+ function VictoryAreaBase() {
74
+ _classCallCheck(this, VictoryAreaBase);
71
75
 
72
76
  return _super.apply(this, arguments);
73
77
  }
74
78
 
75
- _createClass(VictoryArea, [{
79
+ _createClass(VictoryAreaBase, [{
76
80
  key: "shouldAnimate",
77
81
  value: // Overridden in native versions
78
82
  function shouldAnimate() {
@@ -81,8 +85,8 @@ var VictoryArea = /*#__PURE__*/function (_React$Component) {
81
85
  }, {
82
86
  key: "render",
83
87
  value: function render() {
84
- var animationWhitelist = VictoryArea.animationWhitelist,
85
- role = VictoryArea.role;
88
+ var animationWhitelist = VictoryAreaBase.animationWhitelist,
89
+ role = VictoryAreaBase.role;
86
90
 
87
91
  var props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role);
88
92
 
@@ -96,19 +100,17 @@ var VictoryArea = /*#__PURE__*/function (_React$Component) {
96
100
  }
97
101
  }]);
98
102
 
99
- return VictoryArea;
103
+ return VictoryAreaBase;
100
104
  }(_react.default.Component);
101
105
 
102
- _defineProperty(VictoryArea, "animationWhitelist", ["data", "domain", "height", "padding", "style", "width"]);
103
-
104
- _defineProperty(VictoryArea, "propTypes", _objectSpread(_objectSpread(_objectSpread({}, _victoryCore.CommonProps.baseProps), _victoryCore.CommonProps.dataProps), {}, {
106
+ VictoryAreaBase.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
107
+ VictoryAreaBase.propTypes = _objectSpread(_objectSpread(_objectSpread({}, _victoryCore.CommonProps.baseProps), _victoryCore.CommonProps.dataProps), {}, {
105
108
  interpolation: _propTypes.default.oneOfType([_propTypes.default.oneOf(["basis", "cardinal", "catmullRom", "linear", "monotoneX", "monotoneY", "natural", "step", "stepAfter", "stepBefore"]), _propTypes.default.func]),
106
109
  label: _victoryCore.PropTypes.deprecated(_propTypes.default.string, "Use `labels` instead for individual data labels")
107
- }));
108
-
109
- _defineProperty(VictoryArea, "defaultProps", {
110
+ });
111
+ VictoryAreaBase.defaultProps = {
110
112
  containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
111
- dataComponent: /*#__PURE__*/_react.default.createElement(_area.default, null),
113
+ dataComponent: /*#__PURE__*/_react.default.createElement(_area.Area, null),
112
114
  groupComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryClipContainer, null),
113
115
  labelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, {
114
116
  renderInPortal: true
@@ -118,28 +120,20 @@ _defineProperty(VictoryArea, "defaultProps", {
118
120
  sortOrder: "ascending",
119
121
  standalone: true,
120
122
  theme: _victoryCore.VictoryTheme.grayscale
121
- });
122
-
123
- _defineProperty(VictoryArea, "displayName", "VictoryArea");
124
-
125
- _defineProperty(VictoryArea, "role", "area");
126
-
127
- _defineProperty(VictoryArea, "continuous", true);
128
-
129
- _defineProperty(VictoryArea, "defaultTransitions", _victoryCore.DefaultTransitions.continuousTransitions());
130
-
131
- _defineProperty(VictoryArea, "defaultPolarTransitions", _victoryCore.DefaultTransitions.continuousPolarTransitions());
132
-
133
- _defineProperty(VictoryArea, "getDomain", _victoryCore.Domain.getDomainWithZero);
134
-
135
- _defineProperty(VictoryArea, "getData", _victoryCore.Data.getData);
136
-
137
- _defineProperty(VictoryArea, "getBaseProps", function (props) {
123
+ };
124
+ VictoryAreaBase.displayName = "VictoryArea";
125
+ VictoryAreaBase.role = "area";
126
+ VictoryAreaBase.continuous = true;
127
+ VictoryAreaBase.defaultTransitions = _victoryCore.DefaultTransitions.continuousTransitions();
128
+ VictoryAreaBase.defaultPolarTransitions = _victoryCore.DefaultTransitions.continuousPolarTransitions();
129
+ VictoryAreaBase.getDomain = _victoryCore.Domain.getDomainWithZero;
130
+ VictoryAreaBase.getData = _victoryCore.Data.getData;
131
+
132
+ VictoryAreaBase.getBaseProps = function (props) {
138
133
  return (0, _helperMethods.getBaseProps)(props, fallbackProps);
139
- });
140
-
141
- _defineProperty(VictoryArea, "expectedComponents", ["dataComponent", "labelComponent", "groupComponent", "containerComponent"]);
142
-
143
- var _default = (0, _victoryCore.addEvents)(VictoryArea, options);
134
+ };
144
135
 
145
- exports.default = _default;
136
+ VictoryAreaBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
137
+ var VictoryArea = (0, _victoryCore.addEvents)(VictoryAreaBase, options);
138
+ exports.VictoryArea = VictoryArea;
139
+ //# sourceMappingURL=victory-area.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-area",
3
- "version": "36.4.1",
3
+ "version": "36.5.2",
4
4
  "description": "Area 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.4.1",
25
- "victory-vendor": "^36.4.0"
24
+ "victory-core": "^36.5.2",
25
+ "victory-vendor": "^36.5.1"
26
26
  },
27
27
  "peerDependencies": {
28
- "react": "^16.6.0 || ^17.0.0"
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": "aa44a22e5a93989773a560f765f83ac151f44c46"
34
+ "gitHead": "def218e9749ecafc159ef458dd03a8b92e227666"
35
35
  }
@@ -3,7 +3,15 @@ import React from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { assign } from "lodash";
5
5
  import * as d3Shape from "victory-vendor/d3-shape";
6
- import { Helpers, CommonProps, Path, UserProps } from "victory-core";
6
+ import {
7
+ Helpers,
8
+ CommonProps,
9
+ Path,
10
+ UserProps,
11
+ VictoryCommonPrimitiveProps,
12
+ LineHelpers,
13
+ VictoryCommonThemeProps,
14
+ } from "victory-core";
7
15
 
8
16
  const defined = (d) => {
9
17
  const y = d._y1 !== undefined ? d._y1 : d._y;
@@ -29,74 +37,41 @@ const getAngleAccessor = (scale) => {
29
37
  };
30
38
  };
31
39
 
32
- const toNewName = (interpolation) => {
33
- // d3 shape changed the naming scheme for interpolators from "basis" -> "curveBasis" etc.
34
- const capitalize = (s) => s && s[0].toUpperCase() + s.slice(1);
35
- return `curve${capitalize(interpolation)}`;
36
- };
37
-
38
- const getLineFunction = (props) => {
39
- const { polar, scale, horizontal } = props;
40
- const interpolationFunction =
41
- typeof props.interpolation === "function" && props.interpolation;
42
- const interpolationName =
43
- typeof props.interpolation === "string" && toNewName(props.interpolation);
44
- return polar
45
- ? d3Shape
46
- .lineRadial()
47
- .defined(defined)
48
- .curve(interpolationFunction || d3Shape[`${interpolationName}Closed`])
49
- .angle(getAngleAccessor(scale))
50
- .radius(getYAccessor(scale))
51
- : d3Shape
52
- .line()
53
- .defined(defined)
54
- .curve(interpolationFunction || d3Shape[interpolationName])
55
- .x(horizontal ? getYAccessor(scale) : getXAccessor(scale))
56
- .y(horizontal ? getXAccessor(scale) : getYAccessor(scale));
57
- };
58
-
59
- const getCartesianArea = (props, interpolation) => {
40
+ const getCartesianArea = (props: AreaProps) => {
60
41
  const { horizontal, scale } = props;
61
- const interpolationFunction =
62
- typeof interpolation === "function" && interpolation;
63
- const interpolationName = typeof interpolation === "string" && interpolation;
42
+ const interpolationFunction = LineHelpers.getInterpolationFunction(props);
64
43
  return horizontal
65
44
  ? d3Shape
66
45
  .area()
67
46
  .defined(defined)
68
- .curve(interpolationFunction || d3Shape[interpolationName])
47
+ .curve(interpolationFunction)
69
48
  .x0(getY0Accessor(scale))
70
49
  .x1(getYAccessor(scale))
71
50
  .y(getXAccessor(scale))
72
51
  : d3Shape
73
52
  .area()
74
53
  .defined(defined)
75
- .curve(interpolationFunction || d3Shape[interpolationName])
54
+ .curve(interpolationFunction)
76
55
  .x(getXAccessor(scale))
77
56
  .y1(getYAccessor(scale))
78
57
  .y0(getY0Accessor(scale));
79
58
  };
80
59
 
81
- const getAreaFunction = (props) => {
60
+ const getAreaFunction = (props: AreaProps) => {
82
61
  const { polar, scale } = props;
83
- const interpolationFunction =
84
- typeof props.interpolation === "function" && props.interpolation;
85
- const interpolationName =
86
- typeof props.interpolation === "string" && toNewName(props.interpolation);
87
- const interpolation = interpolationFunction || interpolationName;
62
+ const interpolationFunction = LineHelpers.getInterpolationFunction(props);
88
63
  return polar
89
64
  ? d3Shape
90
65
  .radialArea()
91
66
  .defined(defined)
92
- .curve(interpolationFunction || d3Shape[`${interpolationName}Closed`])
67
+ .curve(interpolationFunction)
93
68
  .angle(getAngleAccessor(scale))
94
69
  .outerRadius(getYAccessor(scale))
95
70
  .innerRadius(getY0Accessor(scale))
96
- : getCartesianArea(props, interpolation);
71
+ : getCartesianArea(props);
97
72
  };
98
73
 
99
- const evaluateProps = (props) => {
74
+ const evaluateProps = (props: AreaProps) => {
100
75
  /**
101
76
  * Potential evaluated props are:
102
77
  * `ariaLabel`
@@ -110,14 +85,17 @@ const evaluateProps = (props) => {
110
85
  const id = Helpers.evaluateProp(props.id, props);
111
86
  const style = Helpers.evaluateStyle(
112
87
  assign({ fill: "black" }, props.style),
113
- props
88
+ props,
114
89
  );
115
90
  const tabIndex = Helpers.evaluateProp(props.tabIndex, props);
116
91
 
117
92
  return assign({}, props, { ariaLabel, desc, id, style, tabIndex });
118
93
  };
119
94
 
120
- const Area = (props) => {
95
+ /**
96
+ * The area primitive used by VictoryArea
97
+ */
98
+ export const Area: React.FC<AreaProps> = (props) => {
121
99
  props = evaluateProps(props);
122
100
  const {
123
101
  ariaLabel,
@@ -134,7 +112,7 @@ const Area = (props) => {
134
112
  id,
135
113
  style,
136
114
  desc,
137
- tabIndex
115
+ tabIndex,
138
116
  } = props;
139
117
  const userProps = UserProps.getSafeUserProps(props);
140
118
  const defaultTransform =
@@ -143,7 +121,7 @@ const Area = (props) => {
143
121
  const renderLine =
144
122
  style.stroke && style.stroke !== "none" && style.stroke !== "transparent";
145
123
  const areaFunction = getAreaFunction(props);
146
- const lineFunction = renderLine && getLineFunction(props);
124
+ const lineFunction = renderLine && LineHelpers.getLineFunction(props);
147
125
 
148
126
  const areaStroke = style.stroke ? "none" : style.fill;
149
127
 
@@ -155,40 +133,40 @@ const Area = (props) => {
155
133
  transform,
156
134
  ...events,
157
135
  clipPath,
158
- tabIndex
136
+ tabIndex,
159
137
  };
160
138
 
161
139
  const area = React.cloneElement(
162
- pathComponent,
140
+ pathComponent!,
163
141
  assign(
164
142
  {
165
143
  key: `${id}-area`,
166
144
  style: assign({}, style, { stroke: areaStroke }),
167
145
  d: areaFunction(data),
168
146
  desc,
169
- tabIndex
147
+ tabIndex,
170
148
  },
171
149
  sharedProps,
172
- userProps
173
- )
150
+ userProps,
151
+ ),
174
152
  );
175
153
 
176
154
  const line = renderLine
177
155
  ? React.cloneElement(
178
- pathComponent,
156
+ pathComponent!,
179
157
  assign(
180
158
  {
181
159
  key: `${id}-area-stroke`,
182
160
  style: assign({}, style, { fill: "none" }),
183
- d: lineFunction(data)
161
+ d: lineFunction(data),
184
162
  },
185
- sharedProps
186
- )
163
+ sharedProps,
164
+ ),
187
165
  )
188
166
  : null;
189
167
 
190
168
  return renderLine
191
- ? React.cloneElement(groupComponent, userProps, [area, line])
169
+ ? React.cloneElement(groupComponent!, userProps, [area, line])
192
170
  : area;
193
171
  };
194
172
 
@@ -196,14 +174,20 @@ Area.propTypes = {
196
174
  ...CommonProps.primitiveProps,
197
175
  groupComponent: PropTypes.element,
198
176
  interpolation: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
199
- pathComponent: PropTypes.element
177
+ pathComponent: PropTypes.element,
200
178
  };
201
179
 
202
180
  Area.defaultProps = {
203
181
  groupComponent: <g />,
204
182
  pathComponent: <Path />,
205
183
  role: "presentation",
206
- shapeRendering: "auto"
184
+ shapeRendering: "auto",
207
185
  };
208
186
 
209
- export default Area;
187
+ export interface AreaProps extends VictoryCommonPrimitiveProps {
188
+ horizontal?: VictoryCommonThemeProps["horizontal"];
189
+ groupComponent?: React.ReactElement;
190
+ // eslint-disable-next-line @typescript-eslint/ban-types
191
+ interpolation?: string | Function;
192
+ pathComponent?: React.ReactElement;
193
+ }
@@ -5,7 +5,7 @@ import {
5
5
  Data,
6
6
  Domain,
7
7
  Scale,
8
- Collection
8
+ Collection,
9
9
  } from "victory-core";
10
10
 
11
11
  export const getDataWithBaseline = (props, scale) => {
@@ -19,7 +19,7 @@ export const getDataWithBaseline = (props, scale) => {
19
19
  const domain = scale[axis].domain();
20
20
  const minY = Collection.getMinValue(domain);
21
21
  const maxY = Collection.getMaxValue(domain);
22
- let defaultMin = defaultZero;
22
+ let defaultMin: typeof minY = defaultZero;
23
23
  if (minY < 0 && maxY <= 0) {
24
24
  defaultMin = maxY;
25
25
  } else if (minY >= 0 && maxY > 0) {
@@ -43,11 +43,11 @@ const getCalculatedValues = (props) => {
43
43
  const style = Helpers.getStyles(props.style, defaultStyles);
44
44
  const range = {
45
45
  x: Helpers.getRange(props, "x"),
46
- y: Helpers.getRange(props, "y")
46
+ y: Helpers.getRange(props, "y"),
47
47
  };
48
48
  const domain = {
49
49
  x: Domain.getDomainWithZero(props, "x"),
50
- y: Domain.getDomainWithZero(props, "y")
50
+ y: Domain.getDomainWithZero(props, "y"),
51
51
  };
52
52
  const scale = {
53
53
  x: Scale.getBaseScale(props, "x")
@@ -55,7 +55,7 @@ const getCalculatedValues = (props) => {
55
55
  .range(props.horizontal ? range.y : range.x),
56
56
  y: Scale.getBaseScale(props, "y")
57
57
  .domain(domain.y)
58
- .range(props.horizontal ? range.x : range.y)
58
+ .range(props.horizontal ? range.x : range.y),
59
59
  };
60
60
  const origin = polar
61
61
  ? props.origin || Helpers.getPolarOrigin(props)
@@ -86,7 +86,7 @@ export const getBaseProps = (props, fallbackProps) => {
86
86
  width,
87
87
  labels,
88
88
  name,
89
- disableInlineStyles
89
+ disableInlineStyles,
90
90
  } = props;
91
91
  const initialChildProps = {
92
92
  parent: {
@@ -102,7 +102,7 @@ export const getBaseProps = (props, fallbackProps) => {
102
102
  origin,
103
103
  padding,
104
104
  name,
105
- horizontal
105
+ horizontal,
106
106
  },
107
107
  all: {
108
108
  data: {
@@ -114,9 +114,9 @@ export const getBaseProps = (props, fallbackProps) => {
114
114
  interpolation,
115
115
  groupComponent,
116
116
  style: disableInlineStyles ? {} : style.data,
117
- disableInlineStyles
118
- }
119
- }
117
+ disableInlineStyles,
118
+ },
119
+ },
120
120
  };
121
121
  return data.reduce((childProps, datum, index) => {
122
122
  const text = LabelHelpers.getText(props, datum, index);
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./victory-area";
2
+ export * from "./area";