victory-chart 18.2.0 → 19.1.1

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +9 -5
  3. package/dist/victory-chart.js +17058 -24378
  4. package/dist/victory-chart.min.js +13 -14
  5. package/lib/components/containers/brush-helpers.js +7 -4
  6. package/lib/components/containers/create-container.js +40 -32
  7. package/lib/components/containers/cursor-helpers.js +48 -0
  8. package/lib/components/containers/victory-brush-container.js +7 -3
  9. package/lib/components/containers/victory-cursor-container.js +145 -0
  10. package/lib/components/containers/victory-selection-container.js +5 -2
  11. package/lib/components/containers/victory-voronoi-container.js +40 -15
  12. package/lib/components/containers/victory-zoom-container.js +9 -2
  13. package/lib/components/containers/zoom-helpers.js +7 -2
  14. package/lib/components/victory-area/helper-methods.js +2 -1
  15. package/lib/components/victory-area/victory-area.js +9 -105
  16. package/lib/components/victory-axis/helper-methods.js +5 -2
  17. package/lib/components/victory-axis/victory-axis.js +11 -53
  18. package/lib/components/victory-bar/helper-methods.js +3 -1
  19. package/lib/components/victory-bar/victory-bar.js +8 -114
  20. package/lib/components/victory-candlestick/helper-methods.js +2 -1
  21. package/lib/components/victory-candlestick/victory-candlestick.js +10 -111
  22. package/lib/components/victory-chart/helper-methods.js +4 -3
  23. package/lib/components/victory-chart/victory-chart.js +12 -67
  24. package/lib/components/victory-errorbar/helper-methods.js +1 -1
  25. package/lib/components/victory-errorbar/victory-errorbar.js +8 -113
  26. package/lib/components/victory-group/victory-group.js +12 -86
  27. package/lib/components/victory-line/helper-methods.js +2 -1
  28. package/lib/components/victory-line/victory-line.js +9 -105
  29. package/lib/components/victory-scatter/helper-methods.js +1 -1
  30. package/lib/components/victory-scatter/victory-scatter.js +8 -111
  31. package/lib/components/victory-stack/victory-stack.js +11 -59
  32. package/lib/components/victory-voronoi/helper-methods.js +1 -1
  33. package/lib/components/victory-voronoi/victory-voronoi.js +7 -112
  34. package/lib/helpers/common-props.js +87 -0
  35. package/lib/helpers/wrapper.js +2 -1
  36. package/lib/index.js +9 -7
  37. package/package.json +14 -14
  38. package/src/components/containers/brush-helpers.js +37 -34
  39. package/src/components/containers/create-container.js +52 -43
  40. package/src/components/containers/cursor-helpers.js +49 -0
  41. package/src/components/containers/selection-helpers.js +13 -13
  42. package/src/components/containers/victory-brush-container.js +33 -29
  43. package/src/components/containers/victory-cursor-container.js +145 -0
  44. package/src/components/containers/victory-selection-container.js +14 -11
  45. package/src/components/containers/victory-voronoi-container.js +50 -25
  46. package/src/components/containers/victory-zoom-container.js +17 -10
  47. package/src/components/containers/voronoi-helpers.js +9 -9
  48. package/src/components/containers/zoom-helpers.js +18 -13
  49. package/src/components/victory-area/helper-methods.js +7 -6
  50. package/src/components/victory-area/victory-area.js +14 -110
  51. package/src/components/victory-axis/helper-methods.js +22 -19
  52. package/src/components/victory-axis/victory-axis.js +15 -57
  53. package/src/components/victory-bar/helper-methods.js +7 -5
  54. package/src/components/victory-bar/victory-bar.js +14 -120
  55. package/src/components/victory-candlestick/helper-methods.js +10 -9
  56. package/src/components/victory-candlestick/victory-candlestick.js +20 -121
  57. package/src/components/victory-chart/helper-methods.js +7 -6
  58. package/src/components/victory-chart/victory-chart.js +24 -79
  59. package/src/components/victory-errorbar/helper-methods.js +7 -7
  60. package/src/components/victory-errorbar/victory-errorbar.js +15 -120
  61. package/src/components/victory-group/victory-group.js +26 -100
  62. package/src/components/victory-line/helper-methods.js +5 -4
  63. package/src/components/victory-line/victory-line.js +16 -112
  64. package/src/components/victory-scatter/helper-methods.js +8 -8
  65. package/src/components/victory-scatter/victory-scatter.js +11 -114
  66. package/src/components/victory-stack/victory-stack.js +21 -69
  67. package/src/components/victory-voronoi/helper-methods.js +3 -3
  68. package/src/components/victory-voronoi/victory-voronoi.js +10 -115
  69. package/src/helpers/axis.js +6 -6
  70. package/src/helpers/common-props.js +89 -0
  71. package/src/helpers/wrapper.js +10 -9
  72. package/src/index.js +7 -5
  73. package/lib/components/victory-voronoi-tooltip/helper-methods.js +0 -100
  74. package/lib/components/victory-voronoi-tooltip/victory-voronoi-tooltip.js +0 -180
  75. package/lib/components/victory-zoom/helper-methods.js +0 -48
  76. package/lib/components/victory-zoom/victory-zoom.js +0 -221
  77. package/src/components/victory-voronoi-tooltip/helper-methods.js +0 -101
  78. package/src/components/victory-voronoi-tooltip/victory-voronoi-tooltip.js +0 -180
  79. package/src/components/victory-zoom/helper-methods.js +0 -49
  80. package/src/components/victory-zoom/victory-zoom.js +0 -221
@@ -1,3 +1,4 @@
1
+ /*eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2] }]*/
1
2
  import { assign, defaults, flatten, isFunction, partialRight, uniq, some } from "lodash";
2
3
  import React from "react";
3
4
  import Axis from "./axis";
@@ -27,8 +28,8 @@ export default {
27
28
  }
28
29
  const { offset, children } = groupComponent[0].props;
29
30
  const defaultDomainPadding = horizontal ?
30
- {y: (offset * children.length) / 2} :
31
- {x: (offset * children.length) / 2};
31
+ { y: (offset * children.length) / 2 } :
32
+ { x: (offset * children.length) / 2 };
32
33
  return defaultDomainPadding[axis];
33
34
  },
34
35
 
@@ -44,7 +45,7 @@ export default {
44
45
  const min = Collection.getMinValue([...dataDomain, ...childDomain]);
45
46
  const max = Collection.getMaxValue([...dataDomain, ...childDomain]);
46
47
  const domainPadding = this.getDefaultDomainPadding(props, axis, childComponents);
47
- const paddedDomain = Domain.padDomain([min, max], assign({domainPadding}, props), axis);
48
+ const paddedDomain = Domain.padDomain([min, max], assign({ domainPadding }, props), axis);
48
49
  return Domain.cleanDomain(paddedDomain, props, axis);
49
50
 
50
51
  },
@@ -56,7 +57,7 @@ export default {
56
57
  if (props.animate.parentState) {
57
58
  const nodesWillExit = props.animate.parentState.nodesWillExit;
58
59
  const oldProps = nodesWillExit ? props : null;
59
- this.setState(defaults({oldProps, nextProps}, props.animate.parentState));
60
+ this.setState(defaults({ oldProps, nextProps }, props.animate.parentState));
60
61
  } else {
61
62
  const oldChildren = React.Children.toArray(props.children);
62
63
  const nextChildren = React.Children.toArray(nextProps.children);
@@ -89,7 +90,7 @@ export default {
89
90
  },
90
91
 
91
92
  getAllEvents(props) {
92
- const components = ["groupComponent", "containerComponent"];
93
+ const components = ["groupComponent", "containerComponent", "labelComponent"];
93
94
  this.componentEvents = Events.getComponentEvents(props, components);
94
95
  if (Array.isArray(this.componentEvents)) {
95
96
  return Array.isArray(props.events) ?
@@ -106,7 +107,7 @@ export default {
106
107
  let childrenTransitions = this.state && this.state.childrenTransitions;
107
108
  childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ?
108
109
  childrenTransitions[index] : childrenTransitions;
109
- return defaults({childrenTransitions}, this.state);
110
+ return defaults({ childrenTransitions }, this.state);
110
111
  };
111
112
 
112
113
  let getTransitions = props.animate && props.animate.getTransitions;
@@ -120,7 +121,7 @@ export default {
120
121
  );
121
122
  getTransitions = partialRight(getTransitionProps, index);
122
123
  }
123
- return defaults({getTransitions, parentState}, props.animate, child.props.animate);
124
+ return defaults({ getTransitions, parentState }, props.animate, child.props.animate);
124
125
  },
125
126
 
126
127
  getDomainFromChildren(props, axis, childComponents) { // eslint-disable-line max-statements, complexity, max-len
@@ -144,7 +145,7 @@ export default {
144
145
  if (child.type && isFunction(child.type.getDomain)) {
145
146
  const parentData = props.data ? Data.getData(props, axis) : undefined;
146
147
  const sharedProps = parentData ?
147
- assign({}, child.props, {data: parentData}) : child.props;
148
+ assign({}, child.props, { data: parentData }) : child.props;
148
149
  const childDomain = child.props && child.type.getDomain(sharedProps, currentAxis);
149
150
  if (childDomain) {
150
151
  const childDomainLength = childDomain.length;
@@ -241,7 +242,7 @@ export default {
241
242
  const defaultFill = role === "stack" ?
242
243
  undefined : this.getColor(calculatedProps, child, index);
243
244
  const defaultColor = role === "line" ?
244
- {fill: "none", stroke: defaultFill} : {fill: defaultFill};
245
+ { fill: "none", stroke: defaultFill } : { fill: defaultFill };
245
246
  const childStyle = child.props.style || {};
246
247
  const dataStyle = defaults({}, childStyle.data, assign({}, style.data, defaultColor));
247
248
  const labelsStyle = defaults({}, childStyle.labels, style.labels);
package/src/index.js CHANGED
@@ -8,9 +8,6 @@ export { default as VictoryGroup } from "./components/victory-group/victory-grou
8
8
  export { default as VictoryStack } from "./components/victory-stack/victory-stack";
9
9
  export { default as VictoryErrorBar } from "./components/victory-errorbar/victory-errorbar";
10
10
  export { default as VictoryVoronoi } from "./components/victory-voronoi/victory-voronoi";
11
- export {
12
- default as VictoryVoronoiTooltip
13
- } from "./components/victory-voronoi-tooltip/victory-voronoi-tooltip";
14
11
  export {
15
12
  default as VictoryCandlestick
16
13
  } from "./components/victory-candlestick/victory-candlestick";
@@ -26,16 +23,21 @@ export {
26
23
  voronoiContainerMixin,
27
24
  default as VictoryVoronoiContainer
28
25
  } from "./components/containers/victory-voronoi-container";
26
+ export {
27
+ cursorContainerMixin,
28
+ default as VictoryCursorContainer
29
+ } from "./components/containers/victory-cursor-container";
29
30
  export {
30
31
  zoomContainerMixin,
31
32
  default as VictoryZoomContainer
32
33
  } from "./components/containers/victory-zoom-container";
33
34
  export {
34
35
  combineContainerMixins,
36
+ makeCreateContainerFunction,
35
37
  default as createContainer
36
38
  } from "./components/containers/create-container";
37
- export { default as VictoryZoom } from "./components/victory-zoom/victory-zoom";
38
39
  export { default as BrushHelpers } from "./components/containers/brush-helpers";
40
+ export { default as CursorHelpers } from "./components/containers/cursor-helpers";
39
41
  export { default as SelectionHelpers } from "./components/containers/selection-helpers";
40
42
  export { default as VoronoiHelpers } from "./components/containers/voronoi-helpers";
41
- export { default as ZoomHelpers } from "./components/containers/zoom-helpers";
43
+ export { default as ZoomHelpers, RawZoomHelpers } from "./components/containers/zoom-helpers";
@@ -1,100 +0,0 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});var _without2=require("lodash/without");var _without3=_interopRequireDefault(_without2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);var _omit2=require("lodash/omit");var _omit3=_interopRequireDefault(_omit2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);
2
- var _victoryCore=require("victory-core");
3
- var _d3Voronoi=require("d3-voronoi");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}exports.default=
4
-
5
- {
6
- getBaseProps:function getBaseProps(props,fallbackProps){var _this=this;
7
- props=_victoryCore.Helpers.modifyProps(props,fallbackProps,"voronoi");var _getCalculatedValues=
8
- this.getCalculatedValues(props),data=_getCalculatedValues.data,style=_getCalculatedValues.style,scale=_getCalculatedValues.scale,polygons=_getCalculatedValues.polygons,domain=_getCalculatedValues.domain;var _props=
9
- props,width=_props.width,height=_props.height,standalone=_props.standalone,theme=_props.theme,events=_props.events,sharedEvents=_props.sharedEvents;
10
- var initialChildProps={parent:{
11
- style:style.parent,scale:scale,domain:domain,data:data,standalone:standalone,height:height,width:width,theme:theme}};
12
-
13
-
14
- return data.reduce(function(childProps,datum,index){
15
- var polygon=(0,_without3.default)(polygons[index],"data");
16
- var eventKey=datum.eventKey;
17
- var x=scale.x(datum._x1!==undefined?datum._x1:datum._x);
18
- var y=scale.y(datum._y1!==undefined?datum._y1:datum._y);
19
- var dataProps={
20
- x:x,y:y,datum:datum,data:data,index:index,scale:scale,polygon:polygon,
21
- size:props.size,
22
- style:_this.getDataStyles(datum,style.data)};
23
-
24
-
25
- childProps[eventKey]={data:dataProps};
26
- var text=_this.getLabelText(props,datum,index);
27
- if(text!==undefined&&text!==null||events||sharedEvents){
28
- childProps[eventKey].labels=(0,_assign3.default)(
29
- {},
30
- _this.getFlyoutProps(dataProps,text,style));
31
-
32
- }
33
-
34
- return childProps;
35
- },initialChildProps);
36
- },
37
-
38
- getFlyoutProps:function getFlyoutProps(dataProps,text,style){var
39
- x=dataProps.x,y=dataProps.y,index=dataProps.index,scale=dataProps.scale,datum=dataProps.datum,data=dataProps.data;
40
- return{
41
- x:x,y:y,text:text,index:index,scale:scale,datum:datum,data:data,
42
- flyoutStyle:style.flyout,
43
- style:style.labels};
44
-
45
- },
46
-
47
- getStyles:function getStyles(style,styleObject){
48
- style=style||{};
49
- styleObject=styleObject||{};
50
- var parentStyleProps={height:"auto",width:"100%"};
51
- return{
52
- parent:(0,_defaults3.default)(parentStyleProps,style.parent,styleObject.parent),
53
- data:(0,_defaults3.default)({},style.data,styleObject.data),
54
- labels:(0,_defaults3.default)({},style.labels,styleObject.labels),
55
- flyout:(0,_defaults3.default)({},style.flyout,styleObject.flyout)};
56
-
57
- },
58
-
59
- getCalculatedValues:function getCalculatedValues(props){
60
- var defaultStyles=props.theme&&props.theme.voronoi&&props.theme.voronoi.style?
61
- props.theme.voronoi.style:{};
62
- var style=this.getStyles(props.style,defaultStyles,"auto","100%");
63
- var data=_victoryCore.Data.getData(props);
64
- var range={
65
- x:_victoryCore.Helpers.getRange(props,"x"),
66
- y:_victoryCore.Helpers.getRange(props,"y")};
67
-
68
- var domain={
69
- x:_victoryCore.Domain.getDomain(props,"x"),
70
- y:_victoryCore.Domain.getDomain(props,"y")};
71
-
72
- var scale={
73
- x:_victoryCore.Scale.getBaseScale(props,"x").domain(domain.x).range(range.x),
74
- y:_victoryCore.Scale.getBaseScale(props,"y").domain(domain.y).range(range.y)};
75
-
76
- var polygons=props.polygons||this.getPolygons(range,scale,data);
77
- return{domain:domain,data:data,scale:scale,style:style,polygons:polygons};
78
- },
79
-
80
- getPolygons:function getPolygons(range,scale,data){
81
- var minRange=[Math.min.apply(Math,_toConsumableArray(range.x)),Math.min.apply(Math,_toConsumableArray(range.y))];
82
- var maxRange=[Math.max.apply(Math,_toConsumableArray(range.x)),Math.max.apply(Math,_toConsumableArray(range.y))];
83
- var voronoi=(0,_d3Voronoi.voronoi)().
84
- x(function(d){return scale.x(d._x1!==undefined?d._x1:d._x);}).
85
- y(function(d){return scale.y(d._y1!==undefined?d._y1:d._y);}).
86
- extent([minRange,maxRange]);
87
- return voronoi.polygons(data);
88
- },
89
-
90
- getDataStyles:function getDataStyles(datum,style){
91
- var stylesFromData=(0,_omit3.default)(datum,[
92
- "_x","_y","name","label"]);
93
-
94
- return(0,_defaults3.default)({},stylesFromData,style);
95
- },
96
-
97
- getLabelText:function getLabelText(props,datum,index){
98
- return datum.label||(Array.isArray(props.labels)?
99
- props.labels[index]:props.labels);
100
- }};
@@ -1,180 +0,0 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});var _partialRight2=require("lodash/partialRight");var _partialRight3=_interopRequireDefault(_partialRight2);var _createClass=function(){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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react);
2
-
3
- var _victoryCore=require("victory-core");
4
-
5
-
6
-
7
- var _helperMethods=require("./helper-methods");var _helperMethods2=_interopRequireDefault(_helperMethods);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}
8
-
9
- var fallbackProps={
10
- width:450,
11
- height:300,
12
- padding:50};
13
-
14
-
15
- var animationWhitelist=[
16
- "data","domain","height","padding","samples","size","style","width"];var
17
-
18
-
19
- VictoryVoronoiTooltip=function(_React$Component){_inherits(VictoryVoronoiTooltip,_React$Component);function VictoryVoronoiTooltip(){_classCallCheck(this,VictoryVoronoiTooltip);return _possibleConstructorReturn(this,(VictoryVoronoiTooltip.__proto__||Object.getPrototypeOf(VictoryVoronoiTooltip)).apply(this,arguments));}_createClass(VictoryVoronoiTooltip,[{key:"componentDidMount",value:function componentDidMount()
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
- {
131
- _victoryCore.Log.warn(
132
- "`VictoryVoronoiTooltip` will be deprecated in victory@0.20.0, use `VictoryVoronoiContainer`");
133
-
134
- }},{key:"renderData",value:function renderData(
135
-
136
- props){var _this2=this;var
137
- dataComponent=props.dataComponent,labelComponent=props.labelComponent,groupComponent=props.groupComponent;
138
-
139
- var dataComponents=this.dataKeys.map(function(_dataKey,index){
140
- var dataProps=_this2.getComponentProps(dataComponent,"data",index);
141
- return _react2.default.cloneElement(dataComponent,dataProps);
142
- });
143
-
144
- var labelComponents=this.dataKeys.map(function(_dataKey,index){
145
- var labelProps=_this2.getComponentProps(labelComponent,"labels",index);
146
- if(labelProps.text!==undefined&&labelProps.text!==null){
147
- return _react2.default.cloneElement(labelComponent,labelProps);
148
- }
149
- }).filter(Boolean);
150
-
151
- return labelComponents.length>0?
152
- _react2.default.cloneElement.apply(_react2.default,[groupComponent,{}].concat(_toConsumableArray(dataComponents),_toConsumableArray(labelComponents))):
153
- dataComponents;
154
- }},{key:"shouldAnimate",value:function shouldAnimate()
155
-
156
- {
157
- return!!this.props.animate;
158
- }},{key:"renderContainer",value:function renderContainer(
159
-
160
- props,children){var
161
- containerComponent=props.containerComponent;
162
- var parentProps=this.getComponentProps(containerComponent,"parent","parent");
163
- return _react2.default.cloneElement(containerComponent,parentProps,children);
164
- }},{key:"render",value:function render()
165
-
166
- {var
167
- role=this.constructor.role;
168
- var props=_victoryCore.Helpers.modifyProps(this.props,fallbackProps,role);
169
- if(this.shouldAnimate()){
170
- return(
171
- _react2.default.createElement(_victoryCore.VictoryTransition,{animate:props.animate,animationWhitelist:animationWhitelist},
172
- _react2.default.createElement(this.constructor,props)));
173
-
174
-
175
- }
176
- var children=this.renderData(props);
177
- return this.renderContainer(props,children);
178
- }}]);return VictoryVoronoiTooltip;}(_react2.default.Component);VictoryVoronoiTooltip.displayName="VictoryVoronoiTooltip";VictoryVoronoiTooltip.role="tooltip";VictoryVoronoiTooltip.defaultTransitions=_victoryCore.DefaultTransitions.discreteTransitions();VictoryVoronoiTooltip.propTypes={animate:_react.PropTypes.object,categories:_react.PropTypes.oneOfType([_react.PropTypes.arrayOf(_react.PropTypes.string),_react.PropTypes.shape({x:_react.PropTypes.arrayOf(_react.PropTypes.string),y:_react.PropTypes.arrayOf(_react.PropTypes.string)})]),containerComponent:_react.PropTypes.element,data:_react.PropTypes.array,domainPadding:_react.PropTypes.oneOfType([_react.PropTypes.shape({x:_react.PropTypes.oneOfType([_react.PropTypes.number,_victoryCore.PropTypes.domain]),y:_react.PropTypes.oneOfType([_react.PropTypes.number,_victoryCore.PropTypes.domain])}),_react.PropTypes.number]),dataComponent:_react.PropTypes.element,domain:_react.PropTypes.oneOfType([_victoryCore.PropTypes.domain,_react.PropTypes.shape({x:_victoryCore.PropTypes.domain,y:_victoryCore.PropTypes.domain})]),events:_react.PropTypes.arrayOf(_react.PropTypes.shape({target:_react.PropTypes.oneOf(["data","labels","parent"]),eventKey:_react.PropTypes.oneOfType([_react.PropTypes.array,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_react.PropTypes.string]),eventHandlers:_react.PropTypes.object})),eventKey:_react.PropTypes.oneOfType([_react.PropTypes.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_react.PropTypes.string]),groupComponent:_react.PropTypes.element,height:_victoryCore.PropTypes.nonNegative,labels:_react.PropTypes.oneOfType([_react.PropTypes.func,_react.PropTypes.array]),labelComponent:_react.PropTypes.element,name:_react.PropTypes.string,padding:_react.PropTypes.oneOfType([_react.PropTypes.number,_react.PropTypes.shape({top:_react.PropTypes.number,bottom:_react.PropTypes.number,left:_react.PropTypes.number,right:_react.PropTypes.number})]),samples:_victoryCore.PropTypes.nonNegative,scale:_react.PropTypes.oneOfType([_victoryCore.PropTypes.scale,_react.PropTypes.shape({x:_victoryCore.PropTypes.scale,y:_victoryCore.PropTypes.scale})]),sharedEvents:_react.PropTypes.shape({events:_react.PropTypes.array,getEventState:_react.PropTypes.func}),sortKey:_react.PropTypes.oneOfType([_react.PropTypes.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_react.PropTypes.string,_react.PropTypes.arrayOf(_react.PropTypes.string)]),size:_victoryCore.PropTypes.nonNegative,standalone:_react.PropTypes.bool,style:_react.PropTypes.shape({parent:_react.PropTypes.object,data:_react.PropTypes.object,labels:_react.PropTypes.object,flyout:_react.PropTypes.object}),theme:_react.PropTypes.object,width:_victoryCore.PropTypes.nonNegative,x:_react.PropTypes.oneOfType([_react.PropTypes.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_react.PropTypes.string,_react.PropTypes.arrayOf(_react.PropTypes.string)]),y:_react.PropTypes.oneOfType([_react.PropTypes.func,_victoryCore.PropTypes.allOfType([_victoryCore.PropTypes.integer,_victoryCore.PropTypes.nonNegative]),_react.PropTypes.string,_react.PropTypes.arrayOf(_react.PropTypes.string)])};VictoryVoronoiTooltip.defaultProps={samples:50,scale:"linear",standalone:true,dataComponent:_react2.default.createElement(_victoryCore.Voronoi,null),labelComponent:_react2.default.createElement(_victoryCore.VictoryTooltip,null),containerComponent:_react2.default.createElement(_victoryCore.VictoryContainer,null),groupComponent:_react2.default.createElement("g",{role:"presentation"}),theme:_victoryCore.VictoryTheme.grayscale};VictoryVoronoiTooltip.getDomain=_victoryCore.Domain.getDomain.bind(_victoryCore.Domain);VictoryVoronoiTooltip.getData=_victoryCore.Data.getData.bind(_victoryCore.Data);VictoryVoronoiTooltip.getBaseProps=(0,_partialRight3.default)(_helperMethods2.default.getBaseProps.bind(_helperMethods2.default),fallbackProps);VictoryVoronoiTooltip.expectedComponents=["dataComponent","labelComponent","groupComponent","containerComponent"];exports.default=
179
-
180
- (0,_victoryCore.addEvents)(VictoryVoronoiTooltip);
@@ -1,48 +0,0 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[typeof Symbol==="function"?Symbol.iterator:"@@iterator"](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if((typeof Symbol==="function"?Symbol.iterator:"@@iterator")in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _victoryCore=require("victory-core");exports.default=
2
- {
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
- scale:function scale(currentDomain,originalDomain,factor){var _originalDomain=_slicedToArray(
11
- originalDomain,2),fromBound=_originalDomain[0],toBound=_originalDomain[1];var _currentDomain=_slicedToArray(
12
- currentDomain,2),from=_currentDomain[0],to=_currentDomain[1];
13
- var range=Math.abs(from-to);
14
- var midpoint=+from+range/2;
15
- var newRange=range*factor/2;
16
- return[
17
- _victoryCore.Collection.getMaxValue([midpoint-newRange,fromBound]),
18
- _victoryCore.Collection.getMinValue([midpoint+newRange,toBound])];
19
-
20
- },
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
- pan:function pan(currentDomain,originalDomain,delta){var _currentDomain$map=
30
- currentDomain.map(function(val){return+val;}),_currentDomain$map2=_slicedToArray(_currentDomain$map,2),fromCurrent=_currentDomain$map2[0],toCurrent=_currentDomain$map2[1];var _originalDomain$map=
31
- originalDomain.map(function(val){return+val;}),_originalDomain$map2=_slicedToArray(_originalDomain$map,2),fromOriginal=_originalDomain$map2[0],toOriginal=_originalDomain$map2[1];
32
- var lowerBound=fromCurrent+delta;
33
- var upperBound=toCurrent+delta;
34
- var newDomain=void 0;
35
- if(lowerBound>fromOriginal&&upperBound<toOriginal){
36
- newDomain=[lowerBound,upperBound];
37
- }else if(lowerBound<fromOriginal){
38
- var dx=toCurrent-fromCurrent;
39
- newDomain=[fromOriginal,fromOriginal+dx];
40
- }else if(upperBound>toOriginal){
41
- var _dx=toCurrent-fromCurrent;
42
- newDomain=[toOriginal-_dx,toOriginal];
43
- }else{
44
- newDomain=currentDomain;
45
- }
46
- return _victoryCore.Collection.containsDates(currentDomain)||_victoryCore.Collection.containsDates(originalDomain)?
47
- newDomain.map(function(val){return new Date(val);}):newDomain;
48
- }};
@@ -1,221 +0,0 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});var _isEqual2=require("lodash/isEqual");var _isEqual3=_interopRequireDefault(_isEqual2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[typeof Symbol==="function"?Symbol.iterator:"@@iterator"](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if((typeof Symbol==="function"?Symbol.iterator:"@@iterator")in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _createClass=function(){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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();
2
-
3
-
4
- var _react=require("react");var _react2=_interopRequireDefault(_react);
5
-
6
- var _helperMethods=require("../victory-chart/helper-methods");var _helperMethods2=_interopRequireDefault(_helperMethods);
7
- var _helperMethods3=require("./helper-methods");var _helperMethods4=_interopRequireDefault(_helperMethods3);
8
- var _victoryCore=require("victory-core");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}
9
-
10
-
11
-
12
- var fallbackProps={
13
- width:450,
14
- height:300,
15
- padding:50};var
16
-
17
-
18
- VictoryZoom=function(_Component){_inherits(VictoryZoom,_Component);
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
- function VictoryZoom(props){_classCallCheck(this,VictoryZoom);var _this=_possibleConstructorReturn(this,(VictoryZoom.__proto__||Object.getPrototypeOf(VictoryZoom)).call(this,
43
- props));
44
-
45
- var chart=_react2.default.Children.only(_this.props.children);var _Helpers$getRange=
46
- _victoryCore.Helpers.getRange(
47
- _victoryCore.Helpers.modifyProps(chart.props,{},"chart"),
48
- "x"),_Helpers$getRange2=_slicedToArray(_Helpers$getRange,2),rangex1=_Helpers$getRange2[0],rangex0=_Helpers$getRange2[1];
49
-
50
-
51
- _this.plottableWidth=rangex0-rangex1;
52
- _this.width=chart.props.width||fallbackProps.width;
53
- _this.state={domain:props.zoomDomain||_this.getDataDomain()};
54
-
55
- _this.events=_this.getEvents(props.allowZoom);
56
- _this.clipDataComponents=_this.clipDataComponents.bind(_this);
57
- _this.getTimer=_this.getTimer.bind(_this);return _this;
58
- }_createClass(VictoryZoom,[{key:"getChildContext",value:function getChildContext()
59
-
60
- {
61
- return{
62
- getTimer:this.getTimer};
63
-
64
- }},{key:"getTimer",value:function getTimer()
65
-
66
- {
67
- if(!this.timer){
68
- this.timer=new _victoryCore.Timer();
69
- }
70
- return this.timer;
71
- }},{key:"componentWillMount",value:function componentWillMount()
72
-
73
- {var _this2=this;
74
- this.getChartRef=function(chart){_this2.chartRef=chart;};
75
- }},{key:"componentWillUnmount",value:function componentWillUnmount()
76
-
77
- {
78
- this.getTimer().stop();
79
- }},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(_ref)
80
-
81
- {var nextAllowZoom=_ref.allowZoom,nextDomain=_ref.zoomDomain;var _props=
82
- this.props,allowZoom=_props.allowZoom,zoomDomain=_props.zoomDomain;
83
- if(!(0,_isEqual3.default)(zoomDomain,nextDomain)){
84
- this.setState({domain:nextDomain});
85
- }
86
-
87
- if(allowZoom!==nextAllowZoom){
88
- this.events=this.getEvents(nextAllowZoom);
89
- }
90
- }},{key:"getDataDomain",value:function getDataDomain()
91
-
92
- {
93
- var chart=_react2.default.Children.only(this.props.children);
94
- var chartChildren=_react2.default.Children.toArray(chart);
95
-
96
- return{
97
- x:_helperMethods2.default.getDomain(chart.props,"x",chartChildren)};
98
-
99
- }},{key:"getEvents",value:function getEvents(
100
-
101
- allowZoom){var _this3=this;
102
- var standardEvents={
103
- onMouseDown:function onMouseDown(evt){
104
- _this3.targetBounds=_this3.chartRef.getSvgBounds();
105
- var x=evt.clientX-_this3.targetBounds.left;
106
- _this3.isPanning=true;
107
- _this3.startX=x;
108
- _this3.lastDomain=_this3.state.domain;
109
- },
110
- onMouseUp:function onMouseUp(){_this3.isPanning=false;},
111
- onMouseLeave:function onMouseLeave(){_this3.isPanning=false;},
112
- onMouseMove:function onMouseMove(evt){
113
- var clientX=evt.clientX;
114
- if(_this3.isPanning){
115
- requestAnimationFrame(function(){
116
- var domain=_this3.getDataDomain();
117
- var delta=_this3.startX-(clientX-_this3.targetBounds.left);
118
- var calculatedDx=delta/_this3.getDomainScale();
119
- var nextXDomain=_helperMethods4.default.pan(_this3.lastDomain.x,domain.x,calculatedDx);
120
- _this3.setDomain({x:nextXDomain});
121
- _this3.setState({domain:{x:nextXDomain}});
122
- });
123
- }
124
- }};
125
-
126
- var wheelEvent={
127
- onWheel:function onWheel(evt){
128
- evt.preventDefault();
129
- var deltaY=evt.deltaY;
130
- requestAnimationFrame(function(){var
131
- x=_this3.state.domain.x;
132
- var xBounds=_this3.getDataDomain().x;
133
-
134
-
135
- var nextXDomain=_helperMethods4.default.scale(x,xBounds,1+deltaY/300);
136
- _this3.setDomain({x:nextXDomain});
137
- });
138
- }};
139
-
140
-
141
- return[{
142
- target:"parent",
143
- eventHandlers:allowZoom?(0,_assign3.default)({},standardEvents,wheelEvent):standardEvents}];
144
-
145
- }},{key:"setDomain",value:function setDomain(
146
-
147
- domain){var _this4=this;var
148
- onDomainChange=this.props.onDomainChange;
149
- this.getTimer().bypassAnimation();
150
- this.setState({domain:domain},function(){return _this4.getTimer().resumeAnimation();});
151
- if(onDomainChange){onDomainChange(domain);}
152
- }},{key:"getDomainScale",value:function getDomainScale()
153
-
154
- {var _lastDomain$x=_slicedToArray(
155
- this.lastDomain.x,2),from=_lastDomain$x[0],to=_lastDomain$x[1];
156
- var ratio=this.targetBounds.width/this.width;
157
- var absoluteAxisWidth=ratio*this.plottableWidth;
158
- return absoluteAxisWidth/(to-from);
159
- }},{key:"clipDataComponents",value:function clipDataComponents(
160
-
161
- children,props){var _this5=this;var _Helpers$getRange3=
162
- _victoryCore.Helpers.getRange(props,"x"),_Helpers$getRange4=_slicedToArray(_Helpers$getRange3,2),rangex0=_Helpers$getRange4[0],rangex1=_Helpers$getRange4[1];
163
- var childComponents=[];
164
- var group=[];
165
- var groupNumber=0;
166
-
167
- var makeGroup=function makeGroup(arr,index){
168
- return _react2.default.cloneElement(_this5.props.clipContainerComponent,{
169
- key:"ZoomClipContainer-"+index,
170
- clipWidth:rangex1-rangex0,
171
- clipHeight:fallbackProps.height,
172
- translateX:rangex0,
173
- children:arr});
174
-
175
- };
176
-
177
- var findNextAxis=function findNextAxis(start){
178
- var subset=children.slice(start);
179
- return subset.findIndex(function(child){return child.type.displayName==="VictoryAxis";})+start;
180
- };
181
-
182
- var axisIndex=findNextAxis(0);
183
-
184
- if(axisIndex===-1){
185
- return makeGroup(children,groupNumber);
186
- }
187
- for(var i=0,len=children.length;i<len;i++){
188
- if(i===axisIndex){
189
- childComponents.push(makeGroup(group,groupNumber),children[i]);
190
- axisIndex=findNextAxis(i+1);
191
- group=[];
192
- groupNumber++;
193
- }
194
- group.push(children[i]);
195
- }
196
- childComponents.push(makeGroup(group,groupNumber));
197
- return childComponents;
198
- }},{key:"renderChart",value:function renderChart(
199
-
200
- chartElement,props){
201
- return _react2.default.cloneElement(chartElement,props);
202
- }},{key:"render",value:function render()
203
-
204
- {
205
- var chart=_react2.default.Children.only(this.props.children);
206
- var events=chart.props.events?
207
- (this.events||[]).concat(chart.props.events):
208
- this.events;
209
-
210
- var nextProps=(0,_assign3.default)({},chart.props,{
211
- events:events,
212
- domain:this.state.domain,
213
- ref:this.getChartRef,
214
- modifyChildren:this.clipDataComponents});
215
-
216
-
217
- return this.renderChart(chart,nextProps);
218
- }}]);return VictoryZoom;}(_react.Component);VictoryZoom.displayName="VictoryZoom";VictoryZoom.role="zoom";VictoryZoom.propTypes={children:_react.PropTypes.node,zoomDomain:_react.PropTypes.shape({x:_victoryCore.PropTypes.domain,y:_victoryCore.PropTypes.domain}),onDomainChange:_react.PropTypes.func,clipContainerComponent:_react.PropTypes.element.isRequired,allowZoom:_react.PropTypes.bool};VictoryZoom.childContextTypes={getTimer:_react2.default.PropTypes.func};VictoryZoom.defaultProps={clipContainerComponent:_react2.default.createElement(_victoryCore.VictoryClipContainer,null),allowZoom:true};exports.default=
219
-
220
-
221
- VictoryZoom;