From 353b98a5b55e2ef1a82921536ce81813ba937801 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Tue, 6 Nov 2018 13:24:11 +0100 Subject: [PATCH 01/10] Adding workaround-implementation of 'invert' method for d3-scale ordinal scale. --- src/utils/scales-utils.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/utils/scales-utils.js b/src/utils/scales-utils.js index f4b5bef9a..220fa721d 100644 --- a/src/utils/scales-utils.js +++ b/src/utils/scales-utils.js @@ -150,6 +150,32 @@ export function _getSmallestDistanceIndex(values, scaleObject) { return result; } +/** + * This is a workaround for issue that ordinal scale + * does not have invert method implemented in d3-scale. + * @param {Object} Ordinal d3-scale object. + * @returns {void} + * @private + */ + +function addInvertFunctionToOrdinalScaleObject(scale) { + if (scale.invert) return; + + scale.invert = function(_) { + var domainIndex, + n = scale.domain().length, + reverse = scale.range()[1] < scale.range()[0], + start = scale.range()[reverse - 0], + stop = scale.range()[1 - reverse]; + + if (_ < start + scale.padding() * scale.step()) domainIndex = 0; + else if (_ > stop - scale.padding() * scale.step()) domainIndex = n - 1; + else domainIndex = Math.floor((_ - start - scale.padding() * scale.step()) / scale.step()); + + return scale.domain()[domainIndex]; + } +} + /** * Crate a scale function from the scale object. * @param {Object} scaleObject Scale object. @@ -179,6 +205,7 @@ export function getScaleFnFromScaleObject(scaleObject) { .range(range); if (type === ORDINAL_SCALE_TYPE) { scale.padding(0.5); + addInvertFunctionToOrdinalScaleObject(scale); } return scale; } From 2077f18b85045e7feef55455dec1fefad0068fe8 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Tue, 6 Nov 2018 15:27:20 +0100 Subject: [PATCH 02/10] Adding temp dist for my fork. --- dist/animation.js | 188 ++++ dist/dist.min.js | 23 + dist/index.js | 327 +++++++ dist/legends/continuous-color-legend.js | 107 ++ dist/legends/continuous-size-legend.js | 116 +++ dist/legends/discrete-color-legend-item.js | 103 ++ dist/legends/discrete-color-legend.js | 107 ++ .../searchable-discrete-color-legend.js | 107 ++ dist/main.scss | 9 + dist/make-vis-flexible.js | 250 +++++ dist/parallel-coordinates/index.js | 360 +++++++ dist/plot/axis/axis-line.js | 99 ++ dist/plot/axis/axis-ticks.js | 271 ++++++ dist/plot/axis/axis-title.js | 186 ++++ dist/plot/axis/axis.js | 264 +++++ dist/plot/axis/decorative-axis-ticks.js | 99 ++ dist/plot/axis/decorative-axis.js | 174 ++++ dist/plot/axis/x-axis.js | 66 ++ dist/plot/axis/y-axis.js | 66 ++ dist/plot/borders.js | 125 +++ dist/plot/circular-grid-lines.js | 165 ++++ dist/plot/crosshair.js | 262 +++++ dist/plot/gradient-defs.js | 58 ++ dist/plot/grid-lines.js | 178 ++++ dist/plot/highlight.js | 426 ++++++++ dist/plot/hint.js | 454 +++++++++ dist/plot/horizontal-grid-lines.js | 64 ++ dist/plot/series/abstract-series.js | 415 ++++++++ dist/plot/series/arc-series.js | 279 ++++++ dist/plot/series/area-series.js | 160 +++ dist/plot/series/bar-series-canvas.js | 161 +++ dist/plot/series/bar-series.js | 180 ++++ dist/plot/series/canvas-wrapper.js | 256 +++++ dist/plot/series/contour-series.js | 164 ++++ dist/plot/series/custom-svg-series.js | 237 +++++ dist/plot/series/heatmap-series.js | 147 +++ dist/plot/series/hexbin-series.js | 180 ++++ .../series/horizontal-bar-series-canvas.js | 97 ++ dist/plot/series/horizontal-bar-series.js | 85 ++ .../series/horizontal-rect-series-canvas.js | 97 ++ dist/plot/series/horizontal-rect-series.js | 85 ++ dist/plot/series/label-series.js | 200 ++++ dist/plot/series/line-mark-series-canvas.js | 87 ++ dist/plot/series/line-mark-series.js | 102 ++ dist/plot/series/line-series-canvas.js | 146 +++ dist/plot/series/line-series.js | 177 ++++ dist/plot/series/mark-series-canvas.js | 109 +++ dist/plot/series/mark-series.js | 179 ++++ dist/plot/series/polygon-series.js | 126 +++ dist/plot/series/rect-series-canvas.js | 136 +++ dist/plot/series/rect-series.js | 151 +++ .../plot/series/vertical-bar-series-canvas.js | 97 ++ dist/plot/series/vertical-bar-series.js | 85 ++ .../series/vertical-rect-series-canvas.js | 97 ++ dist/plot/series/vertical-rect-series.js | 85 ++ dist/plot/series/whisker-series.js | 274 ++++++ dist/plot/vertical-grid-lines.js | 64 ++ dist/plot/voronoi.js | 148 +++ dist/plot/xy-plot.js | 660 +++++++++++++ dist/radar-chart/index.js | 418 ++++++++ dist/radial-chart/index.js | 263 +++++ dist/sankey/index.js | 238 +++++ dist/sankey/sankey-link.js | 85 ++ dist/style.css | 1 + dist/styles/examples.scss | 461 +++++++++ dist/styles/legends.scss | 137 +++ dist/styles/plot.scss | 128 +++ dist/styles/radial-chart.scss | 6 + dist/styles/treemap.scss | 22 + dist/sunburst/index.js | 253 +++++ dist/theme.js | 42 + dist/treemap/index.js | 254 +++++ dist/treemap/treemap-dom.js | 82 ++ dist/treemap/treemap-leaf.js | 125 +++ dist/treemap/treemap-svg.js | 246 +++++ dist/utils/axis-utils.js | 167 ++++ dist/utils/chart-utils.js | 104 ++ dist/utils/data-utils.js | 54 ++ dist/utils/react-utils.js | 95 ++ dist/utils/scales-utils.js | 916 ++++++++++++++++++ dist/utils/series-utils.js | 268 +++++ 81 files changed, 14485 insertions(+) create mode 100644 dist/animation.js create mode 100644 dist/dist.min.js create mode 100644 dist/index.js create mode 100644 dist/legends/continuous-color-legend.js create mode 100644 dist/legends/continuous-size-legend.js create mode 100644 dist/legends/discrete-color-legend-item.js create mode 100644 dist/legends/discrete-color-legend.js create mode 100644 dist/legends/searchable-discrete-color-legend.js create mode 100644 dist/main.scss create mode 100644 dist/make-vis-flexible.js create mode 100644 dist/parallel-coordinates/index.js create mode 100644 dist/plot/axis/axis-line.js create mode 100644 dist/plot/axis/axis-ticks.js create mode 100644 dist/plot/axis/axis-title.js create mode 100644 dist/plot/axis/axis.js create mode 100644 dist/plot/axis/decorative-axis-ticks.js create mode 100644 dist/plot/axis/decorative-axis.js create mode 100644 dist/plot/axis/x-axis.js create mode 100644 dist/plot/axis/y-axis.js create mode 100644 dist/plot/borders.js create mode 100644 dist/plot/circular-grid-lines.js create mode 100644 dist/plot/crosshair.js create mode 100644 dist/plot/gradient-defs.js create mode 100644 dist/plot/grid-lines.js create mode 100644 dist/plot/highlight.js create mode 100644 dist/plot/hint.js create mode 100644 dist/plot/horizontal-grid-lines.js create mode 100644 dist/plot/series/abstract-series.js create mode 100644 dist/plot/series/arc-series.js create mode 100644 dist/plot/series/area-series.js create mode 100644 dist/plot/series/bar-series-canvas.js create mode 100644 dist/plot/series/bar-series.js create mode 100644 dist/plot/series/canvas-wrapper.js create mode 100644 dist/plot/series/contour-series.js create mode 100644 dist/plot/series/custom-svg-series.js create mode 100644 dist/plot/series/heatmap-series.js create mode 100644 dist/plot/series/hexbin-series.js create mode 100644 dist/plot/series/horizontal-bar-series-canvas.js create mode 100644 dist/plot/series/horizontal-bar-series.js create mode 100644 dist/plot/series/horizontal-rect-series-canvas.js create mode 100644 dist/plot/series/horizontal-rect-series.js create mode 100644 dist/plot/series/label-series.js create mode 100644 dist/plot/series/line-mark-series-canvas.js create mode 100644 dist/plot/series/line-mark-series.js create mode 100644 dist/plot/series/line-series-canvas.js create mode 100644 dist/plot/series/line-series.js create mode 100644 dist/plot/series/mark-series-canvas.js create mode 100644 dist/plot/series/mark-series.js create mode 100644 dist/plot/series/polygon-series.js create mode 100644 dist/plot/series/rect-series-canvas.js create mode 100644 dist/plot/series/rect-series.js create mode 100644 dist/plot/series/vertical-bar-series-canvas.js create mode 100644 dist/plot/series/vertical-bar-series.js create mode 100644 dist/plot/series/vertical-rect-series-canvas.js create mode 100644 dist/plot/series/vertical-rect-series.js create mode 100644 dist/plot/series/whisker-series.js create mode 100644 dist/plot/vertical-grid-lines.js create mode 100644 dist/plot/voronoi.js create mode 100644 dist/plot/xy-plot.js create mode 100644 dist/radar-chart/index.js create mode 100644 dist/radial-chart/index.js create mode 100644 dist/sankey/index.js create mode 100644 dist/sankey/sankey-link.js create mode 100644 dist/style.css create mode 100644 dist/styles/examples.scss create mode 100644 dist/styles/legends.scss create mode 100644 dist/styles/plot.scss create mode 100644 dist/styles/radial-chart.scss create mode 100644 dist/styles/treemap.scss create mode 100644 dist/sunburst/index.js create mode 100644 dist/theme.js create mode 100644 dist/treemap/index.js create mode 100644 dist/treemap/treemap-dom.js create mode 100644 dist/treemap/treemap-leaf.js create mode 100644 dist/treemap/treemap-svg.js create mode 100644 dist/utils/axis-utils.js create mode 100644 dist/utils/chart-utils.js create mode 100644 dist/utils/data-utils.js create mode 100644 dist/utils/react-utils.js create mode 100644 dist/utils/scales-utils.js create mode 100644 dist/utils/series-utils.js diff --git a/dist/animation.js b/dist/animation.js new file mode 100644 index 000000000..9638ef2d6 --- /dev/null +++ b/dist/animation.js @@ -0,0 +1,188 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.AnimationPropType = undefined; + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.extractAnimatedPropValues = extractAnimatedPropValues; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Interpolate = require('d3-interpolate'); + +var _reactMotion = require('react-motion'); + +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; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +var ANIMATION_PROPTYPES = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({ + stiffness: _propTypes2.default.number, + nonAnimatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string), + damping: _propTypes2.default.number +}), _propTypes2.default.bool]); + +var propTypes = { + animatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string).isRequired, + animation: ANIMATION_PROPTYPES, + onStart: _propTypes2.default.func, + onEnd: _propTypes2.default.func +}; + +/** + * Format the animation style object + * @param {Object|String} animationStyle - The animation style property, either the name of a + * presets are one of noWobble, gentle, wobbly, stiff + */ +function getAnimationStyle() { + var animationStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _reactMotion.presets.noWobble; + + if (typeof animationStyle === 'string') { + return _reactMotion.presets[animationStyle] || _reactMotion.presets.noWobble; + } + var damping = animationStyle.damping, + stiffness = animationStyle.stiffness; + + return _extends({ + damping: damping || _reactMotion.presets.noWobble.damping, + stiffness: stiffness || _reactMotion.presets.noWobble.stiffness + }, animationStyle); +} + +/** + * Extract the animated props from the entire props object. + * @param {Object} props Props. + * @returns {Object} Object of animated props. + */ +function extractAnimatedPropValues(props) { + var animatedProps = props.animatedProps, + otherProps = _objectWithoutProperties(props, ['animatedProps']); + + return animatedProps.reduce(function (result, animatedPropName) { + if (otherProps.hasOwnProperty(animatedPropName)) { + result[animatedPropName] = otherProps[animatedPropName]; + } + return result; + }, {}); +} + +var Animation = function (_PureComponent) { + _inherits(Animation, _PureComponent); + + function Animation(props) { + _classCallCheck(this, Animation); + + var _this = _possibleConstructorReturn(this, (Animation.__proto__ || Object.getPrototypeOf(Animation)).call(this, props)); + + _this._motionEndHandler = function () { + if (_this.props.onEnd) { + _this.props.onEnd(); + } + }; + + _this._renderChildren = function (_ref) { + var i = _ref.i; + var children = _this.props.children; + + var interpolator = _this._interpolator; + var child = _react2.default.Children.only(children); + var interpolatedProps = interpolator ? interpolator(i) : interpolator; + + // interpolator doesnt play nice with deeply nested objected + // so we expose an additional prop for situations like these, soit _data, + // which stores the full tree and can be recombined with the sanitized version + // after interpolation + var data = interpolatedProps && interpolatedProps.data || null; + if (data && child.props._data) { + data = data.map(function (row, index) { + var correspondingCell = child.props._data[index]; + return _extends({}, row, { + parent: correspondingCell.parent, + children: correspondingCell.children + }); + }); + } + + return _react2.default.cloneElement(child, _extends({}, child.props, interpolatedProps, { + data: data || child.props.data || null, + // enforce re-rendering + _animation: Math.random() + })); + }; + + _this._updateInterpolator(props); + return _this; + } + + _createClass(Animation, [{ + key: 'componentWillUpdate', + value: function componentWillUpdate(props) { + this._updateInterpolator(this.props, props); + if (props.onStart) { + props.onStart(); + } + } + + /** + * Render the child into the parent. + * @param {Number} i Number generated by the spring. + * @returns {React.Component} Rendered react element. + * @private + */ + + }, { + key: '_updateInterpolator', + + + /** + * Update the interpolator function and assign it to this._interpolator. + * @param {Object} oldProps Old props. + * @param {Object} newProps New props. + * @private + */ + value: function _updateInterpolator(oldProps, newProps) { + this._interpolator = (0, _d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps), newProps ? extractAnimatedPropValues(newProps) : null); + } + }, { + key: 'render', + value: function render() { + var animationStyle = getAnimationStyle(this.props.animation); + var defaultStyle = { i: 0 }; + var style = { i: (0, _reactMotion.spring)(1, animationStyle) }; + // In order to make Motion re-run animations each time, the random key is + // always passed. + // TODO: find a better solution for the spring. + var key = Math.random(); + return _react2.default.createElement( + _reactMotion.Motion, + _extends({ defaultStyle: defaultStyle, style: style, key: key }, { onRest: this._motionEndHandler }), + this._renderChildren + ); + } + }]); + + return Animation; +}(_react.PureComponent); + +Animation.propTypes = propTypes; +Animation.displayName = 'Animation'; + +exports.default = Animation; +var AnimationPropType = exports.AnimationPropType = ANIMATION_PROPTYPES; \ No newline at end of file diff --git a/dist/dist.min.js b/dist/dist.min.js new file mode 100644 index 000000000..5785693d1 --- /dev/null +++ b/dist/dist.min.js @@ -0,0 +1,23 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.reactVis=f()}})(function(){var define,module,exports;return function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o1){for(var i=1;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}if(newThis!==component&&newThis!==null){if(process.env.NODE_ENV!=="production"){warning(false,"bind(): React component methods may only be bound to the "+"component instance. See %s",componentName)}}else if(!args.length){if(process.env.NODE_ENV!=="production"){warning(false,"bind(): You are binding a component method to the component. "+"React does this for you automatically in a high-performance "+"way, so you can safely remove this call. See %s",componentName)}return boundMethod}var reboundMethod=_bind.apply(boundMethod,arguments);reboundMethod.__reactBoundContext=component;reboundMethod.__reactBoundMethod=method;reboundMethod.__reactBoundArguments=args;return reboundMethod}}return boundMethod}function bindAutoBindMethods(component){var pairs=component.__reactAutoBindPairs;for(var i=0;ib?1:a>=b?0:NaN};var bisector=function(compare){if(compare.length===1)compare=ascendingComparator(compare);return{left:function(a,x,lo,hi){if(lo==null)lo=0;if(hi==null)hi=a.length;while(lo>>1;if(compare(a[mid],x)<0)lo=mid+1;else hi=mid}return lo},right:function(a,x,lo,hi){if(lo==null)lo=0;if(hi==null)hi=a.length;while(lo>>1;if(compare(a[mid],x)>0)hi=mid;else lo=mid+1}return lo}}};function ascendingComparator(f){return function(d,x){return ascending(f(d),x)}}var ascendingBisect=bisector(ascending);var bisectRight=ascendingBisect.right;var bisectLeft=ascendingBisect.left;var pairs=function(array,f){if(f==null)f=pair;var i=0,n=array.length-1,p=array[0],pairs=new Array(n<0?0:n);while(ia?1:b>=a?0:NaN};var number=function(x){return x===null?NaN:+x};var variance=function(values,valueof){var n=values.length,m=0,i=-1,mean=0,value,delta,sum=0;if(valueof==null){while(++i1)return sum/(m-1)};var deviation=function(array,f){var v=variance(array,f);return v?Math.sqrt(v):v};var extent=function(values,valueof){var n=values.length,i=-1,value,min,max;if(valueof==null){while(++i=value){min=max=value;while(++ivalue)min=value;if(max=value){min=max=value;while(++ivalue)min=value;if(max0)return[start];if(reverse=stop0){start=Math.ceil(start/step);stop=Math.floor(stop/step);ticks=new Array(n=Math.ceil(stop-start+1));while(++i=0?(error>=e10?10:error>=e5?5:error>=e2?2:1)*Math.pow(10,power):-Math.pow(10,-power)/(error>=e10?10:error>=e5?5:error>=e2?2:1)}function tickStep(start,stop,count){var step0=Math.abs(stop-start)/Math.max(0,count),step1=Math.pow(10,Math.floor(Math.log(step0)/Math.LN10)),error=step0/step1;if(error>=e10)step1*=10;else if(error>=e5)step1*=5;else if(error>=e2)step1*=2;return stopx1)tz.pop(),--m;var bins=new Array(m+1),bin;for(i=0;i<=m;++i){bin=bins[i]=[];bin.x0=i>0?tz[i-1]:x0;bin.x1=i=1)return+valueof(values[n-1],n-1,values);var n,i=(n-1)*p,i0=Math.floor(i),value0=+valueof(values[i0],i0,values),value1=+valueof(values[i0+1],i0+1,values);return value0+(value1-value0)*(i-i0)};var freedmanDiaconis=function(values,min,max){values=map.call(values,number).sort(ascending);return Math.ceil((max-min)/(2*(quantile(values,.75)-quantile(values,.25))*Math.pow(values.length,-1/3)))};var scott=function(values,min,max){return Math.ceil((max-min)/(3.5*deviation(values)*Math.pow(values.length,-1/3)))};var max=function(values,valueof){var n=values.length,i=-1,value,max;if(valueof==null){while(++i=value){max=value;while(++imax){max=value}}}}}else{while(++i=value){max=value;while(++imax){max=value}}}}}return max};var mean=function(values,valueof){var n=values.length,m=n,i=-1,value,sum=0;if(valueof==null){while(++i=0){array=arrays[n];m=array.length;while(--m>=0){merged[--j]=array[m]}}return merged};var min=function(values,valueof){var n=values.length,i=-1,value,min;if(valueof==null){while(++i=value){min=value;while(++ivalue){min=value}}}}}else{while(++i=value){min=value;while(++ivalue){min=value}}}}}return min};var permute=function(array,indexes){var i=indexes.length,permutes=new Array(i);while(i--)permutes[i]=array[indexes[i]];return permutes};var scan=function(values,compare){if(!(n=values.length))return;var n,i=0,j=0,xi,xj=values[j];if(compare==null)compare=ascending;while(++i=keys.length){if(sortValues!=null)array.sort(sortValues);return rollup!=null?rollup(array):array}var i=-1,n=array.length,key=keys[depth++],keyValue,value,valuesByKey=map(),values,result=createResult();while(++ikeys.length)return map$$1;var array,sortKey=sortKeys[depth-1];if(rollup!=null&&depth>=keys.length)array=map$$1.entries();else array=[],map$$1.each(function(v,k){array.push({key:k,values:entries(v,depth)})});return sortKey!=null?array.sort(function(a,b){return sortKey(a.key,b.key)}):array}return nest={object:function(array){return apply(array,0,createObject,setObject)},map:function(array){return apply(array,0,createMap,setMap)},entries:function(array){return entries(apply(array,0,createMap,setMap),0)},key:function(d){keys.push(d);return nest},sortKeys:function(order){sortKeys[keys.length-1]=order;return nest},sortValues:function(order){sortValues=order;return nest},rollup:function(f){rollup=f;return nest}}};function createObject(){return{}}function setObject(object,key,value){object[key]=value}function createMap(){return map()}function setMap(map$$1,key,value){map$$1.set(key,value)}function Set(){}var proto=map.prototype;Set.prototype=set.prototype={constructor:Set,has:proto.has,add:function(value){value+="";this[prefix+value]=value;return this},remove:proto.remove,clear:proto.clear,values:proto.keys,size:proto.size,empty:proto.empty,each:proto.each};function set(object,f){var set=new Set;if(object instanceof Set)object.each(function(value){set.add(value)});else if(object){var i=-1,n=object.length;if(f==null)while(++i>8&15|m>>4&240,m>>4&15|m&240,(m&15)<<4|m&15,1)):(m=reHex6.exec(format))?rgbn(parseInt(m[1],16)):(m=reRgbInteger.exec(format))?new Rgb(m[1],m[2],m[3],1):(m=reRgbPercent.exec(format))?new Rgb(m[1]*255/100,m[2]*255/100,m[3]*255/100,1):(m=reRgbaInteger.exec(format))?rgba(m[1],m[2],m[3],m[4]):(m=reRgbaPercent.exec(format))?rgba(m[1]*255/100,m[2]*255/100,m[3]*255/100,m[4]):(m=reHslPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,1):(m=reHslaPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,m[4]):named.hasOwnProperty(format)?rgbn(named[format]):format==="transparent"?new Rgb(NaN,NaN,NaN,0):null}function rgbn(n){return new Rgb(n>>16&255,n>>8&255,n&255,1)}function rgba(r,g,b,a){if(a<=0)r=g=b=NaN;return new Rgb(r,g,b,a)}function rgbConvert(o){if(!(o instanceof Color))o=color(o);if(!o)return new Rgb;o=o.rgb();return new Rgb(o.r,o.g,o.b,o.opacity)}function rgb(r,g,b,opacity){return arguments.length===1?rgbConvert(r):new Rgb(r,g,b,opacity==null?1:opacity)}function Rgb(r,g,b,opacity){this.r=+r;this.g=+g;this.b=+b;this.opacity=+opacity}define(Rgb,rgb,extend(Color,{brighter:function(k){k=k==null?brighter:Math.pow(brighter,k);return new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},darker:function(k){k=k==null?darker:Math.pow(darker,k);return new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&(0<=this.g&&this.g<=255)&&(0<=this.b&&this.b<=255)&&(0<=this.opacity&&this.opacity<=1)},toString:function(){var a=this.opacity;a=isNaN(a)?1:Math.max(0,Math.min(1,a));return(a===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(a===1?")":", "+a+")")}}));function hsla(h,s,l,a){if(a<=0)h=s=l=NaN;else if(l<=0||l>=1)h=s=NaN;else if(s<=0)h=NaN;return new Hsl(h,s,l,a)}function hslConvert(o){if(o instanceof Hsl)return new Hsl(o.h,o.s,o.l,o.opacity);if(!(o instanceof Color))o=color(o);if(!o)return new Hsl;if(o instanceof Hsl)return o;o=o.rgb();var r=o.r/255,g=o.g/255,b=o.b/255,min=Math.min(r,g,b),max=Math.max(r,g,b),h=NaN,s=max-min,l=(max+min)/2;if(s){if(r===max)h=(g-b)/s+(g0&&l<1?0:h}return new Hsl(h,s,l,o.opacity)}function hsl(h,s,l,opacity){return arguments.length===1?hslConvert(h):new Hsl(h,s,l,opacity==null?1:opacity)}function Hsl(h,s,l,opacity){this.h=+h;this.s=+s;this.l=+l;this.opacity=+opacity}define(Hsl,hsl,extend(Color,{brighter:function(k){k=k==null?brighter:Math.pow(brighter,k);return new Hsl(this.h,this.s,this.l*k,this.opacity)},darker:function(k){k=k==null?darker:Math.pow(darker,k);return new Hsl(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=this.h%360+(this.h<0)*360,s=isNaN(h)||isNaN(this.s)?0:this.s,l=this.l,m2=l+(l<.5?l:1-l)*s,m1=2*l-m2;return new Rgb(hsl2rgb(h>=240?h-240:h+120,m1,m2),hsl2rgb(h,m1,m2),hsl2rgb(h<120?h+240:h-120,m1,m2),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&(0<=this.l&&this.l<=1)&&(0<=this.opacity&&this.opacity<=1)}}));function hsl2rgb(h,m1,m2){return(h<60?m1+(m2-m1)*h/60:h<180?m2:h<240?m1+(m2-m1)*(240-h)/60:m1)*255}var deg2rad=Math.PI/180;var rad2deg=180/Math.PI;var Kn=18;var Xn=.95047;var Yn=1;var Zn=1.08883;var t0=4/29;var t1=6/29;var t2=3*t1*t1;var t3=t1*t1*t1;function labConvert(o){if(o instanceof Lab)return new Lab(o.l,o.a,o.b,o.opacity);if(o instanceof Hcl){var h=o.h*deg2rad;return new Lab(o.l,Math.cos(h)*o.c,Math.sin(h)*o.c,o.opacity)}if(!(o instanceof Rgb))o=rgbConvert(o);var b=rgb2xyz(o.r),a=rgb2xyz(o.g),l=rgb2xyz(o.b),x=xyz2lab((.4124564*b+.3575761*a+.1804375*l)/Xn),y=xyz2lab((.2126729*b+.7151522*a+.072175*l)/Yn),z=xyz2lab((.0193339*b+.119192*a+.9503041*l)/Zn);return new Lab(116*y-16,500*(x-y),200*(y-z),o.opacity)}function lab(l,a,b,opacity){return arguments.length===1?labConvert(l):new Lab(l,a,b,opacity==null?1:opacity)}function Lab(l,a,b,opacity){this.l=+l;this.a=+a;this.b=+b;this.opacity=+opacity}define(Lab,lab,extend(Color,{brighter:function(k){return new Lab(this.l+Kn*(k==null?1:k),this.a,this.b,this.opacity)},darker:function(k){return new Lab(this.l-Kn*(k==null?1:k),this.a,this.b,this.opacity)},rgb:function(){var y=(this.l+16)/116,x=isNaN(this.a)?y:y+this.a/500,z=isNaN(this.b)?y:y-this.b/200;y=Yn*lab2xyz(y);x=Xn*lab2xyz(x);z=Zn*lab2xyz(z);return new Rgb(xyz2rgb(3.2404542*x-1.5371385*y-.4985314*z),xyz2rgb(-.969266*x+1.8760108*y+.041556*z),xyz2rgb(.0556434*x-.2040259*y+1.0572252*z),this.opacity)}}));function xyz2lab(t){return t>t3?Math.pow(t,1/3):t/t2+t0}function lab2xyz(t){return t>t1?t*t*t:t2*(t-t0)}function xyz2rgb(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function rgb2xyz(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function hclConvert(o){if(o instanceof Hcl)return new Hcl(o.h,o.c,o.l,o.opacity);if(!(o instanceof Lab))o=labConvert(o);var h=Math.atan2(o.b,o.a)*rad2deg;return new Hcl(h<0?h+360:h,Math.sqrt(o.a*o.a+o.b*o.b),o.l,o.opacity)}function hcl(h,c,l,opacity){return arguments.length===1?hclConvert(h):new Hcl(h,c,l,opacity==null?1:opacity)}function Hcl(h,c,l,opacity){this.h=+h;this.c=+c;this.l=+l;this.opacity=+opacity}define(Hcl,hcl,extend(Color,{brighter:function(k){return new Hcl(this.h,this.c,this.l+Kn*(k==null?1:k),this.opacity)},darker:function(k){return new Hcl(this.h,this.c,this.l-Kn*(k==null?1:k),this.opacity)},rgb:function(){return labConvert(this).rgb()}}));var A=-.14861;var B=+1.78277;var C=-.29227;var D=-.90649;var E=+1.97294;var ED=E*D;var EB=E*B;var BC_DA=B*C-D*A;function cubehelixConvert(o){if(o instanceof Cubehelix)return new Cubehelix(o.h,o.s,o.l,o.opacity);if(!(o instanceof Rgb))o=rgbConvert(o);var r=o.r/255,g=o.g/255,b=o.b/255,l=(BC_DA*b+ED*r-EB*g)/(BC_DA+ED-EB),bl=b-l,k=(E*(g-l)-C*bl)/D,s=Math.sqrt(k*k+bl*bl)/(E*l*(1-l)),h=s?Math.atan2(k,bl)*rad2deg-120:NaN;return new Cubehelix(h<0?h+360:h,s,l,o.opacity)}function cubehelix(h,s,l,opacity){return arguments.length===1?cubehelixConvert(h):new Cubehelix(h,s,l,opacity==null?1:opacity)}function Cubehelix(h,s,l,opacity){this.h=+h;this.s=+s;this.l=+l;this.opacity=+opacity}define(Cubehelix,cubehelix,extend(Color,{brighter:function(k){k=k==null?brighter:Math.pow(brighter,k);return new Cubehelix(this.h,this.s,this.l*k,this.opacity)},darker:function(k){k=k==null?darker:Math.pow(darker,k);return new Cubehelix(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=isNaN(this.h)?0:(this.h+120)*deg2rad,l=+this.l,a=isNaN(this.s)?0:this.s*l*(1-l),cosh=Math.cos(h),sinh=Math.sin(h);return new Rgb(255*(l+a*(A*cosh+B*sinh)),255*(l+a*(C*cosh+D*sinh)),255*(l+a*(E*cosh)),this.opacity)}}));exports.color=color;exports.rgb=rgb;exports.hsl=hsl;exports.lab=lab;exports.hcl=hcl;exports.cubehelix=cubehelix;Object.defineProperty(exports,"__esModule",{value:true})})},{}],6:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array")):typeof define==="function"&&define.amd?define(["exports","d3-array"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Array){"use strict";var array=Array.prototype;var slice=array.slice;var ascending=function(a,b){return a-b};var area=function(ring){var i=0,n=ring.length,area=ring[n-1][1]*ring[0][0]-ring[n-1][0]*ring[0][1];while(++iy!==yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi)contains=-contains}return contains}function segmentContains(a,b,c){var i;return collinear(a,b,c)&&within(a[i=+(a[0]===b[0])],c[i],b[i])}function collinear(a,b,c){return(b[0]-a[0])*(c[1]-a[1])===(c[0]-a[0])*(b[1]-a[1])}function within(p,q,r){return p<=q&&q<=r||r<=q&&q<=p}var noop=function(){};var cases=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];var contours=function(){var dx=1,dy=1,threshold=d3Array.thresholdSturges,smooth=smoothLinear;function contours(values){var tz=threshold(values);if(!Array.isArray(tz)){var domain=d3Array.extent(values),start=domain[0],stop=domain[1];tz=d3Array.tickStep(start,stop,tz);tz=d3Array.range(Math.floor(start/tz)*tz,Math.floor(stop/tz)*tz,tz)}else{tz=tz.slice().sort(ascending)}return tz.map(function(value){return contour(values,value)})}function contour(values,value){var polygons=[],holes=[];isorings(values,value,function(ring){smooth(ring,values,value);if(area(ring)>0)polygons.push([ring]);else holes.push(ring)});holes.forEach(function(hole){for(var i=0,n=polygons.length,polygon;i=value;cases[t1<<1].forEach(stitch);while(++x=value;cases[t0|t1<<1].forEach(stitch)}cases[t1<<0].forEach(stitch);while(++y=value;t2=values[y*dx]>=value;cases[t1<<1|t2<<2].forEach(stitch);while(++x=value;t3=t2,t2=values[y*dx+x+1]>=value;cases[t0|t1<<1|t2<<2|t3<<3].forEach(stitch)}cases[t1|t2<<3].forEach(stitch)}x=-1;t2=values[y*dx]>=value;cases[t2<<2].forEach(stitch);while(++x=value;cases[t2<<2|t3<<3].forEach(stitch)}cases[t2<<3].forEach(stitch);function stitch(line){var start=[line[0][0]+x,line[0][1]+y],end=[line[1][0]+x,line[1][1]+y],startIndex=index(start),endIndex=index(end),f,g;if(f=fragmentByEnd[startIndex]){if(g=fragmentByStart[endIndex]){delete fragmentByEnd[f.end];delete fragmentByStart[g.start];if(f===g){f.ring.push(end);callback(f.ring)}else{fragmentByStart[f.start]=fragmentByEnd[g.end]={start:f.start,end:g.end,ring:f.ring.concat(g.ring)}}}else{delete fragmentByEnd[f.end];f.ring.push(end);fragmentByEnd[f.end=endIndex]=f}}else if(f=fragmentByStart[endIndex]){if(g=fragmentByEnd[startIndex]){delete fragmentByStart[f.start];delete fragmentByEnd[g.end];if(f===g){f.ring.push(end);callback(f.ring)}else{fragmentByStart[g.start]=fragmentByEnd[f.end]={start:g.start,end:f.end,ring:g.ring.concat(f.ring)}}}else{delete fragmentByStart[f.start];f.ring.unshift(start);fragmentByStart[f.start=startIndex]=f}}else{fragmentByStart[startIndex]=fragmentByEnd[endIndex]={start:startIndex,end:endIndex,ring:[start,end]}}}}function index(point){return point[0]*2+point[1]*(dx+1)*4}function smoothLinear(ring,values,value){ring.forEach(function(point){var x=point[0],y=point[1],xt=x|0,yt=y|0,v0,v1=values[yt*dx+xt];if(x>0&&x0&&y0)||!(_1>0))throw new Error("invalid size");return dx=_0,dy=_1,contours};contours.thresholds=function(_){return arguments.length?(threshold=typeof _==="function"?_:Array.isArray(_)?constant(slice.call(_)):constant(_),contours):threshold};contours.smooth=function(_){return arguments.length?(smooth=_?smoothLinear:noop,contours):smooth===smoothLinear};return contours};function blurX(source,target,r){var n=source.width,m=source.height,w=(r<<1)+1;for(var j=0;j=r){if(i>=w){sr-=source.data[i-w+j*n]}target.data[i-r+j*n]=sr/Math.min(i+1,n-1+w-i,w)}}}}function blurY(source,target,r){var n=source.width,m=source.height,w=(r<<1)+1;for(var i=0;i=r){if(j>=w){sr-=source.data[i+(j-w)*n]}target.data[i+(j-r)*n]=sr/Math.min(j+1,m-1+w-j,w)}}}}function defaultX(d){return d[0]}function defaultY(d){return d[1]}var density=function(){var x=defaultX,y=defaultY,dx=960,dy=500,r=20,k=2,o=r*3,n=dx+o*2>>k,m=dy+o*2>>k,threshold=constant(20);function density(data){var values0=new Float32Array(n*m),values1=new Float32Array(n*m);data.forEach(function(d,i,data){var xi=x(d,i,data)+o>>k,yi=y(d,i,data)+o>>k;if(xi>=0&&xi=0&&yi>k);blurY({width:n,height:m,data:values1},{width:n,height:m,data:values0},r>>k);blurX({width:n,height:m,data:values0},{width:n,height:m,data:values1},r>>k);blurY({width:n,height:m,data:values1},{width:n,height:m,data:values0},r>>k);blurX({width:n,height:m,data:values0},{width:n,height:m,data:values1},r>>k);blurY({width:n,height:m,data:values1},{width:n,height:m,data:values0},r>>k);var tz=threshold(values0);if(!Array.isArray(tz)){var stop=d3Array.max(values0);tz=d3Array.tickStep(0,stop,tz);tz=d3Array.range(0,Math.floor(stop/tz)*tz,tz);tz.shift()}return contours().thresholds(tz).size([n,m])(values0).map(transform)}function transform(geometry){geometry.value*=Math.pow(2,-2*k);geometry.coordinates.forEach(transformPolygon);return geometry}function transformPolygon(coordinates){coordinates.forEach(transformRing)}function transformRing(coordinates){coordinates.forEach(transformPoint)}function transformPoint(coordinates){coordinates[0]=coordinates[0]*Math.pow(2,k)-o;coordinates[1]=coordinates[1]*Math.pow(2,k)-o}function resize(){o=r*3;n=dx+o*2>>k;m=dy+o*2>>k;return density}density.x=function(_){return arguments.length?(x=typeof _==="function"?_:constant(+_),density):x};density.y=function(_){return arguments.length?(y=typeof _==="function"?_:constant(+_),density):y};density.size=function(_){if(!arguments.length)return[dx,dy];var _0=Math.ceil(_[0]),_1=Math.ceil(_[1]);if(!(_0>=0)&&!(_0>=0))throw new Error("invalid size");return dx=_0,dy=_1,resize()};density.cellSize=function(_){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return k=Math.floor(Math.log(_)/Math.LN2),resize()};density.thresholds=function(_){return arguments.length?(threshold=typeof _==="function"?_:Array.isArray(_)?constant(slice.call(_)):constant(_),density):threshold};density.bandwidth=function(_){if(!arguments.length)return Math.sqrt(r*(r+1));if(!((_=+_)>=0))throw new Error("invalid bandwidth");return r=Math.round((Math.sqrt(4*_*_+1)-1)/2),resize()};return density};exports.contours=contours;exports.contourDensity=density;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3}],7:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var formatDecimal=function(x,p){if((i=(x=p?x.toExponential(p-1):x.toExponential()).indexOf("e"))<0)return null;var i,coefficient=x.slice(0,i);return[coefficient.length>1?coefficient[0]+coefficient.slice(2):coefficient,+x.slice(i+1)]};var exponent=function(x){return x=formatDecimal(Math.abs(x)),x?x[1]:NaN};var formatGroup=function(grouping,thousands){return function(value,width){var i=value.length,t=[],j=0,g=grouping[0],length=0;while(i>0&&g>0){if(length+g+1>width)g=Math.max(1,width-length);t.push(value.substring(i-=g,i+g));if((length+=g+1)>width)break;g=grouping[j=(j+1)%grouping.length]}return t.reverse().join(thousands)}};var formatNumerals=function(numerals){return function(value){return value.replace(/[0-9]/g,function(i){return numerals[+i]})}};var formatDefault=function(x,p){x=x.toPrecision(p);out:for(var n=x.length,i=1,i0=-1,i1;i0)i0=0;break}}return i0>0?x.slice(0,i0)+x.slice(i1+1):x};var prefixExponent;var formatPrefixAuto=function(x,p){var d=formatDecimal(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1],i=exponent-(prefixExponent=Math.max(-8,Math.min(8,Math.floor(exponent/3)))*3)+1,n=coefficient.length;return i===n?coefficient:i>n?coefficient+new Array(i-n+1).join("0"):i>0?coefficient.slice(0,i)+"."+coefficient.slice(i):"0."+new Array(1-i).join("0")+formatDecimal(x,Math.max(0,p+i-1))[0]};var formatRounded=function(x,p){var d=formatDecimal(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1];return exponent<0?"0."+new Array(-exponent).join("0")+coefficient:coefficient.length>exponent+1?coefficient.slice(0,exponent+1)+"."+coefficient.slice(exponent+1):coefficient+new Array(exponent-coefficient.length+2).join("0")};var formatTypes={"":formatDefault,"%":function(x,p){return(x*100).toFixed(p)},b:function(x){return Math.round(x).toString(2)},c:function(x){return x+""},d:function(x){return Math.round(x).toString(10)},e:function(x,p){return x.toExponential(p)},f:function(x,p){return x.toFixed(p)},g:function(x,p){return x.toPrecision(p)},o:function(x){return Math.round(x).toString(8)},p:function(x,p){return formatRounded(x*100,p)},r:formatRounded,s:formatPrefixAuto,X:function(x){return Math.round(x).toString(16).toUpperCase()},x:function(x){return Math.round(x).toString(16)}};var re=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;function formatSpecifier(specifier){return new FormatSpecifier(specifier)}formatSpecifier.prototype=FormatSpecifier.prototype;function FormatSpecifier(specifier){if(!(match=re.exec(specifier)))throw new Error("invalid format: "+specifier);var match,fill=match[1]||" ",align=match[2]||">",sign=match[3]||"-",symbol=match[4]||"",zero=!!match[5],width=match[6]&&+match[6],comma=!!match[7],precision=match[8]&&+match[8].slice(1),type=match[9]||"";if(type==="n")comma=true,type="g";else if(!formatTypes[type])type="";if(zero||fill==="0"&&align==="=")zero=true,fill="0",align="=";this.fill=fill;this.align=align;this.sign=sign;this.symbol=symbol;this.zero=zero;this.width=width;this.comma=comma;this.precision=precision;this.type=type}FormatSpecifier.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width==null?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision==null?"":"."+Math.max(0,this.precision|0))+this.type};var identity=function(x){return x};var prefixes=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];var formatLocale=function(locale){var group=locale.grouping&&locale.thousands?formatGroup(locale.grouping,locale.thousands):identity,currency=locale.currency,decimal=locale.decimal,numerals=locale.numerals?formatNumerals(locale.numerals):identity,percent=locale.percent||"%";function newFormat(specifier){specifier=formatSpecifier(specifier);var fill=specifier.fill,align=specifier.align,sign=specifier.sign,symbol=specifier.symbol,zero=specifier.zero,width=specifier.width,comma=specifier.comma,precision=specifier.precision,type=specifier.type;var prefix=symbol==="$"?currency[0]:symbol==="#"&&/[boxX]/.test(type)?"0"+type.toLowerCase():"",suffix=symbol==="$"?currency[1]:/[%p]/.test(type)?percent:"";var formatType=formatTypes[type],maybeSuffix=!type||/[defgprs%]/.test(type);precision=precision==null?type?6:12:/[gprs]/.test(type)?Math.max(1,Math.min(21,precision)):Math.max(0,Math.min(20,precision));function format(value){var valuePrefix=prefix,valueSuffix=suffix,i,n,c;if(type==="c"){valueSuffix=formatType(value)+valueSuffix;value=""}else{value=+value;var valueNegative=value<0;value=formatType(Math.abs(value),precision);if(valueNegative&&+value===0)valueNegative=false;valuePrefix=(valueNegative?sign==="("?sign:"-":sign==="-"||sign==="("?"":sign)+valuePrefix;valueSuffix=(type==="s"?prefixes[8+prefixExponent/3]:"")+valueSuffix+(valueNegative&&sign==="("?")":"");if(maybeSuffix){i=-1,n=value.length;while(++ic||c>57){valueSuffix=(c===46?decimal+value.slice(i+1):value.slice(i))+valueSuffix;value=value.slice(0,i);break}}}}if(comma&&!zero)value=group(value,Infinity);var length=valuePrefix.length+value.length+valueSuffix.length,padding=length>1)+valuePrefix+value+valueSuffix+padding.slice(length);break;default:value=padding+valuePrefix+value+valueSuffix;break}return numerals(value)}format.toString=function(){return specifier+""};return format}function formatPrefix(specifier,value){var f=newFormat((specifier=formatSpecifier(specifier),specifier.type="f",specifier)),e=Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))*3,k=Math.pow(10,-e),prefix=prefixes[8+e/3];return function(value){return f(k*value)+prefix}}return{format:newFormat,formatPrefix:formatPrefix}};var locale;defaultLocale({decimal:".",thousands:",",grouping:[3],currency:["$",""]});function defaultLocale(definition){locale=formatLocale(definition);exports.format=locale.format;exports.formatPrefix=locale.formatPrefix;return locale}var precisionFixed=function(step){return Math.max(0,-exponent(Math.abs(step)))};var precisionPrefix=function(step,value){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))*3-exponent(Math.abs(step)))};var precisionRound=function(step,max){step=Math.abs(step),max=Math.abs(max)-step;return Math.max(0,exponent(max)-exponent(step))+1};exports.formatDefaultLocale=defaultLocale;exports.formatLocale=formatLocale;exports.formatSpecifier=formatSpecifier;exports.precisionFixed=precisionFixed;exports.precisionPrefix=precisionPrefix;exports.precisionRound=precisionRound;Object.defineProperty(exports,"__esModule",{value:true})})},{}],8:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array")):typeof define==="function"&&define.amd?define(["exports","d3-array"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Array){"use strict";var adder=function(){return new Adder};function Adder(){this.reset()}Adder.prototype={constructor:Adder,reset:function(){this.s=this.t=0},add:function(y){add(temp,y,this.t);add(this,temp.s,this.s);if(this.s)this.t+=temp.t;else this.s=temp.t},valueOf:function(){return this.s}};var temp=new Adder;function add(adder,a,b){var x=adder.s=a+b,bv=x-a,av=x-bv;adder.t=a-av+(b-bv)}var epsilon=1e-6;var epsilon2=1e-12;var pi=Math.PI;var halfPi=pi/2;var quarterPi=pi/4;var tau=pi*2;var degrees=180/pi;var radians=pi/180;var abs=Math.abs;var atan=Math.atan;var atan2=Math.atan2;var cos=Math.cos;var ceil=Math.ceil;var exp=Math.exp;var log=Math.log;var pow=Math.pow;var sin=Math.sin;var sign=Math.sign||function(x){return x>0?1:x<0?-1:0};var sqrt=Math.sqrt;var tan=Math.tan;function acos(x){return x>1?0:x<-1?pi:Math.acos(x)}function asin(x){return x>1?halfPi:x<-1?-halfPi:Math.asin(x)}function haversin(x){return(x=sin(x/2))*x}function noop(){}function streamGeometry(geometry,stream){if(geometry&&streamGeometryType.hasOwnProperty(geometry.type)){streamGeometryType[geometry.type](geometry,stream)}}var streamObjectType={Feature:function(object,stream){streamGeometry(object.geometry,stream)},FeatureCollection:function(object,stream){var features=object.features,i=-1,n=features.length;while(++i=0?1:-1,adLambda=sdLambda*dLambda,cosPhi=cos(phi),sinPhi=sin(phi),k=sinPhi0*sinPhi,u=cosPhi0*cosPhi+k*cos(adLambda),v=k*sdLambda*sin(adLambda);areaRingSum.add(atan2(v,u));lambda0=lambda,cosPhi0=cosPhi,sinPhi0=sinPhi}var area=function(object){areaSum.reset();geoStream(object,areaStream);return areaSum*2};function spherical(cartesian){return[atan2(cartesian[1],cartesian[0]),asin(cartesian[2])]}function cartesian(spherical){var lambda=spherical[0],phi=spherical[1],cosPhi=cos(phi);return[cosPhi*cos(lambda),cosPhi*sin(lambda),sin(phi)]}function cartesianDot(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function cartesianCross(a,b){return[a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]]}function cartesianAddInPlace(a,b){a[0]+=b[0],a[1]+=b[1],a[2]+=b[2]}function cartesianScale(vector,k){return[vector[0]*k,vector[1]*k,vector[2]*k]}function cartesianNormalizeInPlace(d){var l=sqrt(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]);d[0]/=l,d[1]/=l,d[2]/=l}var lambda0$1;var phi0;var lambda1;var phi1;var lambda2;var lambda00$1;var phi00$1;var p0;var deltaSum=adder();var ranges;var range$1;var boundsStream={point:boundsPoint,lineStart:boundsLineStart,lineEnd:boundsLineEnd,polygonStart:function(){boundsStream.point=boundsRingPoint;boundsStream.lineStart=boundsRingStart;boundsStream.lineEnd=boundsRingEnd;deltaSum.reset();areaStream.polygonStart()},polygonEnd:function(){areaStream.polygonEnd();boundsStream.point=boundsPoint;boundsStream.lineStart=boundsLineStart;boundsStream.lineEnd=boundsLineEnd;if(areaRingSum<0)lambda0$1=-(lambda1=180),phi0=-(phi1=90);else if(deltaSum>epsilon)phi1=90;else if(deltaSum<-epsilon)phi0=-90;range$1[0]=lambda0$1,range$1[1]=lambda1}};function boundsPoint(lambda,phi){ranges.push(range$1=[lambda0$1=lambda,lambda1=lambda]);if(phiphi1)phi1=phi}function linePoint(lambda,phi){var p=cartesian([lambda*radians,phi*radians]);if(p0){var normal=cartesianCross(p0,p),equatorial=[normal[1],-normal[0],0],inflection=cartesianCross(equatorial,normal);cartesianNormalizeInPlace(inflection);inflection=spherical(inflection);var delta=lambda-lambda2,sign$$1=delta>0?1:-1,lambdai=inflection[0]*degrees*sign$$1,phii,antimeridian=abs(delta)>180;if(antimeridian^(sign$$1*lambda2phi1)phi1=phii}else if(lambdai=(lambdai+360)%360-180,antimeridian^(sign$$1*lambda2phi1)phi1=phi}if(antimeridian){if(lambdaangle(lambda0$1,lambda1))lambda1=lambda}else{if(angle(lambda,lambda1)>angle(lambda0$1,lambda1))lambda0$1=lambda}}else{if(lambda1>=lambda0$1){if(lambdalambda1)lambda1=lambda}else{if(lambda>lambda2){if(angle(lambda0$1,lambda)>angle(lambda0$1,lambda1))lambda1=lambda}else{if(angle(lambda,lambda1)>angle(lambda0$1,lambda1))lambda0$1=lambda}}}}else{ranges.push(range$1=[lambda0$1=lambda,lambda1=lambda])}if(phiphi1)phi1=phi;p0=p,lambda2=lambda}function boundsLineStart(){boundsStream.point=linePoint}function boundsLineEnd(){range$1[0]=lambda0$1,range$1[1]=lambda1;boundsStream.point=boundsPoint;p0=null}function boundsRingPoint(lambda,phi){if(p0){var delta=lambda-lambda2;deltaSum.add(abs(delta)>180?delta+(delta>0?360:-360):delta)}else{lambda00$1=lambda,phi00$1=phi}areaStream.point(lambda,phi);linePoint(lambda,phi)}function boundsRingStart(){areaStream.lineStart()}function boundsRingEnd(){boundsRingPoint(lambda00$1,phi00$1);areaStream.lineEnd();if(abs(deltaSum)>epsilon)lambda0$1=-(lambda1=180);range$1[0]=lambda0$1,range$1[1]=lambda1;p0=null}function angle(lambda0,lambda1){return(lambda1-=lambda0)<0?lambda1+360:lambda1}function rangeCompare(a,b){return a[0]-b[0]} +function rangeContains(range$$1,x){return range$$1[0]<=range$$1[1]?range$$1[0]<=x&&x<=range$$1[1]:xangle(a[0],a[1]))a[1]=b[1];if(angle(b[0],a[1])>angle(a[0],a[1]))a[0]=b[0]}else{merged.push(a=b)}}for(deltaMax=-Infinity,n=merged.length-1,i=0,a=merged[n];i<=n;a=b,++i){b=merged[i];if((delta=angle(a[1],b[0]))>deltaMax)deltaMax=delta,lambda0$1=b[0],lambda1=a[1]}}ranges=range$1=null;return lambda0$1===Infinity||phi0===Infinity?[[NaN,NaN],[NaN,NaN]]:[[lambda0$1,phi0],[lambda1,phi1]]};var W0;var W1;var X0;var Y0;var Z0;var X1;var Y1;var Z1;var X2;var Y2;var Z2;var lambda00$2;var phi00$2;var x0;var y0;var z0;var centroidStream={sphere:noop,point:centroidPoint,lineStart:centroidLineStart,lineEnd:centroidLineEnd,polygonStart:function(){centroidStream.lineStart=centroidRingStart;centroidStream.lineEnd=centroidRingEnd},polygonEnd:function(){centroidStream.lineStart=centroidLineStart;centroidStream.lineEnd=centroidLineEnd}};function centroidPoint(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi);centroidPointCartesian(cosPhi*cos(lambda),cosPhi*sin(lambda),sin(phi))}function centroidPointCartesian(x,y,z){++W0;X0+=(x-X0)/W0;Y0+=(y-Y0)/W0;Z0+=(z-Z0)/W0}function centroidLineStart(){centroidStream.point=centroidLinePointFirst}function centroidLinePointFirst(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi);x0=cosPhi*cos(lambda);y0=cosPhi*sin(lambda);z0=sin(phi);centroidStream.point=centroidLinePoint;centroidPointCartesian(x0,y0,z0)}function centroidLinePoint(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi),x=cosPhi*cos(lambda),y=cosPhi*sin(lambda),z=sin(phi),w=atan2(sqrt((w=y0*z-z0*y)*w+(w=z0*x-x0*z)*w+(w=x0*y-y0*x)*w),x0*x+y0*y+z0*z);W1+=w;X1+=w*(x0+(x0=x));Y1+=w*(y0+(y0=y));Z1+=w*(z0+(z0=z));centroidPointCartesian(x0,y0,z0)}function centroidLineEnd(){centroidStream.point=centroidPoint}function centroidRingStart(){centroidStream.point=centroidRingPointFirst}function centroidRingEnd(){centroidRingPoint(lambda00$2,phi00$2);centroidStream.point=centroidPoint}function centroidRingPointFirst(lambda,phi){lambda00$2=lambda,phi00$2=phi;lambda*=radians,phi*=radians;centroidStream.point=centroidRingPoint;var cosPhi=cos(phi);x0=cosPhi*cos(lambda);y0=cosPhi*sin(lambda);z0=sin(phi);centroidPointCartesian(x0,y0,z0)}function centroidRingPoint(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi),x=cosPhi*cos(lambda),y=cosPhi*sin(lambda),z=sin(phi),cx=y0*z-z0*y,cy=z0*x-x0*z,cz=x0*y-y0*x,m=sqrt(cx*cx+cy*cy+cz*cz),w=asin(m),v=m&&-w/m;X2+=v*cx;Y2+=v*cy;Z2+=v*cz;W1+=w;X1+=w*(x0+(x0=x));Y1+=w*(y0+(y0=y));Z1+=w*(z0+(z0=z));centroidPointCartesian(x0,y0,z0)}var centroid=function(object){W0=W1=X0=Y0=Z0=X1=Y1=Z1=X2=Y2=Z2=0;geoStream(object,centroidStream);var x=X2,y=Y2,z=Z2,m=x*x+y*y+z*z;if(mpi?lambda-tau:lambda<-pi?lambda+tau:lambda,phi]}rotationIdentity.invert=rotationIdentity;function rotateRadians(deltaLambda,deltaPhi,deltaGamma){return(deltaLambda%=tau)?deltaPhi||deltaGamma?compose(rotationLambda(deltaLambda),rotationPhiGamma(deltaPhi,deltaGamma)):rotationLambda(deltaLambda):deltaPhi||deltaGamma?rotationPhiGamma(deltaPhi,deltaGamma):rotationIdentity}function forwardRotationLambda(deltaLambda){return function(lambda,phi){return lambda+=deltaLambda,[lambda>pi?lambda-tau:lambda<-pi?lambda+tau:lambda,phi]}}function rotationLambda(deltaLambda){var rotation=forwardRotationLambda(deltaLambda);rotation.invert=forwardRotationLambda(-deltaLambda);return rotation}function rotationPhiGamma(deltaPhi,deltaGamma){var cosDeltaPhi=cos(deltaPhi),sinDeltaPhi=sin(deltaPhi),cosDeltaGamma=cos(deltaGamma),sinDeltaGamma=sin(deltaGamma);function rotation(lambda,phi){var cosPhi=cos(phi),x=cos(lambda)*cosPhi,y=sin(lambda)*cosPhi,z=sin(phi),k=z*cosDeltaPhi+x*sinDeltaPhi;return[atan2(y*cosDeltaGamma-k*sinDeltaGamma,x*cosDeltaPhi-z*sinDeltaPhi),asin(k*cosDeltaGamma+y*sinDeltaGamma)]}rotation.invert=function(lambda,phi){var cosPhi=cos(phi),x=cos(lambda)*cosPhi,y=sin(lambda)*cosPhi,z=sin(phi),k=z*cosDeltaGamma-y*sinDeltaGamma;return[atan2(y*cosDeltaGamma+z*sinDeltaGamma,x*cosDeltaPhi+k*sinDeltaPhi),asin(k*cosDeltaPhi-x*sinDeltaPhi)]};return rotation}var rotation=function(rotate){rotate=rotateRadians(rotate[0]*radians,rotate[1]*radians,rotate.length>2?rotate[2]*radians:0);function forward(coordinates){coordinates=rotate(coordinates[0]*radians,coordinates[1]*radians);return coordinates[0]*=degrees,coordinates[1]*=degrees,coordinates}forward.invert=function(coordinates){coordinates=rotate.invert(coordinates[0]*radians,coordinates[1]*radians);return coordinates[0]*=degrees,coordinates[1]*=degrees,coordinates};return forward};function circleStream(stream,radius,delta,direction,t0,t1){if(!delta)return;var cosRadius=cos(radius),sinRadius=sin(radius),step=direction*delta;if(t0==null){t0=radius+direction*tau;t1=radius-step/2}else{t0=circleRadius(cosRadius,t0);t1=circleRadius(cosRadius,t1);if(direction>0?t0t1)t0+=direction*tau}for(var point,t=t0;direction>0?t>t1:t1)lines.push(lines.pop().concat(lines.shift()))},result:function(){var result=lines;lines=[];line=null;return result}}};var pointEqual=function(a,b){return abs(a[0]-b[0])=0;--i)stream.point((point=points[i])[0],point[1])}else{interpolate(current.x,current.p.x,-1,stream)}current=current.p}current=current.o;points=current.z;isSubject=!isSubject}while(!current.v);stream.lineEnd()}};function link(array){if(!(n=array.length))return;var n,i=0,a=array[0],b;while(++i=0?1:-1,absDelta=sign$$1*delta,antimeridian=absDelta>pi,k=sinPhi0*sinPhi1;sum.add(atan2(k*sign$$1*sin(absDelta),cosPhi0*cosPhi1+k*cos(absDelta)));angle+=antimeridian?delta+sign$$1*tau:delta;if(antimeridian^lambda0>=lambda^lambda1>=lambda){var arc=cartesianCross(cartesian(point0),cartesian(point1));cartesianNormalizeInPlace(arc);var intersection=cartesianCross(normal,arc);cartesianNormalizeInPlace(intersection);var phiArc=(antimeridian^delta>=0?-1:1)*asin(intersection[2]);if(phi>phiArc||phi===phiArc&&(arc[0]||arc[1])){winding+=antimeridian^delta>=0?1:-1}}}}return(angle<-epsilon||angle0){if(!polygonStarted)sink.polygonStart(),polygonStarted=true;sink.lineStart();for(i=0;i1&&clean&2)ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));segments.push(ringSegments.filter(validSegment))}return clip}};function validSegment(segment){return segment.length>1}function compareIntersection(a,b){return((a=a.x)[0]<0?a[1]-halfPi-epsilon:halfPi-a[1])-((b=b.x)[0]<0?b[1]-halfPi-epsilon:halfPi-b[1])}var clipAntimeridian=clip(function(){return true},clipAntimeridianLine,clipAntimeridianInterpolate,[-pi,-halfPi]);function clipAntimeridianLine(stream){var lambda0=NaN,phi0=NaN,sign0=NaN,clean;return{lineStart:function(){stream.lineStart();clean=1},point:function(lambda1,phi1){var sign1=lambda1>0?pi:-pi,delta=abs(lambda1-lambda0);if(abs(delta-pi)0?halfPi:-halfPi);stream.point(sign0,phi0);stream.lineEnd();stream.lineStart();stream.point(sign1,phi0);stream.point(lambda1,phi0);clean=0}else if(sign0!==sign1&&delta>=pi){if(abs(lambda0-sign0)epsilon?atan((sin(phi0)*(cosPhi1=cos(phi1))*sin(lambda1)-sin(phi1)*(cosPhi0=cos(phi0))*sin(lambda0))/(cosPhi0*cosPhi1*sinLambda0Lambda1)):(phi0+phi1)/2}function clipAntimeridianInterpolate(from,to,direction,stream){var phi;if(from==null){phi=direction*halfPi;stream.point(-pi,phi);stream.point(0,phi);stream.point(pi,phi);stream.point(pi,0);stream.point(pi,-phi);stream.point(0,-phi);stream.point(-pi,-phi);stream.point(-pi,0);stream.point(-pi,phi)}else if(abs(from[0]-to[0])>epsilon){var lambda=from[0]0,notHemisphere=abs(cr)>epsilon;function interpolate(from,to,direction,stream){circleStream(stream,radius,delta,direction,from,to)}function visible(lambda,phi){return cos(lambda)*cos(phi)>cr}function clipLine(stream){var point0,c0,v0,v00,clean;return{lineStart:function(){v00=v0=false;clean=1},point:function(lambda,phi){var point1=[lambda,phi],point2,v=visible(lambda,phi),c=smallRadius?v?0:code(lambda,phi):v?code(lambda+(lambda<0?pi:-pi),phi):0;if(!point0&&(v00=v0=v))stream.lineStart();if(v!==v0){point2=intersect(point0,point1);if(!point2||pointEqual(point0,point2)||pointEqual(point1,point2)){point1[0]+=epsilon;point1[1]+=epsilon;v=visible(point1[0],point1[1])}}if(v!==v0){clean=0;if(v){stream.lineStart();point2=intersect(point1,point0);stream.point(point2[0],point2[1])}else{point2=intersect(point0,point1);stream.point(point2[0],point2[1]);stream.lineEnd()}point0=point2}else if(notHemisphere&&point0&&smallRadius^v){var t;if(!(c&c0)&&(t=intersect(point1,point0,true))){clean=0;if(smallRadius){stream.lineStart();stream.point(t[0][0],t[0][1]);stream.point(t[1][0],t[1][1]);stream.lineEnd()}else{stream.point(t[1][0],t[1][1]);stream.lineEnd();stream.lineStart();stream.point(t[0][0],t[0][1])}}}if(v&&(!point0||!pointEqual(point0,point1))){stream.point(point1[0],point1[1])}point0=point1,v0=v,c0=c},lineEnd:function(){if(v0)stream.lineEnd();point0=null},clean:function(){return clean|(v00&&v0)<<1}}}function intersect(a,b,two){var pa=cartesian(a),pb=cartesian(b);var n1=[1,0,0],n2=cartesianCross(pa,pb),n2n2=cartesianDot(n2,n2),n1n2=n2[0],determinant=n2n2-n1n2*n1n2;if(!determinant)return!two&&a;var c1=cr*n2n2/determinant,c2=-cr*n1n2/determinant,n1xn2=cartesianCross(n1,n2),A=cartesianScale(n1,c1),B=cartesianScale(n2,c2);cartesianAddInPlace(A,B);var u=n1xn2,w=cartesianDot(A,u),uu=cartesianDot(u,u),t2=w*w-uu*(cartesianDot(A,A)-1);if(t2<0)return;var t=sqrt(t2),q=cartesianScale(u,(-w-t)/uu);cartesianAddInPlace(q,A);q=spherical(q);if(!two)return q;var lambda0=a[0],lambda1=b[0],phi0=a[1],phi1=b[1],z;if(lambda10^q[1]<(abs(q[0]-lambda0)pi^(lambda0<=q[0]&&q[0]<=lambda1)){var q1=cartesianScale(u,(-w+t)/uu);cartesianAddInPlace(q1,A);return[q,spherical(q1)]}}function code(lambda,phi){var r=smallRadius?radius:pi-radius,code=0;if(lambda<-r)code|=1;else if(lambda>r)code|=2;if(phi<-r)code|=4;else if(phi>r)code|=8;return code}return clip(visible,clipLine,interpolate,smallRadius?[0,-radius]:[-pi,radius-pi])};var clipLine=function(a,b,x0,y0,x1,y1){var ax=a[0],ay=a[1],bx=b[0],by=b[1],t0=0,t1=1,dx=bx-ax,dy=by-ay,r;r=x0-ax;if(!dx&&r>0)return;r/=dx;if(dx<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=x1-ax;if(!dx&&r<0)return;r/=dx;if(dx<0){if(r>t1)return;if(r>t0)t0=r}else if(dx>0){if(r0)return;r/=dy;if(dy<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=y1-ay;if(!dy&&r<0)return;r/=dy;if(dy<0){if(r>t1)return;if(r>t0)t0=r}else if(dy>0){if(r0)a[0]=ax+t0*dx,a[1]=ay+t0*dy;if(t1<1)b[0]=ax+t1*dx,b[1]=ay+t1*dy;return true};var clipMax=1e9;var clipMin=-clipMax;function clipRectangle(x0,y0,x1,y1){function visible(x,y){return x0<=x&&x<=x1&&y0<=y&&y<=y1}function interpolate(from,to,direction,stream){var a=0,a1=0;if(from==null||(a=corner(from,direction))!==(a1=corner(to,direction))||comparePoint(from,to)<0^direction>0){do{stream.point(a===0||a===3?x0:x1,a>1?y1:y0)}while((a=(a+direction+4)%4)!==a1)}else{stream.point(to[0],to[1])}}function corner(p,direction){return abs(p[0]-x0)0?0:3:abs(p[0]-x1)0?2:1:abs(p[1]-y0)0?1:0:direction>0?3:2}function compareIntersection(a,b){return comparePoint(a.x,b.x)}function comparePoint(a,b){var ca=corner(a,1),cb=corner(b,1);return ca!==cb?ca-cb:ca===0?b[1]-a[1]:ca===1?a[0]-b[0]:ca===2?a[1]-b[1]:b[0]-a[0]}return function(stream){var activeStream=stream,bufferStream=clipBuffer(),segments,polygon,ring,x__,y__,v__,x_,y_,v_,first,clean;var clipStream={point:point,lineStart:lineStart,lineEnd:lineEnd,polygonStart:polygonStart,polygonEnd:polygonEnd};function point(x,y){if(visible(x,y))activeStream.point(x,y)}function polygonInside(){var winding=0;for(var i=0,n=polygon.length;iy1&&(b0-a0)*(y1-a1)>(b1-a1)*(x0-a0))++winding}else{if(b1<=y1&&(b0-a0)*(y1-a1)<(b1-a1)*(x0-a0))--winding}}}return winding}function polygonStart(){activeStream=bufferStream,segments=[],polygon=[],clean=true}function polygonEnd(){var startInside=polygonInside(),cleanInside=clean&&startInside,visible=(segments=d3Array.merge(segments)).length;if(cleanInside||visible){stream.polygonStart();if(cleanInside){stream.lineStart();interpolate(null,null,1,stream);stream.lineEnd()}if(visible){clipRejoin(segments,compareIntersection,startInside,interpolate,stream)}stream.polygonEnd()}activeStream=stream,segments=polygon=ring=null}function lineStart(){clipStream.point=linePoint;if(polygon)polygon.push(ring=[]);first=true;v_=false;x_=y_=NaN}function lineEnd(){if(segments){linePoint(x__,y__);if(v__&&v_)bufferStream.rejoin();segments.push(bufferStream.result())}clipStream.point=point;if(v_)activeStream.lineEnd()}function linePoint(x,y){var v=visible(x,y);if(polygon)ring.push([x,y]);if(first){x__=x,y__=y,v__=v;first=false;if(v){activeStream.lineStart();activeStream.point(x,y)}}else{if(v&&v_)activeStream.point(x,y);else{var a=[x_=Math.max(clipMin,Math.min(clipMax,x_)),y_=Math.max(clipMin,Math.min(clipMax,y_))],b=[x=Math.max(clipMin,Math.min(clipMax,x)),y=Math.max(clipMin,Math.min(clipMax,y))];if(clipLine(a,b,x0,y0,x1,y1)){if(!v_){activeStream.lineStart();activeStream.point(a[0],a[1])}activeStream.point(b[0],b[1]);if(!v)activeStream.lineEnd();clean=false}else if(v){activeStream.lineStart();activeStream.point(x,y);clean=false}}}x_=x,y_=y,v_=v}return clipStream}}var extent=function(){var x0=0,y0=0,x1=960,y1=500,cache,cacheStream,clip;return clip={stream:function(stream){return cache&&cacheStream===stream?cache:cache=clipRectangle(x0,y0,x1,y1)(cacheStream=stream)},extent:function(_){return arguments.length?(x0=+_[0][0],y0=+_[0][1],x1=+_[1][0],y1=+_[1][1],cache=cacheStream=null,clip):[[x0,y0],[x1,y1]]}}};var lengthSum=adder();var lambda0$2;var sinPhi0$1;var cosPhi0$1;var lengthStream={sphere:noop,point:noop,lineStart:lengthLineStart,lineEnd:noop,polygonStart:noop,polygonEnd:noop};function lengthLineStart(){lengthStream.point=lengthPointFirst;lengthStream.lineEnd=lengthLineEnd}function lengthLineEnd(){lengthStream.point=lengthStream.lineEnd=noop}function lengthPointFirst(lambda,phi){lambda*=radians,phi*=radians;lambda0$2=lambda,sinPhi0$1=sin(phi),cosPhi0$1=cos(phi);lengthStream.point=lengthPoint}function lengthPoint(lambda,phi){lambda*=radians,phi*=radians;var sinPhi=sin(phi),cosPhi=cos(phi),delta=abs(lambda-lambda0$2),cosDelta=cos(delta),sinDelta=sin(delta),x=cosPhi*sinDelta,y=cosPhi0$1*sinPhi-sinPhi0$1*cosPhi*cosDelta,z=sinPhi0$1*sinPhi+cosPhi0$1*cosPhi*cosDelta;lengthSum.add(atan2(sqrt(x*x+y*y),z));lambda0$2=lambda,sinPhi0$1=sinPhi,cosPhi0$1=cosPhi}var length=function(object){lengthSum.reset();geoStream(object,lengthStream);return+lengthSum};var coordinates=[null,null];var object={type:"LineString",coordinates:coordinates};var distance=function(a,b){coordinates[0]=a;coordinates[1]=b;return length(object)};var containsObjectType={Feature:function(object,point){return containsGeometry(object.geometry,point)},FeatureCollection:function(object,point){var features=object.features,i=-1,n=features.length;while(++iepsilon}).map(x)).concat(d3Array.range(ceil(y0/dy)*dy,y1,dy).filter(function(y){return abs(y%DY)>epsilon}).map(y))}graticule.lines=function(){return lines().map(function(coordinates){return{type:"LineString",coordinates:coordinates}})};graticule.outline=function(){return{type:"Polygon",coordinates:[X(X0).concat(Y(Y1).slice(1),X(X1).reverse().slice(1),Y(Y0).reverse().slice(1))]}};graticule.extent=function(_){if(!arguments.length)return graticule.extentMinor();return graticule.extentMajor(_).extentMinor(_)};graticule.extentMajor=function(_){if(!arguments.length)return[[X0,Y0],[X1,Y1]];X0=+_[0][0],X1=+_[1][0];Y0=+_[0][1],Y1=+_[1][1];if(X0>X1)_=X0,X0=X1,X1=_;if(Y0>Y1)_=Y0,Y0=Y1,Y1=_;return graticule.precision(precision)};graticule.extentMinor=function(_){if(!arguments.length)return[[x0,y0],[x1,y1]];x0=+_[0][0],x1=+_[1][0];y0=+_[0][1],y1=+_[1][1];if(x0>x1)_=x0,x0=x1,x1=_;if(y0>y1)_=y0,y0=y1,y1=_;return graticule.precision(precision)};graticule.step=function(_){if(!arguments.length)return graticule.stepMinor();return graticule.stepMajor(_).stepMinor(_)};graticule.stepMajor=function(_){if(!arguments.length)return[DX,DY];DX=+_[0],DY=+_[1];return graticule};graticule.stepMinor=function(_){if(!arguments.length)return[dx,dy];dx=+_[0],dy=+_[1];return graticule};graticule.precision=function(_){if(!arguments.length)return precision;precision=+_;x=graticuleX(y0,y1,90);y=graticuleY(x0,x1,precision);X=graticuleX(Y0,Y1,90);Y=graticuleY(X0,X1,precision);return graticule};return graticule.extentMajor([[-180,-90+epsilon],[180,90-epsilon]]).extentMinor([[-180,-80-epsilon],[180,80+epsilon]])}function graticule10(){return graticule()()}var interpolate=function(a,b){var x0=a[0]*radians,y0=a[1]*radians,x1=b[0]*radians,y1=b[1]*radians,cy0=cos(y0),sy0=sin(y0),cy1=cos(y1),sy1=sin(y1),kx0=cy0*cos(x0),ky0=cy0*sin(x0),kx1=cy1*cos(x1),ky1=cy1*sin(x1),d=2*asin(sqrt(haversin(y1-y0)+cy0*cy1*haversin(x1-x0))),k=sin(d);var interpolate=d?function(t){var B=sin(t*=d)/k,A=sin(d-t)/k,x=A*kx0+B*kx1,y=A*ky0+B*ky1,z=A*sy0+B*sy1;return[atan2(y,x)*degrees,atan2(z,sqrt(x*x+y*y))*degrees]}:function(){return[x0*degrees,y0*degrees]};interpolate.distance=d;return interpolate};var identity=function(x){return x};var areaSum$1=adder();var areaRingSum$1=adder();var x00;var y00;var x0$1;var y0$1;var areaStream$1={point:noop,lineStart:noop,lineEnd:noop,polygonStart:function(){areaStream$1.lineStart=areaRingStart$1;areaStream$1.lineEnd=areaRingEnd$1},polygonEnd:function(){areaStream$1.lineStart=areaStream$1.lineEnd=areaStream$1.point=noop;areaSum$1.add(abs(areaRingSum$1));areaRingSum$1.reset()},result:function(){var area=areaSum$1/2;areaSum$1.reset();return area}};function areaRingStart$1(){areaStream$1.point=areaPointFirst$1}function areaPointFirst$1(x,y){areaStream$1.point=areaPoint$1;x00=x0$1=x,y00=y0$1=y}function areaPoint$1(x,y){areaRingSum$1.add(y0$1*x-x0$1*y);x0$1=x,y0$1=y}function areaRingEnd$1(){areaPoint$1(x00,y00)}var x0$2=Infinity;var y0$2=x0$2;var x1=-x0$2;var y1=x1;var boundsStream$1={point:boundsPoint$1,lineStart:noop,lineEnd:noop,polygonStart:noop,polygonEnd:noop,result:function(){var bounds=[[x0$2,y0$2],[x1,y1]];x1=y1=-(y0$2=x0$2=Infinity);return bounds}};function boundsPoint$1(x,y){if(xx1)x1=x;if(yy1)y1=y}var X0$1=0;var Y0$1=0;var Z0$1=0;var X1$1=0;var Y1$1=0;var Z1$1=0;var X2$1=0;var Y2$1=0;var Z2$1=0;var x00$1;var y00$1;var x0$3;var y0$3;var centroidStream$1={point:centroidPoint$1,lineStart:centroidLineStart$1,lineEnd:centroidLineEnd$1,polygonStart:function(){centroidStream$1.lineStart=centroidRingStart$1;centroidStream$1.lineEnd=centroidRingEnd$1},polygonEnd:function(){centroidStream$1.point=centroidPoint$1;centroidStream$1.lineStart=centroidLineStart$1;centroidStream$1.lineEnd=centroidLineEnd$1},result:function(){var centroid=Z2$1?[X2$1/Z2$1,Y2$1/Z2$1]:Z1$1?[X1$1/Z1$1,Y1$1/Z1$1]:Z0$1?[X0$1/Z0$1,Y0$1/Z0$1]:[NaN,NaN];X0$1=Y0$1=Z0$1=X1$1=Y1$1=Z1$1=X2$1=Y2$1=Z2$1=0;return centroid}};function centroidPoint$1(x,y){X0$1+=x;Y0$1+=y;++Z0$1}function centroidLineStart$1(){centroidStream$1.point=centroidPointFirstLine}function centroidPointFirstLine(x,y){centroidStream$1.point=centroidPointLine;centroidPoint$1(x0$3=x,y0$3=y)}function centroidPointLine(x,y){var dx=x-x0$3,dy=y-y0$3,z=sqrt(dx*dx+dy*dy);X1$1+=z*(x0$3+x)/2;Y1$1+=z*(y0$3+y)/2;Z1$1+=z;centroidPoint$1(x0$3=x,y0$3=y)}function centroidLineEnd$1(){centroidStream$1.point=centroidPoint$1}function centroidRingStart$1(){centroidStream$1.point=centroidPointFirstRing}function centroidRingEnd$1(){centroidPointRing(x00$1,y00$1)}function centroidPointFirstRing(x,y){centroidStream$1.point=centroidPointRing;centroidPoint$1(x00$1=x0$3=x,y00$1=y0$3=y)}function centroidPointRing(x,y){var dx=x-x0$3,dy=y-y0$3,z=sqrt(dx*dx+dy*dy);X1$1+=z*(x0$3+x)/2;Y1$1+=z*(y0$3+y)/2;Z1$1+=z;z=y0$3*x-x0$3*y;X2$1+=z*(x0$3+x);Y2$1+=z*(y0$3+y);Z2$1+=z*3;centroidPoint$1(x0$3=x,y0$3=y)}function PathContext(context){this._context=context}PathContext.prototype={_radius:4.5,pointRadius:function(_){return this._radius=_,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){if(this._line===0)this._context.closePath();this._point=NaN},point:function(x,y){switch(this._point){case 0:{this._context.moveTo(x,y);this._point=1;break}case 1:{this._context.lineTo(x,y);break}default:{this._context.moveTo(x+this._radius,y);this._context.arc(x,y,this._radius,0,tau);break}}},result:noop};var lengthSum$1=adder();var lengthRing;var x00$2;var y00$2;var x0$4;var y0$4;var lengthStream$1={point:noop,lineStart:function(){lengthStream$1.point=lengthPointFirst$1},lineEnd:function(){if(lengthRing)lengthPoint$1(x00$2,y00$2);lengthStream$1.point=noop},polygonStart:function(){lengthRing=true},polygonEnd:function(){lengthRing=null},result:function(){var length=+lengthSum$1;lengthSum$1.reset();return length}};function lengthPointFirst$1(x,y){lengthStream$1.point=lengthPoint$1;x00$2=x0$4=x,y00$2=y0$4=y}function lengthPoint$1(x,y){x0$4-=x,y0$4-=y;lengthSum$1.add(sqrt(x0$4*x0$4+y0$4*y0$4));x0$4=x,y0$4=y}function PathString(){this._string=[]}PathString.prototype={_radius:4.5,_circle:circle$1(4.5),pointRadius:function(_){if((_=+_)!==this._radius)this._radius=_,this._circle=null;return this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){if(this._line===0)this._string.push("Z");this._point=NaN},point:function(x,y){switch(this._point){case 0:{this._string.push("M",x,",",y);this._point=1;break}case 1:{this._string.push("L",x,",",y);break}default:{if(this._circle==null)this._circle=circle$1(this._radius);this._string.push("M",x,",",y,this._circle);break}}},result:function(){if(this._string.length){var result=this._string.join("");this._string=[];return result}else{return null}}};function circle$1(radius){return"m0,"+radius+"a"+radius+","+radius+" 0 1,1 0,"+-2*radius+"a"+radius+","+radius+" 0 1,1 0,"+2*radius+"z"}var index=function(projection,context){var pointRadius=4.5,projectionStream,contextStream;function path(object){if(object){if(typeof pointRadius==="function")contextStream.pointRadius(+pointRadius.apply(this,arguments));geoStream(object,projectionStream(contextStream))}return contextStream.result()}path.area=function(object){geoStream(object,projectionStream(areaStream$1));return areaStream$1.result()};path.measure=function(object){geoStream(object,projectionStream(lengthStream$1)) +;return lengthStream$1.result()};path.bounds=function(object){geoStream(object,projectionStream(boundsStream$1));return boundsStream$1.result()};path.centroid=function(object){geoStream(object,projectionStream(centroidStream$1));return centroidStream$1.result()};path.projection=function(_){return arguments.length?(projectionStream=_==null?(projection=null,identity):(projection=_).stream,path):projection};path.context=function(_){if(!arguments.length)return context;contextStream=_==null?(context=null,new PathString):new PathContext(context=_);if(typeof pointRadius!=="function")contextStream.pointRadius(pointRadius);return path};path.pointRadius=function(_){if(!arguments.length)return pointRadius;pointRadius=typeof _==="function"?_:(contextStream.pointRadius(+_),+_);return path};return path.projection(projection).context(context)};var transform=function(methods){return{stream:transformer(methods)}};function transformer(methods){return function(stream){var s=new TransformStream;for(var key in methods)s[key]=methods[key];s.stream=stream;return s}}function TransformStream(){}TransformStream.prototype={constructor:TransformStream,point:function(x,y){this.stream.point(x,y)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function fit(projection,fitBounds,object){var clip=projection.clipExtent&&projection.clipExtent();projection.scale(150).translate([0,0]);if(clip!=null)projection.clipExtent(null);geoStream(object,projection.stream(boundsStream$1));fitBounds(boundsStream$1.result());if(clip!=null)projection.clipExtent(clip);return projection}function fitExtent(projection,extent,object){return fit(projection,function(b){var w=extent[1][0]-extent[0][0],h=extent[1][1]-extent[0][1],k=Math.min(w/(b[1][0]-b[0][0]),h/(b[1][1]-b[0][1])),x=+extent[0][0]+(w-k*(b[1][0]+b[0][0]))/2,y=+extent[0][1]+(h-k*(b[1][1]+b[0][1]))/2;projection.scale(150*k).translate([x,y])},object)}function fitSize(projection,size,object){return fitExtent(projection,[[0,0],size],object)}function fitWidth(projection,width,object){return fit(projection,function(b){var w=+width,k=w/(b[1][0]-b[0][0]),x=(w-k*(b[1][0]+b[0][0]))/2,y=-k*b[0][1];projection.scale(150*k).translate([x,y])},object)}function fitHeight(projection,height,object){return fit(projection,function(b){var h=+height,k=h/(b[1][1]-b[0][1]),x=-k*b[0][0],y=(h-k*(b[1][1]+b[0][1]))/2;projection.scale(150*k).translate([x,y])},object)}var maxDepth=16;var cosMinDistance=cos(30*radians);var resample=function(project,delta2){return+delta2?resample$1(project,delta2):resampleNone(project)};function resampleNone(project){return transformer({point:function(x,y){x=project(x,y);this.stream.point(x[0],x[1])}})}function resample$1(project,delta2){function resampleLineTo(x0,y0,lambda0,a0,b0,c0,x1,y1,lambda1,a1,b1,c1,depth,stream){var dx=x1-x0,dy=y1-y0,d2=dx*dx+dy*dy;if(d2>4*delta2&&depth--){var a=a0+a1,b=b0+b1,c=c0+c1,m=sqrt(a*a+b*b+c*c),phi2=asin(c/=m),lambda2=abs(abs(c)-1)delta2||abs((dx*dx2+dy*dy2)/d2-.5)>.3||a0*a1+b0*b1+c0*c12?_[2]%360*radians:0,recenter()):[deltaLambda*degrees,deltaPhi*degrees,deltaGamma*degrees]};projection.precision=function(_){return arguments.length?(projectResample=resample(projectTransform,delta2=_*_),reset()):sqrt(delta2)};projection.fitExtent=function(extent,object){return fitExtent(projection,extent,object)};projection.fitSize=function(size,object){return fitSize(projection,size,object)};projection.fitWidth=function(width,object){return fitWidth(projection,width,object)};projection.fitHeight=function(height,object){return fitHeight(projection,height,object)};function recenter(){projectRotate=compose(rotate=rotateRadians(deltaLambda,deltaPhi,deltaGamma),project);var center=project(lambda,phi);dx=x-center[0]*k;dy=y+center[1]*k;return reset()}function reset(){cache=cacheStream=null;return projection}return function(){project=projectAt.apply(this,arguments);projection.invert=project.invert&&invert;return recenter()}}function conicProjection(projectAt){var phi0=0,phi1=pi/3,m=projectionMutator(projectAt),p=m(phi0,phi1);p.parallels=function(_){return arguments.length?m(phi0=_[0]*radians,phi1=_[1]*radians):[phi0*degrees,phi1*degrees]};return p}function cylindricalEqualAreaRaw(phi0){var cosPhi0=cos(phi0);function forward(lambda,phi){return[lambda*cosPhi0,sin(phi)/cosPhi0]}forward.invert=function(x,y){return[x/cosPhi0,asin(y*cosPhi0)]};return forward}function conicEqualAreaRaw(y0,y1){var sy0=sin(y0),n=(sy0+sin(y1))/2;if(abs(n)=.12&&y<.234&&x>=-.425&&x<-.214?alaska:y>=.166&&y<.234&&x>=-.214&&x<-.115?hawaii:lower48).invert(coordinates)};albersUsa.stream=function(stream){return cache&&cacheStream===stream?cache:cache=multiplex([lower48.stream(cacheStream=stream),alaska.stream(stream),hawaii.stream(stream)])};albersUsa.precision=function(_){if(!arguments.length)return lower48.precision();lower48.precision(_),alaska.precision(_),hawaii.precision(_);return reset()};albersUsa.scale=function(_){if(!arguments.length)return lower48.scale();lower48.scale(_),alaska.scale(_*.35),hawaii.scale(_);return albersUsa.translate(lower48.translate())};albersUsa.translate=function(_){if(!arguments.length)return lower48.translate();var k=lower48.scale(),x=+_[0],y=+_[1];lower48Point=lower48.translate(_).clipExtent([[x-.455*k,y-.238*k],[x+.455*k,y+.238*k]]).stream(pointStream);alaskaPoint=alaska.translate([x-.307*k,y+.201*k]).clipExtent([[x-.425*k+epsilon,y+.12*k+epsilon],[x-.214*k-epsilon,y+.234*k-epsilon]]).stream(pointStream);hawaiiPoint=hawaii.translate([x-.205*k,y+.212*k]).clipExtent([[x-.214*k+epsilon,y+.166*k+epsilon],[x-.115*k-epsilon,y+.234*k-epsilon]]).stream(pointStream);return reset()};albersUsa.fitExtent=function(extent,object){return fitExtent(albersUsa,extent,object)};albersUsa.fitSize=function(size,object){return fitSize(albersUsa,size,object)};albersUsa.fitWidth=function(width,object){return fitWidth(albersUsa,width,object)};albersUsa.fitHeight=function(height,object){return fitHeight(albersUsa,height,object)};function reset(){cache=cacheStream=null;return albersUsa}return albersUsa.scale(1070)};function azimuthalRaw(scale){return function(x,y){var cx=cos(x),cy=cos(y),k=scale(cx*cy);return[k*cy*sin(x),k*sin(y)]}}function azimuthalInvert(angle){return function(x,y){var z=sqrt(x*x+y*y),c=angle(z),sc=sin(c),cc=cos(c);return[atan2(x*sc,z*cc),asin(z&&y*sc/z)]}}var azimuthalEqualAreaRaw=azimuthalRaw(function(cxcy){return sqrt(2/(1+cxcy))});azimuthalEqualAreaRaw.invert=azimuthalInvert(function(z){return 2*asin(z/2)});var azimuthalEqualArea=function(){return projection(azimuthalEqualAreaRaw).scale(124.75).clipAngle(180-.001)};var azimuthalEquidistantRaw=azimuthalRaw(function(c){return(c=acos(c))&&c/sin(c)});azimuthalEquidistantRaw.invert=azimuthalInvert(function(z){return z});var azimuthalEquidistant=function(){return projection(azimuthalEquidistantRaw).scale(79.4188).clipAngle(180-.001)};function mercatorRaw(lambda,phi){return[lambda,log(tan((halfPi+phi)/2))]}mercatorRaw.invert=function(x,y){return[x,2*atan(exp(y))-halfPi]};var mercator=function(){return mercatorProjection(mercatorRaw).scale(961/tau)};function mercatorProjection(project){var m=projection(project),center=m.center,scale=m.scale,translate=m.translate,clipExtent=m.clipExtent,x0=null,y0,x1,y1;m.scale=function(_){return arguments.length?(scale(_),reclip()):scale()};m.translate=function(_){return arguments.length?(translate(_),reclip()):translate()};m.center=function(_){return arguments.length?(center(_),reclip()):center()};m.clipExtent=function(_){return arguments.length?(_==null?x0=y0=x1=y1=null:(x0=+_[0][0],y0=+_[0][1],x1=+_[1][0],y1=+_[1][1]),reclip()):x0==null?null:[[x0,y0],[x1,y1]]};function reclip(){var k=pi*scale(),t=m(rotation(m.rotate()).invert([0,0]));return clipExtent(x0==null?[[t[0]-k,t[1]-k],[t[0]+k,t[1]+k]]:project===mercatorRaw?[[Math.max(t[0]-k,x0),y0],[Math.min(t[0]+k,x1),y1]]:[[x0,Math.max(t[1]-k,y0)],[x1,Math.min(t[1]+k,y1)]])}return reclip()}function tany(y){return tan((halfPi+y)/2)}function conicConformalRaw(y0,y1){var cy0=cos(y0),n=y0===y1?sin(y0):log(cy0/cos(y1))/log(tany(y1)/tany(y0)),f=cy0*pow(tany(y0),n)/n;if(!n)return mercatorRaw;function project(x,y){if(f>0){if(y<-halfPi+epsilon)y=-halfPi+epsilon}else{if(y>halfPi-epsilon)y=halfPi-epsilon}var r=f/pow(tany(y),n);return[r*sin(n*x),f-r*cos(n*x)]}project.invert=function(x,y){var fy=f-y,r=sign(n)*sqrt(x*x+fy*fy);return[atan2(x,abs(fy))/n*sign(fy),2*atan(pow(f/r,1/n))-halfPi]};return project}var conicConformal=function(){return conicProjection(conicConformalRaw).scale(109.5).parallels([30,30])};function equirectangularRaw(lambda,phi){return[lambda,phi]}equirectangularRaw.invert=equirectangularRaw;var equirectangular=function(){return projection(equirectangularRaw).scale(152.63)};function conicEquidistantRaw(y0,y1){var cy0=cos(y0),n=y0===y1?sin(y0):(cy0-cos(y1))/(y1-y0),g=cy0/n+y0;if(abs(n)epsilon&&--i>0);return[x/(.8707+(phi2=phi*phi)*(-.131979+phi2*(-.013791+phi2*phi2*phi2*(.003971-.001529*phi2)))),phi]};var naturalEarth1=function(){return projection(naturalEarth1Raw).scale(175.295)};function orthographicRaw(x,y){return[cos(y)*sin(x),sin(y)]}orthographicRaw.invert=azimuthalInvert(asin);var orthographic=function(){return projection(orthographicRaw).scale(249.5).clipAngle(90+epsilon)};function stereographicRaw(x,y){var cy=cos(y),k=1+cos(x)*cy;return[cy*sin(x)/k,sin(y)/k]}stereographicRaw.invert=azimuthalInvert(function(z){return 2*atan(z)});var stereographic=function(){return projection(stereographicRaw).scale(250).clipAngle(142)};function transverseMercatorRaw(lambda,phi){return[log(tan((halfPi+phi)/2)),-lambda]}transverseMercatorRaw.invert=function(x,y){return[-y,2*atan(exp(x))-halfPi]};var transverseMercator=function(){var m=mercatorProjection(transverseMercatorRaw),center=m.center,rotate=m.rotate;m.center=function(_){return arguments.length?center([-_[1],_[0]]):(_=center(),[_[1],-_[0]])};m.rotate=function(_){return arguments.length?rotate([_[0],_[1],_.length>2?_[2]+90:90]):(_=rotate(),[_[0],_[1],_[2]-90])};return rotate([0,0,90]).scale(159.155)};exports.geoArea=area;exports.geoBounds=bounds;exports.geoCentroid=centroid;exports.geoCircle=circle;exports.geoClipAntimeridian=clipAntimeridian;exports.geoClipCircle=clipCircle;exports.geoClipExtent=extent;exports.geoClipRectangle=clipRectangle;exports.geoContains=contains;exports.geoDistance=distance;exports.geoGraticule=graticule;exports.geoGraticule10=graticule10;exports.geoInterpolate=interpolate;exports.geoLength=length;exports.geoPath=index;exports.geoAlbers=albers;exports.geoAlbersUsa=albersUsa;exports.geoAzimuthalEqualArea=azimuthalEqualArea;exports.geoAzimuthalEqualAreaRaw=azimuthalEqualAreaRaw;exports.geoAzimuthalEquidistant=azimuthalEquidistant;exports.geoAzimuthalEquidistantRaw=azimuthalEquidistantRaw;exports.geoConicConformal=conicConformal;exports.geoConicConformalRaw=conicConformalRaw;exports.geoConicEqualArea=conicEqualArea;exports.geoConicEqualAreaRaw=conicEqualAreaRaw;exports.geoConicEquidistant=conicEquidistant;exports.geoConicEquidistantRaw=conicEquidistantRaw;exports.geoEquirectangular=equirectangular;exports.geoEquirectangularRaw=equirectangularRaw;exports.geoGnomonic=gnomonic;exports.geoGnomonicRaw=gnomonicRaw;exports.geoIdentity=identity$1;exports.geoProjection=projection;exports.geoProjectionMutator=projectionMutator;exports.geoMercator=mercator;exports.geoMercatorRaw=mercatorRaw;exports.geoNaturalEarth1=naturalEarth1;exports.geoNaturalEarth1Raw=naturalEarth1Raw;exports.geoOrthographic=orthographic;exports.geoOrthographicRaw=orthographicRaw;exports.geoStereographic=stereographic;exports.geoStereographicRaw=stereographicRaw;exports.geoTransverseMercator=transverseMercator;exports.geoTransverseMercatorRaw=transverseMercatorRaw;exports.geoRotation=rotation;exports.geoStream=geoStream;exports.geoTransform=transform;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3}],9:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var thirdPi=Math.PI/3;var angles=[0,thirdPi,2*thirdPi,3*thirdPi,4*thirdPi,5*thirdPi];function pointX(d){return d[0]}function pointY(d){return d[1]}var hexbin=function(){var x0=0,y0=0,x1=1,y1=1,x=pointX,y=pointY,r,dx,dy;function hexbin(points){var binsById={},bins=[],i,n=points.length;for(i=0;i1){var px1=px-pi,pi2=pi+(pxpx2*px2+py2*py2)pi=pi2+(pj&1?1:-1)/2,pj=pj2}var id=pi+"-"+pj,bin=binsById[id];if(bin)bin.push(point);else{bins.push(bin=binsById[id]=[point]);bin.x=(pi+(pj&1)/2)*dx;bin.y=pj*dy}}return bins}function hexagon(radius){var x0=0,y0=0;return angles.map(function(angle){var x1=Math.sin(angle)*radius,y1=-Math.cos(angle)*radius,dx=x1-x0,dy=y1-y0;x0=x1,y0=y1;return[dx,dy]})}hexbin.hexagon=function(radius){return"m"+hexagon(radius==null?r:+radius).join("l")+"z"};hexbin.centers=function(){var centers=[],j=Math.round(y0/dy),i=Math.round(x0/dx);for(var y=j*dy;y=0)sum+=children[i].value;node.value=sum}var node_count=function(){return this.eachAfter(count)};var node_each=function(callback){var node=this,current,next=[node],children,i,n;do{current=next.reverse(),next=[];while(node=current.pop()){callback(node),children=node.children;if(children)for(i=0,n=children.length;i=0;--i){nodes.push(children[i])}}return this};var node_eachAfter=function(callback){var node=this,nodes=[node],next=[],children,i,n;while(node=nodes.pop()){next.push(node),children=node.children;if(children)for(i=0,n=children.length;i=0)sum+=children[i].value;node.value=sum})};var node_sort=function(compare){return this.eachBefore(function(node){if(node.children){node.children.sort(compare)}})};var node_path=function(end){var start=this,ancestor=leastCommonAncestor(start,end),nodes=[start];while(start!==ancestor){start=start.parent;nodes.push(start)}var k=nodes.length;while(end!==ancestor){nodes.splice(k,0,end);end=end.parent}return nodes};function leastCommonAncestor(a,b){if(a===b)return a;var aNodes=a.ancestors(),bNodes=b.ancestors(),c=null;a=aNodes.pop();b=bNodes.pop();while(a===b){c=a;a=aNodes.pop();b=bNodes.pop()}return c}var node_ancestors=function(){var node=this,nodes=[node];while(node=node.parent){nodes.push(node)}return nodes};var node_descendants=function(){var nodes=[];this.each(function(node){nodes.push(node)});return nodes};var node_leaves=function(){var leaves=[];this.eachBefore(function(node){if(!node.children){leaves.push(node)}});return leaves};var node_links=function(){var root=this,links=[];root.each(function(node){if(node!==root){links.push({source:node.parent,target:node})}});return links};function hierarchy(data,children){var root=new Node(data),valued=+data.value&&(root.value=data.value),node,nodes=[root],child,childs,i,n;if(children==null)children=defaultChildren;while(node=nodes.pop()){if(valued)node.value=+node.data.value;if((childs=children(node.data))&&(n=childs.length)){node.children=new Array(n);for(i=n-1;i>=0;--i){nodes.push(child=node.children[i]=new Node(childs[i]));child.parent=node;child.depth=node.depth+1}}}return root.eachBefore(computeHeight)}function node_copy(){return hierarchy(this).eachBefore(copyData)}function defaultChildren(d){return d.children}function copyData(node){node.data=node.data.data}function computeHeight(node){var height=0;do{node.height=height}while((node=node.parent)&&node.height<++height)}function Node(data){this.data=data;this.depth=this.height=0;this.parent=null}Node.prototype=hierarchy.prototype={constructor:Node,count:node_count,each:node_each,eachAfter:node_eachAfter,eachBefore:node_eachBefore,sum:node_sum,sort:node_sort,path:node_path,ancestors:node_ancestors,descendants:node_descendants,leaves:node_leaves,links:node_links,copy:node_copy};var slice=Array.prototype.slice;function shuffle(array){var m=array.length,t,i;while(m){i=Math.random()*m--|0;t=array[m];array[m]=array[i];array[i]=t}return array}var enclose=function(circles){var i=0,n=(circles=shuffle(slice.call(circles))).length,B=[],p,e;while(i0&&dr*dr>dx*dx+dy*dy}function enclosesWeakAll(a,B){for(var i=0;idx*dx+dy*dy}function score(node){var a=node._,b=node.next._,ab=a.r+b.r,dx=(a.x*b.r+b.x*a.r)/ab,dy=(a.y*b.r+b.y*a.r)/ab;return dx*dx+dy*dy}function Node$1(circle){this._=circle;this.next=null;this.previous=null}function packEnclose(circles){if(!(n=circles.length))return 0;var a,b,c,n,aa,ca,i,j,k,sj,sk;a=circles[0],a.x=0,a.y=0;if(!(n>1))return a.r;b=circles[1],a.x=-b.r,b.x=a.r,b.y=0;if(!(n>2))return a.r+b.r;place(b,a,c=circles[2]);a=new Node$1(a),b=new Node$1(b),c=new Node$1(c);a.next=c.previous=b;b.next=a.previous=c;c.next=b.previous=a;pack:for(i=3;i0)throw new Error("cycle");return root}stratify.id=function(x){return arguments.length?(id=required(x),stratify):id};stratify.parentId=function(x){return arguments.length?(parentId=required(x),stratify):parentId};return stratify};function defaultSeparation$1(a,b){return a.parent===b.parent?1:2}function nextLeft(v){var children=v.children;return children?children[0]:v.t}function nextRight(v){var children=v.children;return children?children[children.length-1]:v.t}function moveSubtree(wm,wp,shift){var change=shift/(wp.i-wm.i);wp.c-=change;wp.s+=shift;wm.c+=change;wp.z+=shift;wp.m+=shift}function executeShifts(v){var shift=0,change=0,children=v.children,i=children.length,w;while(--i>=0){w=children[i];w.z+=shift;w.m+=shift;shift+=w.s+(change+=w.c)}}function nextAncestor(vim,v,ancestor){return vim.a.parent===v.parent?vim.a:ancestor}function TreeNode(node,i){this._=node;this.parent=null;this.children=null;this.A=null;this.a=this;this.z=0;this.m=0;this.c=0;this.s=0;this.t=null;this.i=i}TreeNode.prototype=Object.create(Node.prototype);function treeRoot(root){var tree=new TreeNode(root,0),node,nodes=[tree],child,children,i,n;while(node=nodes.pop()){if(children=node._.children){node.children=new Array(n=children.length);for(i=n-1;i>=0;--i){nodes.push(child=node.children[i]=new TreeNode(children[i],i));child.parent=node}}}(tree.parent=new TreeNode(null,0)).children=[tree];return tree}var tree=function(){var separation=defaultSeparation$1,dx=1,dy=1,nodeSize=null;function tree(root){var t=treeRoot(root);t.eachAfter(firstWalk),t.parent.m=-t.z;t.eachBefore(secondWalk);if(nodeSize)root.eachBefore(sizeNode);else{var left=root,right=root,bottom=root;root.eachBefore(function(node){if(node.xright.x)right=node;if(node.depth>bottom.depth)bottom=node});var s=left===right?1:separation(left,right)/2,tx=s-left.x,kx=dx/(right.x+s+tx),ky=dy/(bottom.depth||1);root.eachBefore(function(node){node.x=(node.x+tx)*kx;node.y=node.depth*ky})}return root}function firstWalk(v){var children=v.children,siblings=v.parent.children,w=v.i?siblings[v.i-1]:null;if(children){executeShifts(v);var midpoint=(children[0].z+children[children.length-1].z)/2;if(w){v.z=w.z+separation(v._,w._);v.m=v.z-midpoint}else{v.z=midpoint}}else if(w){v.z=w.z+separation(v._,w._)}v.parent.A=apportion(v,w,v.parent.A||siblings[0])}function secondWalk(v){v._.x=v.z+v.parent.m;v.m+=v.parent.m}function apportion(v,w,ancestor){if(w){var vip=v,vop=v,vim=w,vom=vip.parent.children[0],sip=vip.m,sop=vop.m,sim=vim.m,som=vom.m,shift;while(vim=nextRight(vim),vip=nextLeft(vip),vim&&vip){vom=nextLeft(vom);vop=nextRight(vop);vop.a=v;shift=vim.z+sim-vip.z-sip+separation(vim._,vip._);if(shift>0){moveSubtree(nextAncestor(vim,v,ancestor),v,shift);sip+=shift;sop+=shift}sim+=vim.m;sip+=vip.m;som+=vom.m;sop+=vop.m}if(vim&&!nextRight(vop)){vop.t=vim;vop.m+=sim-sop}if(vip&&!nextLeft(vom)){vom.t=vip;vom.m+=sip-som;ancestor=v}}return ancestor}function sizeNode(node){node.x*=dx;node.y=node.depth*dy}tree.separation=function(x){return arguments.length?(separation=x,tree):separation};tree.size=function(x){return arguments.length?(nodeSize=false,dx=+x[0],dy=+x[1],tree):nodeSize?null:[dx,dy]};tree.nodeSize=function(x){return arguments.length?(nodeSize=true,dx=+x[0],dy=+x[1],tree):nodeSize?[dx,dy]:null};return tree};var treemapSlice=function(parent,x0,y0,x1,y1){var nodes=parent.children,node,i=-1,n=nodes.length,k=parent.value&&(y1-y0)/parent.value;while(++imaxValue)maxValue=nodeValue;beta=sumValue*sumValue*alpha;newRatio=Math.max(maxValue/beta,beta/minValue);if(newRatio>minRatio){sumValue-=nodeValue;break}minRatio=newRatio}rows.push(row={value:sumValue,dice:dx1?x:1)};return squarify}(phi);var index$1=function(){var tile=squarify,round=false,dx=1,dy=1,paddingStack=[0],paddingInner=constantZero,paddingTop=constantZero,paddingRight=constantZero,paddingBottom=constantZero,paddingLeft=constantZero;function treemap(root){root.x0=root.y0=0;root.x1=dx;root.y1=dy;root.eachBefore(positionNode);paddingStack=[0];if(round)root.eachBefore(roundNode);return root}function positionNode(node){var p=paddingStack[node.depth],x0=node.x0+p,y0=node.y0+p,x1=node.x1-p,y1=node.y1-p;if(x1=j-1){var node=nodes[i];node.x0=x0,node.y0=y0;node.x1=x1,node.y1=y1;return}var valueOffset=sums[i],valueTarget=value/2+valueOffset,k=i+1,hi=j-1;while(k>>1;if(sums[mid]y1-y0){var xk=(x0*valueRight+x1*valueLeft)/value;partition(i,k,valueLeft,x0,y0,xk,y1);partition(k,j,valueRight,xk,y0,x1,y1)}else{var yk=(y0*valueRight+y1*valueLeft)/value;partition(i,k,valueLeft,x0,y0,x1,yk);partition(k,j,valueRight,x0,yk,x1,y1)}}};var sliceDice=function(parent,x0,y0,x1,y1){(parent.depth&1?treemapSlice:treemapDice)(parent,x0,y0,x1,y1)};var resquarify=function custom(ratio){function resquarify(parent,x0,y0,x1,y1){if((rows=parent._squarify)&&rows.ratio===ratio){var rows,row,nodes,i,j=-1,n,m=rows.length,value=parent.value;while(++j1?x:1)};return resquarify}(phi);exports.cluster=cluster;exports.hierarchy=hierarchy;exports.pack=index;exports.packSiblings=siblings;exports.packEnclose=enclose;exports.partition=partition;exports.stratify=stratify;exports.tree=tree;exports.treemap=index$1;exports.treemapBinary=binary;exports.treemapDice=treemapDice;exports.treemapSlice=treemapSlice;exports.treemapSliceDice=sliceDice;exports.treemapSquarify=squarify;exports.treemapResquarify=resquarify;Object.defineProperty(exports,"__esModule",{value:true})})},{}],11:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-color")):typeof define==="function"&&define.amd?define(["exports","d3-color"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Color){"use strict";function basis(t1,v0,v1,v2,v3){var t2=t1*t1,t3=t2*t1;return((1-3*t1+3*t2-t3)*v0+(4-6*t2+3*t3)*v1+(1+3*t1+3*t2-3*t3)*v2+t3*v3)/6}var basis$1=function(values){var n=values.length-1;return function(t){var i=t<=0?t=0:t>=1?(t=1,n-1):Math.floor(t*n),v1=values[i],v2=values[i+1],v0=i>0?values[i-1]:2*v1-v2,v3=i180||d<-180?d-360*Math.round(d/360):d):constant(isNaN(a)?b:a)}function gamma(y){return(y=+y)===1?nogamma:function(a,b){return b-a?exponential(a,b,y):constant(isNaN(a)?b:a)}}function nogamma(a,b){var d=b-a;return d?linear(a,d):constant(isNaN(a)?b:a)}var rgb$1=function rgbGamma(y){var color$$1=gamma(y);function rgb$$1(start,end){var r=color$$1((start=d3Color.rgb(start)).r,(end=d3Color.rgb(end)).r),g=color$$1(start.g,end.g),b=color$$1(start.b,end.b),opacity=nogamma(start.opacity,end.opacity);return function(t){start.r=r(t);start.g=g(t);start.b=b(t);start.opacity=opacity(t);return start+""}}rgb$$1.gamma=rgbGamma;return rgb$$1}(1);function rgbSpline(spline){return function(colors){var n=colors.length,r=new Array(n),g=new Array(n),b=new Array(n),i,color$$1;for(i=0;ibi){bs=b.slice(bi,bs);if(s[i])s[i]+=bs;else s[++i]=bs}if((am=am[0])===(bm=bm[0])){if(s[i])s[i]+=bm;else s[++i]=bm}else{s[++i]=null;q.push({i:i,x:number(am,bm)})}bi=reB.lastIndex}if(bi180)b+=360;else if(b-a>180)a+=360;q.push({i:s.push(pop(s)+"rotate(",null,degParen)-2,x:number(a,b)})}else if(b){s.push(pop(s)+"rotate("+b+degParen)}}function skewX(a,b,s,q){if(a!==b){q.push({i:s.push(pop(s)+"skewX(",null,degParen)-2,x:number(a,b)})}else if(b){s.push(pop(s)+"skewX("+b+degParen)}}function scale(xa,ya,xb,yb,s,q){if(xa!==xb||ya!==yb){var i=s.push(pop(s)+"scale(",null,",",null,")");q.push({i:i-4,x:number(xa,xb)},{i:i-2,x:number(ya,yb)})}else if(xb!==1||yb!==1){s.push(pop(s)+"scale("+xb+","+yb+")")}}return function(a,b){var s=[],q=[];a=parse(a),b=parse(b);translate(a.translateX,a.translateY,b.translateX,b.translateY,s,q);rotate(a.rotate,b.rotate,s,q);skewX(a.skewX,b.skewX,s,q);scale(a.scaleX,a.scaleY,b.scaleX,b.scaleY,s,q);a=b=null;return function(t){var i=-1,n=q.length,o;while(++iepsilon)){}else if(!(Math.abs(y01*x21-y21*x01)>epsilon)||!r){this._+="L"+(this._x1=x1)+","+(this._y1=y1)}else{var x20=x2-x0,y20=y2-y0,l21_2=x21*x21+y21*y21,l20_2=x20*x20+y20*y20,l21=Math.sqrt(l21_2),l01=Math.sqrt(l01_2),l=r*Math.tan((pi-Math.acos((l21_2+l01_2-l20_2)/(2*l21*l01)))/2),t01=l/l01,t21=l/l21;if(Math.abs(t01-1)>epsilon){this._+="L"+(x1+t01*x01)+","+(y1+t01*y01)}this._+="A"+r+","+r+",0,0,"+ +(y01*x20>x01*y20)+","+(this._x1=x1+t21*x21)+","+(this._y1=y1+t21*y21)}},arc:function(x,y,r,a0,a1,ccw){x=+x,y=+y,r=+r;var dx=r*Math.cos(a0),dy=r*Math.sin(a0),x0=x+dx,y0=y+dy,cw=1^ccw,da=ccw?a0-a1:a1-a0;if(r<0)throw new Error("negative radius: "+r);if(this._x1===null){this._+="M"+x0+","+y0}else if(Math.abs(this._x1-x0)>epsilon||Math.abs(this._y1-y0)>epsilon){this._+="L"+x0+","+y0}if(!r)return;if(da<0)da=da%tau+tau;if(da>tauEpsilon){this._+="A"+r+","+r+",0,1,"+cw+","+(x-dx)+","+(y-dy)+"A"+r+","+r+",0,1,"+cw+","+(this._x1=x0)+","+(this._y1=y0)}else if(da>epsilon){this._+="A"+r+","+r+",0,"+ +(da>=pi)+","+cw+","+(this._x1=x+r*Math.cos(a1))+","+(this._y1=y+r*Math.sin(a1))}},rect:function(x,y,w,h){this._+="M"+(this._x0=this._x1=+x)+","+(this._y0=this._y1=+y)+"h"+ +w+"v"+ +h+"h"+-w+"Z"},toString:function(){return this._}};exports.path=path;Object.defineProperty(exports,"__esModule",{value:true})})},{}],13:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array"),require("d3-collection"),require("d3-shape")):typeof define==="function"&&define.amd?define(["exports","d3-array","d3-collection","d3-shape"],factory):factory(global.d3=global.d3||{},global.d3,global.d3,global.d3)})(this,function(exports,d3Array,d3Collection,d3Shape){"use strict";function targetDepth(d){return d.target.depth}function left(node){return node.depth}function right(node,n){return n-1-node.height}function justify(node,n){return node.sourceLinks.length?node.depth:n-1}function center(node){return node.targetLinks.length?node.depth:node.sourceLinks.length?d3Array.min(node.sourceLinks,targetDepth)-1:0}function constant(x){return function(){return x}}function ascendingSourceBreadth(a,b){return ascendingBreadth(a.source,b.source)||a.index-b.index}function ascendingTargetBreadth(a,b){return ascendingBreadth(a.target,b.target)||a.index-b.index}function ascendingBreadth(a,b){return a.y0-b.y0}function value(d){return d.value}function nodeCenter(node){return(node.y0+node.y1)/2}function weightedSource(link){return nodeCenter(link.source)*link.value}function weightedTarget(link){return nodeCenter(link.target)*link.value}function defaultId(d){return d.index}function defaultNodes(graph){return graph.nodes}function defaultLinks(graph){return graph.links}function find(nodeById,id){var node=nodeById.get(id);if(!node)throw new Error("missing: "+id);return node}var sankey=function(){var x0=0,y0=0,x1=1,y1=1,dx=24,py=8,id=defaultId,align=justify,nodes=defaultNodes,links=defaultLinks,iterations=32;function sankey(){var graph={nodes:nodes.apply(null,arguments),links:links.apply(null,arguments)};computeNodeLinks(graph);computeNodeValues(graph);computeNodeDepths(graph);computeNodeBreadths(graph,iterations);computeLinkBreadths(graph);return graph}sankey.update=function(graph){computeLinkBreadths(graph);return graph};sankey.nodeId=function(_){return arguments.length?(id=typeof _==="function"?_:constant(_),sankey):id};sankey.nodeAlign=function(_){return arguments.length?(align=typeof _==="function"?_:constant(_),sankey):align};sankey.nodeWidth=function(_){return arguments.length?(dx=+_,sankey):dx};sankey.nodePadding=function(_){return arguments.length?(py=+_,sankey):py};sankey.nodes=function(_){return arguments.length?(nodes=typeof _==="function"?_:constant(_),sankey):nodes};sankey.links=function(_){return arguments.length?(links=typeof _==="function"?_:constant(_),sankey):links};sankey.size=function(_){return arguments.length?(x0=y0=0,x1=+_[0],y1=+_[1],sankey):[x1-x0,y1-y0]};sankey.extent=function(_){return arguments.length?(x0=+_[0][0],x1=+_[1][0],y0=+_[0][1],y1=+_[1][1],sankey):[[x0,y0],[x1,y1]]};sankey.iterations=function(_){return arguments.length?(iterations=+_,sankey):iterations};function computeNodeLinks(graph){graph.nodes.forEach(function(node,i){node.index=i;node.sourceLinks=[];node.targetLinks=[]});var nodeById=d3Collection.map(graph.nodes,id);graph.links.forEach(function(link,i){link.index=i;var source=link.source,target=link.target;if(typeof source!=="object")source=link.source=find(nodeById,source);if(typeof target!=="object")target=link.target=find(nodeById,target);source.sourceLinks.push(link);target.targetLinks.push(link)})}function computeNodeValues(graph){graph.nodes.forEach(function(node){node.value=Math.max(d3Array.sum(node.sourceLinks,value),d3Array.sum(node.targetLinks,value))})}function computeNodeDepths(graph){var nodes,next,x;for(nodes=graph.nodes,next=[],x=0;nodes.length;++x,nodes=next,next=[]){nodes.forEach(function(node){node.depth=x;node.sourceLinks.forEach(function(link){if(next.indexOf(link.target)<0){next.push(link.target)}})})}for(nodes=graph.nodes,next=[],x=0;nodes.length;++x,nodes=next,next=[]){nodes.forEach(function(node){node.height=x;node.targetLinks.forEach(function(link){if(next.indexOf(link.source)<0){next.push(link.source)}})})}var kx=(x1-x0-dx)/(x-1);graph.nodes.forEach(function(node){node.x1=(node.x0=x0+Math.max(0,Math.min(x-1,Math.floor(align.call(null,node,x))))*kx)+dx})}function computeNodeBreadths(graph){var columns=d3Collection.nest().key(function(d){return d.x0}).sortKeys(d3Array.ascending).entries(graph.nodes).map(function(d){return d.values});initializeNodeBreadth();resolveCollisions();for(var alpha=1,n=iterations;n>0;--n){relaxRightToLeft(alpha*=.99);resolveCollisions();relaxLeftToRight(alpha);resolveCollisions()}function initializeNodeBreadth(){var ky=d3Array.min(columns,function(nodes){return(y1-y0-(nodes.length-1)*py)/d3Array.sum(nodes,value)});columns.forEach(function(nodes){nodes.forEach(function(node,i){node.y1=(node.y0=i)+node.value*ky})});graph.links.forEach(function(link){link.width=link.value*ky})}function relaxLeftToRight(alpha){columns.forEach(function(nodes){nodes.forEach(function(node){if(node.targetLinks.length){var dy=(d3Array.sum(node.targetLinks,weightedSource)/d3Array.sum(node.targetLinks,value)-nodeCenter(node))*alpha;node.y0+=dy,node.y1+=dy}})})}function relaxRightToLeft(alpha){columns.slice().reverse().forEach(function(nodes){nodes.forEach(function(node){if(node.sourceLinks.length){var dy=(d3Array.sum(node.sourceLinks,weightedTarget)/d3Array.sum(node.sourceLinks,value)-nodeCenter(node))*alpha;node.y0+=dy,node.y1+=dy}})})}function resolveCollisions(){columns.forEach(function(nodes){var node,dy,y=y0,n=nodes.length,i;nodes.sort(ascendingBreadth);for(i=0;i0)node.y0+=dy,node.y1+=dy;y=node.y1+py}dy=y-py-y1;if(dy>0){y=node.y0-=dy,node.y1-=dy;for(i=n-2;i>=0;--i){node=nodes[i];dy=node.y1+py-y;if(dy>0)node.y0-=dy,node.y1-=dy;y=node.y0}}})}}function computeLinkBreadths(graph){graph.nodes.forEach(function(node){node.sourceLinks.sort(ascendingTargetBreadth);node.targetLinks.sort(ascendingSourceBreadth)});graph.nodes.forEach(function(node){var y0=node.y0,y1=y0;node.sourceLinks.forEach(function(link){link.y0=y0+link.width/2,y0+=link.width});node.targetLinks.forEach(function(link){link.y1=y1+link.width/2,y1+=link.width})})}return sankey};function horizontalSource(d){return[d.source.x1,d.y0]}function horizontalTarget(d){return[d.target.x0,d.y1]}var sankeyLinkHorizontal=function(){return d3Shape.linkHorizontal().source(horizontalSource).target(horizontalTarget)};exports.sankey=sankey;exports.sankeyCenter=center;exports.sankeyLeft=left;exports.sankeyRight=right;exports.sankeyJustify=justify;exports.sankeyLinkHorizontal=sankeyLinkHorizontal;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3,"d3-collection":4,"d3-shape":15}],14:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array"),require("d3-collection"),require("d3-interpolate"),require("d3-format"),require("d3-time"),require("d3-time-format"),require("d3-color")):typeof define==="function"&&define.amd?define(["exports","d3-array","d3-collection","d3-interpolate","d3-format","d3-time","d3-time-format","d3-color"],factory):factory(global.d3=global.d3||{},global.d3,global.d3,global.d3,global.d3,global.d3,global.d3,global.d3)})(this,function(exports,d3Array,d3Collection,d3Interpolate,d3Format,d3Time,d3TimeFormat,d3Color){"use strict";var array=Array.prototype;var map$1=array.map;var slice=array.slice;var implicit={name:"implicit"};function ordinal(range$$1){var index=d3Collection.map(),domain=[],unknown=implicit;range$$1=range$$1==null?[]:slice.call(range$$1);function scale(d){var key=d+"",i=index.get(key);if(!i){if(unknown!==implicit)return unknown;index.set(key,i=domain.push(d))}return range$$1[(i-1)%range$$1.length]}scale.domain=function(_){if(!arguments.length)return domain.slice();domain=[],index=d3Collection.map();var i=-1,n=_.length,d,key;while(++i=b?1:d(x)}}}function reinterpolateClamp(reinterpolate){return function(a,b){var r=reinterpolate(a=+a,b=+b);return function(t){return t<=0?a:t>=1?b:r(t)}}}function bimap(domain,range$$1,deinterpolate,reinterpolate){var d0=domain[0],d1=domain[1],r0=range$$1[0],r1=range$$1[1];if(d12?polymap:bimap;output=input=null;return scale}function scale(x){return(output||(output=piecewise(domain,range$$1,clamp?deinterpolateClamp(deinterpolate):deinterpolate,interpolate$$1)))(+x)}scale.invert=function(y){return(input||(input=piecewise(range$$1,domain,deinterpolateLinear,clamp?reinterpolateClamp(reinterpolate):reinterpolate)))(+y)};scale.domain=function(_){return arguments.length?(domain=map$1.call(_,number),rescale()):domain.slice()};scale.range=function(_){return arguments.length?(range$$1=slice.call(_),rescale()):range$$1.slice()};scale.rangeRound=function(_){return range$$1=slice.call(_),interpolate$$1=d3Interpolate.interpolateRound,rescale()};scale.clamp=function(_){return arguments.length?(clamp=!!_,rescale()):clamp};scale.interpolate=function(_){return arguments.length?(interpolate$$1=_,rescale()):interpolate$$1};return rescale()}var tickFormat=function(domain,count,specifier){var start=domain[0],stop=domain[domain.length-1],step=d3Array.tickStep(start,stop,count==null?10:count),precision;specifier=d3Format.formatSpecifier(specifier==null?",f":specifier);switch(specifier.type){case"s":{var value=Math.max(Math.abs(start),Math.abs(stop));if(specifier.precision==null&&!isNaN(precision=d3Format.precisionPrefix(step,value)))specifier.precision=precision;return d3Format.formatPrefix(specifier,value)}case"":case"e":case"g":case"p":case"r":{if(specifier.precision==null&&!isNaN(precision=d3Format.precisionRound(step,Math.max(Math.abs(start),Math.abs(stop)))))specifier.precision=precision-(specifier.type==="e");break}case"f":case"%":{if(specifier.precision==null&&!isNaN(precision=d3Format.precisionFixed(step)))specifier.precision=precision-(specifier.type==="%")*2;break}}return d3Format.format(specifier)};function linearish(scale){var domain=scale.domain;scale.ticks=function(count){var d=domain();return d3Array.ticks(d[0],d[d.length-1],count==null?10:count)};scale.tickFormat=function(count,specifier){return tickFormat(domain(),count,specifier)};scale.nice=function(count){if(count==null)count=10;var d=domain(),i0=0,i1=d.length-1,start=d[i0],stop=d[i1],step;if(stop0){start=Math.floor(start/step)*step;stop=Math.ceil(stop/step)*step;step=d3Array.tickIncrement(start,stop,count)}else if(step<0){start=Math.ceil(start*step)/step;stop=Math.floor(stop*step)/step;step=d3Array.tickIncrement(start,stop,count)}if(step>0){d[i0]=Math.floor(start/step)*step;d[i1]=Math.ceil(stop/step)*step;domain(d)}else if(step<0){d[i0]=Math.ceil(start*step)/step;d[i1]=Math.floor(stop*step)/step;domain(d)}return scale};return scale}function linear(){var scale=continuous(deinterpolateLinear,d3Interpolate.interpolateNumber);scale.copy=function(){return copy(scale,linear())};return linearish(scale)}function identity(){var domain=[0,1];function scale(x){return+x}scale.invert=scale;scale.domain=scale.range=function(_){return arguments.length?(domain=map$1.call(_,number),scale):domain.slice()};scale.copy=function(){return identity().domain(domain)};return linearish(scale)}var nice=function(domain,interval){domain=domain.slice();var i0=0,i1=domain.length-1,x0=domain[i0],x1=domain[i1],t;if(x10)for(;iv)break;z.push(t)}}else for(;i=1;--k){t=p*k;if(tv)break;z.push(t)}}}else{z=d3Array.ticks(i,j,Math.min(j-i,n)).map(pows)}return r?z.reverse():z};scale.tickFormat=function(count,specifier){if(specifier==null)specifier=base===10?".0e":",";if(typeof specifier!=="function")specifier=d3Format.format(specifier);if(count===Infinity)return specifier;if(count==null)count=10;var k=Math.max(1,base*count/scale.ticks().length);return function(d){var i=d/pows(Math.round(logs(d)));if(i*base0?thresholds[i-1]:domain[0],i=n?[domain[n-1],x1]:[domain[i-1],domain[i]]};scale.copy=function(){return quantize().domain([x0,x1]).range(range$$1)};return linearish(scale)}function threshold(){var domain=[.5],range$$1=[0,1],n=1;function scale(x){if(x<=x)return range$$1[d3Array.bisect(domain,x,0,n)]}scale.domain=function(_){return arguments.length?(domain=slice.call(_),n=Math.min(domain.length,range$$1.length-1),scale):domain.slice()};scale.range=function(_){return arguments.length?(range$$1=slice.call(_),n=Math.min(domain.length,range$$1.length-1),scale):range$$1.slice()};scale.invertExtent=function(y){var i=range$$1.indexOf(y);return[domain[i-1],domain[i]]};scale.copy=function(){return threshold().domain(domain).range(range$$1)};return scale}var durationSecond=1e3;var durationMinute=durationSecond*60;var durationHour=durationMinute*60;var durationDay=durationHour*24;var durationWeek=durationDay*7;var durationMonth=durationDay*30;var durationYear=durationDay*365;function date(t){return new Date(t)}function number$1(t){return t instanceof Date?+t:+new Date(+t)}function calendar(year,month,week,day,hour,minute,second,millisecond,format$$1){var scale=continuous(deinterpolateLinear,d3Interpolate.interpolateNumber),invert=scale.invert,domain=scale.domain;var formatMillisecond=format$$1(".%L"),formatSecond=format$$1(":%S"),formatMinute=format$$1("%I:%M"),formatHour=format$$1("%I %p"),formatDay=format$$1("%a %d"),formatWeek=format$$1("%b %d"),formatMonth=format$$1("%B"),formatYear=format$$1("%Y");var tickIntervals=[[second,1,durationSecond],[second,5,5*durationSecond],[second,15,15*durationSecond],[second,30,30*durationSecond],[minute,1,durationMinute],[minute,5,5*durationMinute],[minute,15,15*durationMinute],[minute,30,30*durationMinute],[hour,1,durationHour],[hour,3,3*durationHour],[hour,6,6*durationHour],[hour,12,12*durationHour],[day,1,durationDay],[day,2,2*durationDay],[week,1,durationWeek],[month,1,durationMonth],[month,3,3*durationMonth],[year,1,durationYear]];function tickFormat(date){return(second(date)1)t-=Math.floor(t);var ts=Math.abs(t-.5);rainbow.h=360*t-100;rainbow.s=1.5-1.5*ts;rainbow.l=.8-.9*ts;return rainbow+""};function ramp(range$$1){var n=range$$1.length;return function(t){return range$$1[Math.max(0,Math.min(n-1,Math.floor(t*n)))]}}var viridis=ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var magma=ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));var inferno=ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));var plasma=ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function sequential(interpolator){var x0=0,x1=1,clamp=false;function scale(x){var t=(x-x0)/(x1-x0);return interpolator(clamp?Math.max(0,Math.min(1,t)):t)}scale.domain=function(_){return arguments.length?(x0=+_[0],x1=+_[1],scale):[x0,x1]};scale.clamp=function(_){return arguments.length?(clamp=!!_,scale):clamp};scale.interpolator=function(_){return arguments.length?(interpolator=_,scale):interpolator};scale.copy=function(){return sequential(interpolator).domain([x0,x1]).clamp(clamp)};return linearish(scale)}exports.scaleBand=band;exports.scalePoint=point;exports.scaleIdentity=identity;exports.scaleLinear=linear;exports.scaleLog=log;exports.scaleOrdinal=ordinal;exports.scaleImplicit=implicit;exports.scalePow=pow;exports.scaleSqrt=sqrt;exports.scaleQuantile=quantile$1;exports.scaleQuantize=quantize;exports.scaleThreshold=threshold;exports.scaleTime=time;exports.scaleUtc=utcTime;exports.schemeCategory10=category10;exports.schemeCategory20b=category20b;exports.schemeCategory20c=category20c;exports.schemeCategory20=category20;exports.interpolateCubehelixDefault=cubehelix$1;exports.interpolateRainbow=rainbow$1;exports.interpolateWarm=warm;exports.interpolateCool=cool;exports.interpolateViridis=viridis;exports.interpolateMagma=magma;exports.interpolateInferno=inferno;exports.interpolatePlasma=plasma;exports.scaleSequential=sequential;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3,"d3-collection":4,"d3-color":5,"d3-format":7,"d3-interpolate":11,"d3-time":17,"d3-time-format":16}],15:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-path")):typeof define==="function"&&define.amd?define(["exports","d3-path"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Path){"use strict";var constant=function(x){return function constant(){return x}};var abs=Math.abs;var atan2=Math.atan2;var cos=Math.cos;var max=Math.max;var min=Math.min;var sin=Math.sin;var sqrt=Math.sqrt;var epsilon=1e-12;var pi=Math.PI;var halfPi=pi/2;var tau=2*pi;function acos(x){return x>1?0:x<-1?pi:Math.acos(x)}function asin(x){return x>=1?halfPi:x<=-1?-halfPi:Math.asin(x)}function arcInnerRadius(d){return d.innerRadius}function arcOuterRadius(d){return d.outerRadius}function arcStartAngle(d){return d.startAngle}function arcEndAngle(d){return d.endAngle}function arcPadAngle(d){return d&&d.padAngle}function intersect(x0,y0,x1,y1,x2,y2,x3,y3){var x10=x1-x0,y10=y1-y0,x32=x3-x2,y32=y3-y2,t=(x32*(y0-y2)-y32*(x0-x2))/(y32*x10-x32*y10);return[x0+t*x10,y0+t*y10]}function cornerTangents(x0,y0,x1,y1,r1,rc,cw){var x01=x0-x1,y01=y0-y1,lo=(cw?rc:-rc)/sqrt(x01*x01+y01*y01),ox=lo*y01,oy=-lo*x01,x11=x0+ox,y11=y0+oy,x10=x1+ox,y10=y1+oy,x00=(x11+x10)/2,y00=(y11+y10)/2,dx=x10-x11,dy=y10-y11,d2=dx*dx+dy*dy,r=r1-rc,D=x11*y10-x10*y11,d=(dy<0?-1:1)*sqrt(max(0,r*r*d2-D*D)),cx0=(D*dy-dx*d)/d2,cy0=(-D*dx-dy*d)/d2,cx1=(D*dy+dx*d)/d2,cy1=(-D*dx+dy*d)/d2,dx0=cx0-x00,dy0=cy0-y00,dx1=cx1-x00,dy1=cy1-y00;if(dx0*dx0+dy0*dy0>dx1*dx1+dy1*dy1)cx0=cx1,cy0=cy1;return{cx:cx0,cy:cy0,x01:-ox,y01:-oy,x11:cx0*(r1/r-1),y11:cy0*(r1/r-1)}}var arc=function(){var innerRadius=arcInnerRadius,outerRadius=arcOuterRadius,cornerRadius=constant(0),padRadius=null,startAngle=arcStartAngle,endAngle=arcEndAngle,padAngle=arcPadAngle,context=null;function arc(){var buffer,r,r0=+innerRadius.apply(this,arguments),r1=+outerRadius.apply(this,arguments),a0=startAngle.apply(this,arguments)-halfPi,a1=endAngle.apply(this,arguments)-halfPi,da=abs(a1-a0),cw=a1>a0;if(!context)context=buffer=d3Path.path();if(r1epsilon))context.moveTo(0,0);else if(da>tau-epsilon){context.moveTo(r1*cos(a0),r1*sin(a0));context.arc(0,0,r1,a0,a1,!cw);if(r0>epsilon){context.moveTo(r0*cos(a1),r0*sin(a1));context.arc(0,0,r0,a1,a0,cw)}}else{var a01=a0,a11=a1,a00=a0,a10=a1,da0=da,da1=da,ap=padAngle.apply(this,arguments)/2,rp=ap>epsilon&&(padRadius?+padRadius.apply(this,arguments):sqrt(r0*r0+r1*r1)),rc=min(abs(r1-r0)/2,+cornerRadius.apply(this,arguments)),rc0=rc,rc1=rc,t0,t1;if(rp>epsilon){var p0=asin(rp/r0*sin(ap)),p1=asin(rp/r1*sin(ap));if((da0-=p0*2)>epsilon)p0*=cw?1:-1,a00+=p0,a10-=p0;else da0=0,a00=a10=(a0+a1)/2;if((da1-=p1*2)>epsilon)p1*=cw?1:-1,a01+=p1,a11-=p1;else da1=0,a01=a11=(a0+a1)/2}var x01=r1*cos(a01),y01=r1*sin(a01),x10=r0*cos(a10),y10=r0*sin(a10);if(rc>epsilon){var x11=r1*cos(a11),y11=r1*sin(a11),x00=r0*cos(a00),y00=r0*sin(a00);if(daepsilon?intersect(x01,y01,x00,y00,x11,y11,x10,y10):[x10,y10],ax=x01-oc[0],ay=y01-oc[1],bx=x11-oc[0],by=y11-oc[1],kc=1/sin(acos((ax*bx+ay*by)/(sqrt(ax*ax+ay*ay)*sqrt(bx*bx+by*by)))/2),lc=sqrt(oc[0]*oc[0]+oc[1]*oc[1]);rc0=min(rc,(r0-lc)/(kc-1));rc1=min(rc,(r1-lc)/(kc+1))}}if(!(da1>epsilon))context.moveTo(x01,y01);else if(rc1>epsilon){t0=cornerTangents(x00,y00,x01,y01,r1,rc1,cw);t1=cornerTangents(x11,y11,x10,y10,r1,rc1,cw);context.moveTo(t0.cx+t0.x01,t0.cy+t0.y01);if(rc1epsilon)||!(da0>epsilon))context.lineTo(x10,y10);else if(rc0>epsilon){t0=cornerTangents(x10,y10,x11,y11,r0,-rc0,cw);t1=cornerTangents(x01,y01,x00,y00,r0,-rc0,cw);context.lineTo(t0.cx+t0.x01,t0.cy+t0.y01);if(rc0=j;--k){output.point(x0z[k],y0z[k])}output.lineEnd();output.areaEnd()}}if(defined0){x0z[i]=+x0(d,i,data),y0z[i]=+y0(d,i,data);output.point(x1?+x1(d,i,data):x0z[i],y1?+y1(d,i,data):y0z[i])}}if(buffer)return output=null,buffer+""||null}function arealine(){return line().defined(defined).curve(curve).context(context)}area.x=function(_){return arguments.length?(x0=typeof _==="function"?_:constant(+_),x1=null,area):x0};area.x0=function(_){ +return arguments.length?(x0=typeof _==="function"?_:constant(+_),area):x0};area.x1=function(_){return arguments.length?(x1=_==null?null:typeof _==="function"?_:constant(+_),area):x1};area.y=function(_){return arguments.length?(y0=typeof _==="function"?_:constant(+_),y1=null,area):y0};area.y0=function(_){return arguments.length?(y0=typeof _==="function"?_:constant(+_),area):y0};area.y1=function(_){return arguments.length?(y1=_==null?null:typeof _==="function"?_:constant(+_),area):y1};area.lineX0=area.lineY0=function(){return arealine().x(x0).y(y0)};area.lineY1=function(){return arealine().x(x0).y(y1)};area.lineX1=function(){return arealine().x(x1).y(y0)};area.defined=function(_){return arguments.length?(defined=typeof _==="function"?_:constant(!!_),area):defined};area.curve=function(_){return arguments.length?(curve=_,context!=null&&(output=curve(context)),area):curve};area.context=function(_){return arguments.length?(_==null?context=output=null:output=curve(context=_),area):context};return area};var descending=function(a,b){return ba?1:b>=a?0:NaN};var identity=function(d){return d};var pie=function(){var value=identity,sortValues=descending,sort=null,startAngle=constant(0),endAngle=constant(tau),padAngle=constant(0);function pie(data){var i,n=data.length,j,k,sum=0,index=new Array(n),arcs=new Array(n),a0=+startAngle.apply(this,arguments),da=Math.min(tau,Math.max(-tau,endAngle.apply(this,arguments)-a0)),a1,p=Math.min(Math.abs(da)/n,padAngle.apply(this,arguments)),pa=p*(da<0?-1:1),v;for(i=0;i0){sum+=v}}if(sortValues!=null)index.sort(function(i,j){return sortValues(arcs[i],arcs[j])});else if(sort!=null)index.sort(function(i,j){return sort(data[i],data[j])});for(i=0,k=sum?(da-n*pa)/sum:0;i0?v*k:0)+pa,arcs[j]={data:data[j],index:i,value:v,startAngle:a0,endAngle:a1,padAngle:p}}return arcs}pie.value=function(_){return arguments.length?(value=typeof _==="function"?_:constant(+_),pie):value};pie.sortValues=function(_){return arguments.length?(sortValues=_,sort=null,pie):sortValues};pie.sort=function(_){return arguments.length?(sort=_,sortValues=null,pie):sort};pie.startAngle=function(_){return arguments.length?(startAngle=typeof _==="function"?_:constant(+_),pie):startAngle};pie.endAngle=function(_){return arguments.length?(endAngle=typeof _==="function"?_:constant(+_),pie):endAngle};pie.padAngle=function(_){return arguments.length?(padAngle=typeof _==="function"?_:constant(+_),pie):padAngle};return pie};var curveRadialLinear=curveRadial(curveLinear);function Radial(curve){this._curve=curve}Radial.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(a,r){this._curve.point(r*Math.sin(a),r*-Math.cos(a))}};function curveRadial(curve){function radial(context){return new Radial(curve(context))}radial._curve=curve;return radial}function lineRadial(l){var c=l.curve;l.angle=l.x,delete l.x;l.radius=l.y,delete l.y;l.curve=function(_){return arguments.length?c(curveRadial(_)):c()._curve};return l}var lineRadial$1=function(){return lineRadial(line().curve(curveRadialLinear))};var areaRadial=function(){var a=area().curve(curveRadialLinear),c=a.curve,x0=a.lineX0,x1=a.lineX1,y0=a.lineY0,y1=a.lineY1;a.angle=a.x,delete a.x;a.startAngle=a.x0,delete a.x0;a.endAngle=a.x1,delete a.x1;a.radius=a.y,delete a.y;a.innerRadius=a.y0,delete a.y0;a.outerRadius=a.y1,delete a.y1;a.lineStartAngle=function(){return lineRadial(x0())},delete a.lineX0;a.lineEndAngle=function(){return lineRadial(x1())},delete a.lineX1;a.lineInnerRadius=function(){return lineRadial(y0())},delete a.lineY0;a.lineOuterRadius=function(){return lineRadial(y1())},delete a.lineY1;a.curve=function(_){return arguments.length?c(curveRadial(_)):c()._curve};return a};var pointRadial=function(x,y){return[(y=+y)*Math.cos(x-=Math.PI/2),y*Math.sin(x)]};var slice=Array.prototype.slice;function linkSource(d){return d.source}function linkTarget(d){return d.target}function link(curve){var source=linkSource,target=linkTarget,x$$1=x,y$$1=y,context=null;function link(){var buffer,argv=slice.call(arguments),s=source.apply(this,argv),t=target.apply(this,argv);if(!context)context=buffer=d3Path.path();curve(context,+x$$1.apply(this,(argv[0]=s,argv)),+y$$1.apply(this,argv),+x$$1.apply(this,(argv[0]=t,argv)),+y$$1.apply(this,argv));if(buffer)return context=null,buffer+""||null}link.source=function(_){return arguments.length?(source=_,link):source};link.target=function(_){return arguments.length?(target=_,link):target};link.x=function(_){return arguments.length?(x$$1=typeof _==="function"?_:constant(+_),link):x$$1};link.y=function(_){return arguments.length?(y$$1=typeof _==="function"?_:constant(+_),link):y$$1};link.context=function(_){return arguments.length?(context=_==null?null:_,link):context};return link}function curveHorizontal(context,x0,y0,x1,y1){context.moveTo(x0,y0);context.bezierCurveTo(x0=(x0+x1)/2,y0,x0,y1,x1,y1)}function curveVertical(context,x0,y0,x1,y1){context.moveTo(x0,y0);context.bezierCurveTo(x0,y0=(y0+y1)/2,x1,y0,x1,y1)}function curveRadial$1(context,x0,y0,x1,y1){var p0=pointRadial(x0,y0),p1=pointRadial(x0,y0=(y0+y1)/2),p2=pointRadial(x1,y0),p3=pointRadial(x1,y1);context.moveTo(p0[0],p0[1]);context.bezierCurveTo(p1[0],p1[1],p2[0],p2[1],p3[0],p3[1])}function linkHorizontal(){return link(curveHorizontal)}function linkVertical(){return link(curveVertical)}function linkRadial(){var l=link(curveRadial$1);l.angle=l.x,delete l.x;l.radius=l.y,delete l.y;return l}var circle={draw:function(context,size){var r=Math.sqrt(size/pi);context.moveTo(r,0);context.arc(0,0,r,0,tau)}};var cross={draw:function(context,size){var r=Math.sqrt(size/5)/2;context.moveTo(-3*r,-r);context.lineTo(-r,-r);context.lineTo(-r,-3*r);context.lineTo(r,-3*r);context.lineTo(r,-r);context.lineTo(3*r,-r);context.lineTo(3*r,r);context.lineTo(r,r);context.lineTo(r,3*r);context.lineTo(-r,3*r);context.lineTo(-r,r);context.lineTo(-3*r,r);context.closePath()}};var tan30=Math.sqrt(1/3);var tan30_2=tan30*2;var diamond={draw:function(context,size){var y=Math.sqrt(size/tan30_2),x=y*tan30;context.moveTo(0,-y);context.lineTo(x,0);context.lineTo(0,y);context.lineTo(-x,0);context.closePath()}};var ka=.8908130915292852;var kr=Math.sin(pi/10)/Math.sin(7*pi/10);var kx=Math.sin(tau/10)*kr;var ky=-Math.cos(tau/10)*kr;var star={draw:function(context,size){var r=Math.sqrt(size*ka),x=kx*r,y=ky*r;context.moveTo(0,-r);context.lineTo(x,y);for(var i=1;i<5;++i){var a=tau*i/5,c=Math.cos(a),s=Math.sin(a);context.lineTo(s*r,-c*r);context.lineTo(c*x-s*y,s*x+c*y)}context.closePath()}};var square={draw:function(context,size){var w=Math.sqrt(size),x=-w/2;context.rect(x,x,w,w)}};var sqrt3=Math.sqrt(3);var triangle={draw:function(context,size){var y=-Math.sqrt(size/(sqrt3*3));context.moveTo(0,y*2);context.lineTo(-sqrt3*y,-y);context.lineTo(sqrt3*y,-y);context.closePath()}};var c=-.5;var s=Math.sqrt(3)/2;var k=1/Math.sqrt(12);var a=(k/2+1)*3;var wye={draw:function(context,size){var r=Math.sqrt(size/a),x0=r/2,y0=r*k,x1=x0,y1=r*k+r,x2=-x1,y2=y1;context.moveTo(x0,y0);context.lineTo(x1,y1);context.lineTo(x2,y2);context.lineTo(c*x0-s*y0,s*x0+c*y0);context.lineTo(c*x1-s*y1,s*x1+c*y1);context.lineTo(c*x2-s*y2,s*x2+c*y2);context.lineTo(c*x0+s*y0,c*y0-s*x0);context.lineTo(c*x1+s*y1,c*y1-s*x1);context.lineTo(c*x2+s*y2,c*y2-s*x2);context.closePath()}};var symbols=[circle,cross,diamond,square,star,triangle,wye];var symbol=function(){var type=constant(circle),size=constant(64),context=null;function symbol(){var buffer;if(!context)context=buffer=d3Path.path();type.apply(this,arguments).draw(context,+size.apply(this,arguments));if(buffer)return context=null,buffer+""||null}symbol.type=function(_){return arguments.length?(type=typeof _==="function"?_:constant(_),symbol):type};symbol.size=function(_){return arguments.length?(size=typeof _==="function"?_:constant(+_),symbol):size};symbol.context=function(_){return arguments.length?(context=_==null?null:_,symbol):context};return symbol};var noop=function(){};function point(that,x,y){that._context.bezierCurveTo((2*that._x0+that._x1)/3,(2*that._y0+that._y1)/3,(that._x0+2*that._x1)/3,(that._y0+2*that._y1)/3,(that._x0+4*that._x1+x)/6,(that._y0+4*that._y1+y)/6)}function Basis(context){this._context=context}Basis.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN;this._point=0},lineEnd:function(){switch(this._point){case 3:point(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:point(this,x,y);break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y}};var basis=function(context){return new Basis(context)};function BasisClosed(context){this._context=context}BasisClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN;this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2);this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3);this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3);this._context.closePath();break}case 3:{this.point(this._x2,this._y2);this.point(this._x3,this._y3);this.point(this._x4,this._y4);break}}},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._x2=x,this._y2=y;break;case 1:this._point=2;this._x3=x,this._y3=y;break;case 2:this._point=3;this._x4=x,this._y4=y;this._context.moveTo((this._x0+4*this._x1+x)/6,(this._y0+4*this._y1+y)/6);break;default:point(this,x,y);break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y}};var basisClosed=function(context){return new BasisClosed(context)};function BasisOpen(context){this._context=context}BasisOpen.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN;this._point=0},lineEnd:function(){if(this._line||this._line!==0&&this._point===3)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var x0=(this._x0+4*this._x1+x)/6,y0=(this._y0+4*this._y1+y)/6;this._line?this._context.lineTo(x0,y0):this._context.moveTo(x0,y0);break;case 3:this._point=4;default:point(this,x,y);break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y}};var basisOpen=function(context){return new BasisOpen(context)};function Bundle(context,beta){this._basis=new Basis(context);this._beta=beta}Bundle.prototype={lineStart:function(){this._x=[];this._y=[];this._basis.lineStart()},lineEnd:function(){var x=this._x,y=this._y,j=x.length-1;if(j>0){var x0=x[0],y0=y[0],dx=x[j]-x0,dy=y[j]-y0,i=-1,t;while(++i<=j){t=i/j;this._basis.point(this._beta*x[i]+(1-this._beta)*(x0+t*dx),this._beta*y[i]+(1-this._beta)*(y0+t*dy))}}this._x=this._y=null;this._basis.lineEnd()},point:function(x,y){this._x.push(+x);this._y.push(+y)}};var bundle=function custom(beta){function bundle(context){return beta===1?new Basis(context):new Bundle(context,beta)}bundle.beta=function(beta){return custom(+beta)};return bundle}(.85);function point$1(that,x,y){that._context.bezierCurveTo(that._x1+that._k*(that._x2-that._x0),that._y1+that._k*(that._y2-that._y0),that._x2+that._k*(that._x1-x),that._y2+that._k*(that._y1-y),that._x2,that._y2)}function Cardinal(context,tension){this._context=context;this._k=(1-tension)/6}Cardinal.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:point$1(this,this._x1,this._y1);break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;this._x1=x,this._y1=y;break;case 2:this._point=3;default:point$1(this,x,y);break}this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var cardinal=function custom(tension){function cardinal(context){return new Cardinal(context,tension)}cardinal.tension=function(tension){return custom(+tension)};return cardinal}(0);function CardinalClosed(context,tension){this._context=context;this._k=(1-tension)/6}CardinalClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN;this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3);this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3);this._context.closePath();break}case 3:{this.point(this._x3,this._y3);this.point(this._x4,this._y4);this.point(this._x5,this._y5);break}}},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._x3=x,this._y3=y;break;case 1:this._point=2;this._context.moveTo(this._x4=x,this._y4=y);break;case 2:this._point=3;this._x5=x,this._y5=y;break;default:point$1(this,x,y);break}this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var cardinalClosed=function custom(tension){function cardinal(context){return new CardinalClosed(context,tension)}cardinal.tension=function(tension){return custom(+tension)};return cardinal}(0);function CardinalOpen(context,tension){this._context=context;this._k=(1-tension)/6}CardinalOpen.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._point=0},lineEnd:function(){if(this._line||this._line!==0&&this._point===3)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:point$1(this,x,y);break}this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var cardinalOpen=function custom(tension){function cardinal(context){return new CardinalOpen(context,tension)}cardinal.tension=function(tension){return custom(+tension)};return cardinal}(0);function point$2(that,x,y){var x1=that._x1,y1=that._y1,x2=that._x2,y2=that._y2;if(that._l01_a>epsilon){var a=2*that._l01_2a+3*that._l01_a*that._l12_a+that._l12_2a,n=3*that._l01_a*(that._l01_a+that._l12_a);x1=(x1*a-that._x0*that._l12_2a+that._x2*that._l01_2a)/n;y1=(y1*a-that._y0*that._l12_2a+that._y2*that._l01_2a)/n}if(that._l23_a>epsilon){var b=2*that._l23_2a+3*that._l23_a*that._l12_a+that._l12_2a,m=3*that._l23_a*(that._l23_a+that._l12_a);x2=(x2*b+that._x1*that._l23_2a-x*that._l12_2a)/m;y2=(y2*b+that._y1*that._l23_2a-y*that._l12_2a)/m}that._context.bezierCurveTo(x1,y1,x2,y2,that._x2,that._y2)}function CatmullRom(context,alpha){this._context=context;this._alpha=alpha}CatmullRom.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;if(this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;default:point$2(this,x,y);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a;this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a;this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var catmullRom=function custom(alpha){function catmullRom(context){return alpha?new CatmullRom(context,alpha):new Cardinal(context,0)}catmullRom.alpha=function(alpha){return custom(+alpha)};return catmullRom}(.5);function CatmullRomClosed(context,alpha){this._context=context;this._alpha=alpha}CatmullRomClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN;this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3);this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3);this._context.closePath();break}case 3:{this.point(this._x3,this._y3);this.point(this._x4,this._y4);this.point(this._x5,this._y5);break}}},point:function(x,y){x=+x,y=+y;if(this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1;this._x3=x,this._y3=y;break;case 1:this._point=2;this._context.moveTo(this._x4=x,this._y4=y);break;case 2:this._point=3;this._x5=x,this._y5=y;break;default:point$2(this,x,y);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a;this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a;this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var catmullRomClosed=function custom(alpha){function catmullRom(context){return alpha?new CatmullRomClosed(context,alpha):new CardinalClosed(context,0)}catmullRom.alpha=function(alpha){return custom(+alpha)};return catmullRom}(.5);function CatmullRomOpen(context,alpha){this._context=context;this._alpha=alpha}CatmullRomOpen.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){if(this._line||this._line!==0&&this._point===3)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;if(this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:point$2(this,x,y);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a;this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a;this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var catmullRomOpen=function custom(alpha){function catmullRom(context){return alpha?new CatmullRomOpen(context,alpha):new CardinalOpen(context,0)}catmullRom.alpha=function(alpha){return custom(+alpha)};return catmullRom}(.5);function LinearClosed(context){this._context=context}LinearClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._point=0},lineEnd:function(){if(this._point)this._context.closePath()},point:function(x,y){x=+x,y=+y;if(this._point)this._context.lineTo(x,y);else this._point=1,this._context.moveTo(x,y)}};var linearClosed=function(context){return new LinearClosed(context)};function sign(x){return x<0?-1:1}function slope3(that,x2,y2){var h0=that._x1-that._x0,h1=x2-that._x1,s0=(that._y1-that._y0)/(h0||h1<0&&-0),s1=(y2-that._y1)/(h1||h0<0&&-0),p=(s0*h1+s1*h0)/(h0+h1);return(sign(s0)+sign(s1))*Math.min(Math.abs(s0),Math.abs(s1),.5*Math.abs(p))||0}function slope2(that,t){var h=that._x1-that._x0;return h?(3*(that._y1-that._y0)/h-t)/2:t}function point$3(that,t0,t1){var x0=that._x0,y0=that._y0,x1=that._x1,y1=that._y1,dx=(x1-x0)/3;that._context.bezierCurveTo(x0+dx,y0+dx*t0,x1-dx,y1-dx*t1,x1,y1)}function MonotoneX(context){this._context=context}MonotoneX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN;this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:point$3(this,this._t0,slope2(this,this._t0));break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){var t1=NaN;x=+x,y=+y;if(x===this._x1&&y===this._y1)return;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;point$3(this,slope2(this,t1=slope3(this,x,y)),t1);break;default:point$3(this,this._t0,t1=slope3(this,x,y));break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y;this._t0=t1}};function MonotoneY(context){this._context=new ReflectContext(context)}(MonotoneY.prototype=Object.create(MonotoneX.prototype)).point=function(x,y){MonotoneX.prototype.point.call(this,y,x)};function ReflectContext(context){this._context=context}ReflectContext.prototype={moveTo:function(x,y){this._context.moveTo(y,x)},closePath:function(){this._context.closePath()},lineTo:function(x,y){this._context.lineTo(y,x)},bezierCurveTo:function(x1,y1,x2,y2,x,y){this._context.bezierCurveTo(y1,x1,y2,x2,y,x)}};function monotoneX(context){return new MonotoneX(context)}function monotoneY(context){return new MonotoneY(context)}function Natural(context){this._context=context}Natural.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[];this._y=[]},lineEnd:function(){var x=this._x,y=this._y,n=x.length;if(n){this._line?this._context.lineTo(x[0],y[0]):this._context.moveTo(x[0],y[0]);if(n===2){this._context.lineTo(x[1],y[1])}else{var px=controlPoints(x),py=controlPoints(y);for(var i0=0,i1=1;i1=0;--i)a[i]=(r[i]-a[i+1])/b[i];b[n-1]=(x[n]+a[n-1])/2;for(i=0;i=0)this._t=1-this._t,this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;default:{if(this._t<=0){this._context.lineTo(this._x,y);this._context.lineTo(x,y)}else{var x1=this._x*(1-this._t)+x*this._t;this._context.lineTo(x1,this._y);this._context.lineTo(x1,y)}break}}this._x=x,this._y=y}};var step=function(context){return new Step(context,.5)};function stepBefore(context){return new Step(context,0)}function stepAfter(context){return new Step(context,1)}var none=function(series,order){if(!((n=series.length)>1))return;for(var i=1,j,s0,s1=series[order[0]],n,m=s1.length;i=0)o[n]=n;return o};function stackValue(d,key){return d[key]}var stack=function(){var keys=constant([]),order=none$1,offset=none,value=stackValue;function stack(data){var kz=keys.apply(this,arguments),i,m=data.length,n=kz.length,sz=new Array(n),oz;for(i=0;i0))return;for(var i,n,j=0,m=series[0].length,y;j1))return;for(var i,j=0,d,dy,yp,yn,n,m=series[order[0]].length;j=0){d[0]=yp,d[1]=yp+=dy}else if(dy<0){d[1]=yn,d[0]=yn+=dy}else{d[0]=yp}}}};var silhouette=function(series,order){if(!((n=series.length)>0))return;for(var j=0,s0=series[order[0]],n,m=s0.length;j0)||!((m=(s0=series[order[0]]).length)>0))return;for(var y=0,j=1,s0,m,n;j53)return null;if(!("w"in d))d.w=1;if("Z"in d){week=utcDate(newYear(d.y)),day=week.getUTCDay();week=day>4||day===0?d3Time.utcMonday.ceil(week):d3Time.utcMonday(week);week=d3Time.utcDay.offset(week,(d.V-1)*7);d.y=week.getUTCFullYear();d.m=week.getUTCMonth();d.d=week.getUTCDate()+(d.w+6)%7}else{week=newDate(newYear(d.y)),day=week.getDay();week=day>4||day===0?d3Time.timeMonday.ceil(week):d3Time.timeMonday(week);week=d3Time.timeDay.offset(week,(d.V-1)*7);d.y=week.getFullYear();d.m=week.getMonth();d.d=week.getDate()+(d.w+6)%7}}else if("W"in d||"U"in d){if(!("w"in d))d.w="u"in d?d.u%7:"W"in d?1:0;day="Z"in d?utcDate(newYear(d.y)).getUTCDay():newDate(newYear(d.y)).getDay();d.m=0;d.d="W"in d?(d.w+6)%7+d.W*7-(day+5)%7:d.w+d.U*7-(day+6)%7}if("Z"in d){d.H+=d.Z/100|0;d.M+=d.Z%100;return utcDate(d)}return newDate(d)}}function parseSpecifier(d,specifier,string,j){var i=0,n=specifier.length,m=string.length,c,parse;while(i=m)return-1;c=specifier.charCodeAt(i++);if(c===37){c=specifier.charAt(i++);parse=parses[c in pads?specifier.charAt(i++):c];if(!parse||(j=parse(d,string,j))<0)return-1}else if(c!=string.charCodeAt(j++)){return-1}}return j}function parsePeriod(d,string,i){var n=periodRe.exec(string.slice(i));return n?(d.p=periodLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseShortWeekday(d,string,i){var n=shortWeekdayRe.exec(string.slice(i));return n?(d.w=shortWeekdayLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseWeekday(d,string,i){var n=weekdayRe.exec(string.slice(i));return n?(d.w=weekdayLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseShortMonth(d,string,i){var n=shortMonthRe.exec(string.slice(i));return n?(d.m=shortMonthLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseMonth(d,string,i){var n=monthRe.exec(string.slice(i));return n?(d.m=monthLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseLocaleDateTime(d,string,i){return parseSpecifier(d,locale_dateTime,string,i)}function parseLocaleDate(d,string,i){return parseSpecifier(d,locale_date,string,i)}function parseLocaleTime(d,string,i){return parseSpecifier(d,locale_time,string,i)}function formatShortWeekday(d){return locale_shortWeekdays[d.getDay()]}function formatWeekday(d){return locale_weekdays[d.getDay()]}function formatShortMonth(d){return locale_shortMonths[d.getMonth()]}function formatMonth(d){return locale_months[d.getMonth()]}function formatPeriod(d){return locale_periods[+(d.getHours()>=12)]}function formatUTCShortWeekday(d){return locale_shortWeekdays[d.getUTCDay()]}function formatUTCWeekday(d){return locale_weekdays[d.getUTCDay()]}function formatUTCShortMonth(d){return locale_shortMonths[d.getUTCMonth()]}function formatUTCMonth(d){return locale_months[d.getUTCMonth()]}function formatUTCPeriod(d){return locale_periods[+(d.getUTCHours()>=12)]}return{format:function(specifier){var f=newFormat(specifier+="",formats);f.toString=function(){return specifier};return f},parse:function(specifier){var p=newParse(specifier+="",localDate);p.toString=function(){return specifier};return p},utcFormat:function(specifier){var f=newFormat(specifier+="",utcFormats);f.toString=function(){return specifier};return f},utcParse:function(specifier){var p=newParse(specifier,utcDate);p.toString=function(){return specifier};return p}}}var pads={"-":"",_:" ",0:"0"};var numberRe=/^\s*\d+/;var percentRe=/^%/;var requoteRe=/[\\^$*+?|[\]().{}]/g;function pad(value,fill,width){var sign=value<0?"-":"",string=(sign?-value:value)+"",length=string.length;return sign+(length68?1900:2e3),i+n[0].length):-1}function parseZone(d,string,i){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i,i+6));return n?(d.Z=n[1]?0:-(n[2]+(n[3]||"00")),i+n[0].length):-1}function parseMonthNumber(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.m=n[0]-1,i+n[0].length):-1}function parseDayOfMonth(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.d=+n[0],i+n[0].length):-1}function parseDayOfYear(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.m=0,d.d=+n[0],i+n[0].length):-1}function parseHour24(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.H=+n[0],i+n[0].length):-1}function parseMinutes(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.M=+n[0],i+n[0].length):-1}function parseSeconds(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.S=+n[0],i+n[0].length):-1}function parseMilliseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.L=+n[0],i+n[0].length):-1}function parseMicroseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+6));return n?(d.L=Math.floor(n[0]/1e3),i+n[0].length):-1}function parseLiteralPercent(d,string,i){var n=percentRe.exec(string.slice(i,i+1));return n?i+n[0].length:-1}function parseUnixTimestamp(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0],i+n[0].length):-1}function parseUnixTimestampSeconds(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0]*1e3,i+n[0].length):-1}function formatDayOfMonth(d,p){return pad(d.getDate(),p,2)}function formatHour24(d,p){return pad(d.getHours(),p,2)}function formatHour12(d,p){return pad(d.getHours()%12||12,p,2)}function formatDayOfYear(d,p){return pad(1+d3Time.timeDay.count(d3Time.timeYear(d),d),p,3)}function formatMilliseconds(d,p){return pad(d.getMilliseconds(),p,3)}function formatMicroseconds(d,p){return formatMilliseconds(d,p)+"000"}function formatMonthNumber(d,p){return pad(d.getMonth()+1,p,2)}function formatMinutes(d,p){return pad(d.getMinutes(),p,2)}function formatSeconds(d,p){return pad(d.getSeconds(),p,2)}function formatWeekdayNumberMonday(d){var day=d.getDay();return day===0?7:day}function formatWeekNumberSunday(d,p){return pad(d3Time.timeSunday.count(d3Time.timeYear(d),d),p,2)}function formatWeekNumberISO(d,p){var day=d.getDay();d=day>=4||day===0?d3Time.timeThursday(d):d3Time.timeThursday.ceil(d);return pad(d3Time.timeThursday.count(d3Time.timeYear(d),d)+(d3Time.timeYear(d).getDay()===4),p,2)}function formatWeekdayNumberSunday(d){return d.getDay()}function formatWeekNumberMonday(d,p){return pad(d3Time.timeMonday.count(d3Time.timeYear(d),d),p,2)}function formatYear(d,p){return pad(d.getFullYear()%100,p,2)}function formatFullYear(d,p){return pad(d.getFullYear()%1e4,p,4)}function formatZone(d){var z=d.getTimezoneOffset();return(z>0?"-":(z*=-1,"+"))+pad(z/60|0,"0",2)+pad(z%60,"0",2)}function formatUTCDayOfMonth(d,p){return pad(d.getUTCDate(),p,2)}function formatUTCHour24(d,p){return pad(d.getUTCHours(),p,2)}function formatUTCHour12(d,p){return pad(d.getUTCHours()%12||12,p,2)}function formatUTCDayOfYear(d,p){return pad(1+d3Time.utcDay.count(d3Time.utcYear(d),d),p,3)}function formatUTCMilliseconds(d,p){return pad(d.getUTCMilliseconds(),p,3)}function formatUTCMicroseconds(d,p){return formatUTCMilliseconds(d,p)+"000"}function formatUTCMonthNumber(d,p){return pad(d.getUTCMonth()+1,p,2)}function formatUTCMinutes(d,p){return pad(d.getUTCMinutes(),p,2)}function formatUTCSeconds(d,p){return pad(d.getUTCSeconds(),p,2)}function formatUTCWeekdayNumberMonday(d){var dow=d.getUTCDay();return dow===0?7:dow}function formatUTCWeekNumberSunday(d,p){return pad(d3Time.utcSunday.count(d3Time.utcYear(d),d),p,2)}function formatUTCWeekNumberISO(d,p){var day=d.getUTCDay();d=day>=4||day===0?d3Time.utcThursday(d):d3Time.utcThursday.ceil(d);return pad(d3Time.utcThursday.count(d3Time.utcYear(d),d)+(d3Time.utcYear(d).getUTCDay()===4),p,2)}function formatUTCWeekdayNumberSunday(d){return d.getUTCDay()}function formatUTCWeekNumberMonday(d,p){return pad(d3Time.utcMonday.count(d3Time.utcYear(d),d),p,2)}function formatUTCYear(d,p){return pad(d.getUTCFullYear()%100,p,2)}function formatUTCFullYear(d,p){return pad(d.getUTCFullYear()%1e4,p,4)}function formatUTCZone(){return"+0000"}function formatLiteralPercent(){return"%"}function formatUnixTimestamp(d){return+d}function formatUnixTimestampSeconds(d){return Math.floor(+d/1e3)}var locale;defaultLocale({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function defaultLocale(definition){locale=formatLocale(definition);exports.timeFormat=locale.format;exports.timeParse=locale.parse;exports.utcFormat=locale.utcFormat;exports.utcParse=locale.utcParse;return locale}var isoSpecifier="%Y-%m-%dT%H:%M:%S.%LZ";function formatIsoNative(date){return date.toISOString()}var formatIso=Date.prototype.toISOString?formatIsoNative:exports.utcFormat(isoSpecifier);function parseIsoNative(string){var date=new Date(string);return isNaN(date)?null:date}var parseIso=+new Date("2000-01-01T00:00:00.000Z")?parseIsoNative:exports.utcParse(isoSpecifier);exports.timeFormatDefaultLocale=defaultLocale;exports.timeFormatLocale=formatLocale;exports.isoFormat=formatIso;exports.isoParse=parseIso;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-time":17}],17:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var t0=new Date;var t1=new Date;function newInterval(floori,offseti,count,field){function interval(date){return floori(date=new Date(+date)),date}interval.floor=interval;interval.ceil=function(date){return floori(date=new Date(date-1)),offseti(date,1),floori(date),date};interval.round=function(date){var d0=interval(date),d1=interval.ceil(date);return date-d00))return range;do{range.push(previous=new Date(+start)),offseti(start,step),floori(start)}while(previous=date)while(floori(date),!test(date))date.setTime(date-1)},function(date,step){if(date>=date){if(step<0)while(++step<=0){while(offseti(date,-1),!test(date)){}}else while(--step>=0){while(offseti(date,+1),!test(date)){}}}})};if(count){interval.count=function(start,end){t0.setTime(+start),t1.setTime(+end);floori(t0),floori(t1);return Math.floor(count(t0,t1))};interval.every=function(step){step=Math.floor(step);return!isFinite(step)||!(step>0)?null:!(step>1)?interval:interval.filter(field?function(d){return field(d)%step===0}:function(d){return interval.count(0,d)%step===0})}}return interval}var millisecond=newInterval(function(){},function(date,step){date.setTime(+date+step)},function(start,end){return end-start});millisecond.every=function(k){k=Math.floor(k);if(!isFinite(k)||!(k>0))return null;if(!(k>1))return millisecond;return newInterval(function(date){date.setTime(Math.floor(date/k)*k)},function(date,step){date.setTime(+date+step*k)},function(start,end){return(end-start)/k})};var milliseconds=millisecond.range;var durationSecond=1e3;var durationMinute=6e4;var durationHour=36e5;var durationDay=864e5;var durationWeek=6048e5;var second=newInterval(function(date){date.setTime(Math.floor(date/durationSecond)*durationSecond)},function(date,step){date.setTime(+date+step*durationSecond)},function(start,end){return(end-start)/durationSecond},function(date){return date.getUTCSeconds()});var seconds=second.range;var minute=newInterval(function(date){date.setTime(Math.floor(date/durationMinute)*durationMinute)},function(date,step){date.setTime(+date+step*durationMinute)},function(start,end){return(end-start)/durationMinute},function(date){return date.getMinutes()});var minutes=minute.range;var hour=newInterval(function(date){var offset=date.getTimezoneOffset()*durationMinute%durationHour;if(offset<0)offset+=durationHour;date.setTime(Math.floor((+date-offset)/durationHour)*durationHour+offset)},function(date,step){date.setTime(+date+step*durationHour)},function(start,end){return(end-start)/durationHour},function(date){return date.getHours()});var hours=hour.range;var day=newInterval(function(date){date.setHours(0,0,0,0)},function(date,step){date.setDate(date.getDate()+step)},function(start,end){return(end-start-(end.getTimezoneOffset()-start.getTimezoneOffset())*durationMinute)/durationDay},function(date){return date.getDate()-1});var days=day.range;function weekday(i){return newInterval(function(date){date.setDate(date.getDate()-(date.getDay()+7-i)%7);date.setHours(0,0,0,0)},function(date,step){date.setDate(date.getDate()+step*7)},function(start,end){return(end-start-(end.getTimezoneOffset()-start.getTimezoneOffset())*durationMinute)/durationWeek})}var sunday=weekday(0);var monday=weekday(1);var tuesday=weekday(2);var wednesday=weekday(3);var thursday=weekday(4);var friday=weekday(5);var saturday=weekday(6);var sundays=sunday.range;var mondays=monday.range;var tuesdays=tuesday.range;var wednesdays=wednesday.range;var thursdays=thursday.range;var fridays=friday.range;var saturdays=saturday.range;var month=newInterval(function(date){date.setDate(1);date.setHours(0,0,0,0)},function(date,step){date.setMonth(date.getMonth()+step)},function(start,end){return end.getMonth()-start.getMonth()+(end.getFullYear()-start.getFullYear())*12},function(date){return date.getMonth()});var months=month.range;var year=newInterval(function(date){date.setMonth(0,1);date.setHours(0,0,0,0)},function(date,step){date.setFullYear(date.getFullYear()+step)},function(start,end){return end.getFullYear()-start.getFullYear()},function(date){return date.getFullYear()});year.every=function(k){return!isFinite(k=Math.floor(k))||!(k>0)?null:newInterval(function(date){date.setFullYear(Math.floor(date.getFullYear()/k)*k);date.setMonth(0,1);date.setHours(0,0,0,0)},function(date,step){date.setFullYear(date.getFullYear()+step*k)})};var years=year.range;var utcMinute=newInterval(function(date){date.setUTCSeconds(0,0)},function(date,step){date.setTime(+date+step*durationMinute)},function(start,end){return(end-start)/durationMinute},function(date){return date.getUTCMinutes()});var utcMinutes=utcMinute.range;var utcHour=newInterval(function(date){date.setUTCMinutes(0,0,0)},function(date,step){date.setTime(+date+step*durationHour)},function(start,end){return(end-start)/durationHour},function(date){return date.getUTCHours()});var utcHours=utcHour.range;var utcDay=newInterval(function(date){date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCDate(date.getUTCDate()+step)},function(start,end){return(end-start)/durationDay},function(date){return date.getUTCDate()-1});var utcDays=utcDay.range;function utcWeekday(i){return newInterval(function(date){date.setUTCDate(date.getUTCDate()-(date.getUTCDay()+7-i)%7);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCDate(date.getUTCDate()+step*7)},function(start,end){return(end-start)/durationWeek})}var utcSunday=utcWeekday(0);var utcMonday=utcWeekday(1);var utcTuesday=utcWeekday(2);var utcWednesday=utcWeekday(3);var utcThursday=utcWeekday(4);var utcFriday=utcWeekday(5);var utcSaturday=utcWeekday(6);var utcSundays=utcSunday.range;var utcMondays=utcMonday.range;var utcTuesdays=utcTuesday.range;var utcWednesdays=utcWednesday.range;var utcThursdays=utcThursday.range;var utcFridays=utcFriday.range;var utcSaturdays=utcSaturday.range;var utcMonth=newInterval(function(date){date.setUTCDate(1);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCMonth(date.getUTCMonth()+step)},function(start,end){return end.getUTCMonth()-start.getUTCMonth()+(end.getUTCFullYear()-start.getUTCFullYear())*12},function(date){return date.getUTCMonth()});var utcMonths=utcMonth.range;var utcYear=newInterval(function(date){date.setUTCMonth(0,1);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCFullYear(date.getUTCFullYear()+step)},function(start,end){return end.getUTCFullYear()-start.getUTCFullYear()},function(date){return date.getUTCFullYear()});utcYear.every=function(k){return!isFinite(k=Math.floor(k))||!(k>0)?null:newInterval(function(date){date.setUTCFullYear(Math.floor(date.getUTCFullYear()/k)*k);date.setUTCMonth(0,1);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCFullYear(date.getUTCFullYear()+step*k)})};var utcYears=utcYear.range;exports.timeInterval=newInterval;exports.timeMillisecond=millisecond;exports.timeMilliseconds=milliseconds;exports.utcMillisecond=millisecond;exports.utcMilliseconds=milliseconds;exports.timeSecond=second;exports.timeSeconds=seconds;exports.utcSecond=second;exports.utcSeconds=seconds;exports.timeMinute=minute;exports.timeMinutes=minutes;exports.timeHour=hour;exports.timeHours=hours;exports.timeDay=day;exports.timeDays=days;exports.timeWeek=sunday;exports.timeWeeks=sundays;exports.timeSunday=sunday;exports.timeSundays=sundays;exports.timeMonday=monday;exports.timeMondays=mondays;exports.timeTuesday=tuesday;exports.timeTuesdays=tuesdays;exports.timeWednesday=wednesday;exports.timeWednesdays=wednesdays;exports.timeThursday=thursday;exports.timeThursdays=thursdays;exports.timeFriday=friday;exports.timeFridays=fridays;exports.timeSaturday=saturday;exports.timeSaturdays=saturdays;exports.timeMonth=month;exports.timeMonths=months;exports.timeYear=year;exports.timeYears=years;exports.utcMinute=utcMinute;exports.utcMinutes=utcMinutes;exports.utcHour=utcHour;exports.utcHours=utcHours;exports.utcDay=utcDay;exports.utcDays=utcDays;exports.utcWeek=utcSunday;exports.utcWeeks=utcSundays;exports.utcSunday=utcSunday;exports.utcSundays=utcSundays;exports.utcMonday=utcMonday;exports.utcMondays=utcMondays;exports.utcTuesday=utcTuesday;exports.utcTuesdays=utcTuesdays;exports.utcWednesday=utcWednesday;exports.utcWednesdays=utcWednesdays;exports.utcThursday=utcThursday;exports.utcThursdays=utcThursdays;exports.utcFriday=utcFriday;exports.utcFridays=utcFridays;exports.utcSaturday=utcSaturday;exports.utcSaturdays=utcSaturdays;exports.utcMonth=utcMonth;exports.utcMonths=utcMonths;exports.utcYear=utcYear;exports.utcYears=utcYears;Object.defineProperty(exports,"__esModule",{value:true})})},{}],18:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var constant=function(x){return function(){return x}};function x(d){return d[0]}function y(d){return d[1]}function RedBlackTree(){this._=null}function RedBlackNode(node){node.U=node.C=node.L=node.R=node.P=node.N=null}RedBlackTree.prototype={constructor:RedBlackTree,insert:function(after,node){var parent,grandpa,uncle;if(after){node.P=after;node.N=after.N;if(after.N)after.N.P=node;after.N=node;if(after.R){after=after.R;while(after.L)after=after.L;after.L=node}else{after.R=node}parent=after}else if(this._){after=RedBlackFirst(this._);node.P=null;node.N=after;after.P=after.L=node;parent=after}else{node.P=node.N=null;this._=node;parent=null}node.L=node.R=null;node.U=parent;node.C=true;after=node;while(parent&&parent.C){grandpa=parent.U;if(parent===grandpa.L){uncle=grandpa.R;if(uncle&&uncle.C){parent.C=uncle.C=false;grandpa.C=true;after=grandpa}else{if(after===parent.R){RedBlackRotateLeft(this,parent);after=parent;parent=after.U}parent.C=false;grandpa.C=true;RedBlackRotateRight(this,grandpa)}}else{uncle=grandpa.L;if(uncle&&uncle.C){parent.C=uncle.C=false;grandpa.C=true;after=grandpa}else{if(after===parent.L){RedBlackRotateRight(this,parent);after=parent;parent=after.U}parent.C=false;grandpa.C=true;RedBlackRotateLeft(this,grandpa)}}parent=after.U}this._.C=false},remove:function(node){if(node.N)node.N.P=node.P;if(node.P)node.P.N=node.N;node.N=node.P=null;var parent=node.U,sibling,left=node.L,right=node.R,next,red;if(!left)next=right;else if(!right)next=left;else next=RedBlackFirst(right);if(parent){if(parent.L===node)parent.L=next;else parent.R=next}else{this._=next}if(left&&right){red=next.C;next.C=node.C;next.L=left;left.U=next;if(next!==right){parent=next.U;next.U=node.U;node=next.R;parent.L=node;next.R=right;right.U=next}else{next.U=parent;parent=next;node=next.R}}else{red=node.C;node=next}if(node)node.U=parent;if(red)return;if(node&&node.C){node.C=false;return}do{if(node===this._)break;if(node===parent.L){sibling=parent.R;if(sibling.C){sibling.C=false;parent.C=true;RedBlackRotateLeft(this,parent);sibling=parent.R}if(sibling.L&&sibling.L.C||sibling.R&&sibling.R.C){if(!sibling.R||!sibling.R.C){sibling.L.C=false;sibling.C=true;RedBlackRotateRight(this,sibling);sibling=parent.R}sibling.C=parent.C;parent.C=sibling.R.C=false;RedBlackRotateLeft(this,parent);node=this._;break}}else{sibling=parent.L;if(sibling.C){sibling.C=false;parent.C=true;RedBlackRotateRight(this,parent);sibling=parent.L}if(sibling.L&&sibling.L.C||sibling.R&&sibling.R.C){if(!sibling.L||!sibling.L.C){sibling.R.C=false;sibling.C=true;RedBlackRotateLeft(this,sibling);sibling=parent.L}sibling.C=parent.C;parent.C=sibling.L.C=false;RedBlackRotateRight(this,parent);node=this._;break}}sibling.C=true;node=parent;parent=parent.U}while(!node.C);if(node)node.C=false}};function RedBlackRotateLeft(tree,node){var p=node,q=node.R,parent=p.U;if(parent){if(parent.L===p)parent.L=q;else parent.R=q}else{tree._=q}q.U=parent;p.U=q;p.R=q.L;if(p.R)p.R.U=p;q.L=p}function RedBlackRotateRight(tree,node){var p=node,q=node.L,parent=p.U;if(parent){if(parent.L===p)parent.L=q;else parent.R=q}else{tree._=q}q.U=parent;p.U=q;p.L=q.R;if(p.L)p.L.U=p;q.R=p}function RedBlackFirst(node){while(node.L)node=node.L;return node}function createEdge(left,right,v0,v1){var edge=[null,null],index=edges.push(edge)-1;edge.left=left;edge.right=right;if(v0)setEdgeEnd(edge,left,right,v0);if(v1)setEdgeEnd(edge,right,left,v1);cells[left.index].halfedges.push(index);cells[right.index].halfedges.push(index);return edge}function createBorderEdge(left,v0,v1){var edge=[v0,v1];edge.left=left;return edge}function setEdgeEnd(edge,left,right,vertex){if(!edge[0]&&!edge[1]){edge[0]=vertex;edge.left=left;edge.right=right}else if(edge.left===right){edge[1]=vertex}else{edge[0]=vertex}}function clipEdge(edge,x0,y0,x1,y1){var a=edge[0],b=edge[1],ax=a[0],ay=a[1],bx=b[0],by=b[1],t0=0,t1=1,dx=bx-ax,dy=by-ay,r;r=x0-ax;if(!dx&&r>0)return;r/=dx;if(dx<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=x1-ax;if(!dx&&r<0)return;r/=dx;if(dx<0){if(r>t1)return;if(r>t0)t0=r}else if(dx>0){if(r0)return;r/=dy;if(dy<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=y1-ay;if(!dy&&r<0)return;r/=dy;if(dy<0){if(r>t1)return;if(r>t0)t0=r}else if(dy>0){if(r0)&&!(t1<1))return true;if(t0>0)edge[0]=[ax+t0*dx,ay+t0*dy];if(t1<1)edge[1]=[ax+t1*dx,ay+t1*dy];return true}function connectEdge(edge,x0,y0,x1,y1){var v1=edge[1];if(v1)return true;var v0=edge[0],left=edge.left,right=edge.right,lx=left[0],ly=left[1],rx=right[0],ry=right[1],fx=(lx+rx)/2,fy=(ly+ry)/2,fm,fb;if(ry===ly){if(fx=x1)return;if(lx>rx){if(!v0)v0=[fx,y0];else if(v0[1]>=y1)return;v1=[fx,y1]}else{if(!v0)v0=[fx,y1];else if(v0[1]1){if(lx>rx){if(!v0)v0=[(y0-fb)/fm,y0];else if(v0[1]>=y1)return;v1=[(y1-fb)/fm,y1]}else{if(!v0)v0=[(y1-fb)/fm,y1];else if(v0[1]=x1)return;v1=[x1,fm*x1+fb]}else{if(!v0)v0=[x1,fm*x1+fb];else if(v0[0]epsilon||Math.abs(edge[0][1]-edge[1][1])>epsilon)){delete edges[i]}}}function createCell(site){return cells[site.index]={site:site,halfedges:[]}}function cellHalfedgeAngle(cell,edge){var site=cell.site,va=edge.left,vb=edge.right;if(site===vb)vb=va,va=site;if(vb)return Math.atan2(vb[1]-va[1],vb[0]-va[0]);if(site===va)va=edge[1],vb=edge[0];else va=edge[0],vb=edge[1];return Math.atan2(va[0]-vb[0],vb[1]-va[1])}function cellHalfedgeStart(cell,edge){return edge[+(edge.left!==cell.site)]}function cellHalfedgeEnd(cell,edge){return edge[+(edge.left===cell.site)]}function sortCellHalfedges(){for(var i=0,n=cells.length,cell,halfedges,j,m;iepsilon||Math.abs(endY-startY)>epsilon){halfedges.splice(iHalfedge,0,edges.push(createBorderEdge(site,end,Math.abs(endX-x0)epsilon?[x0,Math.abs(startX-x0)epsilon?[Math.abs(startY-y1)epsilon?[x1,Math.abs(startX-x1)epsilon?[Math.abs(startY-y0)=-epsilon2)return;var ha=ax*ax+ay*ay,hc=cx*cx+cy*cy,x=(cy*ha-ay*hc)/d,y=(ax*hc-cx*ha)/d;var circle=circlePool.pop()||new Circle;circle.arc=arc;circle.site=cSite;circle.x=x+bx;circle.y=(circle.cy=y+by)+Math.sqrt(x*x+y*y);arc.circle=circle;var before=null,node=circles._;while(node){if(circle.yepsilon)node=node.L;else{dxr=x-rightBreakPoint(node,directrix);if(dxr>epsilon){if(!node.R){lArc=node;break}node=node.R}else{if(dxl>-epsilon){lArc=node.P;rArc=node}else if(dxr>-epsilon){lArc=node;rArc=node.N}else{lArc=rArc=node}break}}}createCell(site);var newArc=createBeach(site);beaches.insert(lArc,newArc);if(!lArc&&!rArc)return;if(lArc===rArc){detachCircle(lArc);rArc=createBeach(lArc.site);beaches.insert(newArc,rArc);newArc.edge=rArc.edge=createEdge(lArc.site,newArc.site);attachCircle(lArc);attachCircle(rArc);return}if(!rArc){newArc.edge=createEdge(lArc.site,newArc.site);return}detachCircle(lArc);detachCircle(rArc);var lSite=lArc.site,ax=lSite[0],ay=lSite[1],bx=site[0]-ax,by=site[1]-ay,rSite=rArc.site,cx=rSite[0]-ax,cy=rSite[1]-ay,d=2*(bx*cy-by*cx),hb=bx*bx+by*by,hc=cx*cx+cy*cy,vertex=[(cy*hb-by*hc)/d+ax,(bx*hc-cx*hb)/d+ay] +;setEdgeEnd(rArc.edge,lSite,rSite,vertex);newArc.edge=createEdge(lSite,site,null,vertex);rArc.edge=createEdge(site,rSite,null,vertex);attachCircle(lArc);attachCircle(rArc)}function leftBreakPoint(arc,directrix){var site=arc.site,rfocx=site[0],rfocy=site[1],pby2=rfocy-directrix;if(!pby2)return rfocx;var lArc=arc.P;if(!lArc)return-Infinity;site=lArc.site;var lfocx=site[0],lfocy=site[1],plby2=lfocy-directrix;if(!plby2)return lfocx;var hl=lfocx-rfocx,aby2=1/pby2-1/plby2,b=hl/plby2;if(aby2)return(-b+Math.sqrt(b*b-2*aby2*(hl*hl/(-2*plby2)-lfocy+plby2/2+rfocy-pby2/2)))/aby2+rfocx;return(rfocx+lfocx)/2}function rightBreakPoint(arc,directrix){var rArc=arc.N;if(rArc)return leftBreakPoint(rArc,directrix);var site=arc.site;return site[1]===directrix?site[0]:Infinity}var epsilon=1e-6;var epsilon2=1e-12;var beaches;var cells;var circles;var edges;function triangleArea(a,b,c){return(a[0]-c[0])*(b[1]-a[1])-(a[0]-b[0])*(c[1]-a[1])}function lexicographic(a,b){return b[1]-a[1]||b[0]-a[0]}function Diagram(sites,extent){var site=sites.sort(lexicographic).pop(),x,y,circle;edges=[];cells=new Array(sites.length);beaches=new RedBlackTree;circles=new RedBlackTree;while(true){circle=firstCircle;if(site&&(!circle||site[1]=n)return null;var dx=x-cell.site[0],dy=y-cell.site[1],d2=dx*dx+dy*dy;do{cell=that.cells[i0=i1],i1=null;cell.halfedges.forEach(function(e){var edge=that.edges[e],v=edge.left;if((v===cell.site||!v)&&!(v=edge.right))return;var vx=x-v[0],vy=y-v[1],v2=vx*vx+vy*vy;if(v20&&typeof x[0]!=="number")return false;return true}function objEquiv(a,b,opts){var i,key;if(isUndefinedOrNull(a)||isUndefinedOrNull(b))return false;if(a.prototype!==b.prototype)return false;if(isArguments(a)){if(!isArguments(b)){return false}a=pSlice.call(a);b=pSlice.call(b);return deepEqual(a,b,opts)}if(isBuffer(a)){if(!isBuffer(b)){return false}if(a.length!==b.length)return false;for(i=0;i=0;i--){if(ka[i]!=kb[i])return false}for(i=ka.length-1;i>=0;i--){key=ka[i];if(!deepEqual(a[key],b[key],opts))return false}return typeof a===typeof b}},{"./lib/is_arguments.js":20,"./lib/keys.js":21}],20:[function(require,module,exports){var supportsArgumentsClass=function(){return Object.prototype.toString.call(arguments)}()=="[object Arguments]";exports=module.exports=supportsArgumentsClass?supported:unsupported;exports.supported=supported;function supported(object){return Object.prototype.toString.call(object)=="[object Arguments]"}exports.unsupported=unsupported;function unsupported(object){return object&&typeof object=="object"&&typeof object.length=="number"&&Object.prototype.hasOwnProperty.call(object,"callee")&&!Object.prototype.propertyIsEnumerable.call(object,"callee")||false}},{}],21:[function(require,module,exports){exports=module.exports=typeof Object.keys==="function"?Object.keys:shim;exports.shim=shim;function shim(obj){var keys=[];for(var key in obj)keys.push(key);return keys}},{}],22:[function(require,module,exports){"use strict";function makeEmptyFunction(arg){return function(){return arg}}var emptyFunction=function emptyFunction(){};emptyFunction.thatReturns=makeEmptyFunction;emptyFunction.thatReturnsFalse=makeEmptyFunction(false);emptyFunction.thatReturnsTrue=makeEmptyFunction(true);emptyFunction.thatReturnsNull=makeEmptyFunction(null);emptyFunction.thatReturnsThis=function(){return this};emptyFunction.thatReturnsArgument=function(arg){return arg};module.exports=emptyFunction},{}],23:[function(require,module,exports){(function(process){"use strict";var emptyObject={};if(process.env.NODE_ENV!=="production"){Object.freeze(emptyObject)}module.exports=emptyObject}).call(this,require("_process"))},{_process:1}],24:[function(require,module,exports){(function(process){"use strict";var validateFormat=function validateFormat(format){};if(process.env.NODE_ENV!=="production"){validateFormat=function validateFormat(format){if(format===undefined){throw new Error("invariant requires an error message argument")}}}function invariant(condition,format,a,b,c,d,e,f){validateFormat(format);if(!condition){var error;if(format===undefined){error=new Error("Minified exception occurred; use the non-minified dev environment "+"for the full error message and additional helpful warnings.")}else{var args=[a,b,c,d,e,f];var argIndex=0;error=new Error(format.replace(/%s/g,function(){return args[argIndex++]}));error.name="Invariant Violation"}error.framesToPop=1;throw error}}module.exports=invariant}).call(this,require("_process"))},{_process:1}],25:[function(require,module,exports){(function(process){"use strict";var emptyFunction=require("./emptyFunction");var warning=emptyFunction;if(process.env.NODE_ENV!=="production"){var printWarning=function printWarning(format){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.error(message)}try{throw new Error(message)}catch(x){}};warning=function warning(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(format.indexOf("Failed Composite propType: ")===0){return}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=warning}).call(this,require("_process"))},{"./emptyFunction":22,_process:1}],26:[function(require,module,exports){(function(global){var win;if(typeof window!=="undefined"){win=window}else if(typeof global!=="undefined"){win=global}else if(typeof self!=="undefined"){win=self}else{win={}}module.exports=win}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],27:[function(require,module,exports){"use strict";var getOwnPropertySymbols=Object.getOwnPropertySymbols;var hasOwnProperty=Object.prototype.hasOwnProperty;var propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(val===null||val===undefined){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(val)}function shouldUseNative(){try{if(!Object.assign){return false}var test1=new String("abc");test1[5]="de";if(Object.getOwnPropertyNames(test1)[0]==="5"){return false}var test2={};for(var i=0;i<10;i++){test2["_"+String.fromCharCode(i)]=i}var order2=Object.getOwnPropertyNames(test2).map(function(n){return test2[n]});if(order2.join("")!=="0123456789"){return false}var test3={};"abcdefghijklmnopqrst".split("").forEach(function(letter){test3[letter]=letter});if(Object.keys(Object.assign({},test3)).join("")!=="abcdefghijklmnopqrst"){return false}return true}catch(err){return false}}module.exports=shouldUseNative()?Object.assign:function(target,source){var from;var to=toObject(target);var symbols;for(var s=1;smsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var newLastIdealStyle={};var newLastIdealVelocity={};var newCurrentStyle={};var newCurrentVelocity={};for(var key in propsStyle){if(!Object.prototype.hasOwnProperty.call(propsStyle,key)){continue}var styleValue=propsStyle[key];if(typeof styleValue==="number"){newCurrentStyle[key]=styleValue;newCurrentVelocity[key]=0;newLastIdealStyle[key]=styleValue;newLastIdealVelocity[key]=0}else{var newLastIdealStyleValue=_this.state.lastIdealStyle[key];var newLastIdealVelocityValue=_this.state.lastIdealVelocity[key];for(var i=0;imsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var newLastIdealStyles=[];var newLastIdealVelocities=[];var newCurrentStyles=[];var newCurrentVelocities=[];for(var i=0;imsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var _mergeAndSync2=mergeAndSync(_this.props.willEnter,_this.props.willLeave,_this.props.didLeave,_this.state.mergedPropsStyles,destStyles,_this.state.currentStyles,_this.state.currentVelocities,_this.state.lastIdealStyles,_this.state.lastIdealVelocities);var newMergedPropsStyles=_mergeAndSync2[0];var newCurrentStyles=_mergeAndSync2[1];var newCurrentVelocities=_mergeAndSync2[2];var newLastIdealStyles=_mergeAndSync2[3];var newLastIdealVelocities=_mergeAndSync2[4];for(var i=0;iprevKeyIndex[pivot]){return-1}else if(nextOrderA>nextKeyIndex[pivot]&&prevOrderBprevKeyIndex[pivot]){return 1}else if(nextOrderB>nextKeyIndex[pivot]&&prevOrderA1){var childArray=Array(childrenLength);for(var i=0;i1){var childArray=Array(childrenLength);for(var i=0;i."}}return info}function validateExplicitKey(element,parentType){if(!element._store||element._store.validated||element.key!=null){return}element._store.validated=true;var memoizer=ownerHasKeyUseWarning.uniqueKey||(ownerHasKeyUseWarning.uniqueKey={});var currentComponentErrorInfo=getCurrentComponentErrorInfo(parentType);if(memoizer[currentComponentErrorInfo]){return}memoizer[currentComponentErrorInfo]=true;var childOwner="";if(element&&element._owner&&element._owner!==ReactCurrentOwner.current){childOwner=" It was passed a child from "+element._owner.getName()+"."}process.env.NODE_ENV!=="production"?warning(false,'Each child in an array or iterator should have a unique "key" prop.'+"%s%s See https://fb.me/react-warning-keys for more information.%s",currentComponentErrorInfo,childOwner,ReactComponentTreeHook.getCurrentStackAddendum(element)):void 0}function validateChildKeys(node,parentType){if(typeof node!=="object"){return}if(Array.isArray(node)){for(var i=0;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.warn(message)}try{throw new Error(message)}catch(x){}};lowPriorityWarning=function(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=lowPriorityWarning}).call(this,require("_process"))},{_process:1}],70:[function(require,module,exports){(function(process){"use strict";var _prodInvariant=require("./reactProdInvariant");var ReactElement=require("./ReactElement");var invariant=require("fbjs/lib/invariant");function onlyChild(children){!ReactElement.isValidElement(children)?process.env.NODE_ENV!=="production"?invariant(false,"React.Children.only expected to receive a single React element child."):_prodInvariant("143"):void 0;return children}module.exports=onlyChild}).call(this,require("_process"))},{"./ReactElement":57,"./reactProdInvariant":71,_process:1,"fbjs/lib/invariant":24}],71:[function(require,module,exports){"use strict";function reactProdInvariant(code){var argCount=arguments.length-1;var message="Minified React error #"+code+"; visit "+"http://facebook.github.io/react/docs/error-decoder.html?invariant="+code;for(var argIdx=0;argIdx=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}var ANIMATION_PROPTYPES=_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.shape({stiffness:_propTypes2.default.number,nonAnimatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string),damping:_propTypes2.default.number}),_propTypes2.default.bool]);var propTypes={animatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string).isRequired,animation:ANIMATION_PROPTYPES,onStart:_propTypes2.default.func,onEnd:_propTypes2.default.func};function getAnimationStyle(){var animationStyle=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_reactMotion.presets.noWobble;if(typeof animationStyle==="string"){return _reactMotion.presets[animationStyle]||_reactMotion.presets.noWobble}var damping=animationStyle.damping,stiffness=animationStyle.stiffness;return _extends({damping:damping||_reactMotion.presets.noWobble.damping,stiffness:stiffness||_reactMotion.presets.noWobble.stiffness},animationStyle)}function extractAnimatedPropValues(props){var animatedProps=props.animatedProps,otherProps=_objectWithoutProperties(props,["animatedProps"]);return animatedProps.reduce(function(result,animatedPropName){if(otherProps.hasOwnProperty(animatedPropName)){result[animatedPropName]=otherProps[animatedPropName]}return result},{})}var Animation=function(_PureComponent){_inherits(Animation,_PureComponent);function Animation(props){_classCallCheck(this,Animation);var _this=_possibleConstructorReturn(this,(Animation.__proto__||Object.getPrototypeOf(Animation)).call(this,props));_this._motionEndHandler=function(){if(_this.props.onEnd){_this.props.onEnd()}};_this._renderChildren=function(_ref){var i=_ref.i;var children=_this.props.children;var interpolator=_this._interpolator;var child=_react2.default.Children.only(children);var interpolatedProps=interpolator?interpolator(i):interpolator;var data=interpolatedProps&&interpolatedProps.data||null;if(data&&child.props._data){data=data.map(function(row,index){var correspondingCell=child.props._data[index];return _extends({},row,{parent:correspondingCell.parent,children:correspondingCell.children})})}return _react2.default.cloneElement(child,_extends({},child.props,interpolatedProps,{data:data||child.props.data||null,_animation:Math.random()}))};_this._updateInterpolator(props);return _this}_createClass(Animation,[{key:"componentWillUpdate",value:function componentWillUpdate(props){this._updateInterpolator(this.props,props);if(props.onStart){props.onStart()}}},{key:"_updateInterpolator",value:function _updateInterpolator(oldProps,newProps){this._interpolator=(0,_d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps),newProps?extractAnimatedPropValues(newProps):null)}},{key:"render",value:function render(){var animationStyle=getAnimationStyle(this.props.animation);var defaultStyle={i:0};var style={i:(0,_reactMotion.spring)(1,animationStyle)};var key=Math.random();return _react2.default.createElement(_reactMotion.Motion,_extends({defaultStyle:defaultStyle,style:style,key:key},{onRest:this._motionEndHandler}),this._renderChildren)}}]);return Animation}(_react.PureComponent);Animation.propTypes=propTypes;Animation.displayName="Animation";exports.default=Animation;var AnimationPropType=exports.AnimationPropType=ANIMATION_PROPTYPES},{"d3-interpolate":11,"prop-types":33,react:73,"react-motion":43}],75:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ScaleUtils=exports.AxisUtils=exports.FlexibleHeightXYPlot=exports.FlexibleWidthXYPlot=exports.FlexibleXYPlot=exports.makeWidthFlexible=exports.makeVisFlexible=exports.makeHeightFlexible=exports.Sunburst=exports.Sankey=exports.ParallelCoordinates=exports.RadarChart=exports.RadialChart=exports.Treemap=exports.ContinuousSizeLegend=exports.ContinuousColorLegend=exports.SearchableDiscreteColorLegend=exports.DiscreteColorLegend=exports.Highlight=exports.Voronoi=exports.HorizontalGridLines=exports.VerticalGridLines=exports.GradientDefs=exports.GridLines=exports.CircularGridLines=exports.YAxis=exports.XAxis=exports.DecorativeAxis=exports.XYPlot=exports.Crosshair=exports.Borders=exports.Hint=exports.LineMarkSeriesCanvas=exports.LineMarkSeries=exports.ArcSeries=exports.AreaSeries=exports.CustomSVGSeries=exports.ContourSeries=exports.HexbinSeries=exports.HeatmapSeries=exports.WhiskerSeries=exports.MarkSeriesCanvas=exports.MarkSeries=exports.RectSeriesCanvas=exports.RectSeries=exports.PolygonSeries=exports.LabelSeries=exports.HorizontalRectSeriesCanvas=exports.HorizontalRectSeries=exports.VerticalRectSeriesCanvas=exports.VerticalRectSeries=exports.VerticalBarSeriesCanvas=exports.VerticalBarSeries=exports.HorizontalBarSeriesCanvas=exports.HorizontalBarSeries=exports.LineSeriesCanvas=exports.LineSeries=exports.AbstractSeries=undefined;var _makeVisFlexible=require("./make-vis-flexible");Object.defineProperty(exports,"makeHeightFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeHeightFlexible}});Object.defineProperty(exports,"makeVisFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeVisFlexible}});Object.defineProperty(exports,"makeWidthFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeWidthFlexible}});Object.defineProperty(exports,"FlexibleXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleXYPlot}});Object.defineProperty(exports,"FlexibleWidthXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleWidthXYPlot}});Object.defineProperty(exports,"FlexibleHeightXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleHeightXYPlot}});var _abstractSeries=require("./plot/series/abstract-series");var _abstractSeries2=_interopRequireDefault(_abstractSeries);var _lineSeries=require("./plot/series/line-series");var _lineSeries2=_interopRequireDefault(_lineSeries);var _lineSeriesCanvas=require("./plot/series/line-series-canvas");var _lineSeriesCanvas2=_interopRequireDefault(_lineSeriesCanvas);var _horizontalBarSeries=require("./plot/series/horizontal-bar-series");var _horizontalBarSeries2=_interopRequireDefault(_horizontalBarSeries);var _horizontalBarSeriesCanvas=require("./plot/series/horizontal-bar-series-canvas");var _horizontalBarSeriesCanvas2=_interopRequireDefault(_horizontalBarSeriesCanvas);var _verticalBarSeries=require("./plot/series/vertical-bar-series");var _verticalBarSeries2=_interopRequireDefault(_verticalBarSeries);var _verticalBarSeriesCanvas=require("./plot/series/vertical-bar-series-canvas");var _verticalBarSeriesCanvas2=_interopRequireDefault(_verticalBarSeriesCanvas);var _verticalRectSeries=require("./plot/series/vertical-rect-series");var _verticalRectSeries2=_interopRequireDefault(_verticalRectSeries);var _verticalRectSeriesCanvas=require("./plot/series/vertical-rect-series-canvas");var _verticalRectSeriesCanvas2=_interopRequireDefault(_verticalRectSeriesCanvas);var _horizontalRectSeries=require("./plot/series/horizontal-rect-series");var _horizontalRectSeries2=_interopRequireDefault(_horizontalRectSeries);var _horizontalRectSeriesCanvas=require("./plot/series/horizontal-rect-series-canvas");var _horizontalRectSeriesCanvas2=_interopRequireDefault(_horizontalRectSeriesCanvas);var _labelSeries=require("./plot/series/label-series");var _labelSeries2=_interopRequireDefault(_labelSeries);var _polygonSeries=require("./plot/series/polygon-series");var _polygonSeries2=_interopRequireDefault(_polygonSeries);var _rectSeries=require("./plot/series/rect-series");var _rectSeries2=_interopRequireDefault(_rectSeries);var _rectSeriesCanvas=require("./plot/series/rect-series-canvas");var _rectSeriesCanvas2=_interopRequireDefault(_rectSeriesCanvas);var _markSeries=require("./plot/series/mark-series");var _markSeries2=_interopRequireDefault(_markSeries);var _markSeriesCanvas=require("./plot/series/mark-series-canvas");var _markSeriesCanvas2=_interopRequireDefault(_markSeriesCanvas);var _whiskerSeries=require("./plot/series/whisker-series");var _whiskerSeries2=_interopRequireDefault(_whiskerSeries);var _heatmapSeries=require("./plot/series/heatmap-series");var _heatmapSeries2=_interopRequireDefault(_heatmapSeries);var _hexbinSeries=require("./plot/series/hexbin-series");var _hexbinSeries2=_interopRequireDefault(_hexbinSeries);var _contourSeries=require("./plot/series/contour-series");var _contourSeries2=_interopRequireDefault(_contourSeries);var _customSvgSeries=require("./plot/series/custom-svg-series");var _customSvgSeries2=_interopRequireDefault(_customSvgSeries);var _areaSeries=require("./plot/series/area-series");var _areaSeries2=_interopRequireDefault(_areaSeries);var _arcSeries=require("./plot/series/arc-series");var _arcSeries2=_interopRequireDefault(_arcSeries);var _lineMarkSeries=require("./plot/series/line-mark-series");var _lineMarkSeries2=_interopRequireDefault(_lineMarkSeries);var _lineMarkSeriesCanvas=require("./plot/series/line-mark-series-canvas");var _lineMarkSeriesCanvas2=_interopRequireDefault(_lineMarkSeriesCanvas);var _hint=require("./plot/hint");var _hint2=_interopRequireDefault(_hint);var _borders=require("./plot/borders");var _borders2=_interopRequireDefault(_borders);var _crosshair=require("./plot/crosshair");var _crosshair2=_interopRequireDefault(_crosshair);var _xyPlot=require("./plot/xy-plot");var _xyPlot2=_interopRequireDefault(_xyPlot);var _decorativeAxis=require("./plot/axis/decorative-axis");var _decorativeAxis2=_interopRequireDefault(_decorativeAxis);var _xAxis=require("./plot/axis/x-axis");var _xAxis2=_interopRequireDefault(_xAxis);var _yAxis=require("./plot/axis/y-axis");var _yAxis2=_interopRequireDefault(_yAxis);var _circularGridLines=require("./plot/circular-grid-lines");var _circularGridLines2=_interopRequireDefault(_circularGridLines);var _gridLines=require("./plot/grid-lines");var _gridLines2=_interopRequireDefault(_gridLines);var _gradientDefs=require("./plot/gradient-defs");var _gradientDefs2=_interopRequireDefault(_gradientDefs);var _verticalGridLines=require("./plot/vertical-grid-lines");var _verticalGridLines2=_interopRequireDefault(_verticalGridLines);var _horizontalGridLines=require("./plot/horizontal-grid-lines");var _horizontalGridLines2=_interopRequireDefault(_horizontalGridLines);var _voronoi=require("./plot/voronoi");var _voronoi2=_interopRequireDefault(_voronoi);var _highlight=require("./plot/highlight");var _highlight2=_interopRequireDefault(_highlight);var _discreteColorLegend=require("./legends/discrete-color-legend");var _discreteColorLegend2=_interopRequireDefault(_discreteColorLegend);var _searchableDiscreteColorLegend=require("./legends/searchable-discrete-color-legend");var _searchableDiscreteColorLegend2=_interopRequireDefault(_searchableDiscreteColorLegend);var _continuousColorLegend=require("./legends/continuous-color-legend");var _continuousColorLegend2=_interopRequireDefault(_continuousColorLegend);var _continuousSizeLegend=require("./legends/continuous-size-legend");var _continuousSizeLegend2=_interopRequireDefault(_continuousSizeLegend);var _treemap=require("./treemap");var _treemap2=_interopRequireDefault(_treemap) +;var _radialChart=require("./radial-chart");var _radialChart2=_interopRequireDefault(_radialChart);var _radarChart=require("./radar-chart");var _radarChart2=_interopRequireDefault(_radarChart);var _parallelCoordinates=require("./parallel-coordinates");var _parallelCoordinates2=_interopRequireDefault(_parallelCoordinates);var _sankey=require("./sankey");var _sankey2=_interopRequireDefault(_sankey);var _sunburst=require("./sunburst");var _sunburst2=_interopRequireDefault(_sunburst);var _axisUtils=require("./utils/axis-utils");var _axisUtils2=_interopRequireDefault(_axisUtils);var _scalesUtils=require("./utils/scales-utils");var _scalesUtils2=_interopRequireDefault(_scalesUtils);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.AbstractSeries=_abstractSeries2.default;exports.LineSeries=_lineSeries2.default;exports.LineSeriesCanvas=_lineSeriesCanvas2.default;exports.HorizontalBarSeries=_horizontalBarSeries2.default;exports.HorizontalBarSeriesCanvas=_horizontalBarSeriesCanvas2.default;exports.VerticalBarSeries=_verticalBarSeries2.default;exports.VerticalBarSeriesCanvas=_verticalBarSeriesCanvas2.default;exports.VerticalRectSeries=_verticalRectSeries2.default;exports.VerticalRectSeriesCanvas=_verticalRectSeriesCanvas2.default;exports.HorizontalRectSeries=_horizontalRectSeries2.default;exports.HorizontalRectSeriesCanvas=_horizontalRectSeriesCanvas2.default;exports.LabelSeries=_labelSeries2.default;exports.PolygonSeries=_polygonSeries2.default;exports.RectSeries=_rectSeries2.default;exports.RectSeriesCanvas=_rectSeriesCanvas2.default;exports.MarkSeries=_markSeries2.default;exports.MarkSeriesCanvas=_markSeriesCanvas2.default;exports.WhiskerSeries=_whiskerSeries2.default;exports.HeatmapSeries=_heatmapSeries2.default;exports.HexbinSeries=_hexbinSeries2.default;exports.ContourSeries=_contourSeries2.default;exports.CustomSVGSeries=_customSvgSeries2.default;exports.AreaSeries=_areaSeries2.default;exports.ArcSeries=_arcSeries2.default;exports.LineMarkSeries=_lineMarkSeries2.default;exports.LineMarkSeriesCanvas=_lineMarkSeriesCanvas2.default;exports.Hint=_hint2.default;exports.Borders=_borders2.default;exports.Crosshair=_crosshair2.default;exports.XYPlot=_xyPlot2.default;exports.DecorativeAxis=_decorativeAxis2.default;exports.XAxis=_xAxis2.default;exports.YAxis=_yAxis2.default;exports.CircularGridLines=_circularGridLines2.default;exports.GridLines=_gridLines2.default;exports.GradientDefs=_gradientDefs2.default;exports.VerticalGridLines=_verticalGridLines2.default;exports.HorizontalGridLines=_horizontalGridLines2.default;exports.Voronoi=_voronoi2.default;exports.Highlight=_highlight2.default;exports.DiscreteColorLegend=_discreteColorLegend2.default;exports.SearchableDiscreteColorLegend=_searchableDiscreteColorLegend2.default;exports.ContinuousColorLegend=_continuousColorLegend2.default;exports.ContinuousSizeLegend=_continuousSizeLegend2.default;exports.Treemap=_treemap2.default;exports.RadialChart=_radialChart2.default;exports.RadarChart=_radarChart2.default;exports.ParallelCoordinates=_parallelCoordinates2.default;exports.Sankey=_sankey2.default;exports.Sunburst=_sunburst2.default;exports.AxisUtils=_axisUtils2.default;exports.ScaleUtils=_scalesUtils2.default},{"./legends/continuous-color-legend":76,"./legends/continuous-size-legend":77,"./legends/discrete-color-legend":79,"./legends/searchable-discrete-color-legend":80,"./make-vis-flexible":81,"./parallel-coordinates":82,"./plot/axis/decorative-axis":88,"./plot/axis/x-axis":89,"./plot/axis/y-axis":90,"./plot/borders":91,"./plot/circular-grid-lines":92,"./plot/crosshair":93,"./plot/gradient-defs":94,"./plot/grid-lines":95,"./plot/highlight":96,"./plot/hint":97,"./plot/horizontal-grid-lines":98,"./plot/series/abstract-series":99,"./plot/series/arc-series":100,"./plot/series/area-series":101,"./plot/series/contour-series":105,"./plot/series/custom-svg-series":106,"./plot/series/heatmap-series":107,"./plot/series/hexbin-series":108,"./plot/series/horizontal-bar-series":110,"./plot/series/horizontal-bar-series-canvas":109,"./plot/series/horizontal-rect-series":112,"./plot/series/horizontal-rect-series-canvas":111,"./plot/series/label-series":113,"./plot/series/line-mark-series":115,"./plot/series/line-mark-series-canvas":114,"./plot/series/line-series":117,"./plot/series/line-series-canvas":116,"./plot/series/mark-series":119,"./plot/series/mark-series-canvas":118,"./plot/series/polygon-series":120,"./plot/series/rect-series":122,"./plot/series/rect-series-canvas":121,"./plot/series/vertical-bar-series":124,"./plot/series/vertical-bar-series-canvas":123,"./plot/series/vertical-rect-series":126,"./plot/series/vertical-rect-series-canvas":125,"./plot/series/whisker-series":127,"./plot/vertical-grid-lines":128,"./plot/voronoi":129,"./plot/xy-plot":130,"./radar-chart":131,"./radial-chart":132,"./sankey":133,"./sunburst":135,"./treemap":137,"./utils/axis-utils":141,"./utils/scales-utils":145}],76:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _theme=require("../theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,height:_propTypes2.default.number,endColor:_propTypes2.default.string,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,midColor:_propTypes2.default.string,midTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]),startColor:_propTypes2.default.string,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={className:"",startColor:_theme.CONTINUOUS_COLOR_RANGE[0],endColor:_theme.CONTINUOUS_COLOR_RANGE[1]};function ContinuousColorLegend(_ref){var startColor=_ref.startColor,midColor=_ref.midColor,endColor=_ref.endColor,startTitle=_ref.startTitle,midTitle=_ref.midTitle,endTitle=_ref.endTitle,height=_ref.height,width=_ref.width,className=_ref.className;var colors=[startColor];if(midColor){colors.push(midColor)}colors.push(endColor);return _react2.default.createElement("div",{className:"rv-continuous-color-legend "+className,style:{width:width,height:height}},_react2.default.createElement("div",{className:"rv-gradient",style:{background:"linear-gradient(to right, "+colors.join(",")+")"}}),_react2.default.createElement("div",{className:"rv-legend-titles"},_react2.default.createElement("span",{className:"rv-legend-titles__left"},startTitle),_react2.default.createElement("span",{className:"rv-legend-titles__right"},endTitle),midTitle?_react2.default.createElement("span",{className:"rv-legend-titles__center"},midTitle):null))}ContinuousColorLegend.displayName="ContinuousColorLegend";ContinuousColorLegend.propTypes=propTypes;ContinuousColorLegend.defaultProps=defaultProps;exports.default=ContinuousColorLegend},{"../theme":136,"prop-types":33,react:73}],77:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,circlesTotal:_propTypes2.default.number,endSize:_propTypes2.default.number,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,height:_propTypes2.default.number,startSize:_propTypes2.default.number,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={circlesTotal:10,className:"",endSize:20,startSize:2};function ContinuousSizeLegend(_ref){var startTitle=_ref.startTitle,endTitle=_ref.endTitle,startSize=_ref.startSize,endSize=_ref.endSize,circlesTotal=_ref.circlesTotal,height=_ref.height,width=_ref.width,className=_ref.className;var circles=[];var step=(endSize-startSize)/(circlesTotal-1);for(var i=0;i=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}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}var CONTAINER_REF="container";var resizeSubscribers=[];var DEBOUNCE_DURATION=100;var timeoutId=null;function debounceEmitResize(){_window2.default.clearTimeout(timeoutId);timeoutId=_window2.default.setTimeout(emitResize,DEBOUNCE_DURATION)}function emitResize(){resizeSubscribers.forEach(function(cb){return cb()})}function subscribeToDebouncedResize(cb){resizeSubscribers.push(cb);if(resizeSubscribers.length===1){_window2.default.addEventListener("resize",debounceEmitResize)}return function unsubscribe(){removeSubscriber(cb);if(resizeSubscribers.length===0){_window2.default.clearTimeout(timeoutId);_window2.default.removeEventListener("resize",debounceEmitResize)}}}function removeSubscriber(cb){var index=resizeSubscribers.indexOf(cb);if(index>-1){resizeSubscribers.splice(index,1)}}function getDisplayName(Component){return Component.displayName||Component.name||"Component"}function makeFlexible(Component,isWidthFlexible,isHeightFlexible){var ResultClass=function(_React$Component){_inherits(ResultClass,_React$Component);_createClass(ResultClass,null,[{key:"propTypes",get:function get(){var _Component$propTypes=Component.propTypes,height=_Component$propTypes.height,width=_Component$propTypes.width,otherPropTypes=_objectWithoutProperties(_Component$propTypes,["height","width"]);return otherPropTypes}}]);function ResultClass(props){_classCallCheck(this,ResultClass);var _this=_possibleConstructorReturn(this,(ResultClass.__proto__||Object.getPrototypeOf(ResultClass)).call(this,props));_this._onResize=function(){var containerElement=(0,_reactUtils.getDOMNode)(_this[CONTAINER_REF]);var offsetHeight=containerElement.offsetHeight,offsetWidth=containerElement.offsetWidth;var newHeight=_this.state.height===offsetHeight?{}:{height:offsetHeight};var newWidth=_this.state.width===offsetWidth?{}:{width:offsetWidth};_this.setState(_extends({},newHeight,newWidth))};_this.state={height:0,width:0};return _this}_createClass(ResultClass,[{key:"componentDidMount",value:function componentDidMount(){this._onResize();this.cancelSubscription=subscribeToDebouncedResize(this._onResize)}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(){this._onResize()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.cancelSubscription()}},{key:"render",value:function render(){var _this2=this;var _state=this.state,height=_state.height,width=_state.width;var props=_extends({},this.props,{animation:height===0&&width===0?null:this.props.animation});var updatedDimensions=_extends({},isHeightFlexible?{height:height}:{},isWidthFlexible?{width:width}:{});return _react2.default.createElement("div",{ref:function ref(_ref){return _this2[CONTAINER_REF]=_ref},style:{width:"100%",height:"100%"}},_react2.default.createElement(Component,_extends({},updatedDimensions,props)))}}]);return ResultClass}(_react2.default.Component);ResultClass.displayName="Flexible"+getDisplayName(Component);return ResultClass}function makeHeightFlexible(component){return makeFlexible(component,false,true)}function makeVisFlexible(component){return makeFlexible(component,true,true)}function makeWidthFlexible(component){return makeFlexible(component,true,false)}var FlexibleWidthXYPlot=exports.FlexibleWidthXYPlot=makeWidthFlexible(_xyPlot2.default);var FlexibleHeightXYPlot=exports.FlexibleHeightXYPlot=makeHeightFlexible(_xyPlot2.default);var FlexibleXYPlot=exports.FlexibleXYPlot=makeVisFlexible(_xyPlot2.default)},{"./plot/xy-plot":130,"./utils/react-utils":144,"global/window":26,react:73}],82:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;ifilter.max)){withinFilteredRange=false}return{x:name,y:yVal}});var selectedName=predefinedClassName+"-line";var unselectedName=selectedName+" "+predefinedClassName+"-line-unselected";var lineProps={animation:animation,className:withinFilteredRange?selectedName:unselectedName,key:rowIndex+"-polygon",data:mappedData,color:row.color||colorRange[rowIndex%colorRange.length],style:_extends({},style.lines,row.style||{})};if(!withinFilteredRange){lineProps.style=_extends({},lineProps.style,style.deselectedLineStyle)}return showMarks?_react2.default.createElement(_lineMarkSeries2.default,lineProps):_react2.default.createElement(_lineSeries2.default,lineProps)})}var ParallelCoordinates=function(_Component){_inherits(ParallelCoordinates,_Component);function ParallelCoordinates(){var _ref2;var _temp,_this,_ret;_classCallCheck(this,ParallelCoordinates);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}return _ret=(_temp=(_this=_possibleConstructorReturn(this,(_ref2=ParallelCoordinates.__proto__||Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2,[this].concat(args))),_this),_this.state={brushFilters:{}},_temp),_possibleConstructorReturn(_this,_ret)}_createClass(ParallelCoordinates,[{key:"render",value:function render(){var _this2=this;var brushFilters=this.state.brushFilters;var _props=this.props,animation=_props.animation,brushing=_props.brushing,className=_props.className,children=_props.children,colorRange=_props.colorRange,data=_props.data,domains=_props.domains,height=_props.height,hideInnerMostValues=_props.hideInnerMostValues,margin=_props.margin,onMouseLeave=_props.onMouseLeave,onMouseEnter=_props.onMouseEnter,showMarks=_props.showMarks,style=_props.style,tickFormat=_props.tickFormat,width=_props.width;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,style:style,tickFormat:tickFormat});var lines=getLines({animation:animation,brushFilters:brushFilters,colorRange:colorRange,domains:domains,data:data,showMarks:showMarks,style:style});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:true,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels})});var _getInnerDimensions=(0,_chartUtils.getInnerDimensions)(this.props,_chartUtils.DEFAULT_MARGINS),marginLeft=_getInnerDimensions.marginLeft,marginRight=_getInnerDimensions.marginRight;return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xType:"ordinal",yDomain:[0,1]},children,axes.concat(lines).concat(labelSeries),brushing&&domains.map(function(d){var trigger=function trigger(row){_this2.setState({brushFilters:_extends({},brushFilters,_defineProperty({},d.name,row?{min:row.bottom,max:row.top}:null))})};return _react2.default.createElement(_highlight2.default,{key:d.name,drag:true,highlightX:d.name,onBrushEnd:trigger,onDragEnd:trigger,highlightWidth:(width-marginLeft-marginRight)/domains.length,enableX:false})}))}}]);return ParallelCoordinates}(_react.Component);ParallelCoordinates.displayName="ParallelCoordinates";ParallelCoordinates.propTypes={animation:_animation.AnimationPropType,brushing:_propTypes2.default.bool,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,margin:_chartUtils.MarginPropType,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,lines:_propTypes2.default.object}),showMarks:_propTypes2.default.bool,tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};ParallelCoordinates.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},lines:{strokeWidth:1,strokeOpacity:1},deselectedLineStyle:{strokeOpacity:.1}},tickFormat:DEFAULT_FORMAT};exports.default=ParallelCoordinates},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/highlight":96,"../plot/series/label-series":113,"../plot/series/line-mark-series":115,"../plot/series/line-series":117,"../plot/xy-plot":130,"../theme":136,"../utils/chart-utils":142,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],83:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{ +value:true});var _extends=Object.assign||function(target){for(var i=1;i-1;var axisClassName=isVertical?VERTICAL_CLASS_NAME:HORIZONTAL_CLASS_NAME;var leftPos=left;var topPos=top;if(on0){var scale=(0,_scalesUtils.getAttributeScale)(props,attrAxis);if(isVertical){leftPos=scale(0)}else{topPos=marginTop+scale(0)}}return _react2.default.createElement("g",{transform:"translate("+leftPos+","+topPos+")",className:predefinedClassName+" "+axisClassName+" "+className,style:style},!hideLine&&_react2.default.createElement(_axisLine2.default,{height:height,width:width,orientation:orientation,style:_extends({},style,style.line)}),!hideTicks&&_react2.default.createElement(_axisTicks2.default,_extends({},props,{style:_extends({},style,style.ticks)})),title?_react2.default.createElement(_axisTitle2.default,{position:position,title:title,height:height,width:width,style:_extends({},style,style.title),orientation:orientation}):null)}}]);return Axis}(_react.PureComponent);Axis.displayName="Axis";Axis.propTypes=propTypes;Axis.defaultProps=defaultProps;Axis.requiresSVG=true;exports.default=Axis},{"../../animation":74,"../../utils/axis-utils":141,"../../utils/scales-utils":145,"./axis-line":83,"./axis-ticks":84,"./axis-title":85,"prop-types":33,react:73}],87:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;irRange[1])){return res}return res.concat([_react2.default.createElement("circle",_extends({cx:0,cy:0,r:radius},{key:index,className:"rv-xy-plot__circular-grid-lines__line",style:style}))])},[]))}}]);return CircularGridLines}(_react.PureComponent);CircularGridLines.displayName="CircularGridLines";CircularGridLines.propTypes={centerX:_propTypes2.default.number,centerY:_propTypes2.default.number,width:_propTypes2.default.number,height:_propTypes2.default.number,top:_propTypes2.default.number,left:_propTypes2.default.number,rRange:_propTypes2.default.arrayOf(_propTypes2.default.number),style:_propTypes2.default.object,tickValues:_propTypes2.default.arrayOf(_propTypes2.default.number),tickTotal:_propTypes2.default.number,animation:_animation.AnimationPropType,marginTop:_propTypes2.default.number,marginBottom:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginRight:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number};CircularGridLines.defaultProps={centerX:0,centerY:0};CircularGridLines.requiresSVG=true;exports.default=CircularGridLines},{"../animation":74,"../utils/axis-utils":141,"../utils/scales-utils":145,"prop-types":33,react:73}],93:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?"left":"right":_props$orientation;var left=marginLeft+innerLeft;var top=marginTop;var innerClassName="rv-crosshair__inner rv-crosshair__inner--"+orientation;return _react2.default.createElement("div",{className:"rv-crosshair "+className,style:{left:left+"px",top:top+"px"}},_react2.default.createElement("div",{className:"rv-crosshair__line",style:_extends({height:innerHeight+"px"},style.line)}),_react2.default.createElement("div",{className:innerClassName},children?children:_react2.default.createElement("div",{className:"rv-crosshair__inner__content",style:style.box},_react2.default.createElement("div",null,this._renderCrosshairTitle(),this._renderCrosshairItems()))))}}],[{key:"defaultProps",get:function get(){return{titleFormat:defaultTitleFormat,itemsFormat:defaultItemsFormat,style:{line:{},title:{},box:{}}}}},{key:"propTypes",get:function get(){return{className:_propTypes2.default.string,values:_propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string,_propTypes2.default.object])),series:_propTypes2.default.object,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,orientation:_propTypes2.default.oneOf(["left","right"]),itemsFormat:_propTypes2.default.func,titleFormat:_propTypes2.default.func,style:_propTypes2.default.shape({line:_propTypes2.default.object,title:_propTypes2.default.object,box:_propTypes2.default.object})}}}]);return Crosshair}(_react.PureComponent);Crosshair.displayName="Crosshair";exports.default=Crosshair},{"../utils/scales-utils":145,"prop-types":33,react:73}],94:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var predefinedClassName="rv-gradient-defs";function GradientDefs(props){var className=props.className;return _react2.default.createElement("defs",{className:predefinedClassName+" "+className},props.children)}GradientDefs.displayName="GradientDefs";GradientDefs.requiresSVG=true;GradientDefs.propTypes={className:_propTypes2.default.string};GradientDefs.defaultProps={className:""};exports.default=GradientDefs},{"prop-types":33,react:73}],95:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iright);var clickedOutsideDragY=dragArea&&(yLocbottom);if(enableX&&enableY){return clickedOutsideDragX||clickedOutsideDragY}if(enableX){return clickedOutsideDragX}if(enableY){return clickedOutsideDragY}return true}},{key:"_convertAreaToCoordinates",value:function _convertAreaToCoordinates(brushArea){var _props4=this.props,enableX=_props4.enableX,enableY=_props4.enableY,marginLeft=_props4.marginLeft,marginTop=_props4.marginTop;var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");if(enableX&&enableY){return{bottom:yScale.invert(brushArea.bottom),left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft),top:yScale.invert(brushArea.top)}}if(enableY){return{bottom:yScale.invert(brushArea.bottom-marginTop),top:yScale.invert(brushArea.top-marginTop)}}if(enableX){return{left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft)}}return{}}},{key:"startBrushing",value:function startBrushing(e){var _this2=this;var _props5=this.props,onBrushStart=_props5.onBrushStart,onDragStart=_props5.onDragStart,drag=_props5.drag;var dragArea=this.state.dragArea;var _getLocs=getLocs(e.nativeEvent),xLoc=_getLocs.xLoc,yLoc=_getLocs.yLoc;var startArea=function startArea(dragging,resetDrag){var emptyBrush={bottom:yLoc,left:xLoc,right:xLoc,top:yLoc};_this2.setState({dragging:dragging,brushArea:dragArea&&!resetDrag?dragArea:emptyBrush,brushing:!dragging,startLocX:xLoc,startLocY:yLoc})};var clickedOutsideDrag=this._clickedOutsideDrag(xLoc,yLoc);if(drag&&!dragArea||!drag||clickedOutsideDrag){startArea(false,clickedOutsideDrag);if(onBrushStart){onBrushStart(e)}return}if(drag&&dragArea){startArea(true,clickedOutsideDrag);if(onDragStart){onDragStart(e)}}}},{key:"stopBrushing",value:function stopBrushing(e){var _state4=this.state,brushing=_state4.brushing,dragging=_state4.dragging,brushArea=_state4.brushArea;if(!brushing&&!dragging){return}var _props6=this.props,onBrushEnd=_props6.onBrushEnd,onDragEnd=_props6.onDragEnd,drag=_props6.drag;var noHorizontal=Math.abs(brushArea.right-brushArea.left)<5;var noVertical=Math.abs(brushArea.top-brushArea.bottom)<5;var isNulled=noVertical||noHorizontal;this.setState({brushing:false,dragging:false,brushArea:drag?brushArea:{top:0,right:0,bottom:0,left:0},startLocX:0,startLocY:0,dragArea:drag&&!isNulled&&brushArea});if(brushing&&onBrushEnd){onBrushEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}if(drag&&onDragEnd){onDragEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}}},{key:"onBrush",value:function onBrush(e){var _props7=this.props,onBrush=_props7.onBrush,onDrag=_props7.onDrag,drag=_props7.drag;var _state5=this.state,brushing=_state5.brushing,dragging=_state5.dragging;var _getLocs2=getLocs(e.nativeEvent),xLoc=_getLocs2.xLoc,yLoc=_getLocs2.yLoc;if(brushing){var brushArea=this._getDrawArea(xLoc,yLoc);this.setState({brushArea:brushArea});if(onBrush){onBrush(this._convertAreaToCoordinates(brushArea))}}if(drag&&dragging){var _brushArea=this._getDragArea(xLoc,yLoc);this.setState({brushArea:_brushArea});if(onDrag){onDrag(this._convertAreaToCoordinates(_brushArea))}}}},{key:"render",value:function render(){var _this3=this;var _props8=this.props,color=_props8.color,className=_props8.className,highlightHeight=_props8.highlightHeight,highlightWidth=_props8.highlightWidth,highlightX=_props8.highlightX,highlightY=_props8.highlightY,innerWidth=_props8.innerWidth,innerHeight=_props8.innerHeight,marginLeft=_props8.marginLeft,marginRight=_props8.marginRight,marginTop=_props8.marginTop,marginBottom=_props8.marginBottom,opacity=_props8.opacity;var _state$brushArea=this.state.brushArea,left=_state$brushArea.left,right=_state$brushArea.right,top=_state$brushArea.top,bottom=_state$brushArea.bottom;var leftPos=0;if(highlightX){var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");leftPos=xScale(highlightX)}var topPos=0;if(highlightY){var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");topPos=yScale(highlightY)}var plotWidth=marginLeft+marginRight+innerWidth;var plotHeight=marginTop+marginBottom+innerHeight;var touchWidth=highlightWidth||plotWidth;var touchHeight=highlightHeight||plotHeight;return _react2.default.createElement("g",{transform:"translate("+leftPos+", "+topPos+")",className:className+" rv-highlight-container"},_react2.default.createElement("rect",{className:"rv-mouse-target",fill:"black",opacity:"0",x:"0",y:"0",width:Math.max(touchWidth,0),height:Math.max(touchHeight,0),onMouseDown:function onMouseDown(e){return _this3.startBrushing(e)},onMouseMove:function onMouseMove(e){return _this3.onBrush(e)},onMouseUp:function onMouseUp(e){return _this3.stopBrushing(e)},onMouseLeave:function onMouseLeave(e){return _this3.stopBrushing(e)},onTouchEnd:function onTouchEnd(e){e.preventDefault();_this3.stopBrushing(e)},onTouchCancel:function onTouchCancel(e){e.preventDefault();_this3.stopBrushing(e)},onContextMenu:function onContextMenu(e){return e.preventDefault()},onContextMenuCapture:function onContextMenuCapture(e){return e.preventDefault()}}),_react2.default.createElement("rect",{className:"rv-highlight",pointerEvents:"none",opacity:opacity,fill:color,x:left,y:top,width:Math.min(Math.max(0,right-left),touchWidth),height:Math.min(Math.max(0,bottom-top),touchHeight)}))}}]);return Highlight}(_abstractSeries2.default);Highlight.displayName="HighlightOverlay";Highlight.defaultProps={color:"rgb(77, 182, 172)",className:"",enableX:true,enableY:true,opacity:.3};Highlight.propTypes=_extends({},_abstractSeries2.default.propTypes,{enableX:_propTypes2.default.bool,enableY:_propTypes2.default.bool,highlightHeight:_propTypes2.default.number,highlightWidth:_propTypes2.default.number,highlightX:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),highlightY:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),onBrushStart:_propTypes2.default.func,onDragStart:_propTypes2.default.func,onBrush:_propTypes2.default.func,onDrag:_propTypes2.default.func,onBrushEnd:_propTypes2.default.func,onDragEnd:_propTypes2.default.func});exports.default=Highlight},{"../utils/scales-utils":145,"./series/abstract-series":99,"prop-types":33,react:73}],97:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?ALIGN.LEFT:ALIGN.RIGHT}if(vertical===ALIGN.AUTO){align.vertical=y>innerHeight/2?ALIGN.TOP:ALIGN.BOTTOM}return align}},{key:"_getAlignClassNames",value:function _getAlignClassNames(align){var orientation=this.props.orientation;var orientationClass=orientation?"rv-hint--orientation-"+orientation:"";return orientationClass+" rv-hint--horizontalAlign-"+align.horizontal+"\n rv-hint--verticalAlign-"+align.vertical}},{key:"_getAlignStyle",value:function _getAlignStyle(align,x,y){return _extends({},this._getXCSS(align.horizontal,x),this._getYCSS(align.vertical,y))}},{key:"_getCSSBottom",value:function _getCSSBottom(y){if(y===undefined||y===null){return{bottom:0}}var _props2=this.props,innerHeight=_props2.innerHeight,marginBottom=_props2.marginBottom;return{bottom:marginBottom+innerHeight-y}}},{key:"_getCSSLeft",value:function _getCSSLeft(x){if(x===undefined||x===null){return{left:0}}var marginLeft=this.props.marginLeft;return{left:marginLeft+x}}},{key:"_getCSSRight",value:function _getCSSRight(x){if(x===undefined||x===null){return{right:0}}var _props3=this.props,innerWidth=_props3.innerWidth,marginRight=_props3.marginRight;return{right:marginRight+innerWidth-x}}},{key:"_getCSSTop",value:function _getCSSTop(y){if(y===undefined||y===null){return{top:0}}var marginTop=this.props.marginTop;return{top:marginTop+y}}},{key:"_getPositionInfo",value:function _getPositionInfo(){var _props4=this.props,value=_props4.value,getAlignStyle=_props4.getAlignStyle +;var x=(0,_scalesUtils.getAttributeFunctor)(this.props,"x")(value);var y=(0,_scalesUtils.getAttributeFunctor)(this.props,"y")(value);var align=this._getAlign(x,y);return{position:getAlignStyle?getAlignStyle(align,x,y):this._getAlignStyle(align,x,y),className:this._getAlignClassNames(align)}}},{key:"_getXCSS",value:function _getXCSS(horizontal,x){switch(horizontal){case ALIGN.LEFT_EDGE:return this._getCSSLeft(null);case ALIGN.RIGHT_EDGE:return this._getCSSRight(null);case ALIGN.LEFT:return this._getCSSRight(x);case ALIGN.RIGHT:default:return this._getCSSLeft(x)}}},{key:"_getYCSS",value:function _getYCSS(verticalAlign,y){switch(verticalAlign){case ALIGN.TOP_EDGE:return this._getCSSTop(null);case ALIGN.BOTTOM_EDGE:return this._getCSSBottom(null);case ALIGN.BOTTOM:return this._getCSSTop(y);case ALIGN.TOP:default:return this._getCSSBottom(y)}}},{key:"_mapOrientationToAlign",value:function _mapOrientationToAlign(orientation){switch(orientation){case ORIENTATION.BOTTOM_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.BOTTOM};case ORIENTATION.BOTTOM_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.BOTTOM};case ORIENTATION.TOP_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.TOP};case ORIENTATION.TOP_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.TOP};default:break}}},{key:"render",value:function render(){var _props5=this.props,value=_props5.value,format=_props5.format,children=_props5.children,style=_props5.style;var _getPositionInfo2=this._getPositionInfo(),position=_getPositionInfo2.position,className=_getPositionInfo2.className;return _react2.default.createElement("div",{className:"rv-hint "+className,style:_extends({},style,position,{position:"absolute"})},children?children:_react2.default.createElement("div",{className:"rv-hint__content",style:style.content},format(value).map(function(formattedProp,i){return _react2.default.createElement("div",{key:"rv-hint"+i,style:style.row},_react2.default.createElement("span",{className:"rv-hint__title",style:style.title},formattedProp.title),": ",_react2.default.createElement("span",{className:"rv-hint__value",style:style.value},formattedProp.value))})))}}],[{key:"defaultProps",get:function get(){return{format:defaultFormat,align:{horizontal:ALIGN.AUTO,vertical:ALIGN.AUTO},style:{}}}},{key:"propTypes",get:function get(){return{marginTop:_propTypes2.default.number,marginLeft:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,scales:_propTypes2.default.object,value:_propTypes2.default.object,format:_propTypes2.default.func,style:_propTypes2.default.object,align:_propTypes2.default.shape({horizontal:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.LEFT,ALIGN.RIGHT,ALIGN.LEFT_EDGE,ALIGN.RIGHT_EDGE]),vertical:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.BOTTOM,ALIGN.TOP,ALIGN.BOTTOM_EDGE,ALIGN.TOP_EDGE])}),getAlignStyle:_propTypes2.default.func,orientation:_propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT,ORIENTATION.BOTTOM_RIGHT,ORIENTATION.TOP_LEFT,ORIENTATION.TOP_RIGHT])}}}]);return Hint}(_react.PureComponent);Hint.displayName="Hint";Hint.ORIENTATION=ORIENTATION;Hint.ALIGN=ALIGN;exports.default=Hint},{"../utils/scales-utils":145,"prop-types":33,react:73}],98:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iMAX_DRAWS){clearInterval(drawCycle)}drawIteration+=1},1)}function drawLayers(ctx,height,width,layers,drawIteration){ctx.clearRect(0,0,width,height);layers.forEach(function(layer){var interpolator=layer.interpolator,newProps=layer.newProps,animation=layer.animation;var interpolatedProps=animation?interpolator?interpolator(drawIteration/MAX_DRAWS):interpolator:function(){return{}};layer.renderLayer(_extends({},newProps,interpolatedProps),ctx)})}function buildLayers(newChildren,oldChildren){return newChildren.map(function(child,index){var oldProps=oldChildren[index]?oldChildren[index].props:{};var newProps=child.props;var oldAnimatedProps=(0,_animation.extractAnimatedPropValues)(_extends({},oldProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}));var newAnimatedProps=newProps?(0,_animation.extractAnimatedPropValues)(_extends({},newProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS})):null;var interpolator=(0,_d3Interpolate.interpolate)(oldAnimatedProps,newAnimatedProps);return{renderLayer:child.type.renderLayer,newProps:child.props,animation:child.props.animation,interpolator:interpolator}})}var CanvasWrapper=function(_Component){_inherits(CanvasWrapper,_Component);function CanvasWrapper(){_classCallCheck(this,CanvasWrapper);return _possibleConstructorReturn(this,(CanvasWrapper.__proto__||Object.getPrototypeOf(CanvasWrapper)).apply(this,arguments))}_createClass(CanvasWrapper,[{key:"componentDidMount",value:function componentDidMount(){var ctx=this.canvas.getContext("2d");if(!ctx){return}var pixelRatio=this.props.pixelRatio;if(!ctx){return}ctx.scale(pixelRatio,pixelRatio);this.drawChildren(null,this.props,ctx)}},{key:"componentDidUpdate",value:function componentDidUpdate(oldProps){this.drawChildren(oldProps,this.props,this.canvas.getContext("2d"))}},{key:"drawChildren",value:function drawChildren(oldProps,newProps,ctx){var children=newProps.children,innerHeight=newProps.innerHeight,innerWidth=newProps.innerWidth,marginBottom=newProps.marginBottom,marginLeft=newProps.marginLeft,marginRight=newProps.marginRight,marginTop=newProps.marginTop;if(!ctx){return}var childrenShouldAnimate=children.find(function(child){return child.props.animation});var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;var layers=buildLayers(newProps.children,oldProps?oldProps.children:[]);if(!childrenShouldAnimate){drawLayers(ctx,height,width,layers);return}engageDrawLoop(ctx,height,width,layers)}},{key:"render",value:function render(){var _this2=this;var _props=this.props,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginBottom=_props.marginBottom,marginLeft=_props.marginLeft,marginRight=_props.marginRight,marginTop=_props.marginTop,pixelRatio=_props.pixelRatio;var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;return _react2.default.createElement("div",{style:{left:0,top:0},className:"rv-xy-canvas"},_react2.default.createElement("canvas",{className:"rv-xy-canvas-element",height:height*pixelRatio,width:width*pixelRatio,style:{height:height+"px",width:width+"px"},ref:function ref(_ref){return _this2.canvas=_ref}}),this.props.children)}}],[{key:"defaultProps",get:function get(){return{pixelRatio:window&&window.devicePixelRatio||1}}}]);return CanvasWrapper}(_react.Component);CanvasWrapper.displayName="CanvasWrapper";CanvasWrapper.propTypes={marginBottom:_propTypes2.default.number.isRequired,marginLeft:_propTypes2.default.number.isRequired,marginRight:_propTypes2.default.number.isRequired,marginTop:_propTypes2.default.number.isRequired,innerHeight:_propTypes2.default.number.isRequired,innerWidth:_propTypes2.default.number.isRequired,pixelRatio:_propTypes2.default.number.isRequired};exports.default=CanvasWrapper},{"../../animation":74,"../../utils/series-utils":146,"d3-interpolate":11,"prop-types":33,react:73}],105:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i1&&arguments[1]!==undefined?arguments[1]:2;var style=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_STYLE;switch(type){case"diamond":return _react2.default.createElement("polygon",{style:style,points:"0 0 "+size/2+" "+size/2+" 0 "+size+" "+-size/2+" "+size/2+" 0 0"});case"star":var starPoints=[].concat(_toConsumableArray(new Array(5))).map(function(c,index){var angle=index/5*Math.PI*2;var innerAngle=angle+Math.PI/10;var outerAngle=angle-Math.PI/10;var innerRadius=size/2.61;return"\n "+Math.cos(outerAngle)*size+" "+Math.sin(outerAngle)*size+"\n "+Math.cos(innerAngle)*innerRadius+" "+Math.sin(innerAngle)*innerRadius+"\n "}).join(" ");return _react2.default.createElement("polygon",{points:starPoints,x:"0",y:"0",height:size,width:size,style:style});case"square":return _react2.default.createElement("rect",{x:""+-size/2,y:""+-size/2,height:size,width:size,style:style});default:case"circle":return _react2.default.createElement("circle",{cx:"0",cy:"0",r:size/2,style:style})}}function getInnerComponent(_ref){var customComponent=_ref.customComponent,defaultType=_ref.defaultType,positionInPixels=_ref.positionInPixels,positionFunctions=_ref.positionFunctions,style=_ref.style,propsSize=_ref.propsSize;var size=customComponent.size;var aggStyle=_extends({},style,customComponent.style||{});var innerComponent=customComponent.customComponent;if(!innerComponent&&typeof defaultType==="string"){return predefinedComponents(defaultType,size||propsSize,aggStyle)}if(!innerComponent){return defaultType(customComponent,positionInPixels,aggStyle)}if(typeof innerComponent==="string"){return predefinedComponents(innerComponent||defaultType,size,aggStyle)}return innerComponent(customComponent,positionInPixels,aggStyle)}var CustomSVGSeries=function(_AbstractSeries){_inherits(CustomSVGSeries,_AbstractSeries);function CustomSVGSeries(){_classCallCheck(this,CustomSVGSeries);return _possibleConstructorReturn(this,(CustomSVGSeries.__proto__||Object.getPrototypeOf(CustomSVGSeries)).apply(this,arguments))}_createClass(CustomSVGSeries,[{key:"render",value:function render(){var _this2=this;var _props=this.props,animation=_props.animation,className=_props.className,customComponent=_props.customComponent,data=_props.data,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginLeft=_props.marginLeft,marginTop=_props.marginTop,style=_props.style,size=_props.size;if(!data||!innerWidth||!innerHeight){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(CustomSVGSeries,_extends({},this.props,{animation:false})))}var x=this._getAttributeFunctor("x");var y=this._getAttributeFunctor("y");var contents=data.map(function(seriesComponent,index){var positionInPixels={x:x({x:seriesComponent.x}),y:y({y:seriesComponent.y})};var innerComponent=getInnerComponent({customComponent:seriesComponent,positionInPixels:positionInPixels,defaultType:customComponent,positionFunctions:{x:x,y:y},style:style,propsSize:size});return _react2.default.createElement("g",{className:"rv-xy-plot__series--custom-svg",key:"rv-xy-plot__series--custom-svg-"+index,transform:"translate("+positionInPixels.x+","+positionInPixels.y+")",onMouseEnter:function onMouseEnter(e){return _this2._valueMouseOverHandler(seriesComponent,e)},onMouseLeave:function onMouseLeave(e){return _this2._valueMouseOutHandler(seriesComponent,e)}},innerComponent)});return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},contents)}}]);return CustomSVGSeries}(_abstractSeries2.default);CustomSVGSeries.propTypes={animation:_propTypes2.default.bool,className:_propTypes2.default.string,customComponent:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.func]),data:_propTypes2.default.arrayOf(_propTypes2.default.shape({x:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired,y:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired})).isRequired,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,style:_propTypes2.default.object,size:_propTypes2.default.number,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func};CustomSVGSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{animation:false,customComponent:"circle",style:{},size:2});exports.default=CustomSVGSeries},{"../../animation":74,"../../utils/series-utils":146,"./abstract-series":99,"prop-types":33,react:73}],107:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;ipositiveYVariance;if(!hasXWhiskers&&!hasYWhiskers){return null}var styleAttr=_extends({opacity:opacityFunctor?opacityFunctor(d):_theme.DEFAULT_OPACITY,stroke:strokeFunctor&&strokeFunctor(d),strokeWidth:strokeWidth||DEFAULT_STROKE_WIDTH},style);var crossBarExtension=crossBarWidth/2;var rightLineAttrs={x1:cx+r,y1:cy,x2:positiveXVariance,y2:cy,style:styleAttr};var leftLineAttrs={x1:cx-r,y1:cy,x2:negativeXVariance,y2:cy,style:styleAttr};var rightCrossBarAttrs={x1:positiveXVariance,y1:cy-crossBarExtension,x2:positiveXVariance,y2:cy+crossBarExtension,style:styleAttr};var leftCrossBarAttrs={x1:negativeXVariance,y1:cy-crossBarExtension,x2:negativeXVariance,y2:cy+crossBarExtension,style:styleAttr};var upperLineAttrs={x1:cx,y1:cy-r,x2:cx,y2:positiveYVariance,style:styleAttr};var lowerLineAttrs={x1:cx,y1:cy+r,x2:cx,y2:negativeYVariance,style:styleAttr};var upperCrossBarAttrs={x1:cx-crossBarExtension,y1:positiveYVariance,x2:cx+crossBarExtension,y2:positiveYVariance,style:styleAttr};var lowerCrossBarAttrs={x1:cx-crossBarExtension,y1:negativeYVariance,x2:cx+crossBarExtension,y2:negativeYVariance,style:styleAttr};return _react2.default.createElement("g",{className:"mark-whiskers",key:i,onClick:function onClick(e){return valueClickHandler(d,e)},onContextMenu:function onContextMenu(e){return valueRightClickHandler(d,e)},onMouseOver:function onMouseOver(e){return valueMouseOverHandler(d,e)},onMouseOut:function onMouseOut(e){return valueMouseOutHandler(d,e)}},hasXWhiskers?_react2.default.createElement("g",{className:"x-whiskers"},_react2.default.createElement("line",rightLineAttrs),_react2.default.createElement("line",leftLineAttrs),_react2.default.createElement("line",rightCrossBarAttrs),_react2.default.createElement("line",leftCrossBarAttrs)):null,hasYWhiskers?_react2.default.createElement("g",{className:"y-whiskers"},_react2.default.createElement("line",upperLineAttrs),_react2.default.createElement("line",lowerLineAttrs),_react2.default.createElement("line",upperCrossBarAttrs),_react2.default.createElement("line",lowerCrossBarAttrs)):null)}};var WhiskerSeries=function(_AbstractSeries){_inherits(WhiskerSeries,_AbstractSeries);function WhiskerSeries(){_classCallCheck(this,WhiskerSeries);return _possibleConstructorReturn(this,(WhiskerSeries.__proto__||Object.getPrototypeOf(WhiskerSeries)).apply(this,arguments))}_createClass(WhiskerSeries,[{key:"render",value:function render(){var _props=this.props,animation=_props.animation,className=_props.className,crossBarWidth=_props.crossBarWidth,data=_props.data,marginLeft=_props.marginLeft,marginTop=_props.marginTop,strokeWidth=_props.strokeWidth,style=_props.style;if(!data){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(WhiskerSeries,_extends({},this.props,{animation:null})))}var whiskerMarkProps={crossBarWidth:crossBarWidth,opacityFunctor:this._getAttributeFunctor("opacity"),sizeFunctor:this._getAttributeFunctor("size"),strokeFunctor:this._getAttributeFunctor("stroke")||this._getAttributeFunctor("color"),strokeWidth:strokeWidth,style:style,xFunctor:this._getAttributeFunctor("x"),yFunctor:this._getAttributeFunctor("y"),valueClickHandler:this._valueClickHandler,valueRightClickHandler:this._valueRightClickHandler,valueMouseOverHandler:this._valueMouseOverHandler,valueMouseOutHandler:this._valueMouseOutHandler};return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},data.map(renderWhiskerMark(whiskerMarkProps)))}}]);return WhiskerSeries}(_abstractSeries2.default);WhiskerSeries.displayName="WhiskerSeries";WhiskerSeries.propTypes=_extends({},_abstractSeries2.default.propTypes,{strokeWidth:_propTypes2.default.number});WhiskerSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{crossBarWidth:DEFAULT_CROSS_BAR_WIDTH,size:0,strokeWidth:DEFAULT_STROKE_WIDTH});exports.default=WhiskerSeries},{"../../animation":74,"../../theme":136,"../../utils/series-utils":146,"./abstract-series":99,"prop-types":33,react:73}],128:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i-1&&index0){if(Math.abs(axisEndPoint-.5)<=epsilon){axisEndPoint=.5}}else if(axisEndPoint<0){if(Math.abs(axisEndPoint+.5)<=epsilon){axisEndPoint=-.5}}return axisEndPoint}function getLabels(props){var domains=props.domains,startingAngle=props.startingAngle,style=props.style;return domains.map(function(_ref,index){var name=_ref.name;var angle=index/domains.length*Math.PI*2+startingAngle;var radius=1.2;return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),label:name,style:style}})}function getPolygons(props){var animation=props.animation,colorRange=props.colorRange,domains=props.domains,data=props.data,style=props.style,startingAngle=props.startingAngle,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var scales=domains.reduce(function(acc,_ref2){var domain=_ref2.domain,name=_ref2.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref3,index){var name=_ref3.name,getValue=_ref3.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),name:row.name}});return _react2.default.createElement(_polygonSeries2.default,{animation:animation,className:predefinedClassName+"-polygon",key:rowIndex+"-polygon",data:mappedData,style:_extends({stroke:row.color||row.stroke||colorRange[rowIndex%colorRange.length],fill:row.color||row.fill||colorRange[rowIndex%colorRange.length]},style.polygons),onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut})})}function getPolygonPoints(props){var animation=props.animation,domains=props.domains,data=props.data,startingAngle=props.startingAngle,style=props.style,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut;if(!onValueMouseOver){return}var scales=domains.reduce(function(acc,_ref4){var domain=_ref4.domain,name=_ref4.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref5,index){var name=_ref5.name,getValue=_ref5.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),domain:name,value:dataPoint,dataName:row.name}});return _react2.default.createElement(_markSeries2.default,{animation:animation,className:predefinedClassName+"-polygonPoint",key:rowIndex+"-polygonPoint",data:mappedData,size:10,style:_extends({},style.polygons,{fill:"transparent",stroke:"transparent"}),onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut})})}function RadarChart(props){var animation=props.animation,className=props.className,children=props.children,colorRange=props.colorRange,data=props.data,domains=props.domains,height=props.height,hideInnerMostValues=props.hideInnerMostValues,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,startingAngle=props.startingAngle,style=props.style,tickFormat=props.tickFormat,width=props.width,renderAxesOverPolygons=props.renderAxesOverPolygons,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,startingAngle:startingAngle,style:style,tickFormat:tickFormat});var polygons=getPolygons({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut});var polygonPoints=getPolygonPoints({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:animation,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels,startingAngle:startingAngle})});return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-1,1],yDomain:[-1,1]},children,!renderAxesOverPolygons&&axes.concat(polygons).concat(labelSeries).concat(polygonPoints),renderAxesOverPolygons&&polygons.concat(labelSeries).concat(axes).concat(polygonPoints))}RadarChart.displayName="RadarChart";RadarChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,hideInnerMostValues:_propTypes2.default.bool,margin:_chartUtils.MarginPropType,startingAngle:_propTypes2.default.number,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,polygons:_propTypes2.default.object}),tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,renderAxesOverPolygons:_propTypes2.default.bool,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,onSeriesMouseOver:_propTypes2.default.func,onSeriesMouseOut:_propTypes2.default.func};RadarChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,hideInnerMostValues:true,startingAngle:Math.PI/2,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},polygons:{strokeWidth:.5,strokeOpacity:1,fillOpacity:.1}},tickFormat:DEFAULT_FORMAT,renderAxesOverPolygons:false};exports.default=RadarChart},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/series/label-series":113,"../plot/series/mark-series":119,"../plot/series/polygon-series":120,"../plot/xy-plot":130,"../theme":136,"../utils/chart-utils":142,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],132:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i2&&arguments[2]!==undefined?arguments[2]:1.1;var getLabel=accessors.getLabel,getSubLabel=accessors.getSubLabel;return mappedData.reduce(function(res,row){var angle=row.angle,angle0=row.angle0,radius=row.radius;var centeredAngle=(angle+angle0)/2;var updatedAngle=-1*centeredAngle+Math.PI/2;var newLabels=[];if(getLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getLabel(row)})}if(getSubLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getSubLabel(row),style:{fontSize:10},yOffset:12})}return res.concat(newLabels)},[])}function getMaxRadius(width,height){return Math.min(width,height)/2-DEFAULT_RADIUS_MARGIN}function RadialChart(props){var animation=props.animation,className=props.className,children=props.children,colorType=props.colorType,data=props.data,getAngle=props.getAngle,getLabel=props.getLabel,getSubLabel=props.getSubLabel,height=props.height,hideRootNode=props.hideRootNode,innerRadius=props.innerRadius,labelsAboveChildren=props.labelsAboveChildren,labelsRadiusMultiplier=props.labelsRadiusMultiplier,labelsStyle=props.labelsStyle,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,radius=props.radius,showLabels=props.showLabels,style=props.style,width=props.width;var mappedData=getWedgesToRender({data:data,height:height,hideRootNode:hideRootNode,width:width,getAngle:getAngle});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var arcProps=_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:mappedData,radiusNoFallBack:true,style:style,arcClassName:"rv-radial-chart__series--pie__slice"});if(radius){arcProps.radiusDomain=[0,1];arcProps.radiusRange=[innerRadius||0,radius];arcProps.radiusType="linear"}var maxRadius=radius?radius:getMaxRadius(width,height);var defaultMargin=(0,_chartUtils.getRadialLayoutMargin)(width,height,maxRadius);var labels=generateLabels(mappedData,{getLabel:getLabel,getSubLabel:getSubLabel},labelsRadiusMultiplier);return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:_extends({},margin,defaultMargin),className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({},arcProps,{getAngle:function getAngle(d){return d.angle}})),showLabels&&!labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}),children,showLabels&&labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}))}RadialChart.displayName="RadialChart";RadialChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.arrayOf(_propTypes2.default.shape({angle:_propTypes2.default.number,className:_propTypes2.default.string,label:_propTypes2.default.string,radius:_propTypes2.default.number,style:_propTypes2.default.object})).isRequired,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number]),getRadius:_propTypes2.default.func,getRadius0:_propTypes2.default.func,getLabel:_propTypes2.default.func,height:_propTypes2.default.number.isRequired,labelsAboveChildren:_propTypes2.default.bool,labelsStyle:_propTypes2.default.object,margin:_chartUtils.MarginPropType,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,showLabels:_propTypes2.default.bool,style:_propTypes2.default.object,subLabel:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};RadialChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,padAngle:0,getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},getRadius:function getRadius(d){return d.radius},getRadius0:function getRadius0(d){return d.radius0},getLabel:function getLabel(d){return d.label},getSubLabel:function getSubLabel(d){return d.subLabel}};exports.default=RadialChart},{"../animation":74,"../plot/series/arc-series":100,"../plot/series/label-series":113,"../plot/xy-plot":130,"../theme":136,"../utils/chart-utils":142,"../utils/series-utils":146,"d3-shape":15,"prop-types":33,react:73}],133:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i90?"end":"start"},row.labelStyle),rotation:rotateLabels?rotAngle>90?rotAngle+180:rotAngle===90?90:rotAngle:null})})}var NOOP=function NOOP(){};function Sunburst(props){var getAngle=props.getAngle,getAngle0=props.getAngle0,animation=props.animation,className=props.className,children=props.children,data=props.data,height=props.height,hideRootNode=props.hideRootNode,getLabel=props.getLabel,width=props.width,getSize=props.getSize,colorType=props.colorType;var mappedData=getNodesToRender({data:data,height:height,hideRootNode:hideRootNode,width:width,getSize:getSize});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var margin=(0,_chartUtils.getRadialLayoutMargin)(width,height,radialDomain);var labelData=buildLabels(mappedData,{getAngle:getAngle,getAngle0:getAngle0,getLabel:getLabel,getRadius0:function getRadius0(d){return d.radius0}});var hofBuilder=function hofBuilder(f){return function(e,i){return f?f(mappedData[e.index],i):NOOP}};return _react2.default.createElement(_xyPlot2.default,{height:height,hasTreeStructure:true,width:width,className:predefinedClassName+" "+className,margin:margin,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:animation?mappedData.map(function(row,index){return _extends({},row,{parent:null,children:null,index:index})}):mappedData,_data:animation?mappedData:null,arcClassName:predefinedClassName+"__series--radial__arc"},LISTENERS_TO_OVERWRITE.reduce(function(acc,propName){var prop=props[propName];acc[propName]=animation?hofBuilder(prop):prop;return acc},{}))),labelData.length>0&&_react2.default.createElement(_labelSeries2.default,{data:labelData,getLabel:getLabel}),children)}Sunburst.displayName="Sunburst";Sunburst.propTypes={animation:_animation.AnimationPropType,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.object.isRequired,height:_propTypes2.default.number.isRequired,hideRootNode:_propTypes2.default.bool,getLabel:_propTypes2.default.func,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,getSize:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number])};Sunburst.defaultProps={getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},className:"",colorType:"literal",getColor:function getColor(d){return d.color},hideRootNode:false,getLabel:function getLabel(d){return d.label},getSize:function getSize(d){return d.size},padAngle:0};exports.default=Sunburst},{"../animation":74,"../plot/series/arc-series":100,"../plot/series/label-series":113,"../plot/xy-plot":130,"../utils/chart-utils":142,"../utils/series-utils":146,"d3-hierarchy":10,"d3-scale":14,"prop-types":33,react:73}],136:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var DISCRETE_COLOR_RANGE=exports.DISCRETE_COLOR_RANGE=["#12939A","#79C7E3","#1A3177","#FF9833","#EF5D28"];var EXTENDED_DISCRETE_COLOR_RANGE=exports.EXTENDED_DISCRETE_COLOR_RANGE=["#19CDD7","#DDB27C","#88572C","#FF991F","#F15C17","#223F9A","#DA70BF","#125C77","#4DC19C","#776E57","#12939A","#17B8BE","#F6D18A","#B7885E","#FFCB99","#F89570","#829AE3","#E79FD5","#1E96BE","#89DAC1","#B3AD9E"];var CONTINUOUS_COLOR_RANGE=exports.CONTINUOUS_COLOR_RANGE=["#EF5D28","#FF9833"];var SIZE_RANGE=exports.SIZE_RANGE=[1,10];var OPACITY_RANGE=exports.OPACITY_RANGE=[.1,1];var OPACITY_TYPE=exports.OPACITY_TYPE="literal";var DEFAULT_OPACITY=exports.DEFAULT_OPACITY=1;var DEFAULT_SIZE=exports.DEFAULT_SIZE=5;var DEFAULT_COLOR=exports.DEFAULT_COLOR=DISCRETE_COLOR_RANGE[0];var DEFAULT_TICK_SIZE=exports.DEFAULT_TICK_SIZE=7},{}],137:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i300){return 10}return 5}return 20}function getTickValues(scale,tickTotal,tickValues){return!tickValues?scale.ticks?scale.ticks(tickTotal):scale.domain():tickValues}function generateFit(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return{left:axisStart.y,right:axisEnd.y,slope:0,offset:axisStart.x}}var slope=(axisStart.y-axisEnd.y)/(axisStart.x-axisEnd.x);return{left:axisStart.x,right:axisEnd.x,slope:slope,offset:axisStart.y-slope*axisStart.x}}function generatePoints(_ref){var axisStart=_ref.axisStart,axisEnd=_ref.axisEnd,numberOfTicks=_ref.numberOfTicks,axisDomain=_ref.axisDomain;var _generateFit=generateFit(axisStart,axisEnd),left=_generateFit.left,right=_generateFit.right,slope=_generateFit.slope,offset=_generateFit.offset;var pointSlope=(right-left)/numberOfTicks;var axisScale=(0,_d3Scale.scaleLinear)().domain([left,right]).range(axisDomain);var slopeVertical=axisStart.x===axisEnd.x;return{slope:slopeVertical?Infinity:slope,points:(0,_d3Array.range)(left,right+pointSlope,pointSlope).map(function(val){if(slopeVertical){return{y:val,x:slope*val+offset,text:axisScale(val)}}return{x:val,y:slope*val+offset,text:axisScale(val)}}).slice(0,numberOfTicks+1)}}function getAxisAngle(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return axisEnd.y>axisStart.y?Math.PI/2:3*Math.PI/2}return Math.atan((axisEnd.y-axisStart.y)/(axisEnd.x-axisStart.x))}exports.default={DIRECTION:DIRECTION,ORIENTATION:ORIENTATION,getTicksTotalFromSize:getTicksTotalFromSize,getTickValues:getTickValues}},{"d3-array":3,"d3-scale":14}],142:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_MARGINS=exports.MarginPropType=undefined;var _extends=Object.assign||function(target){for(var i=1;ivalue){result[0]=value}if(result[result.length-1]13||Number(major)>13;var isReactDOMSupported=exports.isReactDOMSupported=function isReactDOMSupported(){return versionHigherThanThirteen};var getDOMNode=exports.getDOMNode=function getDOMNode(ref){if(!isReactDOMSupported()){return ref&&ref.getDOMNode()}return ref};var USED_MESSAGES={};var HIDDEN_PROCESSES={test:true,production:true};function warning(message){var onlyShowMessageOnce=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(global.process&&HIDDEN_PROCESSES[process.env.NODE_ENV]){return}if(!onlyShowMessageOnce||!USED_MESSAGES[message]){console.warn(message);USED_MESSAGES[message]=true}}function warnOnce(message){warning(message,true)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:1,react:73}],145:[function(require,module,exports){"use strict";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[Symbol.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(Symbol.iterator in Object(arr)){return sliceIterator(arr,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();var _extends=Object.assign||function(target){for(var i=1;istop-scale.padding()*scale.step())domainIndex=n-1;else domainIndex=Math.floor((_-start-scale.padding()*scale.step())/scale.step());return scale.domain()[domainIndex]}}function getScaleFnFromScaleObject(scaleObject){if(!scaleObject){return null}var type=scaleObject.type,domain=scaleObject.domain,range=scaleObject.range;var modDomain=domain[0]===domain[1]?domain[0]===0?[-1,0]:[-domain[0],domain[0]]:domain;if(type===LITERAL_SCALE_TYPE){return literalScale(range[0])}var scale=SCALE_FUNCTIONS[type]().domain(modDomain).range(range);if(type===ORDINAL_SCALE_TYPE){scale.padding(.5);addInvertFunctionToOrdinalScaleObject(scale)}return scale}function getDomainByAccessor(allData,accessor,accessor0,type){var domain=void 0;var values=allData.reduce(function(data,d){var value=accessor(d);var value0=accessor0(d);if(_isDefined(value)){data.push(value)}if(_isDefined(value0)){data.push(value0)}return data},[]);if(!values.length){return[]}if(type!==ORDINAL_SCALE_TYPE&&type!==CATEGORY_SCALE_TYPE){domain=(0,_d3Array.extent)(values)}else{domain=(0,_d3Collection.set)(values).values()}return domain}function _createScaleObjectForValue(attr,value,type,accessor,accessor0){if(type===LITERAL_SCALE_TYPE){return{type:LITERAL_SCALE_TYPE,domain:[],range:[value],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}if(typeof value==="undefined"){return null}return{type:CATEGORY_SCALE_TYPE,range:[value],domain:[],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}function _createScaleObjectForFunction(_ref){var domain=_ref.domain,range=_ref.range,type=_ref.type,distance=_ref.distance,attr=_ref.attr,baseValue=_ref.baseValue,accessor=_ref.accessor,accessor0=_ref.accessor0;return{domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,isValue:false,accessor:accessor,accessor0:accessor0}}function _collectScaleObjectFromProps(props,attr){var value=props[attr],fallbackValue=props["_"+attr+"Value"],range=props[attr+"Range"],_props$=props[attr+"Distance"],distance=_props$===undefined?0:_props$,baseValue=props[attr+"BaseValue"],_props$2=props[attr+"Type"],type=_props$2===undefined?LINEAR_SCALE_TYPE:_props$2,noFallBack=props[attr+"NoFallBack"],_props$3=props["get"+toTitleCase(attr)],accessor=_props$3===undefined?function(d){return d[attr]}:_props$3,_props$4=props["get"+toTitleCase(attr)+"0"],accessor0=_props$4===undefined?function(d){return d[attr+"0"]}:_props$4;var domain=props[attr+"Domain"];if(!noFallBack&&typeof value!=="undefined"){return _createScaleObjectForValue(attr,value,props[attr+"Type"],accessor,accessor0)}if(typeof baseValue!=="undefined"){domain=(0,_dataUtils.addValueToArray)(domain,baseValue)}if(!range||!domain||!domain.length){return _createScaleObjectForValue(attr,fallbackValue,props[attr+"Type"],accessor,accessor0)}return _createScaleObjectForFunction({domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,accessor:accessor,accessor0:accessor0})}function _computeLeftDomainAdjustment(values){if(values.length>1){return(values[1]-values[0])/2}if(values.length===1){return values[0]-.5}return 0}function _computeRightDomainAdjustment(values){if(values.length>1){return(values[values.length-1]-values[values.length-2])/2}if(values.length===1){return values[0]-.5}return 0}function _computeScaleDistance(values,domain,bestDistIndex,scaleFn){if(values.length>1){var i=Math.max(bestDistIndex,1);return Math.abs(scaleFn(values[i])-scaleFn(values[i-1]))}if(values.length===1){return Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}return 0}function _normalizeValues(data,values,accessor0,type){ +if(type===TIME_SCALE_TYPE&&values.length===1){var attr0=accessor0(data[0]);return[attr0].concat(_toConsumableArray(values))}return values}function _getScaleDistanceAndAdjustedDomain(data,scaleObject){var domain=scaleObject.domain,type=scaleObject.type,accessor=scaleObject.accessor,accessor0=scaleObject.accessor0;var uniqueValues=(0,_dataUtils.getUniquePropertyValues)(data,accessor);var values=_normalizeValues(data,uniqueValues,accessor0,type);var index=_getSmallestDistanceIndex(values,scaleObject);var adjustedDomain=[].concat(domain);adjustedDomain[0]-=_computeLeftDomainAdjustment(values);adjustedDomain[domain.length-1]+=_computeRightDomainAdjustment(values);if(type===LOG_SCALE_TYPE&&domain[0]<=0){adjustedDomain[0]=Math.min(domain[1]/10,1)}var adjustedScaleFn=getScaleFnFromScaleObject(_extends({},scaleObject,{domain:adjustedDomain}));var distance=_computeScaleDistance(values,adjustedDomain,index,adjustedScaleFn);return{domain0:adjustedDomain[0],domainN:adjustedDomain[adjustedDomain.length-1],distance:distance}}function _isScaleAdjustmentPossible(props,scaleObject){var attr=scaleObject.attr;var _props$_adjustBy=props._adjustBy,adjustBy=_props$_adjustBy===undefined?[]:_props$_adjustBy,_props$_adjustWhat=props._adjustWhat,adjustWhat=_props$_adjustWhat===undefined?[]:_props$_adjustWhat;return adjustWhat.length&&adjustBy.length&&adjustBy.indexOf(attr)!==-1}function _adjustContinuousScale(props,scaleObject){var allSeriesData=props._allData,_props$_adjustWhat2=props._adjustWhat,adjustWhat=_props$_adjustWhat2===undefined?[]:_props$_adjustWhat2;var domainLength=scaleObject.domain.length;var domain=scaleObject.domain;var scaleDomain0=domain[0];var scaleDomainN=domain[domainLength-1];var scaleDistance=scaleObject.distance;allSeriesData.forEach(function(data,index){if(adjustWhat.indexOf(index)===-1){return}if(data&&data.length){var _getScaleDistanceAndA=_getScaleDistanceAndAdjustedDomain(data,scaleObject),domain0=_getScaleDistanceAndA.domain0,domainN=_getScaleDistanceAndA.domainN,distance=_getScaleDistanceAndA.distance;scaleDomain0=Math.min(scaleDomain0,domain0);scaleDomainN=Math.max(scaleDomainN,domainN);scaleDistance=Math.max(scaleDistance,distance)}});scaleObject.domain=[scaleDomain0].concat(_toConsumableArray(domain.slice(1,-1)),[scaleDomainN]);scaleObject.distance=scaleDistance;return scaleObject}function _adjustCategoricalScale(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);var domain=scaleObject.domain,range=scaleObject.range;if(domain.length>1){scaleObject.distance=Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}else{scaleObject.distance=Math.abs(range[1]-range[0])}return scaleObject}function getScaleObjectFromProps(props,attr){var scaleObject=_collectScaleObjectFromProps(props,attr);if(!scaleObject){return null}if(!_isScaleAdjustmentPossible(props,scaleObject)){return scaleObject}var type=scaleObject.type;if(type===ORDINAL_SCALE_TYPE||type===CATEGORY_SCALE_TYPE){return _adjustCategoricalScale(scaleObject)}return _adjustContinuousScale(props,scaleObject)}function getAttributeScale(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);return getScaleFnFromScaleObject(scaleObject)}function _getAttrValue(d,accessor){return accessor(d.data?d.data:d)}function _isDefined(value){return typeof value!=="undefined"}function _padDomain(domain,padding){if(!domain){return domain}if(isNaN(parseFloat(domain[0]))||isNaN(parseFloat(domain[1]))){return domain}var _domain=_slicedToArray(domain,2),min=_domain[0],max=_domain[1];var domainPadding=(max-min)*(padding*.01);return[min-domainPadding,max+domainPadding]}function getAttributeFunctor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){return scaleFn(_getAttrValue(d,scaleObject.accessor))}}return null}function getAttr0Functor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var domain=scaleObject.domain;var _scaleObject$baseValu=scaleObject.baseValue,baseValue=_scaleObject$baseValu===undefined?domain[0]:_scaleObject$baseValu;var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){var value=_getAttrValue(d,scaleObject.accessor0);return scaleFn(_isDefined(value)?value:baseValue)}}return null}function getAttributeValue(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){if(!scaleObject.isValue&&props["_"+attr+"Value"]===undefined){(0,_reactUtils.warning)("[React-vis] Cannot use data defined "+attr+" for this "+"series type. Using fallback value instead.")}return props["_"+attr+"Value"]||scaleObject.range[0]}return null}function getScalePropTypesByAttribute(attr){var _ref2;return _ref2={},_defineProperty(_ref2,"_"+attr+"Value",_propTypes2.default.any),_defineProperty(_ref2,attr+"Domain",_propTypes2.default.array),_defineProperty(_ref2,"get"+toTitleCase(attr),_propTypes2.default.func),_defineProperty(_ref2,"get"+toTitleCase(attr)+"0",_propTypes2.default.func),_defineProperty(_ref2,attr+"Range",_propTypes2.default.array),_defineProperty(_ref2,attr+"Type",_propTypes2.default.oneOf(Object.keys(SCALE_FUNCTIONS))),_defineProperty(_ref2,attr+"Distance",_propTypes2.default.number),_defineProperty(_ref2,attr+"BaseValue",_propTypes2.default.any),_ref2}function extractScalePropsFromProps(props,attributes){var result={};Object.keys(props).forEach(function(key){var attr=attributes.find(function(a){var isPlainSet=key.indexOf(a)===0;var isUnderscoreSet=key.indexOf("_"+a)===0;var usesGet=key.indexOf("get"+toTitleCase(a))===0;return isPlainSet||isUnderscoreSet||usesGet});if(!attr){return}result[key]=props[key]});return result}function getMissingScaleProps(props,data,attributes){var result={};attributes.forEach(function(attr){if(!props["get"+toTitleCase(attr)]){result["get"+toTitleCase(attr)]=function(d){return d[attr]}}if(!props["get"+toTitleCase(attr)+"0"]){result["get"+toTitleCase(attr)+"0"]=function(d){return d[attr+"0"]}}if(!props[attr+"Domain"]){result[attr+"Domain"]=getDomainByAccessor(data,props["get"+toTitleCase(attr)]||result["get"+toTitleCase(attr)],props["get"+toTitleCase(attr)+"0"]||result["get"+toTitleCase(attr)+"0"],props[attr+"Type"]);if(props[attr+"Padding"]){result[attr+"Domain"]=_padDomain(result[attr+"Domain"],props[attr+"Padding"])}}});return result}function literalScale(defaultValue){function scale(d){if(d===undefined){return defaultValue}return d}function response(){return scale}scale.domain=response;scale.range=response;scale.unknown=response;scale.copy=response;return scale}function getFontColorFromBackground(background){if(background){return(0,_d3Color.hsl)(background).l>.57?"#222":"#fff"}return null}function getXYPlotValues(props,children){var XYPlotScales=XYPLOT_ATTR.reduce(function(prev,attr){var domain=props[attr+"Domain"],range=props[attr+"Range"],type=props[attr+"Type"];if(domain&&range&&type){return _extends({},prev,_defineProperty({},attr,SCALE_FUNCTIONS[type]().domain(domain).range(range)))}return prev},{});return children.map(function(child){return XYPLOT_ATTR.reduce(function(prev,attr){if(child.props&&child.props[attr]!==undefined){var scaleInput=child.props[attr];var scale=XYPlotScales[attr];var fallbackValue=scale?scale(scaleInput):scaleInput;return _extends({},prev,_defineProperty({},"_"+attr+"Value",fallbackValue))}return prev},{})})}var OPTIONAL_SCALE_PROPS=["Padding"];var OPTIONAL_SCALE_PROPS_REGS=OPTIONAL_SCALE_PROPS.map(function(str){return new RegExp(str+"$","i")});function getOptionalScaleProps(props){return Object.keys(props).reduce(function(acc,prop){var propIsNotOptional=OPTIONAL_SCALE_PROPS_REGS.every(function(reg){return!prop.match(reg)});if(propIsNotOptional){return acc}acc[prop]=props[prop];return acc},{})}exports.default={extractScalePropsFromProps:extractScalePropsFromProps,getAttributeScale:getAttributeScale,getAttributeFunctor:getAttributeFunctor,getAttr0Functor:getAttr0Functor,getAttributeValue:getAttributeValue,getDomainByAccessor:getDomainByAccessor,getFontColorFromBackground:getFontColorFromBackground,getMissingScaleProps:getMissingScaleProps,getOptionalScaleProps:getOptionalScaleProps,getScaleObjectFromProps:getScaleObjectFromProps,getScalePropTypesByAttribute:getScalePropTypesByAttribute,getXYPlotValues:getXYPlotValues,literalScale:literalScale}},{"./data-utils":143,"./react-utils":144,"d3-array":3,"d3-collection":4,"d3-color":5,"d3-scale":14,"prop-types":33}],146:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ANIMATED_SERIES_PROPS=undefined;var _extends=Object.assign||function(target){for(var i=1;i0&&arguments[0]!==undefined?arguments[0]:[];if(!data){return false}return data.some(function(row){return row.radius&&row.angle})}function prepareData(data){if(!seriesHasAngleRadius(data)){return data}return data.map(function(row){return _extends({},row,{x:row.radius*Math.cos(row.angle),y:row.radius*Math.sin(row.angle)})})}function getStackedData(children,attr){var areSomeSeriesStacked=children.some(function(series){return series&&series.props.stack});var latestAttrPositions={};return children.reduce(function(accumulator,series,seriesIndex){if(!series){accumulator.push(null);return accumulator}var _series$props=series.props,data=_series$props.data,_series$props$cluster=_series$props.cluster,cluster=_series$props$cluster===undefined?"default":_series$props$cluster,stack=_series$props.stack;var preppedData=prepareData(data,attr);if(!attr||!preppedData||!preppedData.length||areSomeSeriesStacked&&!stack){accumulator.push(preppedData);return accumulator}var attr0=attr+"0";var baseAttr=attr==="y"?"x":"y";accumulator.push(preppedData.map(function(d,dIndex){var _extends2,_latestAttrPositions$2;if(!latestAttrPositions[cluster]){latestAttrPositions[cluster]={}}var prevD=latestAttrPositions[cluster][d[baseAttr]];if(!prevD){var _latestAttrPositions$;latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$={},_defineProperty(_latestAttrPositions$,attr0,d[attr0]),_defineProperty(_latestAttrPositions$,attr,d[attr]),_latestAttrPositions$);return _extends({},d)}var nextD=_extends({},d,(_extends2={},_defineProperty(_extends2,attr0,prevD[attr]),_defineProperty(_extends2,attr,prevD[attr]+d[attr]-(d[attr0]||0)),_extends2));latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$2={},_defineProperty(_latestAttrPositions$2,attr0,nextD[attr0]),_defineProperty(_latestAttrPositions$2,attr,nextD[attr]),_latestAttrPositions$2);return nextD}));return accumulator},[])}function getSeriesPropsFromChildren(children){var result=[];var seriesTypesInfo=collectSeriesTypesInfo(children);var seriesIndex=0;var _opacityValue=_theme.DEFAULT_OPACITY;children.forEach(function(child){var props=void 0;if(isSeriesChild(child)){var seriesTypeInfo=seriesTypesInfo[child.type.displayName];var _colorValue=_theme.DISCRETE_COLOR_RANGE[seriesIndex%_theme.DISCRETE_COLOR_RANGE.length];props=_extends({},seriesTypeInfo,{seriesIndex:seriesIndex,_colorValue:_colorValue,_opacityValue:_opacityValue});seriesTypeInfo.sameTypeIndex++;seriesIndex++;if(child.props.cluster){props.cluster=child.props.cluster;props.clusters=Array.from(seriesTypeInfo.clusters);props.sameTypeTotal=props.clusters.length;props.sameTypeIndex=props.clusters.indexOf(child.props.cluster)}}result.push(props)});return result}function getRadialDomain(data){return data.reduce(function(res,row){return Math.max(row.radius,res)},0)}var ANIMATED_SERIES_PROPS=exports.ANIMATED_SERIES_PROPS=["xRange","xDomain","x","yRange","yDomain","y","colorRange","colorDomain","color","opacityRange","opacityDomain","opacity","strokeRange","strokeDomain","stroke","fillRange","fillDomain","fill","width","height","marginLeft","marginTop","marginRight","marginBottom","data","angleDomain","angleRange","angle","radiusDomain","radiusRange","radius","innerRadiusDomain","innerRadiusRange","innerRadius"];function getStackParams(props){var _stackBy=props._stackBy,valuePosAttr=props.valuePosAttr,cluster=props.cluster;var _props$sameTypeTotal=props.sameTypeTotal,sameTypeTotal=_props$sameTypeTotal===undefined?1:_props$sameTypeTotal,_props$sameTypeIndex=props.sameTypeIndex,sameTypeIndex=_props$sameTypeIndex===undefined?0:_props$sameTypeIndex;if(_stackBy===valuePosAttr&&!cluster){sameTypeTotal=1;sameTypeIndex=0}return{sameTypeTotal:sameTypeTotal,sameTypeIndex:sameTypeIndex}}},{"../plot/series/abstract-series":99,"../theme":136,react:73}]},{},[75])(75)}); diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 000000000..0920cac8e --- /dev/null +++ b/dist/index.js @@ -0,0 +1,327 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ScaleUtils = exports.AxisUtils = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = exports.FlexibleXYPlot = exports.makeWidthFlexible = exports.makeVisFlexible = exports.makeHeightFlexible = exports.Sunburst = exports.Sankey = exports.ParallelCoordinates = exports.RadarChart = exports.RadialChart = exports.Treemap = exports.ContinuousSizeLegend = exports.ContinuousColorLegend = exports.SearchableDiscreteColorLegend = exports.DiscreteColorLegend = exports.Highlight = exports.Voronoi = exports.HorizontalGridLines = exports.VerticalGridLines = exports.GradientDefs = exports.GridLines = exports.CircularGridLines = exports.YAxis = exports.XAxis = exports.DecorativeAxis = exports.XYPlot = exports.Crosshair = exports.Borders = exports.Hint = exports.LineMarkSeriesCanvas = exports.LineMarkSeries = exports.ArcSeries = exports.AreaSeries = exports.CustomSVGSeries = exports.ContourSeries = exports.HexbinSeries = exports.HeatmapSeries = exports.WhiskerSeries = exports.MarkSeriesCanvas = exports.MarkSeries = exports.RectSeriesCanvas = exports.RectSeries = exports.PolygonSeries = exports.LabelSeries = exports.HorizontalRectSeriesCanvas = exports.HorizontalRectSeries = exports.VerticalRectSeriesCanvas = exports.VerticalRectSeries = exports.VerticalBarSeriesCanvas = exports.VerticalBarSeries = exports.HorizontalBarSeriesCanvas = exports.HorizontalBarSeries = exports.LineSeriesCanvas = exports.LineSeries = exports.AbstractSeries = undefined; + +var _makeVisFlexible = require('./make-vis-flexible'); + +Object.defineProperty(exports, 'makeHeightFlexible', { + enumerable: true, + get: function get() { + return _makeVisFlexible.makeHeightFlexible; + } +}); +Object.defineProperty(exports, 'makeVisFlexible', { + enumerable: true, + get: function get() { + return _makeVisFlexible.makeVisFlexible; + } +}); +Object.defineProperty(exports, 'makeWidthFlexible', { + enumerable: true, + get: function get() { + return _makeVisFlexible.makeWidthFlexible; + } +}); +Object.defineProperty(exports, 'FlexibleXYPlot', { + enumerable: true, + get: function get() { + return _makeVisFlexible.FlexibleXYPlot; + } +}); +Object.defineProperty(exports, 'FlexibleWidthXYPlot', { + enumerable: true, + get: function get() { + return _makeVisFlexible.FlexibleWidthXYPlot; + } +}); +Object.defineProperty(exports, 'FlexibleHeightXYPlot', { + enumerable: true, + get: function get() { + return _makeVisFlexible.FlexibleHeightXYPlot; + } +}); + +var _abstractSeries = require('./plot/series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _lineSeries = require('./plot/series/line-series'); + +var _lineSeries2 = _interopRequireDefault(_lineSeries); + +var _lineSeriesCanvas = require('./plot/series/line-series-canvas'); + +var _lineSeriesCanvas2 = _interopRequireDefault(_lineSeriesCanvas); + +var _horizontalBarSeries = require('./plot/series/horizontal-bar-series'); + +var _horizontalBarSeries2 = _interopRequireDefault(_horizontalBarSeries); + +var _horizontalBarSeriesCanvas = require('./plot/series/horizontal-bar-series-canvas'); + +var _horizontalBarSeriesCanvas2 = _interopRequireDefault(_horizontalBarSeriesCanvas); + +var _verticalBarSeries = require('./plot/series/vertical-bar-series'); + +var _verticalBarSeries2 = _interopRequireDefault(_verticalBarSeries); + +var _verticalBarSeriesCanvas = require('./plot/series/vertical-bar-series-canvas'); + +var _verticalBarSeriesCanvas2 = _interopRequireDefault(_verticalBarSeriesCanvas); + +var _verticalRectSeries = require('./plot/series/vertical-rect-series'); + +var _verticalRectSeries2 = _interopRequireDefault(_verticalRectSeries); + +var _verticalRectSeriesCanvas = require('./plot/series/vertical-rect-series-canvas'); + +var _verticalRectSeriesCanvas2 = _interopRequireDefault(_verticalRectSeriesCanvas); + +var _horizontalRectSeries = require('./plot/series/horizontal-rect-series'); + +var _horizontalRectSeries2 = _interopRequireDefault(_horizontalRectSeries); + +var _horizontalRectSeriesCanvas = require('./plot/series/horizontal-rect-series-canvas'); + +var _horizontalRectSeriesCanvas2 = _interopRequireDefault(_horizontalRectSeriesCanvas); + +var _labelSeries = require('./plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _polygonSeries = require('./plot/series/polygon-series'); + +var _polygonSeries2 = _interopRequireDefault(_polygonSeries); + +var _rectSeries = require('./plot/series/rect-series'); + +var _rectSeries2 = _interopRequireDefault(_rectSeries); + +var _rectSeriesCanvas = require('./plot/series/rect-series-canvas'); + +var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); + +var _markSeries = require('./plot/series/mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +var _markSeriesCanvas = require('./plot/series/mark-series-canvas'); + +var _markSeriesCanvas2 = _interopRequireDefault(_markSeriesCanvas); + +var _whiskerSeries = require('./plot/series/whisker-series'); + +var _whiskerSeries2 = _interopRequireDefault(_whiskerSeries); + +var _heatmapSeries = require('./plot/series/heatmap-series'); + +var _heatmapSeries2 = _interopRequireDefault(_heatmapSeries); + +var _hexbinSeries = require('./plot/series/hexbin-series'); + +var _hexbinSeries2 = _interopRequireDefault(_hexbinSeries); + +var _contourSeries = require('./plot/series/contour-series'); + +var _contourSeries2 = _interopRequireDefault(_contourSeries); + +var _customSvgSeries = require('./plot/series/custom-svg-series'); + +var _customSvgSeries2 = _interopRequireDefault(_customSvgSeries); + +var _areaSeries = require('./plot/series/area-series'); + +var _areaSeries2 = _interopRequireDefault(_areaSeries); + +var _arcSeries = require('./plot/series/arc-series'); + +var _arcSeries2 = _interopRequireDefault(_arcSeries); + +var _lineMarkSeries = require('./plot/series/line-mark-series'); + +var _lineMarkSeries2 = _interopRequireDefault(_lineMarkSeries); + +var _lineMarkSeriesCanvas = require('./plot/series/line-mark-series-canvas'); + +var _lineMarkSeriesCanvas2 = _interopRequireDefault(_lineMarkSeriesCanvas); + +var _hint = require('./plot/hint'); + +var _hint2 = _interopRequireDefault(_hint); + +var _borders = require('./plot/borders'); + +var _borders2 = _interopRequireDefault(_borders); + +var _crosshair = require('./plot/crosshair'); + +var _crosshair2 = _interopRequireDefault(_crosshair); + +var _xyPlot = require('./plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _decorativeAxis = require('./plot/axis/decorative-axis'); + +var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); + +var _xAxis = require('./plot/axis/x-axis'); + +var _xAxis2 = _interopRequireDefault(_xAxis); + +var _yAxis = require('./plot/axis/y-axis'); + +var _yAxis2 = _interopRequireDefault(_yAxis); + +var _circularGridLines = require('./plot/circular-grid-lines'); + +var _circularGridLines2 = _interopRequireDefault(_circularGridLines); + +var _gridLines = require('./plot/grid-lines'); + +var _gridLines2 = _interopRequireDefault(_gridLines); + +var _gradientDefs = require('./plot/gradient-defs'); + +var _gradientDefs2 = _interopRequireDefault(_gradientDefs); + +var _verticalGridLines = require('./plot/vertical-grid-lines'); + +var _verticalGridLines2 = _interopRequireDefault(_verticalGridLines); + +var _horizontalGridLines = require('./plot/horizontal-grid-lines'); + +var _horizontalGridLines2 = _interopRequireDefault(_horizontalGridLines); + +var _voronoi = require('./plot/voronoi'); + +var _voronoi2 = _interopRequireDefault(_voronoi); + +var _highlight = require('./plot/highlight'); + +var _highlight2 = _interopRequireDefault(_highlight); + +var _discreteColorLegend = require('./legends/discrete-color-legend'); + +var _discreteColorLegend2 = _interopRequireDefault(_discreteColorLegend); + +var _searchableDiscreteColorLegend = require('./legends/searchable-discrete-color-legend'); + +var _searchableDiscreteColorLegend2 = _interopRequireDefault(_searchableDiscreteColorLegend); + +var _continuousColorLegend = require('./legends/continuous-color-legend'); + +var _continuousColorLegend2 = _interopRequireDefault(_continuousColorLegend); + +var _continuousSizeLegend = require('./legends/continuous-size-legend'); + +var _continuousSizeLegend2 = _interopRequireDefault(_continuousSizeLegend); + +var _treemap = require('./treemap'); + +var _treemap2 = _interopRequireDefault(_treemap); + +var _radialChart = require('./radial-chart'); + +var _radialChart2 = _interopRequireDefault(_radialChart); + +var _radarChart = require('./radar-chart'); + +var _radarChart2 = _interopRequireDefault(_radarChart); + +var _parallelCoordinates = require('./parallel-coordinates'); + +var _parallelCoordinates2 = _interopRequireDefault(_parallelCoordinates); + +var _sankey = require('./sankey'); + +var _sankey2 = _interopRequireDefault(_sankey); + +var _sunburst = require('./sunburst'); + +var _sunburst2 = _interopRequireDefault(_sunburst); + +var _axisUtils = require('./utils/axis-utils'); + +var _axisUtils2 = _interopRequireDefault(_axisUtils); + +var _scalesUtils = require('./utils/scales-utils'); + +var _scalesUtils2 = _interopRequireDefault(_scalesUtils); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.AbstractSeries = _abstractSeries2.default; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.LineSeries = _lineSeries2.default; +exports.LineSeriesCanvas = _lineSeriesCanvas2.default; +exports.HorizontalBarSeries = _horizontalBarSeries2.default; +exports.HorizontalBarSeriesCanvas = _horizontalBarSeriesCanvas2.default; +exports.VerticalBarSeries = _verticalBarSeries2.default; +exports.VerticalBarSeriesCanvas = _verticalBarSeriesCanvas2.default; +exports.VerticalRectSeries = _verticalRectSeries2.default; +exports.VerticalRectSeriesCanvas = _verticalRectSeriesCanvas2.default; +exports.HorizontalRectSeries = _horizontalRectSeries2.default; +exports.HorizontalRectSeriesCanvas = _horizontalRectSeriesCanvas2.default; +exports.LabelSeries = _labelSeries2.default; +exports.PolygonSeries = _polygonSeries2.default; +exports.RectSeries = _rectSeries2.default; +exports.RectSeriesCanvas = _rectSeriesCanvas2.default; +exports.MarkSeries = _markSeries2.default; +exports.MarkSeriesCanvas = _markSeriesCanvas2.default; +exports.WhiskerSeries = _whiskerSeries2.default; +exports.HeatmapSeries = _heatmapSeries2.default; +exports.HexbinSeries = _hexbinSeries2.default; +exports.ContourSeries = _contourSeries2.default; +exports.CustomSVGSeries = _customSvgSeries2.default; +exports.AreaSeries = _areaSeries2.default; +exports.ArcSeries = _arcSeries2.default; +exports.LineMarkSeries = _lineMarkSeries2.default; +exports.LineMarkSeriesCanvas = _lineMarkSeriesCanvas2.default; +exports.Hint = _hint2.default; +exports.Borders = _borders2.default; +exports.Crosshair = _crosshair2.default; +exports.XYPlot = _xyPlot2.default; +exports.DecorativeAxis = _decorativeAxis2.default; +exports.XAxis = _xAxis2.default; +exports.YAxis = _yAxis2.default; +exports.CircularGridLines = _circularGridLines2.default; +exports.GridLines = _gridLines2.default; +exports.GradientDefs = _gradientDefs2.default; +exports.VerticalGridLines = _verticalGridLines2.default; +exports.HorizontalGridLines = _horizontalGridLines2.default; +exports.Voronoi = _voronoi2.default; +exports.Highlight = _highlight2.default; +exports.DiscreteColorLegend = _discreteColorLegend2.default; +exports.SearchableDiscreteColorLegend = _searchableDiscreteColorLegend2.default; +exports.ContinuousColorLegend = _continuousColorLegend2.default; +exports.ContinuousSizeLegend = _continuousSizeLegend2.default; +exports.Treemap = _treemap2.default; +exports.RadialChart = _radialChart2.default; +exports.RadarChart = _radarChart2.default; +exports.ParallelCoordinates = _parallelCoordinates2.default; +exports.Sankey = _sankey2.default; +exports.Sunburst = _sunburst2.default; +exports.AxisUtils = _axisUtils2.default; +exports.ScaleUtils = _scalesUtils2.default; \ No newline at end of file diff --git a/dist/legends/continuous-color-legend.js b/dist/legends/continuous-color-legend.js new file mode 100644 index 000000000..8784a3dcc --- /dev/null +++ b/dist/legends/continuous-color-legend.js @@ -0,0 +1,107 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _theme = require('../theme'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var propTypes = { + className: _propTypes2.default.string, + height: _propTypes2.default.number, + endColor: _propTypes2.default.string, + endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + midColor: _propTypes2.default.string, + midTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + startColor: _propTypes2.default.string, + startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + width: _propTypes2.default.number +}; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var defaultProps = { + className: '', + startColor: _theme.CONTINUOUS_COLOR_RANGE[0], + endColor: _theme.CONTINUOUS_COLOR_RANGE[1] +}; + +function ContinuousColorLegend(_ref) { + var startColor = _ref.startColor, + midColor = _ref.midColor, + endColor = _ref.endColor, + startTitle = _ref.startTitle, + midTitle = _ref.midTitle, + endTitle = _ref.endTitle, + height = _ref.height, + width = _ref.width, + className = _ref.className; + + var colors = [startColor]; + if (midColor) { + colors.push(midColor); + } + colors.push(endColor); + return _react2.default.createElement( + 'div', + { + className: 'rv-continuous-color-legend ' + className, + style: { width: width, height: height } + }, + _react2.default.createElement('div', { + className: 'rv-gradient', + style: { background: 'linear-gradient(to right, ' + colors.join(',') + ')' } + }), + _react2.default.createElement( + 'div', + { className: 'rv-legend-titles' }, + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__left' }, + startTitle + ), + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__right' }, + endTitle + ), + midTitle ? _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__center' }, + midTitle + ) : null + ) + ); +} + +ContinuousColorLegend.displayName = 'ContinuousColorLegend'; +ContinuousColorLegend.propTypes = propTypes; +ContinuousColorLegend.defaultProps = defaultProps; + +exports.default = ContinuousColorLegend; \ No newline at end of file diff --git a/dist/legends/continuous-size-legend.js b/dist/legends/continuous-size-legend.js new file mode 100644 index 000000000..91f072d5e --- /dev/null +++ b/dist/legends/continuous-size-legend.js @@ -0,0 +1,116 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var propTypes = { + className: _propTypes2.default.string, + circlesTotal: _propTypes2.default.number, + endSize: _propTypes2.default.number, + endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + height: _propTypes2.default.number, + startSize: _propTypes2.default.number, + startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + width: _propTypes2.default.number +}; + +var defaultProps = { + circlesTotal: 10, + className: '', + endSize: 20, + startSize: 2 +}; + +function ContinuousSizeLegend(_ref) { + var startTitle = _ref.startTitle, + endTitle = _ref.endTitle, + startSize = _ref.startSize, + endSize = _ref.endSize, + circlesTotal = _ref.circlesTotal, + height = _ref.height, + width = _ref.width, + className = _ref.className; + + var circles = []; + var step = (endSize - startSize) / (circlesTotal - 1); + + for (var i = 0; i < circlesTotal; i++) { + var size = step * i + startSize; + circles.push(_react2.default.createElement('div', { + key: i, + className: 'rv-bubble', + style: { + width: size, + height: size, + borderRadius: size / 2 + } + })); + // Add the separator in order to justify the content (otherwise the tags + // will be stacked together without any margins around). + circles.push(' '); + } + return _react2.default.createElement( + 'div', + { + className: 'rv-continuous-size-legend ' + className, + style: { width: width, height: height } + }, + _react2.default.createElement( + 'div', + { className: 'rv-bubbles', style: { height: endSize } }, + circles, + _react2.default.createElement('div', { className: 'rv-spacer' }) + ), + _react2.default.createElement( + 'div', + { className: 'rv-legend-titles' }, + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__left' }, + startTitle + ), + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__right' }, + endTitle + ) + ) + ); +} + +ContinuousSizeLegend.displayName = 'ContinuousSizeLegend'; +ContinuousSizeLegend.propTypes = propTypes; +ContinuousSizeLegend.defaultProps = defaultProps; + +exports.default = ContinuousSizeLegend; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend-item.js b/dist/legends/discrete-color-legend-item.js new file mode 100644 index 000000000..4b12b4428 --- /dev/null +++ b/dist/legends/discrete-color-legend-item.js @@ -0,0 +1,103 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var STROKE_STYLES = { + dashed: '6, 2', + solid: null +}; + +function DiscreteColorLegendItem(_ref) { + var color = _ref.color, + strokeDasharray = _ref.strokeDasharray, + strokeStyle = _ref.strokeStyle, + strokeWidth = _ref.strokeWidth, + disabled = _ref.disabled, + onClick = _ref.onClick, + orientation = _ref.orientation, + onMouseEnter = _ref.onMouseEnter, + onMouseLeave = _ref.onMouseLeave, + title = _ref.title; + + var className = 'rv-discrete-color-legend-item ' + orientation; + if (disabled) { + className += ' disabled'; + } + if (onClick) { + className += ' clickable'; + } + var strokeDasharrayStyle = STROKE_STYLES[strokeStyle] || strokeDasharray; + return _react2.default.createElement( + 'div', + { className: className, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, + _react2.default.createElement( + 'svg', + { className: 'rv-discrete-color-legend-item__color', height: 2, width: 14 }, + _react2.default.createElement('path', { + className: 'rv-discrete-color-legend-item__color__path', + d: 'M 0, 1 L 14, 1', + style: _extends({}, strokeWidth ? { strokeWidth: strokeWidth } : {}, strokeDasharrayStyle ? { strokeDasharray: strokeDasharrayStyle } : {}, { + stroke: disabled ? null : color + }) + + }) + ), + _react2.default.createElement( + 'span', + { className: 'rv-discrete-color-legend-item__title' }, + title + ) + ); +} + +DiscreteColorLegendItem.propTypes = { + color: _propTypes2.default.string.isRequired, + disabled: _propTypes2.default.bool, + title: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]).isRequired, + onClick: _propTypes2.default.func, + onMouseEnter: _propTypes2.default.func, + onMouseLeave: _propTypes2.default.func, + orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']).isRequired, + strokeDasharray: _propTypes2.default.string, + strokeWidth: _propTypes2.default.number, + strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)) +}; +DiscreteColorLegendItem.defaultProps = { + disabled: false, + strokeStyle: 'solid' +}; +DiscreteColorLegendItem.displayName = 'DiscreteColorLegendItem'; + +exports.default = DiscreteColorLegendItem; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend.js b/dist/legends/discrete-color-legend.js new file mode 100644 index 000000000..76424e745 --- /dev/null +++ b/dist/legends/discrete-color-legend.js @@ -0,0 +1,107 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _discreteColorLegendItem = require('./discrete-color-legend-item'); + +var _discreteColorLegendItem2 = _interopRequireDefault(_discreteColorLegendItem); + +var _theme = require('../theme'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function DiscreteColorLegend(_ref) { + var className = _ref.className, + colors = _ref.colors, + height = _ref.height, + items = _ref.items, + onItemClick = _ref.onItemClick, + onItemMouseEnter = _ref.onItemMouseEnter, + onItemMouseLeave = _ref.onItemMouseLeave, + orientation = _ref.orientation, + style = _ref.style, + width = _ref.width; + + return _react2.default.createElement( + 'div', + { + className: 'rv-discrete-color-legend ' + orientation + ' ' + className, + style: _extends({ width: width, height: height }, style) + }, + items.map(function (item, i) { + return _react2.default.createElement(_discreteColorLegendItem2.default, { + title: item.title ? item.title : item, + color: item.color ? item.color : colors[i % colors.length], + strokeDasharray: item.strokeDasharray, + strokeStyle: item.strokeStyle, + strokeWidth: item.strokeWidth, + disabled: Boolean(item.disabled), + orientation: orientation, + key: i, + onClick: onItemClick ? function (e) { + return onItemClick(item, i, e); + } : null, + onMouseEnter: onItemMouseEnter ? function (e) { + return onItemMouseEnter(item, i, e); + } : null, + onMouseLeave: onItemMouseEnter ? function (e) { + return onItemMouseLeave(item, i, e); + } : null + }); + }) + ); +} + +DiscreteColorLegend.displayName = 'DiscreteColorLegendItem'; +DiscreteColorLegend.propTypes = { + className: _propTypes2.default.string, + items: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.shape({ + title: _propTypes2.default.string.isRequired, + color: _propTypes2.default.string, + disabled: _propTypes2.default.bool + }), _propTypes2.default.string.isRequired, _propTypes2.default.element])).isRequired, + onItemClick: _propTypes2.default.func, + onItemMouseEnter: _propTypes2.default.func, + onItemMouseLeave: _propTypes2.default.func, + height: _propTypes2.default.number, + width: _propTypes2.default.number, + orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']) +}; + +DiscreteColorLegend.defaultProps = { + className: '', + colors: _theme.DISCRETE_COLOR_RANGE, + orientation: 'vertical' +}; + +exports.default = DiscreteColorLegend; \ No newline at end of file diff --git a/dist/legends/searchable-discrete-color-legend.js b/dist/legends/searchable-discrete-color-legend.js new file mode 100644 index 000000000..49e081ef0 --- /dev/null +++ b/dist/legends/searchable-discrete-color-legend.js @@ -0,0 +1,107 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _discreteColorLegend = require('./discrete-color-legend'); + +var _discreteColorLegend2 = _interopRequireDefault(_discreteColorLegend); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var propTypes = _extends({}, _discreteColorLegend2.default.propTypes, { + searchText: _propTypes2.default.string, + onSearchChange: _propTypes2.default.func, + searchPlaceholder: _propTypes2.default.string, + searchFn: _propTypes2.default.func +}); + +var defaultProps = { + className: '', + searchText: '', + searchFn: function searchFn(items, s) { + return items.filter(function (item) { + return String(item.title || item).toLowerCase().indexOf(s) !== -1; + }); + } +}; + +function SearchableDiscreteColorLegend(props) { + var className = props.className, + colors = props.colors, + height = props.height, + items = props.items, + onItemClick = props.onItemClick, + onSearchChange = props.onSearchChange, + orientation = props.orientation, + searchFn = props.searchFn, + searchPlaceholder = props.searchPlaceholder, + searchText = props.searchText, + width = props.width; + + var onChange = onSearchChange ? function (_ref) { + var value = _ref.target.value; + return onSearchChange(value); + } : null; + var filteredItems = searchFn(items, searchText); + return _react2.default.createElement( + 'div', + { className: 'rv-search-wrapper ' + className, style: { width: width, height: height } }, + _react2.default.createElement( + 'form', + { className: 'rv-search-wrapper__form' }, + _react2.default.createElement('input', { + type: 'search', + placeholder: searchPlaceholder, + className: 'rv-search-wrapper__form__input', + value: searchText, + onChange: onChange + }) + ), + _react2.default.createElement( + 'div', + { className: 'rv-search-wrapper__contents' }, + _react2.default.createElement(_discreteColorLegend2.default, { + colors: colors, + items: filteredItems, + onItemClick: onItemClick, + orientation: orientation + }) + ) + ); +} + +SearchableDiscreteColorLegend.propTypes = propTypes; +SearchableDiscreteColorLegend.defaultProps = defaultProps; +SearchableDiscreteColorLegend.displayName = 'SearchableDiscreteColorLegend'; + +exports.default = SearchableDiscreteColorLegend; \ No newline at end of file diff --git a/dist/main.scss b/dist/main.scss new file mode 100644 index 000000000..30bac3dc2 --- /dev/null +++ b/dist/main.scss @@ -0,0 +1,9 @@ +// special tag for using to check if the style file has been imported +.react-vis-magic-css-import-rule { + display: inherit; +} + +@import 'styles/treemap'; +@import 'styles/plot'; +@import 'styles/legends'; +@import 'styles/radial-chart'; diff --git a/dist/make-vis-flexible.js b/dist/make-vis-flexible.js new file mode 100644 index 000000000..c99808b61 --- /dev/null +++ b/dist/make-vis-flexible.js @@ -0,0 +1,250 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.FlexibleXYPlot = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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; }; }(); + +exports.makeHeightFlexible = makeHeightFlexible; +exports.makeVisFlexible = makeVisFlexible; +exports.makeWidthFlexible = makeWidthFlexible; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _window = require('global/window'); + +var _window2 = _interopRequireDefault(_window); + +var _xyPlot = require('./plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _reactUtils = require('./utils/react-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var CONTAINER_REF = 'container'; + +// As a performance enhancement, we want to only listen once +var resizeSubscribers = []; +var DEBOUNCE_DURATION = 100; +var timeoutId = null; + +/** + * Calls each subscriber, debounced to the + */ +function debounceEmitResize() { + _window2.default.clearTimeout(timeoutId); + timeoutId = _window2.default.setTimeout(emitResize, DEBOUNCE_DURATION); +} + +/** + * Calls each subscriber once syncronously. + */ +function emitResize() { + resizeSubscribers.forEach(function (cb) { + return cb(); + }); +} + +/** + * Add the given callback to the list of subscribers to be caled when the + * window resizes. Returns a function that, when called, removes the given + * callback from the list of subscribers. This function is also resposible for + * adding and removing the resize listener on `window`. + * + * @param {Function} cb - Subscriber callback function + * @returns {Function} Unsubscribe function + */ +function subscribeToDebouncedResize(cb) { + resizeSubscribers.push(cb); + + // if we go from zero to one Flexible components instances, add the listener + if (resizeSubscribers.length === 1) { + _window2.default.addEventListener('resize', debounceEmitResize); + } + return function unsubscribe() { + removeSubscriber(cb); + + // if we have no Flexible components, remove the listener + if (resizeSubscribers.length === 0) { + _window2.default.clearTimeout(timeoutId); + _window2.default.removeEventListener('resize', debounceEmitResize); + } + }; +} + +/** + * Helper for removing the given callback from the list of subscribers. + * + * @param {Function} cb - Subscriber callback function + */ +function removeSubscriber(cb) { + var index = resizeSubscribers.indexOf(cb); + if (index > -1) { + resizeSubscribers.splice(index, 1); + } +} + +/** + * Helper for getting a display name for the child component + * @param {*} Component React class for the child component. + * @returns {String} The child components name + */ +function getDisplayName(Component) { + return Component.displayName || Component.name || 'Component'; +} + +/** + * Add the ability to stretch the visualization on window resize. + * @param {*} Component React class for the child component. + * @returns {*} Flexible component. + */ + +function makeFlexible(Component, isWidthFlexible, isHeightFlexible) { + var ResultClass = function (_React$Component) { + _inherits(ResultClass, _React$Component); + + _createClass(ResultClass, null, [{ + key: 'propTypes', + get: function get() { + var _Component$propTypes = Component.propTypes, + height = _Component$propTypes.height, + width = _Component$propTypes.width, + otherPropTypes = _objectWithoutProperties(_Component$propTypes, ['height', 'width']); // eslint-disable-line no-unused-vars + + + return otherPropTypes; + } + }]); + + function ResultClass(props) { + _classCallCheck(this, ResultClass); + + var _this = _possibleConstructorReturn(this, (ResultClass.__proto__ || Object.getPrototypeOf(ResultClass)).call(this, props)); + + _this._onResize = function () { + var containerElement = (0, _reactUtils.getDOMNode)(_this[CONTAINER_REF]); + var offsetHeight = containerElement.offsetHeight, + offsetWidth = containerElement.offsetWidth; + + + var newHeight = _this.state.height === offsetHeight ? {} : { height: offsetHeight }; + + var newWidth = _this.state.width === offsetWidth ? {} : { width: offsetWidth }; + + _this.setState(_extends({}, newHeight, newWidth)); + }; + + _this.state = { + height: 0, + width: 0 + }; + return _this; + } + + /** + * Get the width of the container and assign the width. + * @private + */ + + + _createClass(ResultClass, [{ + key: 'componentDidMount', + value: function componentDidMount() { + this._onResize(); + this.cancelSubscription = subscribeToDebouncedResize(this._onResize); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps() { + this._onResize(); + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + this.cancelSubscription(); + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _state = this.state, + height = _state.height, + width = _state.width; + + var props = _extends({}, this.props, { + animation: height === 0 && width === 0 ? null : this.props.animation + }); + + var updatedDimensions = _extends({}, isHeightFlexible ? { height: height } : {}, isWidthFlexible ? { width: width } : {}); + + return _react2.default.createElement( + 'div', + { + ref: function ref(_ref) { + return _this2[CONTAINER_REF] = _ref; + }, + style: { width: '100%', height: '100%' } + }, + _react2.default.createElement(Component, _extends({}, updatedDimensions, props)) + ); + } + }]); + + return ResultClass; + }(_react2.default.Component); + + ResultClass.displayName = 'Flexible' + getDisplayName(Component); + + return ResultClass; +} + +function makeHeightFlexible(component) { + return makeFlexible(component, false, true); +} + +function makeVisFlexible(component) { + return makeFlexible(component, true, true); +} + +function makeWidthFlexible(component) { + return makeFlexible(component, true, false); +} + +var FlexibleWidthXYPlot = exports.FlexibleWidthXYPlot = makeWidthFlexible(_xyPlot2.default); +var FlexibleHeightXYPlot = exports.FlexibleHeightXYPlot = makeHeightFlexible(_xyPlot2.default); +var FlexibleXYPlot = exports.FlexibleXYPlot = makeVisFlexible(_xyPlot2.default); \ No newline at end of file diff --git a/dist/parallel-coordinates/index.js b/dist/parallel-coordinates/index.js new file mode 100644 index 000000000..6b39942e9 --- /dev/null +++ b/dist/parallel-coordinates/index.js @@ -0,0 +1,360 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Scale = require('d3-scale'); + +var _d3Format = require('d3-format'); + +var _animation = require('../animation'); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _theme = require('../theme'); + +var _chartUtils = require('../utils/chart-utils'); + +var _lineSeries = require('../plot/series/line-series'); + +var _lineSeries2 = _interopRequireDefault(_lineSeries); + +var _lineMarkSeries = require('../plot/series/line-mark-series'); + +var _lineMarkSeries2 = _interopRequireDefault(_lineMarkSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _decorativeAxis = require('../plot/axis/decorative-axis'); + +var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); + +var _highlight = require('../plot/highlight'); + +var _highlight2 = _interopRequireDefault(_highlight); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +var predefinedClassName = 'rv-parallel-coordinates-chart'; +var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); +/** + * Generate axes for each of the domains + * @param {Object} props + - props.animation {Boolean} + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for the whole chart + - props.tickFormat {Function} formatting function for axes + * @return {Array} the plotted axis components + */ +function getAxes(props) { + var animation = props.animation, + domains = props.domains, + style = props.style, + tickFormat = props.tickFormat; + + return domains.map(function (domain, index) { + var sortedDomain = domain.domain; + + var domainTickFormat = function domainTickFormat(t) { + return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); + }; + + return _react2.default.createElement(_decorativeAxis2.default, { + animation: animation, + key: index + '-axis', + axisStart: { x: domain.name, y: 0 }, + axisEnd: { x: domain.name, y: 1 }, + axisDomain: sortedDomain, + numberOfTicks: 5, + tickValue: domainTickFormat, + style: style.axes + }); + }); +} + +/** + * Generate labels for the ends of the axes + * @param {Object} props + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for just the labels + * @return {Array} the prepped data for the labelSeries + */ +function getLabels(props) { + var domains = props.domains, + style = props.style; + + return domains.map(function (domain, index) { + return { + x: domain.name, + y: 1.1, + label: domain.name, + style: style + }; + }); +} + +/** + * Generate the actual lines to be plotted + * @param {Object} props + - props.animation {Boolean} + - props.data {Array} array of object specifying what values are to be plotted + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for the whole chart + - props.showMarks {Bool} whether or not to use the line mark series + * @return {Array} the plotted axis components + */ +function getLines(props) { + var animation = props.animation, + brushFilters = props.brushFilters, + colorRange = props.colorRange, + domains = props.domains, + data = props.data, + style = props.style, + showMarks = props.showMarks; + + var scales = domains.reduce(function (acc, _ref) { + var domain = _ref.domain, + name = _ref.name; + + acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); + return acc; + }, {}); + // const + + return data.map(function (row, rowIndex) { + var withinFilteredRange = true; + var mappedData = domains.map(function (domain, index) { + var getValue = domain.getValue, + name = domain.name; + + // watch out! Gotcha afoot + // yVal after being scale is in [0, 1] range + + var yVal = scales[name](getValue ? getValue(row) : row[name]); + var filter = brushFilters[name]; + // filter value after being scale back from pixel space is also in [0, 1] + if (filter && (yVal < filter.min || yVal > filter.max)) { + withinFilteredRange = false; + } + return { x: name, y: yVal }; + }); + var selectedName = predefinedClassName + '-line'; + var unselectedName = selectedName + ' ' + predefinedClassName + '-line-unselected'; + var lineProps = { + animation: animation, + className: withinFilteredRange ? selectedName : unselectedName, + key: rowIndex + '-polygon', + data: mappedData, + color: row.color || colorRange[rowIndex % colorRange.length], + style: _extends({}, style.lines, row.style || {}) + }; + if (!withinFilteredRange) { + lineProps.style = _extends({}, lineProps.style, style.deselectedLineStyle); + } + return showMarks ? _react2.default.createElement(_lineMarkSeries2.default, lineProps) : _react2.default.createElement(_lineSeries2.default, lineProps); + }); +} + +var ParallelCoordinates = function (_Component) { + _inherits(ParallelCoordinates, _Component); + + function ParallelCoordinates() { + var _ref2; + + var _temp, _this, _ret; + + _classCallCheck(this, ParallelCoordinates); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = ParallelCoordinates.__proto__ || Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2, [this].concat(args))), _this), _this.state = { + brushFilters: {} + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(ParallelCoordinates, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var brushFilters = this.state.brushFilters; + var _props = this.props, + animation = _props.animation, + brushing = _props.brushing, + className = _props.className, + children = _props.children, + colorRange = _props.colorRange, + data = _props.data, + domains = _props.domains, + height = _props.height, + hideInnerMostValues = _props.hideInnerMostValues, + margin = _props.margin, + onMouseLeave = _props.onMouseLeave, + onMouseEnter = _props.onMouseEnter, + showMarks = _props.showMarks, + style = _props.style, + tickFormat = _props.tickFormat, + width = _props.width; + + + var axes = getAxes({ + domains: domains, + animation: animation, + hideInnerMostValues: hideInnerMostValues, + style: style, + tickFormat: tickFormat + }); + + var lines = getLines({ + animation: animation, + brushFilters: brushFilters, + colorRange: colorRange, + domains: domains, + data: data, + showMarks: showMarks, + style: style + }); + var labelSeries = _react2.default.createElement(_labelSeries2.default, { + animation: true, + key: className, + className: predefinedClassName + '-label', + data: getLabels({ domains: domains, style: style.labels }) + }); + + var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS), + marginLeft = _getInnerDimensions.marginLeft, + marginRight = _getInnerDimensions.marginRight; + + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + width: width, + margin: margin, + dontCheckIfEmpty: true, + className: className + ' ' + predefinedClassName, + onMouseLeave: onMouseLeave, + onMouseEnter: onMouseEnter, + xType: 'ordinal', + yDomain: [0, 1] + }, + children, + axes.concat(lines).concat(labelSeries), + brushing && domains.map(function (d) { + var trigger = function trigger(row) { + _this2.setState({ + brushFilters: _extends({}, brushFilters, _defineProperty({}, d.name, row ? { min: row.bottom, max: row.top } : null)) + }); + }; + return _react2.default.createElement(_highlight2.default, { + key: d.name, + drag: true, + highlightX: d.name, + onBrushEnd: trigger, + onDragEnd: trigger, + highlightWidth: (width - marginLeft - marginRight) / domains.length, + enableX: false + }); + }) + ); + } + }]); + + return ParallelCoordinates; +}(_react.Component); + +ParallelCoordinates.displayName = 'ParallelCoordinates'; +ParallelCoordinates.propTypes = { + animation: _animation.AnimationPropType, + brushing: _propTypes2.default.bool, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), + data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + name: _propTypes2.default.string.isRequired, + domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, + tickFormat: _propTypes2.default.func + })).isRequired, + height: _propTypes2.default.number.isRequired, + margin: _chartUtils.MarginPropType, + style: _propTypes2.default.shape({ + axes: _propTypes2.default.object, + labels: _propTypes2.default.object, + lines: _propTypes2.default.object + }), + showMarks: _propTypes2.default.bool, + tickFormat: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired +}; +ParallelCoordinates.defaultProps = { + className: '', + colorType: 'category', + colorRange: _theme.DISCRETE_COLOR_RANGE, + style: { + axes: { + line: {}, + ticks: {}, + text: {} + }, + labels: { + fontSize: 10, + textAnchor: 'middle' + }, + lines: { + strokeWidth: 1, + strokeOpacity: 1 + }, + deselectedLineStyle: { + strokeOpacity: 0.1 + } + }, + tickFormat: DEFAULT_FORMAT +}; + +exports.default = ParallelCoordinates; \ No newline at end of file diff --git a/dist/plot/axis/axis-line.js b/dist/plot/axis/axis-line.js new file mode 100644 index 000000000..23b8f0d9c --- /dev/null +++ b/dist/plot/axis/axis-line.js @@ -0,0 +1,99 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = { + height: _propTypes2.default.number.isRequired, + style: _propTypes2.default.object, + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, + width: _propTypes2.default.number.isRequired +}; + +var defaultProps = { + style: {} +}; + +function AxisLine(_ref) { + var orientation = _ref.orientation, + width = _ref.width, + height = _ref.height, + style = _ref.style; + + var lineProps = void 0; + if (orientation === LEFT) { + lineProps = { + x1: width, + x2: width, + y1: 0, + y2: height + }; + } else if (orientation === RIGHT) { + lineProps = { + x1: 0, + x2: 0, + y1: 0, + y2: height + }; + } else if (orientation === TOP) { + lineProps = { + x1: 0, + x2: width, + y1: height, + y2: height + }; + } else { + lineProps = { + x1: 0, + x2: width, + y1: 0, + y2: 0 + }; + } + return _react2.default.createElement('line', _extends({}, lineProps, { className: 'rv-xy-plot__axis__line', style: style })); +} + +AxisLine.defaultProps = defaultProps; +AxisLine.displayName = 'AxisLine'; +AxisLine.propTypes = propTypes; + +exports.default = AxisLine; \ No newline at end of file diff --git a/dist/plot/axis/axis-ticks.js b/dist/plot/axis/axis-ticks.js new file mode 100644 index 000000000..f0d0b8e91 --- /dev/null +++ b/dist/plot/axis/axis-ticks.js @@ -0,0 +1,271 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +var _scalesUtils = require('../../utils/scales-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = { + height: _propTypes2.default.number.isRequired, + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, + style: _propTypes2.default.object, + width: _propTypes2.default.number.isRequired +}; + +var defaultProps = { + style: {} +}; + +function _getTickFormatFn(scale, tickTotal, tickFormat) { + return !tickFormat ? scale.tickFormat ? scale.tickFormat(tickTotal) : function (v) { + return v; + } : tickFormat; +} + +var AxisTicks = function (_React$Component) { + _inherits(AxisTicks, _React$Component); + + function AxisTicks() { + _classCallCheck(this, AxisTicks); + + return _possibleConstructorReturn(this, (AxisTicks.__proto__ || Object.getPrototypeOf(AxisTicks)).apply(this, arguments)); + } + + _createClass(AxisTicks, [{ + key: '_areTicksWrapped', + + /** + * Check if axis ticks should be mirrored (for the right and top positions. + * @returns {boolean} True if mirrored. + * @private + */ + value: function _areTicksWrapped() { + var orientation = this.props.orientation; + + return orientation === LEFT || orientation === TOP; + } + }, { + key: '_getTickContainerPropsGetterFn', + value: function _getTickContainerPropsGetterFn() { + if (this._isAxisVertical()) { + return function (pos) { + return { transform: 'translate(0, ' + pos + ')' }; + }; + } + return function (pos) { + return { transform: 'translate(' + pos + ', 0)' }; + }; + } + + /** + * Get attributes for the label of the tick. + * @returns {Object} Object with properties. + * @private + */ + + }, { + key: '_getTickLabelProps', + value: function _getTickLabelProps() { + var _props = this.props, + orientation = _props.orientation, + tickLabelAngle = _props.tickLabelAngle, + tickSize = _props.tickSize, + _props$tickSizeOuter = _props.tickSizeOuter, + tickSizeOuter = _props$tickSizeOuter === undefined ? tickSize : _props$tickSizeOuter, + _props$tickPadding = _props.tickPadding, + tickPadding = _props$tickPadding === undefined ? tickSize : _props$tickPadding; + + // Assign the text orientation inside the label of the tick mark. + + var textAnchor = void 0; + if (orientation === LEFT || orientation === BOTTOM && tickLabelAngle) { + textAnchor = 'end'; + } else if (orientation === RIGHT || orientation === TOP && tickLabelAngle) { + textAnchor = 'start'; + } else { + textAnchor = 'middle'; + } + + // The label's position is translated to the given padding and then the + // label is rotated to the given angle. + var isVertical = this._isAxisVertical(); + var wrap = this._areTicksWrapped() ? -1 : 1; + + var labelOffset = wrap * (tickSizeOuter + tickPadding); + var transform = (isVertical ? 'translate(' + labelOffset + ', 0)' : 'translate(0, ' + labelOffset + ')') + (tickLabelAngle ? ' rotate(' + tickLabelAngle + ')' : ''); + + // Set the vertical offset of the label according to the position of + // the axis. + var dy = orientation === TOP || tickLabelAngle ? '0' : orientation === BOTTOM ? '0.72em' : '0.32em'; + + return { + textAnchor: textAnchor, + dy: dy, + transform: transform + }; + } + + /** + * Get the props of the tick line. + * @returns {Object} Props. + * @private + */ + + }, { + key: '_getTickLineProps', + value: function _getTickLineProps() { + var _ref; + + var _props2 = this.props, + tickSize = _props2.tickSize, + _props2$tickSizeOuter = _props2.tickSizeOuter, + tickSizeOuter = _props2$tickSizeOuter === undefined ? tickSize : _props2$tickSizeOuter, + _props2$tickSizeInner = _props2.tickSizeInner, + tickSizeInner = _props2$tickSizeInner === undefined ? tickSize : _props2$tickSizeInner; + + var isVertical = this._isAxisVertical(); + var tickXAttr = isVertical ? 'y' : 'x'; + var tickYAttr = isVertical ? 'x' : 'y'; + var wrap = this._areTicksWrapped() ? -1 : 1; + return _ref = {}, _defineProperty(_ref, tickXAttr + '1', 0), _defineProperty(_ref, tickXAttr + '2', 0), _defineProperty(_ref, tickYAttr + '1', -wrap * tickSizeInner), _defineProperty(_ref, tickYAttr + '2', wrap * tickSizeOuter), _ref; + } + + /** + * Gets if the axis is vertical. + * @returns {boolean} True if vertical. + * @private + */ + + }, { + key: '_isAxisVertical', + value: function _isAxisVertical() { + var orientation = this.props.orientation; + + return orientation === LEFT || orientation === RIGHT; + } + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + attr = _props3.attr, + orientation = _props3.orientation, + width = _props3.width, + height = _props3.height, + style = _props3.style, + tickFormat = _props3.tickFormat, + tickTotal = _props3.tickTotal, + tickValues = _props3.tickValues; + + + var x = orientation === LEFT ? width : 0; + var y = orientation === TOP ? height : 0; + + var scale = (0, _scalesUtils.getAttributeScale)(this.props, attr); + + var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); + var tickFormatFn = _getTickFormatFn(scale, tickTotal, tickFormat); + + var translateFn = this._getTickContainerPropsGetterFn(); + var pathProps = this._getTickLineProps(); + var textProps = this._getTickLabelProps(); + + var ticks = values.map(function (v, i) { + var pos = scale(v); + var labelNode = tickFormatFn(v, i, scale, tickTotal); + var shouldRenderAsOwnNode = _react2.default.isValidElement(labelNode) && !['tspan', 'textPath'].includes(labelNode.type); + var shouldAddProps = labelNode && typeof labelNode.type !== 'string'; + return _react2.default.createElement( + 'g', + _extends({ + key: i + }, translateFn(pos, 0), { + className: 'rv-xy-plot__axis__tick', + style: style + }), + _react2.default.createElement('line', _extends({}, pathProps, { + className: 'rv-xy-plot__axis__tick__line', + style: _extends({}, style, style.line) + })), + shouldRenderAsOwnNode ? _react2.default.cloneElement(labelNode, shouldAddProps ? _extends({}, textProps, { + containerWidth: width, + tickCount: values.length + }) : undefined) : _react2.default.createElement( + 'text', + _extends({}, textProps, { + className: 'rv-xy-plot__axis__tick__text', + style: _extends({}, style, style.text) + }), + labelNode + ) + ); + }); + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + x + ', ' + y + ')', + className: 'rv-xy-plot__axis__ticks' + }, + ticks + ); + } + }]); + + return AxisTicks; +}(_react2.default.Component); + +AxisTicks.defaultProps = defaultProps; +AxisTicks.displayName = 'AxisTicks'; +AxisTicks.propTypes = propTypes; +AxisTicks.requiresSVG = true; + +exports.default = AxisTicks; \ No newline at end of file diff --git a/dist/plot/axis/axis-title.js b/dist/plot/axis/axis-title.js new file mode 100644 index 000000000..619a31ec1 --- /dev/null +++ b/dist/plot/axis/axis-title.js @@ -0,0 +1,186 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// Assuming that 16px = 1em +var ADJUSTMENT_FOR_TEXT_SIZE = 16; +var MARGIN = 6; +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + +var defaultProps = { + position: 'end' +}; + +/** + * Compute transformations, keyed by orientation + * @param {number} width - width of axis + * @param {number} height - height of axis + * @returns {Object} Object of transformations, keyed by orientation + */ +var transformation = function transformation(width, height) { + var _ref; + + return _ref = {}, _defineProperty(_ref, LEFT, { + end: { + x: ADJUSTMENT_FOR_TEXT_SIZE, + y: MARGIN, + rotation: -90, + textAnchor: 'end' + }, + middle: { + x: ADJUSTMENT_FOR_TEXT_SIZE, + y: height / 2 - MARGIN, + rotation: -90, + textAnchor: 'middle' + }, + start: { + x: ADJUSTMENT_FOR_TEXT_SIZE, + y: height - MARGIN, + rotation: -90, + textAnchor: 'start' + } + }), _defineProperty(_ref, RIGHT, { + end: { + x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, + y: MARGIN, + rotation: -90, + textAnchor: 'end' + }, + middle: { + x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, + y: height / 2 - MARGIN, + rotation: -90, + textAnchor: 'middle' + }, + start: { + x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, + y: height - MARGIN, + rotation: -90, + textAnchor: 'start' + } + }), _defineProperty(_ref, TOP, { + start: { + x: MARGIN, + y: ADJUSTMENT_FOR_TEXT_SIZE, + rotation: 0, + textAnchor: 'start' + }, + middle: { + x: width / 2 - MARGIN, + y: ADJUSTMENT_FOR_TEXT_SIZE, + rotation: 0, + textAnchor: 'middle' + }, + end: { + x: width - MARGIN, + y: ADJUSTMENT_FOR_TEXT_SIZE, + rotation: 0, + textAnchor: 'end' + } + }), _defineProperty(_ref, BOTTOM, { + start: { + x: MARGIN, + y: -MARGIN, + rotation: 0, + textAnchor: 'start' + }, + middle: { + x: width / 2 - MARGIN, + y: -MARGIN, + rotation: 0, + textAnchor: 'middle' + }, + end: { + x: width - MARGIN, + y: -MARGIN, + rotation: 0, + textAnchor: 'end' + } + }), _ref; +}; + +var propTypes = { + width: _propTypes2.default.number.isRequired, + height: _propTypes2.default.number.isRequired, + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, + style: _propTypes2.default.object, + title: _propTypes2.default.string.isRequired +}; + +function AxisTitle(_ref2) { + var orientation = _ref2.orientation, + position = _ref2.position, + width = _ref2.width, + height = _ref2.height, + style = _ref2.style, + title = _ref2.title; + + var outerGroupTranslateX = orientation === LEFT ? width : 0; + var outerGroupTranslateY = orientation === TOP ? height : 0; + var outerGroupTransform = 'translate(' + outerGroupTranslateX + ', ' + outerGroupTranslateY + ')'; + var _transformation$orien = transformation(width, height)[orientation][position], + x = _transformation$orien.x, + y = _transformation$orien.y, + rotation = _transformation$orien.rotation, + textAnchor = _transformation$orien.textAnchor; + + var innerGroupTransform = 'translate(' + x + ', ' + y + ') rotate(' + rotation + ')'; + + return _react2.default.createElement( + 'g', + { transform: outerGroupTransform, className: 'rv-xy-plot__axis__title' }, + _react2.default.createElement( + 'g', + { style: _extends({ textAnchor: textAnchor }, style), transform: innerGroupTransform }, + _react2.default.createElement( + 'text', + { style: style }, + title + ) + ) + ); +} + +AxisTitle.displayName = 'AxisTitle'; +AxisTitle.propTypes = propTypes; +AxisTitle.defaultProps = defaultProps; +exports.default = AxisTitle; \ No newline at end of file diff --git a/dist/plot/axis/axis.js b/dist/plot/axis/axis.js new file mode 100644 index 000000000..e41a8d82b --- /dev/null +++ b/dist/plot/axis/axis.js @@ -0,0 +1,264 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _axisUtils = require('../../utils/axis-utils'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _axisLine = require('./axis-line'); + +var _axisLine2 = _interopRequireDefault(_axisLine); + +var _axisTicks = require('./axis-ticks'); + +var _axisTicks2 = _interopRequireDefault(_axisTicks); + +var _axisTitle = require('./axis-title'); + +var _axisTitle2 = _interopRequireDefault(_axisTitle); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var defaultAnimatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = { + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]), + attr: _propTypes2.default.string.isRequired, + attrAxis: _propTypes2.default.string, + width: _propTypes2.default.number, + height: _propTypes2.default.number, + top: _propTypes2.default.number, + left: _propTypes2.default.number, + title: _propTypes2.default.string, + + style: _propTypes2.default.object, + + className: _propTypes2.default.string, + hideTicks: _propTypes2.default.bool, + hideLine: _propTypes2.default.bool, + on0: _propTypes2.default.bool, + tickLabelAngle: _propTypes2.default.number, + tickSize: _propTypes2.default.number, + tickSizeInner: _propTypes2.default.number, + tickSizeOuter: _propTypes2.default.number, + tickPadding: _propTypes2.default.number, + tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), + tickFormat: _propTypes2.default.func, + tickTotal: _propTypes2.default.number, + + // Not expected to be used by the users. + // TODO: Add underscore to these properties later. + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; + +var defaultProps = { + className: '', + on0: false, + style: {}, + tickSize: 6, + tickPadding: 8, + orientation: BOTTOM +}; + +var predefinedClassName = 'rv-xy-plot__axis'; +var VERTICAL_CLASS_NAME = 'rv-xy-plot__axis--vertical'; +var HORIZONTAL_CLASS_NAME = 'rv-xy-plot__axis--horizontal'; + +var Axis = function (_PureComponent) { + _inherits(Axis, _PureComponent); + + function Axis() { + _classCallCheck(this, Axis); + + return _possibleConstructorReturn(this, (Axis.__proto__ || Object.getPrototypeOf(Axis)).apply(this, arguments)); + } + + _createClass(Axis, [{ + key: '_getDefaultAxisProps', + + /** + * Define the default values depending on the data passed from the outside. + * @returns {*} Object of default properties. + * @private + */ + value: function _getDefaultAxisProps() { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginTop = _props.marginTop, + marginBottom = _props.marginBottom, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + orientation = _props.orientation; + + if (orientation === BOTTOM) { + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), + top: innerHeight + marginTop, + left: marginLeft, + width: innerWidth, + height: marginBottom + }; + } else if (orientation === TOP) { + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), + top: 0, + left: marginLeft, + width: innerWidth, + height: marginTop + }; + } else if (orientation === LEFT) { + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), + top: marginTop, + left: 0, + width: marginLeft, + height: innerHeight + }; + } + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), + top: marginTop, + left: marginLeft + innerWidth, + width: marginRight, + height: innerHeight + }; + } + }, { + key: 'render', + value: function render() { + var animation = this.props.animation; + + + if (animation) { + var animatedProps = animation.nonAnimatedProps ? defaultAnimatedProps.filter(function (prop) { + return animation.nonAnimatedProps.indexOf(prop) < 0; + }) : defaultAnimatedProps; + + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(Axis, _extends({}, this.props, { animation: null })) + ); + } + + var props = _extends({}, this._getDefaultAxisProps(), this.props); + + var attrAxis = props.attrAxis, + className = props.className, + height = props.height, + hideLine = props.hideLine, + hideTicks = props.hideTicks, + left = props.left, + marginTop = props.marginTop, + on0 = props.on0, + orientation = props.orientation, + position = props.position, + style = props.style, + title = props.title, + top = props.top, + width = props.width; + + var isVertical = [LEFT, RIGHT].indexOf(orientation) > -1; + var axisClassName = isVertical ? VERTICAL_CLASS_NAME : HORIZONTAL_CLASS_NAME; + + var leftPos = left; + var topPos = top; + if (on0) { + var scale = (0, _scalesUtils.getAttributeScale)(props, attrAxis); + if (isVertical) { + leftPos = scale(0); + } else { + topPos = marginTop + scale(0); + } + } + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + leftPos + ',' + topPos + ')', + className: predefinedClassName + ' ' + axisClassName + ' ' + className, + style: style + }, + !hideLine && _react2.default.createElement(_axisLine2.default, { + height: height, + width: width, + orientation: orientation, + style: _extends({}, style, style.line) + }), + !hideTicks && _react2.default.createElement(_axisTicks2.default, _extends({}, props, { style: _extends({}, style, style.ticks) })), + title ? _react2.default.createElement(_axisTitle2.default, { + position: position, + title: title, + height: height, + width: width, + style: _extends({}, style, style.title), + orientation: orientation + }) : null + ); + } + }]); + + return Axis; +}(_react.PureComponent); + +Axis.displayName = 'Axis'; +Axis.propTypes = propTypes; +Axis.defaultProps = defaultProps; +Axis.requiresSVG = true; + +exports.default = Axis; \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis-ticks.js b/dist/plot/axis/decorative-axis-ticks.js new file mode 100644 index 000000000..f070bea88 --- /dev/null +++ b/dist/plot/axis/decorative-axis-ticks.js @@ -0,0 +1,99 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.default = decorativeAxisTick; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _axisUtils = require('../../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Generate the actual polygons to be plotted + * @param {Object} props + - props.animation {Boolean} + - props.axisDomain {Array} a pair of values specifying the domain of the axis + - props.numberOfTicks{Number} the number of ticks on the axis + - props.axisStart {Object} a object specify in cartesian space the start of the axis + example: {x: 0, y: 0} + - props.axisEnd {Object} a object specify in cartesian space the start of the axis + - props.tickValue {Func} a formatting function for the tick values + - props.tickSize {Number} a pixel size of the axis + - props.style {Object} The style object for the axis + * @return {Component} the plotted axis + */ +function decorativeAxisTick(props) { + var axisDomain = props.axisDomain, + numberOfTicks = props.numberOfTicks, + axisStart = props.axisStart, + axisEnd = props.axisEnd, + tickValue = props.tickValue, + tickSize = props.tickSize, + style = props.style; + + var _generatePoints = (0, _axisUtils.generatePoints)({ + axisStart: axisStart, + axisEnd: axisEnd, + numberOfTicks: numberOfTicks, + axisDomain: axisDomain + }), + points = _generatePoints.points; + // add a quarter rotation to make ticks orthogonal to axis + + + var tickAngle = (0, _axisUtils.getAxisAngle)(axisStart, axisEnd) + Math.PI / 2; + return points.map(function (point, index) { + var tickProps = _extends({ + x1: 0, + y1: 0, + x2: tickSize * Math.cos(tickAngle), + y2: tickSize * Math.sin(tickAngle) + }, style.ticks); + + var textProps = _extends({ + x: tickSize * Math.cos(tickAngle), + y: tickSize * Math.sin(tickAngle), + textAnchor: 'start' + }, style.text); + return _react2.default.createElement( + 'g', + { + key: index, + transform: 'translate(' + point.x + ', ' + point.y + ')', + className: 'rv-xy-plot__axis__tick' + }, + _react2.default.createElement('line', _extends({}, tickProps, { className: 'rv-xy-plot__axis__tick__line' })), + _react2.default.createElement( + 'text', + _extends({}, textProps, { className: 'rv-xy-plot__axis__tick__text' }), + tickValue(point.text) + ) + ); + }); +} \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis.js b/dist/plot/axis/decorative-axis.js new file mode 100644 index 000000000..809b9dfec --- /dev/null +++ b/dist/plot/axis/decorative-axis.js @@ -0,0 +1,174 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _d3Format = require('d3-format'); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('../series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _decorativeAxisTicks = require('./decorative-axis-ticks'); + +var _decorativeAxisTicks2 = _interopRequireDefault(_decorativeAxisTicks); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-manipulable-axis rv-xy-plot__axis'; + +var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; + +var DecorativeAxis = function (_AbstractSeries) { + _inherits(DecorativeAxis, _AbstractSeries); + + function DecorativeAxis() { + _classCallCheck(this, DecorativeAxis); + + return _possibleConstructorReturn(this, (DecorativeAxis.__proto__ || Object.getPrototypeOf(DecorativeAxis)).apply(this, arguments)); + } + + _createClass(DecorativeAxis, [{ + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + axisStart = _props.axisStart, + axisEnd = _props.axisEnd, + axisDomain = _props.axisDomain, + numberOfTicks = _props.numberOfTicks, + tickValue = _props.tickValue, + tickSize = _props.tickSize, + style = _props.style; + + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(DecorativeAxis, _extends({}, this.props, { animation: null })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + _react2.default.createElement('line', _extends({}, _extends({ + x1: x({ x: axisStart.x }), + x2: x({ x: axisEnd.x }), + y1: y({ y: axisStart.y }), + y2: y({ y: axisEnd.y }) + }, style.line), { + className: 'rv-xy-plot__axis__line' + })), + _react2.default.createElement( + 'g', + { className: 'rv-xy-manipulable-axis__ticks' }, + (0, _decorativeAxisTicks2.default)({ + axisDomain: axisDomain, + axisEnd: { x: x(axisEnd), y: y(axisEnd) }, + axisStart: { x: x(axisStart), y: y(axisStart) }, + numberOfTicks: numberOfTicks, + tickValue: tickValue, + tickSize: tickSize, + style: style + }) + ) + ); + } + }]); + + return DecorativeAxis; +}(_abstractSeries2.default); + +var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); + +DecorativeAxis.defaultProps = { + className: '', + numberOfTicks: 10, + tickValue: function tickValue(d) { + return DEFAULT_FORMAT(d); + }, + tickSize: 5, + style: { + line: { + strokeWidth: 1 + }, + ticks: { + strokeWidth: 2 + }, + text: {} + } +}; +DecorativeAxis.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + axisDomain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, + axisEnd: _propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) + }).isRequired, + axisStart: _propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) + }).isRequired, + className: _propTypes2.default.string, + numberOfTicks: _propTypes2.default.number, + tickValue: _propTypes2.default.func, + tickSize: _propTypes2.default.number, + style: _propTypes2.default.shape({ + line: _propTypes2.default.object, + ticks: _propTypes2.default.object, + text: _propTypes2.default.object + }) +}); +DecorativeAxis.displayName = 'DecorativeAxis'; +exports.default = DecorativeAxis; \ No newline at end of file diff --git a/dist/plot/axis/x-axis.js b/dist/plot/axis/x-axis.js new file mode 100644 index 000000000..7ea59bbeb --- /dev/null +++ b/dist/plot/axis/x-axis.js @@ -0,0 +1,66 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +var _axis = require('./axis'); + +var _axis2 = _interopRequireDefault(_axis); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = _extends({}, _axis2.default.propTypes, { + orientation: _propTypes2.default.oneOf([TOP, BOTTOM]) +}); + +var defaultProps = { + orientation: BOTTOM, + attr: 'x', + attrAxis: 'y' +}; + +function XAxis(props) { + return _react2.default.createElement(_axis2.default, props); +} + +XAxis.displayName = 'XAxis'; +XAxis.propTypes = propTypes; +XAxis.defaultProps = defaultProps; +XAxis.requiresSVG = true; + +exports.default = XAxis; \ No newline at end of file diff --git a/dist/plot/axis/y-axis.js b/dist/plot/axis/y-axis.js new file mode 100644 index 000000000..a77570258 --- /dev/null +++ b/dist/plot/axis/y-axis.js @@ -0,0 +1,66 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +var _axis = require('./axis'); + +var _axis2 = _interopRequireDefault(_axis); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT; + + +var propTypes = _extends({}, _axis2.default.propTypes, { + orientation: _propTypes2.default.oneOf([LEFT, RIGHT]) +}); + +var defaultProps = { + orientation: LEFT, + attr: 'y', + attrAxis: 'x' +}; + +function YAxis(props) { + return _react2.default.createElement(_axis2.default, props); +} + +YAxis.displayName = 'YAxis'; +YAxis.propTypes = propTypes; +YAxis.defaultProps = defaultProps; +YAxis.requiresSVG = true; + +exports.default = YAxis; \ No newline at end of file diff --git a/dist/plot/borders.js b/dist/plot/borders.js new file mode 100644 index 000000000..fd83342f7 --- /dev/null +++ b/dist/plot/borders.js @@ -0,0 +1,125 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var propTypes = { + style: _propTypes2.default.shape({ + bottom: _propTypes2.default.object, + left: _propTypes2.default.object, + right: _propTypes2.default.object, + top: _propTypes2.default.object + }), + // supplied by xyplot + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; + +var CLASSES = { + bottom: 'rv-xy-plot__borders-bottom', + container: 'rv-xy-plot__borders', + left: 'rv-xy-plot__borders-left', + right: 'rv-xy-plot__borders-right', + top: 'rv-xy-plot__borders-top' +}; + +function Borders(props) { + var marginTop = props.marginTop, + marginBottom = props.marginBottom, + marginLeft = props.marginLeft, + marginRight = props.marginRight, + innerWidth = props.innerWidth, + innerHeight = props.innerHeight, + style = props.style, + className = props.className; + + var height = innerHeight + marginTop + marginBottom; + var width = innerWidth + marginLeft + marginRight; + return _react2.default.createElement( + 'g', + { className: CLASSES.container + ' ' + className }, + _react2.default.createElement('rect', { + className: CLASSES.bottom + ' ' + className + '-bottom', + style: _extends({}, style.all, style.bottom), + x: 0, + y: height - marginBottom, + width: width, + height: marginBottom + }), + _react2.default.createElement('rect', { + className: CLASSES.left + ' ' + className + '-left', + style: _extends({}, style.all, style.left), + x: 0, + y: 0, + width: marginLeft, + height: height + }), + _react2.default.createElement('rect', { + className: CLASSES.right + ' ' + className + '-right', + style: _extends({}, style.all, style.right), + x: width - marginRight, + y: 0, + width: marginRight, + height: height + }), + _react2.default.createElement('rect', { + className: CLASSES.top + ' ' + className + '-top', + style: _extends({}, style.all, style.top), + x: 0, + y: 0, + width: width, + height: marginTop + }) + ); +} + +Borders.displayName = 'Borders'; +Borders.defaultProps = { + className: '', + style: { + all: {}, + bottom: {}, + left: {}, + right: {}, + top: {} + } +}; +Borders.propTypes = propTypes; +Borders.requiresSVG = true; + +exports.default = Borders; \ No newline at end of file diff --git a/dist/plot/circular-grid-lines.js b/dist/plot/circular-grid-lines.js new file mode 100644 index 000000000..a8638ad64 --- /dev/null +++ b/dist/plot/circular-grid-lines.js @@ -0,0 +1,165 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _axisUtils = require('../utils/axis-utils'); + +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; } // Copyright (c) 2016 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; + +var CircularGridLines = function (_PureComponent) { + _inherits(CircularGridLines, _PureComponent); + + function CircularGridLines() { + _classCallCheck(this, CircularGridLines); + + return _possibleConstructorReturn(this, (CircularGridLines.__proto__ || Object.getPrototypeOf(CircularGridLines)).apply(this, arguments)); + } + + _createClass(CircularGridLines, [{ + key: '_getDefaultProps', + value: function _getDefaultProps() { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginTop = _props.marginTop, + marginLeft = _props.marginLeft; + + return { + left: marginLeft, + top: marginTop, + width: innerWidth, + height: innerHeight, + style: {}, + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(Math.min(innerWidth, innerHeight)) + }; + } + }, { + key: 'render', + value: function render() { + var _props2 = this.props, + animation = _props2.animation, + centerX = _props2.centerX, + centerY = _props2.centerY; + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(CircularGridLines, _extends({}, this.props, { animation: null })) + ); + } + + var props = _extends({}, this._getDefaultProps(), this.props); + + var tickTotal = props.tickTotal, + tickValues = props.tickValues, + marginLeft = props.marginLeft, + marginTop = props.marginTop, + rRange = props.rRange, + style = props.style; + + + var xScale = (0, _scalesUtils.getAttributeScale)(props, 'x'); + var yScale = (0, _scalesUtils.getAttributeScale)(props, 'y'); + var values = (0, _axisUtils.getTickValues)(xScale, tickTotal, tickValues); + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + (xScale(centerX) + marginLeft) + ',' + (yScale(centerY) + marginTop) + ')', + className: 'rv-xy-plot__circular-grid-lines' + }, + values.reduce(function (res, value, index) { + var radius = xScale(value); + if (rRange && (radius < rRange[0] || radius > rRange[1])) { + return res; + } + return res.concat([_react2.default.createElement('circle', _extends({ cx: 0, cy: 0, r: radius }, { + key: index, + className: 'rv-xy-plot__circular-grid-lines__line', + style: style + }))]); + }, []) + ); + } + }]); + + return CircularGridLines; +}(_react.PureComponent); + +CircularGridLines.displayName = 'CircularGridLines'; +CircularGridLines.propTypes = { + centerX: _propTypes2.default.number, + centerY: _propTypes2.default.number, + width: _propTypes2.default.number, + height: _propTypes2.default.number, + top: _propTypes2.default.number, + left: _propTypes2.default.number, + rRange: _propTypes2.default.arrayOf(_propTypes2.default.number), + + style: _propTypes2.default.object, + + tickValues: _propTypes2.default.arrayOf(_propTypes2.default.number), + tickTotal: _propTypes2.default.number, + + animation: _animation.AnimationPropType, + // generally supplied by xyplot + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; +CircularGridLines.defaultProps = { + centerX: 0, + centerY: 0 +}; +CircularGridLines.requiresSVG = true; + +exports.default = CircularGridLines; \ No newline at end of file diff --git a/dist/plot/crosshair.js b/dist/plot/crosshair.js new file mode 100644 index 000000000..b9c6edeb7 --- /dev/null +++ b/dist/plot/crosshair.js @@ -0,0 +1,262 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/** + * Format title by detault. + * @param {Array} values List of values. + * @returns {*} Formatted value or undefined. + */ +function defaultTitleFormat(values) { + var value = getFirstNonEmptyValue(values); + if (value) { + return { + title: 'x', + value: value.x + }; + } +} + +/** + * Format items by default. + * @param {Array} values Array of values. + * @returns {*} Formatted list of items. + */ +function defaultItemsFormat(values) { + return values.map(function (v, i) { + if (v) { + return { value: v.y, title: i }; + } + }); +} + +/** + * Get the first non-empty item from an array. + * @param {Array} values Array of values. + * @returns {*} First non-empty value or undefined. + */ +function getFirstNonEmptyValue(values) { + return (values || []).find(function (v) { + return Boolean(v); + }); +} + +var Crosshair = function (_PureComponent) { + _inherits(Crosshair, _PureComponent); + + function Crosshair() { + _classCallCheck(this, Crosshair); + + return _possibleConstructorReturn(this, (Crosshair.__proto__ || Object.getPrototypeOf(Crosshair)).apply(this, arguments)); + } + + _createClass(Crosshair, [{ + key: '_renderCrosshairItems', + + + /** + * Render crosshair items (title + value for each series). + * @returns {*} Array of React classes with the crosshair values. + * @private + */ + value: function _renderCrosshairItems() { + var _props = this.props, + values = _props.values, + itemsFormat = _props.itemsFormat; + + var items = itemsFormat(values); + if (!items) { + return null; + } + return items.filter(function (i) { + return i; + }).map(function renderValue(item, i) { + return _react2.default.createElement( + 'div', + { className: 'rv-crosshair__item', key: 'item' + i }, + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__item__title' }, + item.title + ), + ': ', + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__item__value' }, + item.value + ) + ); + }); + } + + /** + * Render crosshair title. + * @returns {*} Container with the crosshair title. + * @private + */ + + }, { + key: '_renderCrosshairTitle', + value: function _renderCrosshairTitle() { + var _props2 = this.props, + values = _props2.values, + titleFormat = _props2.titleFormat, + style = _props2.style; + + var titleItem = titleFormat(values); + if (!titleItem) { + return null; + } + return _react2.default.createElement( + 'div', + { className: 'rv-crosshair__title', key: 'title', style: style.title }, + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__title__title' }, + titleItem.title + ), + ': ', + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__title__value' }, + titleItem.value + ) + ); + } + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + children = _props3.children, + className = _props3.className, + values = _props3.values, + marginTop = _props3.marginTop, + marginLeft = _props3.marginLeft, + innerWidth = _props3.innerWidth, + innerHeight = _props3.innerHeight, + style = _props3.style; + + var value = getFirstNonEmptyValue(values); + if (!value) { + return null; + } + var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x'); + var innerLeft = x(value); + + var _props$orientation = this.props.orientation, + orientation = _props$orientation === undefined ? innerLeft > innerWidth / 2 ? 'left' : 'right' : _props$orientation; + + var left = marginLeft + innerLeft; + var top = marginTop; + var innerClassName = 'rv-crosshair__inner rv-crosshair__inner--' + orientation; + + return _react2.default.createElement( + 'div', + { + className: 'rv-crosshair ' + className, + style: { left: left + 'px', top: top + 'px' } + }, + _react2.default.createElement('div', { + className: 'rv-crosshair__line', + style: _extends({ height: innerHeight + 'px' }, style.line) + }), + _react2.default.createElement( + 'div', + { className: innerClassName }, + children ? children : _react2.default.createElement( + 'div', + { className: 'rv-crosshair__inner__content', style: style.box }, + _react2.default.createElement( + 'div', + null, + this._renderCrosshairTitle(), + this._renderCrosshairItems() + ) + ) + ) + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return { + titleFormat: defaultTitleFormat, + itemsFormat: defaultItemsFormat, + style: { + line: {}, + title: {}, + box: {} + } + }; + } + }, { + key: 'propTypes', + get: function get() { + return { + className: _propTypes2.default.string, + values: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.object])), + series: _propTypes2.default.object, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + orientation: _propTypes2.default.oneOf(['left', 'right']), + itemsFormat: _propTypes2.default.func, + titleFormat: _propTypes2.default.func, + style: _propTypes2.default.shape({ + line: _propTypes2.default.object, + title: _propTypes2.default.object, + box: _propTypes2.default.object + }) + }; + } + }]); + + return Crosshair; +}(_react.PureComponent); + +Crosshair.displayName = 'Crosshair'; + +exports.default = Crosshair; \ No newline at end of file diff --git a/dist/plot/gradient-defs.js b/dist/plot/gradient-defs.js new file mode 100644 index 000000000..2da31b486 --- /dev/null +++ b/dist/plot/gradient-defs.js @@ -0,0 +1,58 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-gradient-defs'; + +function GradientDefs(props) { + var className = props.className; + + return _react2.default.createElement( + 'defs', + { className: predefinedClassName + ' ' + className }, + props.children + ); +} + +GradientDefs.displayName = 'GradientDefs'; +GradientDefs.requiresSVG = true; +GradientDefs.propTypes = { + className: _propTypes2.default.string +}; +GradientDefs.defaultProps = { + className: '' +}; + +exports.default = GradientDefs; \ No newline at end of file diff --git a/dist/plot/grid-lines.js b/dist/plot/grid-lines.js new file mode 100644 index 000000000..1336d8718 --- /dev/null +++ b/dist/plot/grid-lines.js @@ -0,0 +1,178 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _axisUtils = require('../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var VERTICAL = _axisUtils.DIRECTION.VERTICAL, + HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; + + +var propTypes = { + direction: _propTypes2.default.oneOf([VERTICAL, HORIZONTAL]), + attr: _propTypes2.default.string.isRequired, + width: _propTypes2.default.number, + height: _propTypes2.default.number, + top: _propTypes2.default.number, + left: _propTypes2.default.number, + + style: _propTypes2.default.object, + + tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), + tickTotal: _propTypes2.default.number, + + animation: _animation.AnimationPropType, + + // generally supplied by xyplot + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; + +var defaultProps = { + direction: VERTICAL +}; + +var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; + +var GridLines = function (_PureComponent) { + _inherits(GridLines, _PureComponent); + + function GridLines() { + _classCallCheck(this, GridLines); + + return _possibleConstructorReturn(this, (GridLines.__proto__ || Object.getPrototypeOf(GridLines)).apply(this, arguments)); + } + + _createClass(GridLines, [{ + key: '_getDefaultProps', + value: function _getDefaultProps() { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginTop = _props.marginTop, + marginLeft = _props.marginLeft, + direction = _props.direction; + + return { + left: marginLeft, + top: marginTop, + width: innerWidth, + height: innerHeight, + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(direction === VERTICAL ? innerWidth : innerHeight) + }; + } + }, { + key: 'render', + value: function render() { + var animation = this.props.animation; + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(GridLines, _extends({}, this.props, { animation: null })) + ); + } + + var props = _extends({}, this._getDefaultProps(), this.props); + + var attr = props.attr, + direction = props.direction, + width = props.width, + height = props.height, + style = props.style, + tickTotal = props.tickTotal, + tickValues = props.tickValues, + top = props.top, + left = props.left; + + var isVertical = direction === VERTICAL; + var tickXAttr = isVertical ? 'y' : 'x'; + var tickYAttr = isVertical ? 'x' : 'y'; + var length = isVertical ? height : width; + + var scale = (0, _scalesUtils.getAttributeScale)(props, attr); + var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + left + ',' + top + ')', + className: 'rv-xy-plot__grid-lines' + }, + values.map(function (v, i) { + var _pathProps; + + var pos = scale(v); + var pathProps = (_pathProps = {}, _defineProperty(_pathProps, tickYAttr + '1', pos), _defineProperty(_pathProps, tickYAttr + '2', pos), _defineProperty(_pathProps, tickXAttr + '1', 0), _defineProperty(_pathProps, tickXAttr + '2', length), _pathProps); + return _react2.default.createElement('line', _extends({}, pathProps, { + key: i, + className: 'rv-xy-plot__grid-lines__line', + style: style + })); + }) + ); + } + }]); + + return GridLines; +}(_react.PureComponent); + +GridLines.displayName = 'GridLines'; +GridLines.defaultProps = defaultProps; +GridLines.propTypes = propTypes; +GridLines.requiresSVG = true; + +exports.default = GridLines; \ No newline at end of file diff --git a/dist/plot/highlight.js b/dist/plot/highlight.js new file mode 100644 index 000000000..63458b3e1 --- /dev/null +++ b/dist/plot/highlight.js @@ -0,0 +1,426 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _scalesUtils = require('../utils/scales-utils'); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +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; } + +function getLocs(evt) { + var xLoc = evt.type === 'touchstart' ? evt.pageX : evt.offsetX; + var yLoc = evt.type === 'touchstart' ? evt.pageY : evt.offsetY; + return { xLoc: xLoc, yLoc: yLoc }; +} + +var Highlight = function (_AbstractSeries) { + _inherits(Highlight, _AbstractSeries); + + function Highlight() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, Highlight); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Highlight.__proto__ || Object.getPrototypeOf(Highlight)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + dragging: false, + brushArea: { top: 0, right: 0, bottom: 0, left: 0 }, + brushing: false, + startLocX: 0, + startLocY: 0, + dragArea: null + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(Highlight, [{ + key: '_getDrawArea', + value: function _getDrawArea(xLoc, yLoc) { + var _state = this.state, + startLocX = _state.startLocX, + startLocY = _state.startLocY; + var _props = this.props, + enableX = _props.enableX, + enableY = _props.enableY, + highlightWidth = _props.highlightWidth, + highlightHeight = _props.highlightHeight, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + marginBottom = _props.marginBottom, + marginTop = _props.marginTop; + + var plotHeight = innerHeight + marginTop + marginBottom; + var plotWidth = innerWidth + marginLeft + marginRight; + var touchWidth = highlightWidth || plotWidth; + var touchHeight = highlightHeight || plotHeight; + + return { + bottom: enableY ? Math.max(startLocY, yLoc) : touchHeight, + right: enableX ? Math.max(startLocX, xLoc) : touchWidth, + left: enableX ? Math.min(xLoc, startLocX) : 0, + top: enableY ? Math.min(yLoc, startLocY) : 0 + }; + } + }, { + key: '_getDragArea', + value: function _getDragArea(xLoc, yLoc) { + var _props2 = this.props, + enableX = _props2.enableX, + enableY = _props2.enableY; + var _state2 = this.state, + startLocX = _state2.startLocX, + startLocY = _state2.startLocY, + dragArea = _state2.dragArea; + + + return { + bottom: dragArea.bottom + (enableY ? yLoc - startLocY : 0), + left: dragArea.left + (enableX ? xLoc - startLocX : 0), + right: dragArea.right + (enableX ? xLoc - startLocX : 0), + top: dragArea.top + (enableY ? yLoc - startLocY : 0) + }; + } + }, { + key: '_clickedOutsideDrag', + value: function _clickedOutsideDrag(xLoc, yLoc) { + var _props3 = this.props, + enableX = _props3.enableX, + enableY = _props3.enableY; + var _state3 = this.state, + dragArea = _state3.dragArea, + _state3$brushArea = _state3.brushArea, + left = _state3$brushArea.left, + right = _state3$brushArea.right, + top = _state3$brushArea.top, + bottom = _state3$brushArea.bottom; + + var clickedOutsideDragX = dragArea && (xLoc < left || xLoc > right); + var clickedOutsideDragY = dragArea && (yLoc < top || yLoc > bottom); + if (enableX && enableY) { + return clickedOutsideDragX || clickedOutsideDragY; + } + if (enableX) { + return clickedOutsideDragX; + } + if (enableY) { + return clickedOutsideDragY; + } + return true; + } + }, { + key: '_convertAreaToCoordinates', + value: function _convertAreaToCoordinates(brushArea) { + // NOTE only continuous scales are supported for brushing/getting coordinates back + var _props4 = this.props, + enableX = _props4.enableX, + enableY = _props4.enableY, + marginLeft = _props4.marginLeft, + marginTop = _props4.marginTop; + + var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); + var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); + + // Ensure that users wishes are being respected about which scales are evaluated + // this is specifically enabled to ensure brushing on mixed categorical and linear + // charts will run as expected + + if (enableX && enableY) { + return { + bottom: yScale.invert(brushArea.bottom), + left: xScale.invert(brushArea.left - marginLeft), + right: xScale.invert(brushArea.right - marginLeft), + top: yScale.invert(brushArea.top) + }; + } + + if (enableY) { + return { + bottom: yScale.invert(brushArea.bottom - marginTop), + top: yScale.invert(brushArea.top - marginTop) + }; + } + + if (enableX) { + return { + left: xScale.invert(brushArea.left - marginLeft), + right: xScale.invert(brushArea.right - marginLeft) + }; + } + + return {}; + } + }, { + key: 'startBrushing', + value: function startBrushing(e) { + var _this2 = this; + + var _props5 = this.props, + onBrushStart = _props5.onBrushStart, + onDragStart = _props5.onDragStart, + drag = _props5.drag; + var dragArea = this.state.dragArea; + + var _getLocs = getLocs(e.nativeEvent), + xLoc = _getLocs.xLoc, + yLoc = _getLocs.yLoc; + + var startArea = function startArea(dragging, resetDrag) { + var emptyBrush = { + bottom: yLoc, + left: xLoc, + right: xLoc, + top: yLoc + }; + _this2.setState({ + dragging: dragging, + brushArea: dragArea && !resetDrag ? dragArea : emptyBrush, + brushing: !dragging, + startLocX: xLoc, + startLocY: yLoc + }); + }; + + var clickedOutsideDrag = this._clickedOutsideDrag(xLoc, yLoc); + if (drag && !dragArea || !drag || clickedOutsideDrag) { + startArea(false, clickedOutsideDrag); + + if (onBrushStart) { + onBrushStart(e); + } + return; + } + + if (drag && dragArea) { + startArea(true, clickedOutsideDrag); + if (onDragStart) { + onDragStart(e); + } + } + } + }, { + key: 'stopBrushing', + value: function stopBrushing(e) { + var _state4 = this.state, + brushing = _state4.brushing, + dragging = _state4.dragging, + brushArea = _state4.brushArea; + // Quickly short-circuit if the user isn't brushing in our component + + if (!brushing && !dragging) { + return; + } + var _props6 = this.props, + onBrushEnd = _props6.onBrushEnd, + onDragEnd = _props6.onDragEnd, + drag = _props6.drag; + + var noHorizontal = Math.abs(brushArea.right - brushArea.left) < 5; + var noVertical = Math.abs(brushArea.top - brushArea.bottom) < 5; + // Invoke the callback with null if the selected area was < 5px + var isNulled = noVertical || noHorizontal; + // Clear the draw area + this.setState({ + brushing: false, + dragging: false, + brushArea: drag ? brushArea : { top: 0, right: 0, bottom: 0, left: 0 }, + startLocX: 0, + startLocY: 0, + dragArea: drag && !isNulled && brushArea + }); + + if (brushing && onBrushEnd) { + onBrushEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); + } + + if (drag && onDragEnd) { + onDragEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); + } + } + }, { + key: 'onBrush', + value: function onBrush(e) { + var _props7 = this.props, + onBrush = _props7.onBrush, + onDrag = _props7.onDrag, + drag = _props7.drag; + var _state5 = this.state, + brushing = _state5.brushing, + dragging = _state5.dragging; + + var _getLocs2 = getLocs(e.nativeEvent), + xLoc = _getLocs2.xLoc, + yLoc = _getLocs2.yLoc; + + if (brushing) { + var brushArea = this._getDrawArea(xLoc, yLoc); + this.setState({ brushArea: brushArea }); + + if (onBrush) { + onBrush(this._convertAreaToCoordinates(brushArea)); + } + } + + if (drag && dragging) { + var _brushArea = this._getDragArea(xLoc, yLoc); + this.setState({ brushArea: _brushArea }); + if (onDrag) { + onDrag(this._convertAreaToCoordinates(_brushArea)); + } + } + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var _props8 = this.props, + color = _props8.color, + className = _props8.className, + highlightHeight = _props8.highlightHeight, + highlightWidth = _props8.highlightWidth, + highlightX = _props8.highlightX, + highlightY = _props8.highlightY, + innerWidth = _props8.innerWidth, + innerHeight = _props8.innerHeight, + marginLeft = _props8.marginLeft, + marginRight = _props8.marginRight, + marginTop = _props8.marginTop, + marginBottom = _props8.marginBottom, + opacity = _props8.opacity; + var _state$brushArea = this.state.brushArea, + left = _state$brushArea.left, + right = _state$brushArea.right, + top = _state$brushArea.top, + bottom = _state$brushArea.bottom; + + + var leftPos = 0; + if (highlightX) { + var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); + leftPos = xScale(highlightX); + } + + var topPos = 0; + if (highlightY) { + var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); + topPos = yScale(highlightY); + } + + var plotWidth = marginLeft + marginRight + innerWidth; + var plotHeight = marginTop + marginBottom + innerHeight; + var touchWidth = highlightWidth || plotWidth; + var touchHeight = highlightHeight || plotHeight; + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + leftPos + ', ' + topPos + ')', + className: className + ' rv-highlight-container' + }, + _react2.default.createElement('rect', { + className: 'rv-mouse-target', + fill: 'black', + opacity: '0', + x: '0', + y: '0', + width: Math.max(touchWidth, 0), + height: Math.max(touchHeight, 0), + onMouseDown: function onMouseDown(e) { + return _this3.startBrushing(e); + }, + onMouseMove: function onMouseMove(e) { + return _this3.onBrush(e); + }, + onMouseUp: function onMouseUp(e) { + return _this3.stopBrushing(e); + }, + onMouseLeave: function onMouseLeave(e) { + return _this3.stopBrushing(e); + } + // preventDefault() so that mouse event emulation does not happen + , onTouchEnd: function onTouchEnd(e) { + e.preventDefault(); + _this3.stopBrushing(e); + }, + onTouchCancel: function onTouchCancel(e) { + e.preventDefault(); + _this3.stopBrushing(e); + }, + onContextMenu: function onContextMenu(e) { + return e.preventDefault(); + }, + onContextMenuCapture: function onContextMenuCapture(e) { + return e.preventDefault(); + } + }), + _react2.default.createElement('rect', { + className: 'rv-highlight', + pointerEvents: 'none', + opacity: opacity, + fill: color, + x: left, + y: top, + width: Math.min(Math.max(0, right - left), touchWidth), + height: Math.min(Math.max(0, bottom - top), touchHeight) + }) + ); + } + }]); + + return Highlight; +}(_abstractSeries2.default); + +Highlight.displayName = 'HighlightOverlay'; +Highlight.defaultProps = { + color: 'rgb(77, 182, 172)', + className: '', + enableX: true, + enableY: true, + opacity: 0.3 +}; + +Highlight.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + enableX: _propTypes2.default.bool, + enableY: _propTypes2.default.bool, + highlightHeight: _propTypes2.default.number, + highlightWidth: _propTypes2.default.number, + highlightX: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), + highlightY: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), + onBrushStart: _propTypes2.default.func, + onDragStart: _propTypes2.default.func, + onBrush: _propTypes2.default.func, + onDrag: _propTypes2.default.func, + onBrushEnd: _propTypes2.default.func, + onDragEnd: _propTypes2.default.func +}); + +exports.default = Highlight; \ No newline at end of file diff --git a/dist/plot/hint.js b/dist/plot/hint.js new file mode 100644 index 000000000..8e15b3cae --- /dev/null +++ b/dist/plot/hint.js @@ -0,0 +1,454 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/* + * Hint provides two options for placement of hint: + * a) around a data point in one of four quadrants (imagine the point bisected + * by two axes -vertical, horizontal- creating 4 quadrants around a data + * point). + * b) **New** pin to an edge of chart/plot area and position along that edge + * using data point's other dimension value. + * + * To support these two options, deprecate one Hint props (orientation) with two + * new Hint align prop object (horizontal, vertical) with following values: + * + * horizontal: auto, left, right, leftEdge, rightEdge + * vertical: auto, bottom, top, bottomEdge, topEdge + * + * Thus, the following ALIGN constants are the values for horizontal + * and vertical + */ +var ALIGN = { + AUTO: 'auto', + LEFT: 'left', + RIGHT: 'right', + LEFT_EDGE: 'leftEdge', + RIGHT_EDGE: 'rightEdge', + BOTTOM: 'bottom', + TOP: 'top', + BOTTOM_EDGE: 'bottomEdge', + TOP_EDGE: 'topEdge' +}; + +/** + * For backwards support, retain the ORIENTATION prop constants + */ +var ORIENTATION = { + BOTTOM_LEFT: 'bottomleft', + BOTTOM_RIGHT: 'bottomright', + TOP_LEFT: 'topleft', + TOP_RIGHT: 'topright' +}; + +/** + * Default format function for the value. + * @param {Object} value Value. + * @returns {Array} title-value pairs. + */ +function defaultFormat(value) { + return Object.keys(value).map(function getProp(key) { + return { title: key, value: value[key] }; + }); +} + +var Hint = function (_PureComponent) { + _inherits(Hint, _PureComponent); + + function Hint() { + _classCallCheck(this, Hint); + + return _possibleConstructorReturn(this, (Hint.__proto__ || Object.getPrototypeOf(Hint)).apply(this, arguments)); + } + + _createClass(Hint, [{ + key: '_getAlign', + + + /** + * Obtain align object with horizontal and vertical settings + * but convert any AUTO values to the non-auto ALIGN depending on the + * values of x and y. + * @param {number} x X value. + * @param {number} y Y value. + * @returns {Object} Align object w/ horizontal, vertical prop strings. + * @private + */ + value: function _getAlign(x, y) { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + orientation = _props.orientation, + _props$align = _props.align, + horizontal = _props$align.horizontal, + vertical = _props$align.vertical; + + var align = orientation ? this._mapOrientationToAlign(orientation) : { horizontal: horizontal, vertical: vertical }; + if (horizontal === ALIGN.AUTO) { + align.horizontal = x > innerWidth / 2 ? ALIGN.LEFT : ALIGN.RIGHT; + } + if (vertical === ALIGN.AUTO) { + align.vertical = y > innerHeight / 2 ? ALIGN.TOP : ALIGN.BOTTOM; + } + return align; + } + + /** + * Get the class names from align values. + * @param {Object} align object with horizontal and vertical prop strings. + * @returns {string} Class names. + * @private + */ + + }, { + key: '_getAlignClassNames', + value: function _getAlignClassNames(align) { + var orientation = this.props.orientation; + + var orientationClass = orientation ? 'rv-hint--orientation-' + orientation : ''; + return orientationClass + ' rv-hint--horizontalAlign-' + align.horizontal + '\n rv-hint--verticalAlign-' + align.vertical; + } + + /** + * Get a CSS mixin for a proper positioning of the element. + * @param {Object} align object with horizontal and vertical prop strings. + * @param {number} x X position. + * @param {number} y Y position. + * @returns {Object} Object, that may contain `left` or `right, `top` or + * `bottom` properties. + * @private + */ + + }, { + key: '_getAlignStyle', + value: function _getAlignStyle(align, x, y) { + return _extends({}, this._getXCSS(align.horizontal, x), this._getYCSS(align.vertical, y)); + } + + /** + * Get the bottom coordinate of the hint. + * When y undefined or null, edge case, pin bottom. + * @param {number} y Y. + * @returns {{bottom: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSBottom', + value: function _getCSSBottom(y) { + if (y === undefined || y === null) { + return { + bottom: 0 + }; + } + + var _props2 = this.props, + innerHeight = _props2.innerHeight, + marginBottom = _props2.marginBottom; + + return { + bottom: marginBottom + innerHeight - y + }; + } + + /** + * Get the left coordinate of the hint. + * When x undefined or null, edge case, pin left. + * @param {number} x X. + * @returns {{left: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSLeft', + value: function _getCSSLeft(x) { + if (x === undefined || x === null) { + return { + left: 0 + }; + } + + var marginLeft = this.props.marginLeft; + + return { + left: marginLeft + x + }; + } + + /** + * Get the right coordinate of the hint. + * When x undefined or null, edge case, pin right. + * @param {number} x X. + * @returns {{right: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSRight', + value: function _getCSSRight(x) { + if (x === undefined || x === null) { + return { + right: 0 + }; + } + + var _props3 = this.props, + innerWidth = _props3.innerWidth, + marginRight = _props3.marginRight; + + return { + right: marginRight + innerWidth - x + }; + } + + /** + * Get the top coordinate of the hint. + * When y undefined or null, edge case, pin top. + * @param {number} y Y. + * @returns {{top: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSTop', + value: function _getCSSTop(y) { + if (y === undefined || y === null) { + return { + top: 0 + }; + } + + var marginTop = this.props.marginTop; + + return { + top: marginTop + y + }; + } + + /** + * Get the position for the hint and the appropriate class name. + * @returns {{style: Object, className: string}} Style and className for the + * hint. + * @private + */ + + }, { + key: '_getPositionInfo', + value: function _getPositionInfo() { + var _props4 = this.props, + value = _props4.value, + getAlignStyle = _props4.getAlignStyle; + + + var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x')(value); + var y = (0, _scalesUtils.getAttributeFunctor)(this.props, 'y')(value); + + var align = this._getAlign(x, y); + + return { + position: getAlignStyle ? getAlignStyle(align, x, y) : this._getAlignStyle(align, x, y), + className: this._getAlignClassNames(align) + }; + } + }, { + key: '_getXCSS', + value: function _getXCSS(horizontal, x) { + // obtain xCSS + switch (horizontal) { + case ALIGN.LEFT_EDGE: + // this pins x to left edge + return this._getCSSLeft(null); + case ALIGN.RIGHT_EDGE: + // this pins x to left edge + return this._getCSSRight(null); + case ALIGN.LEFT: + // this places hint text to the left of center, so set its right edge + return this._getCSSRight(x); + case ALIGN.RIGHT: + default: + // this places hint text to the right of center, so set its left edge + // default case should not be possible but if it happens set to RIGHT + return this._getCSSLeft(x); + } + } + }, { + key: '_getYCSS', + value: function _getYCSS(verticalAlign, y) { + // obtain yCSS + switch (verticalAlign) { + case ALIGN.TOP_EDGE: + // this pins x to top edge + return this._getCSSTop(null); + case ALIGN.BOTTOM_EDGE: + // this pins x to bottom edge + return this._getCSSBottom(null); + case ALIGN.BOTTOM: + // this places hint text to the bottom of center, so set its top edge + return this._getCSSTop(y); + case ALIGN.TOP: + default: + // this places hint text to the top of center, so set its bottom edge + // default case should not be possible but if it happens set to BOTTOM + return this._getCSSBottom(y); + } + } + }, { + key: '_mapOrientationToAlign', + value: function _mapOrientationToAlign(orientation) { + // TODO: print warning that this feature is deprecated and support will be + // removed in next major release. + switch (orientation) { + case ORIENTATION.BOTTOM_LEFT: + return { + horizontal: ALIGN.LEFT, + vertical: ALIGN.BOTTOM + }; + case ORIENTATION.BOTTOM_RIGHT: + return { + horizontal: ALIGN.RIGHT, + vertical: ALIGN.BOTTOM + }; + case ORIENTATION.TOP_LEFT: + return { + horizontal: ALIGN.LEFT, + vertical: ALIGN.TOP + }; + case ORIENTATION.TOP_RIGHT: + return { + horizontal: ALIGN.RIGHT, + vertical: ALIGN.TOP + }; + default: + // fall back to horizontalAlign, verticalAlign that are either + // provided or defaulted to AUTO. So, don't change things + break; + } + } + }, { + key: 'render', + value: function render() { + var _props5 = this.props, + value = _props5.value, + format = _props5.format, + children = _props5.children, + style = _props5.style; + + var _getPositionInfo2 = this._getPositionInfo(), + position = _getPositionInfo2.position, + className = _getPositionInfo2.className; + + return _react2.default.createElement( + 'div', + { + className: 'rv-hint ' + className, + style: _extends({}, style, position, { + position: 'absolute' + }) + }, + children ? children : _react2.default.createElement( + 'div', + { className: 'rv-hint__content', style: style.content }, + format(value).map(function (formattedProp, i) { + return _react2.default.createElement( + 'div', + { key: 'rv-hint' + i, style: style.row }, + _react2.default.createElement( + 'span', + { className: 'rv-hint__title', style: style.title }, + formattedProp.title + ), + ': ', + _react2.default.createElement( + 'span', + { className: 'rv-hint__value', style: style.value }, + formattedProp.value + ) + ); + }) + ) + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return { + format: defaultFormat, + align: { + horizontal: ALIGN.AUTO, + vertical: ALIGN.AUTO + }, + style: {} + }; + } + }, { + key: 'propTypes', + get: function get() { + return { + marginTop: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number, + scales: _propTypes2.default.object, + value: _propTypes2.default.object, + format: _propTypes2.default.func, + style: _propTypes2.default.object, + align: _propTypes2.default.shape({ + horizontal: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.LEFT, ALIGN.RIGHT, ALIGN.LEFT_EDGE, ALIGN.RIGHT_EDGE]), + vertical: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.BOTTOM, ALIGN.TOP, ALIGN.BOTTOM_EDGE, ALIGN.TOP_EDGE]) + }), + getAlignStyle: _propTypes2.default.func, + orientation: _propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT, ORIENTATION.BOTTOM_RIGHT, ORIENTATION.TOP_LEFT, ORIENTATION.TOP_RIGHT]) + }; + } + }]); + + return Hint; +}(_react.PureComponent); + +Hint.displayName = 'Hint'; +Hint.ORIENTATION = ORIENTATION; +Hint.ALIGN = ALIGN; + +exports.default = Hint; \ No newline at end of file diff --git a/dist/plot/horizontal-grid-lines.js b/dist/plot/horizontal-grid-lines.js new file mode 100644 index 000000000..549b2d8b5 --- /dev/null +++ b/dist/plot/horizontal-grid-lines.js @@ -0,0 +1,64 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../utils/axis-utils'); + +var _gridLines = require('./grid-lines'); + +var _gridLines2 = _interopRequireDefault(_gridLines); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; + + +var propTypes = _extends({}, _gridLines2.default.propTypes, { + direction: _propTypes2.default.oneOf([HORIZONTAL]) +}); + +var defaultProps = { + direction: HORIZONTAL, + attr: 'y' +}; + +function HorizontalGridLines(props) { + return _react2.default.createElement(_gridLines2.default, props); +} + +HorizontalGridLines.displayName = 'HorizontalGridLines'; +HorizontalGridLines.propTypes = propTypes; +HorizontalGridLines.defaultProps = defaultProps; +HorizontalGridLines.requiresSVG = true; + +exports.default = HorizontalGridLines; \ No newline at end of file diff --git a/dist/plot/series/abstract-series.js b/dist/plot/series/abstract-series.js new file mode 100644 index 000000000..7f86a482f --- /dev/null +++ b/dist/plot/series/abstract-series.js @@ -0,0 +1,415 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Voronoi = require('d3-voronoi'); + +var _react = require('react'); + +var _animation = require('../../animation'); + +var _scalesUtils = require('../../utils/scales-utils'); + +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; } + +var propTypes = _extends({}, (0, _scalesUtils.getScalePropTypesByAttribute)('x'), (0, _scalesUtils.getScalePropTypesByAttribute)('y'), (0, _scalesUtils.getScalePropTypesByAttribute)('size'), (0, _scalesUtils.getScalePropTypesByAttribute)('opacity'), (0, _scalesUtils.getScalePropTypesByAttribute)('color'), { + width: _propTypes2.default.number, + height: _propTypes2.default.number, + data: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.array])), + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + onValueClick: _propTypes2.default.func, + onValueRightClick: _propTypes2.default.func, + onSeriesMouseOver: _propTypes2.default.func, + onSeriesMouseOut: _propTypes2.default.func, + onSeriesClick: _propTypes2.default.func, + onSeriesRightClick: _propTypes2.default.func, + onNearestX: _propTypes2.default.func, + onNearestXY: _propTypes2.default.func, + style: _propTypes2.default.object, + animation: _animation.AnimationPropType, + stack: _propTypes2.default.bool +}); + +var defaultProps = { + className: '', + stack: false, + style: {} +}; + +var AbstractSeries = function (_PureComponent) { + _inherits(AbstractSeries, _PureComponent); + + function AbstractSeries() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, AbstractSeries); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AbstractSeries.__proto__ || Object.getPrototypeOf(AbstractSeries)).call.apply(_ref, [this].concat(args))), _this), _this._seriesClickHandler = function (event) { + var onSeriesClick = _this.props.onSeriesClick; + + if (onSeriesClick) { + onSeriesClick({ event: event }); + } + }, _this._seriesMouseOutHandler = function (event) { + var onSeriesMouseOut = _this.props.onSeriesMouseOut; + + if (onSeriesMouseOut) { + onSeriesMouseOut({ event: event }); + } + }, _this._seriesMouseOverHandler = function (event) { + var onSeriesMouseOver = _this.props.onSeriesMouseOver; + + if (onSeriesMouseOver) { + onSeriesMouseOver({ event: event }); + } + }, _this._seriesRightClickHandler = function (event) { + var onSeriesRightClick = _this.props.onSeriesRightClick; + + if (onSeriesRightClick) { + onSeriesRightClick({ event: event }); + } + }, _this._valueClickHandler = function (d, event) { + var _this$props = _this.props, + onValueClick = _this$props.onValueClick, + onSeriesClick = _this$props.onSeriesClick; + + if (onValueClick) { + onValueClick(d, { event: event }); + } + if (onSeriesClick) { + onSeriesClick({ event: event }); + } + }, _this._valueMouseOutHandler = function (d, event) { + var _this$props2 = _this.props, + onValueMouseOut = _this$props2.onValueMouseOut, + onSeriesMouseOut = _this$props2.onSeriesMouseOut; + + if (onValueMouseOut) { + onValueMouseOut(d, { event: event }); + } + if (onSeriesMouseOut) { + onSeriesMouseOut({ event: event }); + } + }, _this._valueMouseOverHandler = function (d, event) { + var _this$props3 = _this.props, + onValueMouseOver = _this$props3.onValueMouseOver, + onSeriesMouseOver = _this$props3.onSeriesMouseOver; + + if (onValueMouseOver) { + onValueMouseOver(d, { event: event }); + } + if (onSeriesMouseOver) { + onSeriesMouseOver({ event: event }); + } + }, _this._valueRightClickHandler = function (d, event) { + var _this$props4 = _this.props, + onValueRightClick = _this$props4.onValueRightClick, + onSeriesRightClick = _this$props4.onSeriesRightClick; + + if (onValueRightClick) { + onValueRightClick(d, { event: event }); + } + if (onSeriesRightClick) { + onSeriesRightClick({ event: event }); + } + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(AbstractSeries, [{ + key: 'onParentMouseMove', + value: function onParentMouseMove(event) { + var _props = this.props, + onNearestX = _props.onNearestX, + onNearestXY = _props.onNearestXY, + data = _props.data; + + if (!onNearestX && !onNearestXY || !data) { + return; + } + if (onNearestXY) { + this._handleNearestXY(event); + } else { + this._handleNearestX(event); + } + } + }, { + key: 'onParentTouchMove', + value: function onParentTouchMove(e) { + e.preventDefault(); + this.onParentMouseMove(e); + } + }, { + key: 'onParentTouchStart', + value: function onParentTouchStart(e) { + // prevent mouse event emulation + e.preventDefault(); + } + + /** + * Get the attr0 functor. + * @param {string} attr Attribute name. + * @returns {*} Functor. + * @private + */ + + }, { + key: '_getAttr0Functor', + value: function _getAttr0Functor(attr) { + return (0, _scalesUtils.getAttr0Functor)(this.props, attr); + } + + /** + * Get attribute functor. + * @param {string} attr Attribute name + * @returns {*} Functor. + * @protected + */ + + }, { + key: '_getAttributeFunctor', + value: function _getAttributeFunctor(attr) { + return (0, _scalesUtils.getAttributeFunctor)(this.props, attr); + } + + /** + * Get the attribute value if it is available. + * @param {string} attr Attribute name. + * @returns {*} Attribute value if available, fallback value or undefined + * otherwise. + * @protected + */ + + }, { + key: '_getAttributeValue', + value: function _getAttributeValue(attr) { + return (0, _scalesUtils.getAttributeValue)(this.props, attr); + } + + /** + * Get the scale object distance by the attribute from the list of properties. + * @param {string} attr Attribute name. + * @returns {number} Scale distance. + * @protected + */ + + }, { + key: '_getScaleDistance', + value: function _getScaleDistance(attr) { + var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(this.props, attr); + return scaleObject ? scaleObject.distance : 0; + } + }, { + key: '_getXYCoordinateInContainer', + value: function _getXYCoordinateInContainer(event) { + var _props2 = this.props, + _props2$marginTop = _props2.marginTop, + marginTop = _props2$marginTop === undefined ? 0 : _props2$marginTop, + _props2$marginLeft = _props2.marginLeft, + marginLeft = _props2$marginLeft === undefined ? 0 : _props2$marginLeft; + var evt = event.nativeEvent, + currentTarget = event.currentTarget; + + var rect = currentTarget.getBoundingClientRect(); + var x = evt.clientX; + var y = evt.clientY; + if (evt.type === 'touchmove') { + x = evt.touches[0].pageX; + y = evt.touches[0].pageY; + } + return { + x: x - rect.left - currentTarget.clientLeft - marginLeft, + y: y - rect.top - currentTarget.clientTop - marginTop + }; + } + }, { + key: '_handleNearestX', + value: function _handleNearestX(event) { + var _props3 = this.props, + onNearestX = _props3.onNearestX, + data = _props3.data; + + var minDistance = Number.POSITIVE_INFINITY; + var value = null; + var valueIndex = null; + + var coordinate = this._getXYCoordinateInContainer(event); + var xScaleFn = this._getAttributeFunctor('x'); + + data.forEach(function (item, i) { + var currentCoordinate = xScaleFn(item); + var newDistance = Math.abs(coordinate.x - currentCoordinate); + if (newDistance < minDistance) { + minDistance = newDistance; + value = item; + valueIndex = i; + } + }); + if (!value) { + return; + } + onNearestX(value, { + innerX: xScaleFn(value), + index: valueIndex, + event: event.nativeEvent + }); + } + }, { + key: '_handleNearestXY', + value: function _handleNearestXY(event) { + var _props4 = this.props, + onNearestXY = _props4.onNearestXY, + data = _props4.data; + + + var coordinate = this._getXYCoordinateInContainer(event); + var xScaleFn = this._getAttributeFunctor('x'); + var yScaleFn = this._getAttributeFunctor('y'); + + // Create a voronoi with each node center points + var voronoiInstance = (0, _d3Voronoi.voronoi)().x(xScaleFn).y(yScaleFn); + + var foundPoint = voronoiInstance(data).find(coordinate.x, coordinate.y); + var value = foundPoint.data; + + if (!value) { + return; + } + onNearestXY(value, { + innerX: foundPoint.x, + innerY: foundPoint.y, + index: foundPoint.index, + event: event.nativeEvent + }); + } + + /** + * Click handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse out handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse over handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Right Click handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Click handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse out handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse over handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + + /** + * Right Click handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + }], [{ + key: 'getParentConfig', + + /** + * Get a default config for the parent. + * @returns {Object} Empty config. + */ + value: function getParentConfig() { + return {}; + } + + /** + * Tells the rest of the world that it requires SVG to work. + * @returns {boolean} Result. + */ + + }, { + key: 'requiresSVG', + get: function get() { + return true; + } + }]); + + return AbstractSeries; +}(_react.PureComponent); + +AbstractSeries.displayName = 'AbstractSeries'; +AbstractSeries.propTypes = propTypes; +AbstractSeries.defaultProps = defaultProps; + +exports.default = AbstractSeries; \ No newline at end of file diff --git a/dist/plot/series/arc-series.js b/dist/plot/series/arc-series.js new file mode 100644 index 000000000..465cf5a91 --- /dev/null +++ b/dist/plot/series/arc-series.js @@ -0,0 +1,279 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _d3Shape = require('d3-shape'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _scalesUtils = require('../../utils/scales-utils'); + +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; } + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--arc'; +var ATTRIBUTES = ['radius', 'angle']; + +var defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + center: { x: 0, y: 0 }, + arcClassName: '', + className: '', + style: {}, + padAngle: 0 +}); + +/** + * Prepare the internal representation of row for real use. + * This is necessary because d3 insists on starting at 12 oclock and moving + * clockwise, rather than starting at 3 oclock and moving counter clockwise + * as one might expect from polar + * @param {Object} row - coordinate object to be modifed + * @return {Object} angle corrected object + */ +function modifyRow(row) { + var radius = row.radius, + angle = row.angle, + angle0 = row.angle0; + + var truedAngle = -1 * angle + Math.PI / 2; + var truedAngle0 = -1 * angle0 + Math.PI / 2; + return _extends({}, row, { + x: radius * Math.cos(truedAngle), + y: radius * Math.sin(truedAngle), + angle: truedAngle, + angle0: truedAngle0 + }); +} + +var ArcSeries = function (_AbstractSeries) { + _inherits(ArcSeries, _AbstractSeries); + + function ArcSeries(props) { + _classCallCheck(this, ArcSeries); + + var _this = _possibleConstructorReturn(this, (ArcSeries.__proto__ || Object.getPrototypeOf(ArcSeries)).call(this, props)); + + var scaleProps = _this._getAllScaleProps(props); + _this.state = { scaleProps: scaleProps }; + return _this; + } + + _createClass(ArcSeries, [{ + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + this.setState({ scaleProps: this._getAllScaleProps(nextProps) }); + } + + /** + * Get the map of scales from the props. + * @param {Object} props Props. + * @param {Array} data Array of all data. + * @returns {Object} Map of scales. + * @private + */ + + }, { + key: '_getAllScaleProps', + value: function _getAllScaleProps(props) { + var defaultScaleProps = this._getDefaultScaleProps(props); + var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); + var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, userScaleProps), props.data, ATTRIBUTES); + + return _extends({}, defaultScaleProps, userScaleProps, missingScaleProps); + } + + /** + * Get the list of scale-related settings that should be applied by default. + * @param {Object} props Object of props. + * @returns {Object} Defaults. + * @private + */ + + }, { + key: '_getDefaultScaleProps', + value: function _getDefaultScaleProps(props) { + var innerWidth = props.innerWidth, + innerHeight = props.innerHeight; + + var radius = Math.min(innerWidth / 2, innerHeight / 2); + return { + radiusRange: [0, radius], + _radiusValue: radius, + angleType: 'literal' + }; + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + arcClassName = _props.arcClassName, + animation = _props.animation, + className = _props.className, + center = _props.center, + data = _props.data, + disableSeries = _props.disableSeries, + hideSeries = _props.hideSeries, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + padAngle = _props.padAngle, + style = _props.style; + + + if (!data) { + return null; + } + + if (animation) { + var cloneData = data.map(function (d) { + return _extends({}, d); + }); + return _react2.default.createElement( + 'g', + { className: 'rv-xy-plot__series--arc__animation-wrapper' }, + _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { + animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS, + data: cloneData + }), + _react2.default.createElement(ArcSeries, _extends({}, this.props, { + animation: null, + disableSeries: true, + data: cloneData + })) + ), + _react2.default.createElement(ArcSeries, _extends({}, this.props, { + animation: null, + hideSeries: true, + style: { stroke: 'red' } + })) + ); + } + + var scaleProps = this.state.scaleProps; + var radiusDomain = scaleProps.radiusDomain; + // need to generate our own functors as abstract series doesnt have anythign for us + + var radius = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'radius'); + var radius0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'radius'); + var angle = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'angle'); + var angle0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'angle'); + // but it does have good color support! + var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var opacity = this._getAttributeFunctor('opacity'); + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + onMouseOver: this._seriesMouseOverHandler, + onMouseOut: this._seriesMouseOutHandler, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + opacity: hideSeries ? 0 : 1, + pointerEvents: disableSeries ? 'none' : 'all', + transform: 'translate(' + (marginLeft + x(center)) + ',' + (marginTop + y(center)) + ')' + }, + data.map(function (row, i) { + var noRadius = radiusDomain[1] === radiusDomain[0]; + var arcArg = { + innerRadius: noRadius ? 0 : radius0(row), + outerRadius: radius(row), + startAngle: angle0(row) || 0, + endAngle: angle(row) + }; + var arcedData = (0, _d3Shape.arc)().padAngle(padAngle); + var rowStyle = row.style || {}; + var rowClassName = row.className || ''; + return _react2.default.createElement('path', { + style: _extends({ + opacity: opacity && opacity(row), + stroke: stroke && stroke(row), + fill: fill && fill(row) + }, style, rowStyle), + onClick: function onClick(e) { + return _this2._valueClickHandler(modifyRow(row), e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(modifyRow(row), e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(modifyRow(row), e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(modifyRow(row), e); + }, + key: i, + className: predefinedClassName + '-path ' + arcClassName + ' ' + rowClassName, + d: arcedData(arcArg) + }); + }) + ); + } + }]); + + return ArcSeries; +}(_abstractSeries2.default); + +ArcSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, (0, _scalesUtils.getScalePropTypesByAttribute)('radius'), (0, _scalesUtils.getScalePropTypesByAttribute)('angle'), { + center: _propTypes2.default.shape({ + x: _propTypes2.default.number, + y: _propTypes2.default.number + }), + arcClassName: _propTypes2.default.string, + padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) +}); +ArcSeries.defaultProps = defaultProps; +ArcSeries.displayName = 'ArcSeries'; + +exports.default = ArcSeries; \ No newline at end of file diff --git a/dist/plot/series/area-series.js b/dist/plot/series/area-series.js new file mode 100644 index 000000000..10b6f12b0 --- /dev/null +++ b/dist/plot/series/area-series.js @@ -0,0 +1,160 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Shape = require('d3-shape'); + +var d3Shape = _interopRequireWildcard(_d3Shape); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _theme = require('../../theme'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _reactUtils = require('../../utils/react-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; + +var AreaSeries = function (_AbstractSeries) { + _inherits(AreaSeries, _AbstractSeries); + + function AreaSeries() { + _classCallCheck(this, AreaSeries); + + return _possibleConstructorReturn(this, (AreaSeries.__proto__ || Object.getPrototypeOf(AreaSeries)).apply(this, arguments)); + } + + _createClass(AreaSeries, [{ + key: '_renderArea', + value: function _renderArea(data, x, y0, y, curve, getNull) { + var area = d3Shape.area(); + if (curve !== null) { + if (typeof curve === 'string' && d3Shape[curve]) { + area = area.curve(d3Shape[curve]); + } else if (typeof curve === 'function') { + area = area.curve(curve); + } + } + area = area.defined(getNull); + area = area.x(x).y0(y0).y1(y); + return area(data); + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + curve = _props.curve, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + + if (this.props.nullAccessor) { + (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); + } + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(AreaSeries, _extends({}, this.props, { animation: null })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var y0 = this._getAttr0Functor('y'); + var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); + var fill = this._getAttributeValue('fill') || this._getAttributeValue('color'); + var newOpacity = this._getAttributeValue('opacity'); + var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; + var getNull = this.props.nullAccessor || this.props.getNull; + var d = this._renderArea(data, x, y0, y, curve, getNull); + + return _react2.default.createElement('path', { + d: d, + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')', + onMouseOver: this._seriesMouseOverHandler, + onMouseOut: this._seriesMouseOutHandler, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + style: _extends({ + opacity: opacity, + stroke: stroke, + fill: fill + }, style) + }); + } + }]); + + return AreaSeries; +}(_abstractSeries2.default); + +AreaSeries.displayName = 'AreaSeries'; +AreaSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + getNull: _propTypes2.default.func +}); +AreaSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + getNull: function getNull() { + return true; + } +}); + +exports.default = AreaSeries; \ No newline at end of file diff --git a/dist/plot/series/bar-series-canvas.js b/dist/plot/series/bar-series-canvas.js new file mode 100644 index 000000000..3ede5b8fe --- /dev/null +++ b/dist/plot/series/bar-series-canvas.js @@ -0,0 +1,161 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Color = require('d3-color'); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +function getScaleDistance(props, attr) { + var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(props, attr); + return scaleObject ? scaleObject.distance : 0; +} + +var BarSeriesCanvas = function (_AbstractSeries) { + _inherits(BarSeriesCanvas, _AbstractSeries); + + function BarSeriesCanvas() { + _classCallCheck(this, BarSeriesCanvas); + + return _possibleConstructorReturn(this, (BarSeriesCanvas.__proto__ || Object.getPrototypeOf(BarSeriesCanvas)).apply(this, arguments)); + } + + _createClass(BarSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var data = props.data, + linePosAttr = props.linePosAttr, + lineSizeAttr = props.lineSizeAttr, + valuePosAttr = props.valuePosAttr, + marginTop = props.marginTop, + marginBottom = props.marginBottom; + + if (!data || data.length === 0) { + return; + } + + var distance = getScaleDistance(props, linePosAttr); + var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); + var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); + var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); + var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); + + var halfSpace = distance / 2 * 0.85; + // totalSpaceAvailable is the space we have available to draw all the + // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) + var totalSpaceAvailable = halfSpace * 2; + + var _getStackParams = (0, _seriesUtils.getStackParams)(props), + sameTypeTotal = _getStackParams.sameTypeTotal, + sameTypeIndex = _getStackParams.sameTypeIndex; + + data.forEach(function (row) { + var totalSpaceCenter = line(row); + // totalSpaceStartingPoint is the first pixel were we can start drawing + var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; + + // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal + var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; + // lineSize is the space we have available to draw sameTypeIndex bar + var lineSize = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; + + var fillColor = (0, _d3Color.rgb)(fill(row)); + var strokeColor = (0, _d3Color.rgb)(stroke(row)); + var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; + + // linePos is the first pixel were we can start drawing sameTypeIndex bar + var linePos = totalSpaceStartingPoint + lineSize * sameTypeIndex + sameTypeIndex; + var valuePos = Math.min(value0(row), value(row)); + var x = valuePosAttr === 'x' ? valuePos : linePos; + var y = valuePosAttr === 'y' ? valuePos : linePos; + + var valueSize = Math.abs(-value0(row) + value(row)); + var height = lineSizeAttr === 'height' ? lineSize : valueSize; + var width = lineSizeAttr === 'width' ? lineSize : valueSize; + + ctx.beginPath(); + ctx.rect(x + marginBottom, y + marginTop, width, height); + ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; + ctx.fill(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; + ctx.stroke(); + }); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return BarSeriesCanvas; +}(_abstractSeries2.default); + +BarSeriesCanvas.displayName = 'BarSeriesCanvas'; +BarSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + linePosAttr: _propTypes2.default.string.isRequired, + valuePosAttr: _propTypes2.default.string.isRequired, + lineSizeAttr: _propTypes2.default.string.isRequired, + valueSizeAttr: _propTypes2.default.string.isRequired +}); + +BarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = BarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/bar-series.js b/dist/plot/series/bar-series.js new file mode 100644 index 000000000..2c38ee25f --- /dev/null +++ b/dist/plot/series/bar-series.js @@ -0,0 +1,180 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--bar'; + +var BarSeries = function (_AbstractSeries) { + _inherits(BarSeries, _AbstractSeries); + + function BarSeries() { + _classCallCheck(this, BarSeries); + + return _possibleConstructorReturn(this, (BarSeries.__proto__ || Object.getPrototypeOf(BarSeries)).apply(this, arguments)); + } + + _createClass(BarSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + linePosAttr = _props.linePosAttr, + lineSizeAttr = _props.lineSizeAttr, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style, + valuePosAttr = _props.valuePosAttr, + valueSizeAttr = _props.valueSizeAttr, + barWidth = _props.barWidth; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(BarSeries, _extends({}, this.props, { animation: null })) + ); + } + + var _getStackParams = (0, _seriesUtils.getStackParams)(this.props), + sameTypeTotal = _getStackParams.sameTypeTotal, + sameTypeIndex = _getStackParams.sameTypeIndex; + + var distance = this._getScaleDistance(linePosAttr); + var lineFunctor = this._getAttributeFunctor(linePosAttr); + var valueFunctor = this._getAttributeFunctor(valuePosAttr); + var value0Functor = this._getAttr0Functor(valuePosAttr); + var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var opacityFunctor = this._getAttributeFunctor('opacity'); + + var halfSpace = distance / 2 * barWidth; + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + var _attrs; + + // totalSpaceAvailable is the space we have available to draw all the + // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) + var totalSpaceAvailable = halfSpace * 2; + var totalSpaceCenter = lineFunctor(d); + // totalSpaceStartingPoint is the first pixel were we can start drawing + var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; + // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal + var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; + // spacePerBar is the space we have available to draw sameTypeIndex bar + var spacePerBar = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; + // barStartingPoint is the first pixel were we can start drawing sameTypeIndex bar + var barStartingPoint = totalSpaceStartingPoint + spacePerBar * sameTypeIndex + sameTypeIndex; + + var attrs = (_attrs = { + style: _extends({ + opacity: opacityFunctor && opacityFunctor(d), + stroke: strokeFunctor && strokeFunctor(d), + fill: fillFunctor && fillFunctor(d) + }, style) + }, _defineProperty(_attrs, linePosAttr, barStartingPoint), _defineProperty(_attrs, lineSizeAttr, spacePerBar), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { + return _this2._valueClickHandler(d, e); + }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + }), _defineProperty(_attrs, 'key', i), _attrs); + return _react2.default.createElement('rect', attrs); + }) + ); + } + }], [{ + key: 'propTypes', + get: function get() { + return _extends({}, _abstractSeries2.default.propTypes, { + linePosAttr: _propTypes2.default.string, + valuePosAttr: _propTypes2.default.string, + lineSizeAttr: _propTypes2.default.string, + valueSizeAttr: _propTypes2.default.string, + cluster: _propTypes2.default.string, + barWidth: _propTypes2.default.number + }); + } + }, { + key: 'defaultProps', + get: function get() { + return { + barWidth: 0.85 + }; + } + }]); + + return BarSeries; +}(_abstractSeries2.default); + +BarSeries.displayName = 'BarSeries'; + +exports.default = BarSeries; \ No newline at end of file diff --git a/dist/plot/series/canvas-wrapper.js b/dist/plot/series/canvas-wrapper.js new file mode 100644 index 000000000..5211e2bd7 --- /dev/null +++ b/dist/plot/series/canvas-wrapper.js @@ -0,0 +1,256 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Interpolate = require('d3-interpolate'); + +var _animation = require('../../animation'); + +var _seriesUtils = require('../../utils/series-utils'); + +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; } + +var MAX_DRAWS = 30; + +/** + * Draw loop draws each of the layers until it should draw more + * @param {CanvasContext} ctx - the context where the drawing will take place + * @param {Number} height - height of the canvas + * @param {Number} width - width of the canvas + * @param {Array} layers - the layer objects to render + */ +function engageDrawLoop(ctx, height, width, layers) { + var drawIteration = 0; + // using setInterval because request animation frame goes too fast + var drawCycle = setInterval(function () { + if (!ctx) { + clearInterval(drawCycle); + return; + } + drawLayers(ctx, height, width, layers, drawIteration); + if (drawIteration > MAX_DRAWS) { + clearInterval(drawCycle); + } + drawIteration += 1; + }, 1); +} + +/** + * Loops across each of the layers to be drawn and draws them + * @param {CanvasContext} ctx - the context where the drawing will take place + * @param {Number} height - height of the canvas + * @param {Number} width - width of the canvas + * @param {Array} layers - the layer objects to render + * @param {Number} drawIteration - width of the canvas + */ +function drawLayers(ctx, height, width, layers, drawIteration) { + ctx.clearRect(0, 0, width, height); + layers.forEach(function (layer) { + var interpolator = layer.interpolator, + newProps = layer.newProps, + animation = layer.animation; + // return an empty object if dont need to be animating + + var interpolatedProps = animation ? interpolator ? interpolator(drawIteration / MAX_DRAWS) : interpolator : function () { + return {}; + }; + layer.renderLayer(_extends({}, newProps, interpolatedProps), ctx); + }); +} + +/** + * Build an array of layer of objects the contain the method for drawing each series + * as well as an interpolar (specifically a d3-interpolate interpolator) + * @param {Object} newChildren the new children to be rendered. + * @param {Object} oldChildren the old children to be rendered. + * @returns {Array} Object for rendering + */ +function buildLayers(newChildren, oldChildren) { + return newChildren.map(function (child, index) { + var oldProps = oldChildren[index] ? oldChildren[index].props : {}; + var newProps = child.props; + + var oldAnimatedProps = (0, _animation.extractAnimatedPropValues)(_extends({}, oldProps, { + animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS + })); + var newAnimatedProps = newProps ? (0, _animation.extractAnimatedPropValues)(_extends({}, newProps, { + animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS + })) : null; + var interpolator = (0, _d3Interpolate.interpolate)(oldAnimatedProps, newAnimatedProps); + + return { + renderLayer: child.type.renderLayer, + newProps: child.props, + animation: child.props.animation, + interpolator: interpolator + }; + }); +} + +var CanvasWrapper = function (_Component) { + _inherits(CanvasWrapper, _Component); + + function CanvasWrapper() { + _classCallCheck(this, CanvasWrapper); + + return _possibleConstructorReturn(this, (CanvasWrapper.__proto__ || Object.getPrototypeOf(CanvasWrapper)).apply(this, arguments)); + } + + _createClass(CanvasWrapper, [{ + key: 'componentDidMount', + value: function componentDidMount() { + var ctx = this.canvas.getContext('2d'); + if (!ctx) { + return; + } + var pixelRatio = this.props.pixelRatio; + + if (!ctx) { + return; + } + ctx.scale(pixelRatio, pixelRatio); + + this.drawChildren(null, this.props, ctx); + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate(oldProps) { + this.drawChildren(oldProps, this.props, this.canvas.getContext('2d')); + } + + /** + * Check that we can and should be animating, then kick off animations as apporpriate + * @param {Object} newProps the new props to be interpolated to + * @param {Object} oldProps the old props to be interpolated against + * @param {DomRef} ctx the canvas context to be drawn on. + * @returns {Array} Object for rendering + */ + + }, { + key: 'drawChildren', + value: function drawChildren(oldProps, newProps, ctx) { + var children = newProps.children, + innerHeight = newProps.innerHeight, + innerWidth = newProps.innerWidth, + marginBottom = newProps.marginBottom, + marginLeft = newProps.marginLeft, + marginRight = newProps.marginRight, + marginTop = newProps.marginTop; + + if (!ctx) { + return; + } + + var childrenShouldAnimate = children.find(function (child) { + return child.props.animation; + }); + + var height = innerHeight + marginTop + marginBottom; + var width = innerWidth + marginLeft + marginRight; + var layers = buildLayers(newProps.children, oldProps ? oldProps.children : []); + // if we don't need to be animating, dont! cut short + if (!childrenShouldAnimate) { + drawLayers(ctx, height, width, layers); + return; + } + + engageDrawLoop(ctx, height, width, layers); + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginBottom = _props.marginBottom, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + marginTop = _props.marginTop, + pixelRatio = _props.pixelRatio; + + + var height = innerHeight + marginTop + marginBottom; + var width = innerWidth + marginLeft + marginRight; + + return _react2.default.createElement( + 'div', + { style: { left: 0, top: 0 }, className: 'rv-xy-canvas' }, + _react2.default.createElement('canvas', { + className: 'rv-xy-canvas-element', + height: height * pixelRatio, + width: width * pixelRatio, + style: { + height: height + 'px', + width: width + 'px' + }, + ref: function ref(_ref) { + return _this2.canvas = _ref; + } + }), + this.props.children + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return { + pixelRatio: window && window.devicePixelRatio || 1 + }; + } + }]); + + return CanvasWrapper; +}(_react.Component); + +CanvasWrapper.displayName = 'CanvasWrapper'; +CanvasWrapper.propTypes = { + marginBottom: _propTypes2.default.number.isRequired, + marginLeft: _propTypes2.default.number.isRequired, + marginRight: _propTypes2.default.number.isRequired, + marginTop: _propTypes2.default.number.isRequired, + innerHeight: _propTypes2.default.number.isRequired, + innerWidth: _propTypes2.default.number.isRequired, + pixelRatio: _propTypes2.default.number.isRequired +}; + +exports.default = CanvasWrapper; \ No newline at end of file diff --git a/dist/plot/series/contour-series.js b/dist/plot/series/contour-series.js new file mode 100644 index 000000000..030567d86 --- /dev/null +++ b/dist/plot/series/contour-series.js @@ -0,0 +1,164 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Contour = require('d3-contour'); + +var _d3Geo = require('d3-geo'); + +var _d3Scale = require('d3-scale'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _theme = require('../../theme'); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--contour'; + +function getDomain(data) { + return data.reduce(function (acc, row) { + return { + min: Math.min(acc.min, row.value), + max: Math.max(acc.max, row.value) + }; + }, { min: Infinity, max: -Infinity }); +} + +var ContourSeries = function (_AbstractSeries) { + _inherits(ContourSeries, _AbstractSeries); + + function ContourSeries() { + _classCallCheck(this, ContourSeries); + + return _possibleConstructorReturn(this, (ContourSeries.__proto__ || Object.getPrototypeOf(ContourSeries)).apply(this, arguments)); + } + + _createClass(ContourSeries, [{ + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + bandwidth = _props.bandwidth, + className = _props.className, + colorRange = _props.colorRange, + data = _props.data, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + + if (!data || !innerWidth || !innerHeight) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(ContourSeries, _extends({}, this.props, { animation: null })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + var contouredData = (0, _d3Contour.contourDensity)().x(function (d) { + return x(d); + }).y(function (d) { + return y(d); + }).size([innerWidth, innerHeight]).bandwidth(bandwidth)(data); + + var geo = (0, _d3Geo.geoPath)(); + + var _getDomain = getDomain(contouredData), + min = _getDomain.min, + max = _getDomain.max; + + var colorScale = (0, _d3Scale.scaleLinear)().domain([min, max]).range(colorRange || _theme.CONTINUOUS_COLOR_RANGE); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + contouredData.map(function (polygon, index) { + return _react2.default.createElement('path', { + className: 'rv-xy-plot__series--contour-line', + key: 'rv-xy-plot__series--contour-line-' + index, + d: geo(polygon), + style: _extends({ + fill: colorScale(polygon.value) + }, style) + }); + }) + ); + } + }]); + + return ContourSeries; +}(_abstractSeries2.default); + +ContourSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + animation: _propTypes2.default.bool, + bandwidth: _propTypes2.default.number, + className: _propTypes2.default.string, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + style: _propTypes2.default.object +}); + +ContourSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + bandwidth: 40, + style: {} +}); + +exports.default = ContourSeries; \ No newline at end of file diff --git a/dist/plot/series/custom-svg-series.js b/dist/plot/series/custom-svg-series.js new file mode 100644 index 000000000..1dfedfcb2 --- /dev/null +++ b/dist/plot/series/custom-svg-series.js @@ -0,0 +1,237 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +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; } + +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); } } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--custom-svg-wrapper'; + +var DEFAULT_STYLE = { + stroke: 'blue', + fill: 'blue' +}; + +function predefinedComponents(type) { + var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_STYLE; + + switch (type) { + case 'diamond': + return _react2.default.createElement('polygon', { + style: style, + points: '0 0 ' + size / 2 + ' ' + size / 2 + ' 0 ' + size + ' ' + -size / 2 + ' ' + size / 2 + ' 0 0' + }); + case 'star': + var starPoints = [].concat(_toConsumableArray(new Array(5))).map(function (c, index) { + var angle = index / 5 * Math.PI * 2; + var innerAngle = angle + Math.PI / 10; + var outerAngle = angle - Math.PI / 10; + // ratio of inner polygon to outer polgyon + var innerRadius = size / 2.61; + return '\n ' + Math.cos(outerAngle) * size + ' ' + Math.sin(outerAngle) * size + '\n ' + Math.cos(innerAngle) * innerRadius + ' ' + Math.sin(innerAngle) * innerRadius + '\n '; + }).join(' '); + return _react2.default.createElement('polygon', { + points: starPoints, + x: '0', + y: '0', + height: size, + width: size, + style: style + }); + case 'square': + return _react2.default.createElement('rect', { + x: '' + -size / 2, + y: '' + -size / 2, + height: size, + width: size, + style: style + }); + default: + case 'circle': + return _react2.default.createElement('circle', { cx: '0', cy: '0', r: size / 2, style: style }); + } +} + +function getInnerComponent(_ref) { + var customComponent = _ref.customComponent, + defaultType = _ref.defaultType, + positionInPixels = _ref.positionInPixels, + positionFunctions = _ref.positionFunctions, + style = _ref.style, + propsSize = _ref.propsSize; + var size = customComponent.size; + + var aggStyle = _extends({}, style, customComponent.style || {}); + var innerComponent = customComponent.customComponent; + if (!innerComponent && typeof defaultType === 'string') { + return predefinedComponents(defaultType, size || propsSize, aggStyle); + } + // if default component is a function + if (!innerComponent) { + return defaultType(customComponent, positionInPixels, aggStyle); + } + if (typeof innerComponent === 'string') { + return predefinedComponents(innerComponent || defaultType, size, aggStyle); + } + // if inner component is a function + return innerComponent(customComponent, positionInPixels, aggStyle); +} + +var CustomSVGSeries = function (_AbstractSeries) { + _inherits(CustomSVGSeries, _AbstractSeries); + + function CustomSVGSeries() { + _classCallCheck(this, CustomSVGSeries); + + return _possibleConstructorReturn(this, (CustomSVGSeries.__proto__ || Object.getPrototypeOf(CustomSVGSeries)).apply(this, arguments)); + } + + _createClass(CustomSVGSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + customComponent = _props.customComponent, + data = _props.data, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style, + size = _props.size; + + + if (!data || !innerWidth || !innerHeight) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(CustomSVGSeries, _extends({}, this.props, { animation: false })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var contents = data.map(function (seriesComponent, index) { + var positionInPixels = { + x: x({ x: seriesComponent.x }), + y: y({ y: seriesComponent.y }) + }; + var innerComponent = getInnerComponent({ + customComponent: seriesComponent, + positionInPixels: positionInPixels, + defaultType: customComponent, + positionFunctions: { x: x, y: y }, + style: style, + propsSize: size + }); + return _react2.default.createElement( + 'g', + { + className: 'rv-xy-plot__series--custom-svg', + key: 'rv-xy-plot__series--custom-svg-' + index, + transform: 'translate(' + positionInPixels.x + ',' + positionInPixels.y + ')', + onMouseEnter: function onMouseEnter(e) { + return _this2._valueMouseOverHandler(seriesComponent, e); + }, + onMouseLeave: function onMouseLeave(e) { + return _this2._valueMouseOutHandler(seriesComponent, e); + } + }, + innerComponent + ); + }); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + contents + ); + } + }]); + + return CustomSVGSeries; +}(_abstractSeries2.default); + +CustomSVGSeries.propTypes = { + animation: _propTypes2.default.bool, + className: _propTypes2.default.string, + customComponent: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), + data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired, + y: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired + })).isRequired, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + style: _propTypes2.default.object, + size: _propTypes2.default.number, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func +}; + +CustomSVGSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + animation: false, + customComponent: 'circle', + style: {}, + size: 2 +}); + +exports.default = CustomSVGSeries; \ No newline at end of file diff --git a/dist/plot/series/heatmap-series.js b/dist/plot/series/heatmap-series.js new file mode 100644 index 000000000..69c142265 --- /dev/null +++ b/dist/plot/series/heatmap-series.js @@ -0,0 +1,147 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--heatmap'; + +var HeatmapSeries = function (_AbstractSeries) { + _inherits(HeatmapSeries, _AbstractSeries); + + function HeatmapSeries() { + _classCallCheck(this, HeatmapSeries); + + return _possibleConstructorReturn(this, (HeatmapSeries.__proto__ || Object.getPrototypeOf(HeatmapSeries)).apply(this, arguments)); + } + + _createClass(HeatmapSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + if (!data) { + return null; + } + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(HeatmapSeries, _extends({}, this.props, { animation: null })) + ); + } + + var _rectStyle$style = _extends({ rectStyle: {} }, style), + rectStyle = _rectStyle$style.rectStyle; + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var opacity = this._getAttributeFunctor('opacity'); + var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var xDistance = this._getScaleDistance('x'); + var yDistance = this._getScaleDistance('y'); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + var attrs = _extends({ + style: _extends({ + stroke: stroke && stroke(d), + fill: fill && fill(d), + opacity: opacity && opacity(d) + }, style) + }, rectStyle, { + x: x(d) - xDistance / 2, + y: y(d) - yDistance / 2, + width: xDistance, + height: yDistance, + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + } + }); + return _react2.default.createElement('rect', attrs); + }) + ); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'x' || attr === 'y'; + return { isDomainAdjustmentNeeded: isDomainAdjustmentNeeded }; + } + }]); + + return HeatmapSeries; +}(_abstractSeries2.default); + +HeatmapSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +HeatmapSeries.displayName = 'HeatmapSeries'; + +exports.default = HeatmapSeries; \ No newline at end of file diff --git a/dist/plot/series/hexbin-series.js b/dist/plot/series/hexbin-series.js new file mode 100644 index 000000000..2f2cadcf9 --- /dev/null +++ b/dist/plot/series/hexbin-series.js @@ -0,0 +1,180 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _d3Hexbin = require('d3-hexbin'); + +var _d3Scale = require('d3-scale'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _theme = require('../../theme'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } + +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); } } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--hexbin'; + +function getColorDomain(_ref, hexes) { + var countDomain = _ref.countDomain; + + if (countDomain) { + return countDomain; + } + return [0, Math.max.apply(Math, _toConsumableArray(hexes.map(function (row) { + return row.length; + })))]; +} + +var HexbinSeries = function (_AbstractSeries) { + _inherits(HexbinSeries, _AbstractSeries); + + function HexbinSeries() { + _classCallCheck(this, HexbinSeries); + + return _possibleConstructorReturn(this, (HexbinSeries.__proto__ || Object.getPrototypeOf(HexbinSeries)).apply(this, arguments)); + } + + _createClass(HexbinSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + colorRange = _props.colorRange, + data = _props.data, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + radius = _props.radius, + sizeHexagonsWithCount = _props.sizeHexagonsWithCount, + style = _props.style, + xOffset = _props.xOffset, + yOffset = _props.yOffset; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(HexbinSeries, _extends({}, this.props, { animation: null })) + ); + } + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + var hex = (0, _d3Hexbin.hexbin)().x(function (d) { + return x(d) + xOffset; + }).y(function (d) { + return y(d) + yOffset; + }).radius(radius).size([innerWidth, innerHeight]); + + var hexagonPath = hex.hexagon(); + var hexes = hex(data); + + var countDomain = getColorDomain(this.props, hexes); + var color = (0, _d3Scale.scaleLinear)().domain(countDomain).range(colorRange); + var size = (0, _d3Scale.scaleLinear)().domain(countDomain).range([0, radius]); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + hexes.map(function (d, i) { + var attrs = { + style: style, + d: sizeHexagonsWithCount ? hex.hexagon(size(d.length)) : hexagonPath, + fill: color(d.length), + transform: 'translate(' + d.x + ', ' + d.y + ')', + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + } + }; + return _react2.default.createElement('path', attrs); + }) + ); + } + }]); + + return HexbinSeries; +}(_abstractSeries2.default); + +HexbinSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + radius: _propTypes2.default.number +}); + +HexbinSeries.defaultProps = { + radius: 20, + colorRange: _theme.CONTINUOUS_COLOR_RANGE, + xOffset: 0, + yOffset: 0 +}; + +HexbinSeries.displayName = 'HexbinSeries'; + +exports.default = HexbinSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series-canvas.js b/dist/plot/series/horizontal-bar-series-canvas.js new file mode 100644 index 000000000..fa817cc24 --- /dev/null +++ b/dist/plot/series/horizontal-bar-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeriesCanvas = require('./bar-series-canvas'); + +var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalBarSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); + + function HorizontalBarSeriesCanvas() { + _classCallCheck(this, HorizontalBarSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalBarSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'y'; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _barSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalBarSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; +HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series.js b/dist/plot/series/horizontal-bar-series.js new file mode 100644 index 000000000..ef65b02da --- /dev/null +++ b/dist/plot/series/horizontal-bar-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeries = require('./bar-series'); + +var _barSeries2 = _interopRequireDefault(_barSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalBarSeries = function (_AbstractSeries) { + _inherits(HorizontalBarSeries, _AbstractSeries); + + function HorizontalBarSeries() { + _classCallCheck(this, HorizontalBarSeries); + + return _possibleConstructorReturn(this, (HorizontalBarSeries.__proto__ || Object.getPrototypeOf(HorizontalBarSeries)).apply(this, arguments)); + } + + _createClass(HorizontalBarSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'y'; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return HorizontalBarSeries; +}(_abstractSeries2.default); + +HorizontalBarSeries.displayName = 'HorizontalBarSeries'; + +exports.default = HorizontalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series-canvas.js b/dist/plot/series/horizontal-rect-series-canvas.js new file mode 100644 index 000000000..c275a349d --- /dev/null +++ b/dist/plot/series/horizontal-rect-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeriesCanvas = require('./rect-series-canvas'); + +var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalRectSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); + + function HorizontalRectSeriesCanvas() { + _classCallCheck(this, HorizontalRectSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalRectSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalRectSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; +HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series.js b/dist/plot/series/horizontal-rect-series.js new file mode 100644 index 000000000..014390674 --- /dev/null +++ b/dist/plot/series/horizontal-rect-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeries = require('./rect-series'); + +var _rectSeries2 = _interopRequireDefault(_rectSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalRectSeries = function (_AbstractSeries) { + _inherits(HorizontalRectSeries, _AbstractSeries); + + function HorizontalRectSeries() { + _classCallCheck(this, HorizontalRectSeries); + + return _possibleConstructorReturn(this, (HorizontalRectSeries.__proto__ || Object.getPrototypeOf(HorizontalRectSeries)).apply(this, arguments)); + } + + _createClass(HorizontalRectSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return HorizontalRectSeries; +}(_abstractSeries2.default); + +HorizontalRectSeries.displayName = 'HorizontalRectSeries'; + +exports.default = HorizontalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/label-series.js b/dist/plot/series/label-series.js new file mode 100644 index 000000000..62e335748 --- /dev/null +++ b/dist/plot/series/label-series.js @@ -0,0 +1,200 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--label'; + +var getTextAnchor = function getTextAnchor(labelAnchorX, leftOfMiddle) { + return labelAnchorX ? labelAnchorX : leftOfMiddle ? 'start' : 'end'; +}; +var getAlignmentBaseline = function getAlignmentBaseline(labelAnchorY, aboveMiddle) { + return labelAnchorY ? labelAnchorY : aboveMiddle ? 'text-before-edge' : 'text-after-edge'; +}; + +var LabelSeries = function (_AbstractSeries) { + _inherits(LabelSeries, _AbstractSeries); + + function LabelSeries() { + _classCallCheck(this, LabelSeries); + + return _possibleConstructorReturn(this, (LabelSeries.__proto__ || Object.getPrototypeOf(LabelSeries)).apply(this, arguments)); + } + + _createClass(LabelSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + allowOffsetToBeReversed = _props.allowOffsetToBeReversed, + className = _props.className, + data = _props.data, + _data = _props._data, + getLabel = _props.getLabel, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + rotation = _props.rotation, + style = _props.style, + xRange = _props.xRange, + yRange = _props.yRange, + labelAnchorX = _props.labelAnchorX, + labelAnchorY = _props.labelAnchorY; + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(LabelSeries, _extends({}, this.props, { animation: null, _data: data })) + ); + } + + var xFunctor = this._getAttributeFunctor('x'); + var yFunctor = this._getAttributeFunctor('y'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')', + style: style + }, + data.reduce(function (res, d, i) { + var markStyle = d.style, + xOffset = d.xOffset, + yOffset = d.yOffset; + + if (!getLabel(d)) { + return res; + } + var xVal = xFunctor(d); + var yVal = yFunctor(d); + var leftOfMiddle = xVal < (xRange[1] - xRange[0]) / 2; + var aboveMiddle = yVal < Math.abs(yRange[1] - yRange[0]) / 2; + + var x = xVal + (allowOffsetToBeReversed && leftOfMiddle ? -1 : 1) * (xOffset || 0); + var y = yVal + (allowOffsetToBeReversed && aboveMiddle ? -1 : 1) * (yOffset || 0); + + var hasRotationValueSet = d.rotation === 0 || d.rotation; + var labelRotation = hasRotationValueSet ? d.rotation : rotation; + var attrs = _extends({ + alignmentBaseline: getAlignmentBaseline(labelAnchorY, aboveMiddle), + className: 'rv-xy-plot__series--label-text', + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + }, + textAnchor: getTextAnchor(labelAnchorX, leftOfMiddle), + x: x, + y: y, + transform: 'rotate(' + labelRotation + ',' + x + ',' + y + ')' + }, markStyle); + var textContent = getLabel(_data ? _data[i] : d); + return res.concat([_react2.default.createElement( + 'text', + attrs, + textContent + )]); + }, []) + ); + } + }]); + + return LabelSeries; +}(_abstractSeries2.default); + +LabelSeries.propTypes = { + animation: _propTypes2.default.bool, + allowOffsetToBeReversed: _propTypes2.default.bool, + className: _propTypes2.default.string, + data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + angle: _propTypes2.default.number, + radius: _propTypes2.default.number, + label: _propTypes2.default.string, + xOffset: _propTypes2.default.number, + yOffset: _propTypes2.default.number, + style: _propTypes2.default.object + })).isRequired, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + rotation: _propTypes2.default.number, + style: _propTypes2.default.object, + xRange: _propTypes2.default.arrayOf(_propTypes2.default.number), + yRange: _propTypes2.default.arrayOf(_propTypes2.default.number), + labelAnchorX: _propTypes2.default.string, + labelAnchorY: _propTypes2.default.string +}; +LabelSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + animation: false, + rotation: 0, + getLabel: function getLabel(d) { + return d.label; + } +}); +LabelSeries.displayName = 'LabelSeries'; +exports.default = LabelSeries; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series-canvas.js b/dist/plot/series/line-mark-series-canvas.js new file mode 100644 index 000000000..501c2745a --- /dev/null +++ b/dist/plot/series/line-mark-series-canvas.js @@ -0,0 +1,87 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _markSeriesCanvas = require('./mark-series-canvas'); + +var _markSeriesCanvas2 = _interopRequireDefault(_markSeriesCanvas); + +var _lineSeriesCanvas = require('./line-series-canvas'); + +var _lineSeriesCanvas2 = _interopRequireDefault(_lineSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var LineMarkSeriesCanvas = function (_AbstractSeries) { + _inherits(LineMarkSeriesCanvas, _AbstractSeries); + + function LineMarkSeriesCanvas() { + _classCallCheck(this, LineMarkSeriesCanvas); + + return _possibleConstructorReturn(this, (LineMarkSeriesCanvas.__proto__ || Object.getPrototypeOf(LineMarkSeriesCanvas)).apply(this, arguments)); + } + + _createClass(LineMarkSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _lineSeriesCanvas2.default.renderLayer(props, ctx); + _markSeriesCanvas2.default.renderLayer(props, ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return LineMarkSeriesCanvas; +}(_abstractSeries2.default); + +LineMarkSeriesCanvas.displayName = 'LineMarkSeriesCanvas'; +LineMarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = LineMarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series.js b/dist/plot/series/line-mark-series.js new file mode 100644 index 000000000..7c3c876cf --- /dev/null +++ b/dist/plot/series/line-mark-series.js @@ -0,0 +1,102 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _lineSeries = require('./line-series'); + +var _lineSeries2 = _interopRequireDefault(_lineSeries); + +var _markSeries = require('./mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +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; } + +var propTypes = _extends({}, _lineSeries2.default.propTypes, { + lineStyle: _propTypes2.default.object, + markStyle: _propTypes2.default.object +}); + +var LineMarkSeries = function (_AbstractSeries) { + _inherits(LineMarkSeries, _AbstractSeries); + + function LineMarkSeries() { + _classCallCheck(this, LineMarkSeries); + + return _possibleConstructorReturn(this, (LineMarkSeries.__proto__ || Object.getPrototypeOf(LineMarkSeries)).apply(this, arguments)); + } + + _createClass(LineMarkSeries, [{ + key: 'render', + value: function render() { + var _props = this.props, + lineStyle = _props.lineStyle, + markStyle = _props.markStyle, + style = _props.style; + + return _react2.default.createElement( + 'g', + { className: 'rv-xy-plot__series rv-xy-plot__series--linemark' }, + _react2.default.createElement(_lineSeries2.default, _extends({}, this.props, { style: _extends({}, style, lineStyle) })), + _react2.default.createElement(_markSeries2.default, _extends({}, this.props, { style: _extends({}, style, markStyle) })) + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return _extends({}, _lineSeries2.default.defaultProps, { + lineStyle: {}, + markStyle: {} + }); + } + }]); + + return LineMarkSeries; +}(_abstractSeries2.default); + +LineMarkSeries.displayName = 'LineMarkSeries'; +LineMarkSeries.propTypes = propTypes; + +exports.default = LineMarkSeries; \ No newline at end of file diff --git a/dist/plot/series/line-series-canvas.js b/dist/plot/series/line-series-canvas.js new file mode 100644 index 000000000..9694a334d --- /dev/null +++ b/dist/plot/series/line-series-canvas.js @@ -0,0 +1,146 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Color = require('d3-color'); + +var _d3Shape = require('d3-shape'); + +var d3Shape = _interopRequireWildcard(_d3Shape); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +var LineSeriesCanvas = function (_AbstractSeries) { + _inherits(LineSeriesCanvas, _AbstractSeries); + + function LineSeriesCanvas() { + _classCallCheck(this, LineSeriesCanvas); + + return _possibleConstructorReturn(this, (LineSeriesCanvas.__proto__ || Object.getPrototypeOf(LineSeriesCanvas)).apply(this, arguments)); + } + + _createClass(LineSeriesCanvas, [{ + key: 'render', + value: function render() { + return _react2.default.createElement('div', null); + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var curve = props.curve, + data = props.data, + marginLeft = props.marginLeft, + marginTop = props.marginTop, + strokeWidth = props.strokeWidth, + strokeDasharray = props.strokeDasharray; + + if (!data || data.length === 0) { + return; + } + + var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); + var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); + var stroke = (0, _scalesUtils.getAttributeValue)(props, 'stroke') || (0, _scalesUtils.getAttributeValue)(props, 'color'); + var strokeColor = (0, _d3Color.rgb)(stroke); + var newOpacity = (0, _scalesUtils.getAttributeValue)(props, 'opacity'); + var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; + var line = d3Shape.line().x(function (row) { + return x(row) + marginLeft; + }).y(function (row) { + return y(row) + marginTop; + }); + if (typeof curve === 'string' && d3Shape[curve]) { + line = line.curve(d3Shape[curve]); + } else if (typeof curve === 'function') { + line = line.curve(curve); + } + + ctx.beginPath(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + opacity + ')'; + ctx.lineWidth = strokeWidth; + + if (strokeDasharray) { + ctx.setLineDash(strokeDasharray); + } + + line.context(ctx)(data); + ctx.stroke(); + ctx.closePath(); + // set back to default + ctx.lineWidth = 1; + ctx.setLineDash([]); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return LineSeriesCanvas; +}(_abstractSeries2.default); + +LineSeriesCanvas.displayName = 'LineSeriesCanvas'; +LineSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + strokeWidth: 2 +}); + +LineSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + strokeWidth: _propTypes2.default.number +}); + +exports.default = LineSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-series.js b/dist/plot/series/line-series.js new file mode 100644 index 000000000..d643b3b7f --- /dev/null +++ b/dist/plot/series/line-series.js @@ -0,0 +1,177 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Shape = require('d3-shape'); + +var d3Shape = _interopRequireWildcard(_d3Shape); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _theme = require('../../theme'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _reactUtils = require('../../utils/react-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; + +var STROKE_STYLES = { + dashed: '6, 2', + solid: null +}; + +var LineSeries = function (_AbstractSeries) { + _inherits(LineSeries, _AbstractSeries); + + function LineSeries() { + _classCallCheck(this, LineSeries); + + return _possibleConstructorReturn(this, (LineSeries.__proto__ || Object.getPrototypeOf(LineSeries)).apply(this, arguments)); + } + + _createClass(LineSeries, [{ + key: '_renderLine', + value: function _renderLine(data, x, y, curve, getNull) { + var line = d3Shape.line(); + if (curve !== null) { + if (typeof curve === 'string' && d3Shape[curve]) { + line = line.curve(d3Shape[curve]); + } else if (typeof curve === 'function') { + line = line.curve(curve); + } + } + line = line.defined(getNull); + line = line.x(x).y(y); + return line(data); + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data; + + + if (this.props.nullAccessor) { + (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); + } + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(LineSeries, _extends({}, this.props, { animation: null })) + ); + } + + var _props2 = this.props, + curve = _props2.curve, + marginLeft = _props2.marginLeft, + marginTop = _props2.marginTop, + strokeDasharray = _props2.strokeDasharray, + strokeStyle = _props2.strokeStyle, + strokeWidth = _props2.strokeWidth, + style = _props2.style; + + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); + var newOpacity = this._getAttributeValue('opacity'); + var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; + var getNull = this.props.nullAccessor || this.props.getNull; + var d = this._renderLine(data, x, y, curve, getNull); + + return _react2.default.createElement('path', { + d: d, + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')', + onMouseOver: this._seriesMouseOverHandler, + onMouseOut: this._seriesMouseOutHandler, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + style: _extends({ + opacity: opacity, + strokeDasharray: STROKE_STYLES[strokeStyle] || strokeDasharray, + strokeWidth: strokeWidth, + stroke: stroke + }, style) + }); + } + }]); + + return LineSeries; +}(_abstractSeries2.default); + +LineSeries.displayName = 'LineSeries'; +LineSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)), + curve: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), + getNull: _propTypes2.default.func +}); +LineSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + strokeStyle: 'solid', + style: {}, + opacity: 1, + curve: null, + className: '', + getNull: function getNull() { + return true; + } +}); + +exports.default = LineSeries; \ No newline at end of file diff --git a/dist/plot/series/mark-series-canvas.js b/dist/plot/series/mark-series-canvas.js new file mode 100644 index 000000000..de7f2e814 --- /dev/null +++ b/dist/plot/series/mark-series-canvas.js @@ -0,0 +1,109 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _d3Color = require('d3-color'); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var MarkSeriesCanvas = function (_AbstractSeries) { + _inherits(MarkSeriesCanvas, _AbstractSeries); + + function MarkSeriesCanvas() { + _classCallCheck(this, MarkSeriesCanvas); + + return _possibleConstructorReturn(this, (MarkSeriesCanvas.__proto__ || Object.getPrototypeOf(MarkSeriesCanvas)).apply(this, arguments)); + } + + _createClass(MarkSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var data = props.data, + marginLeft = props.marginLeft, + marginTop = props.marginTop; + + + var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); + var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); + var size = (0, _scalesUtils.getAttributeFunctor)(props, 'size') || function (p) { + return _theme.DEFAULT_SIZE; + }; + var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); + + data.forEach(function (row) { + var fillColor = (0, _d3Color.rgb)(fill(row)); + var strokeColor = (0, _d3Color.rgb)(stroke(row)); + var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; + ctx.beginPath(); + ctx.arc(x(row) + marginLeft, y(row) + marginTop, size(row), 0, 2 * Math.PI); + ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; + ctx.fill(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; + ctx.stroke(); + }); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return MarkSeriesCanvas; +}(_abstractSeries2.default); + +MarkSeriesCanvas.displayName = 'MarkSeriesCanvas'; + +MarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = MarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/mark-series.js b/dist/plot/series/mark-series.js new file mode 100644 index 000000000..9ba9a0e8a --- /dev/null +++ b/dist/plot/series/mark-series.js @@ -0,0 +1,179 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _reactUtils = require('../../utils/react-utils'); + +var _theme = require('../../theme'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--mark'; +var DEFAULT_STROKE_WIDTH = 1; + +var MarkSeries = function (_AbstractSeries) { + _inherits(MarkSeries, _AbstractSeries); + + function MarkSeries() { + _classCallCheck(this, MarkSeries); + + return _possibleConstructorReturn(this, (MarkSeries.__proto__ || Object.getPrototypeOf(MarkSeries)).apply(this, arguments)); + } + + _createClass(MarkSeries, [{ + key: '_renderCircle', + value: function _renderCircle(d, i, strokeWidth, style, scalingFunctions) { + var _this2 = this; + + var fill = scalingFunctions.fill, + opacity = scalingFunctions.opacity, + size = scalingFunctions.size, + stroke = scalingFunctions.stroke, + x = scalingFunctions.x, + y = scalingFunctions.y; + + + var attrs = { + r: size ? size(d) : _theme.DEFAULT_SIZE, + cx: x(d), + cy: y(d), + style: _extends({ + opacity: opacity ? opacity(d) : _theme.DEFAULT_OPACITY, + stroke: stroke && stroke(d), + fill: fill && fill(d), + strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH + }, style), + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + } + }; + return _react2.default.createElement('circle', attrs); + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + strokeWidth = _props.strokeWidth, + style = _props.style; + + + if (this.props.nullAccessor) { + (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); + } + + var getNull = this.props.nullAccessor || this.props.getNull; + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(MarkSeries, _extends({}, this.props, { animation: null })) + ); + } + + var scalingFunctions = { + fill: this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'), + opacity: this._getAttributeFunctor('opacity'), + size: this._getAttributeFunctor('size'), + stroke: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), + x: this._getAttributeFunctor('x'), + y: this._getAttributeFunctor('y') + }; + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + return getNull(d) && _this3._renderCircle(d, i, strokeWidth, style, scalingFunctions); + }) + ); + } + }]); + + return MarkSeries; +}(_abstractSeries2.default); + +MarkSeries.displayName = 'MarkSeries'; +MarkSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + getNull: _propTypes2.default.func, + strokeWidth: _propTypes2.default.number +}); +MarkSeries.defaultProps = { + getNull: function getNull() { + return true; + } +}; + +exports.default = MarkSeries; \ No newline at end of file diff --git a/dist/plot/series/polygon-series.js b/dist/plot/series/polygon-series.js new file mode 100644 index 000000000..d922d284b --- /dev/null +++ b/dist/plot/series/polygon-series.js @@ -0,0 +1,126 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--polygon'; +var DEFAULT_COLOR = '#12939A'; + +var generatePath = function generatePath(data, xFunctor, yFunctor) { + return data.reduce(function (res, row, i) { + return res + ' ' + (i ? 'L' : 'M') + xFunctor(row) + ' ' + yFunctor(row); + }, '') + ' Z'; +}; + +var PolygonSeries = function (_AbstractSeries) { + _inherits(PolygonSeries, _AbstractSeries); + + function PolygonSeries() { + _classCallCheck(this, PolygonSeries); + + return _possibleConstructorReturn(this, (PolygonSeries.__proto__ || Object.getPrototypeOf(PolygonSeries)).apply(this, arguments)); + } + + _createClass(PolygonSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + color = _props.color, + className = _props.className, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(PolygonSeries, _extends({}, this.props, { animation: null })) + ); + } + var xFunctor = this._getAttributeFunctor('x'); + var yFunctor = this._getAttributeFunctor('y'); + + return _react2.default.createElement('path', { + className: predefinedClassName + ' ' + className, + onMouseOver: function onMouseOver(e) { + return _this2._seriesMouseOverHandler(data, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._seriesMouseOutHandler(data, e); + }, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + fill: color || DEFAULT_COLOR, + style: style, + d: generatePath(data, xFunctor, yFunctor), + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }); + } + }], [{ + key: 'propTypes', + get: function get() { + return _extends({}, _abstractSeries2.default.propTypes); + } + }]); + + return PolygonSeries; +}(_abstractSeries2.default); + +PolygonSeries.displayName = 'PolygonSeries'; + +exports.default = PolygonSeries; \ No newline at end of file diff --git a/dist/plot/series/rect-series-canvas.js b/dist/plot/series/rect-series-canvas.js new file mode 100644 index 000000000..727596c9b --- /dev/null +++ b/dist/plot/series/rect-series-canvas.js @@ -0,0 +1,136 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Color = require('d3-color'); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +var RectSeriesCanvas = function (_AbstractSeries) { + _inherits(RectSeriesCanvas, _AbstractSeries); + + function RectSeriesCanvas() { + _classCallCheck(this, RectSeriesCanvas); + + return _possibleConstructorReturn(this, (RectSeriesCanvas.__proto__ || Object.getPrototypeOf(RectSeriesCanvas)).apply(this, arguments)); + } + + _createClass(RectSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var data = props.data, + linePosAttr = props.linePosAttr, + lineSizeAttr = props.lineSizeAttr, + marginLeft = props.marginLeft, + marginTop = props.marginTop, + valuePosAttr = props.valuePosAttr; + + if (!data || data.length === 0) { + return; + } + + var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); + var line0 = (0, _scalesUtils.getAttr0Functor)(props, linePosAttr); + var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); + var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); + var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); + + data.forEach(function (row) { + var fillColor = (0, _d3Color.rgb)(fill(row)); + var strokeColor = (0, _d3Color.rgb)(stroke(row)); + var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; + + var linePos = line0(row); + var valuePos = Math.min(value0(row), value(row)); + var x = valuePosAttr === 'x' ? valuePos : linePos; + var y = valuePosAttr === 'y' ? valuePos : linePos; + + var lineSize = Math.abs(line(row) - line0(row)); + var valueSize = Math.abs(-value0(row) + value(row)); + var height = lineSizeAttr === 'height' ? lineSize : valueSize; + var width = lineSizeAttr === 'width' ? lineSize : valueSize; + + ctx.beginPath(); + ctx.rect(x + marginLeft, y + marginTop, width, height); + ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; + ctx.fill(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; + ctx.stroke(); + }); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return RectSeriesCanvas; +}(_abstractSeries2.default); + +RectSeriesCanvas.displayName = 'RectSeriesCanvas'; +RectSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + linePosAttr: _propTypes2.default.string.isRequired, + valuePosAttr: _propTypes2.default.string.isRequired, + lineSizeAttr: _propTypes2.default.string.isRequired, + valueSizeAttr: _propTypes2.default.string.isRequired +}); + +RectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = RectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/rect-series.js b/dist/plot/series/rect-series.js new file mode 100644 index 000000000..75bbd5f46 --- /dev/null +++ b/dist/plot/series/rect-series.js @@ -0,0 +1,151 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--rect'; + +var RectSeries = function (_AbstractSeries) { + _inherits(RectSeries, _AbstractSeries); + + function RectSeries() { + _classCallCheck(this, RectSeries); + + return _possibleConstructorReturn(this, (RectSeries.__proto__ || Object.getPrototypeOf(RectSeries)).apply(this, arguments)); + } + + _createClass(RectSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + linePosAttr = _props.linePosAttr, + lineSizeAttr = _props.lineSizeAttr, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style, + valuePosAttr = _props.valuePosAttr, + valueSizeAttr = _props.valueSizeAttr; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(RectSeries, _extends({}, this.props, { animation: null })) + ); + } + + var lineFunctor = this._getAttributeFunctor(linePosAttr); + var line0Functor = this._getAttr0Functor(linePosAttr); + var valueFunctor = this._getAttributeFunctor(valuePosAttr); + var value0Functor = this._getAttr0Functor(valuePosAttr); + var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var opacityFunctor = this._getAttributeFunctor('opacity'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + var _attrs; + + var attrs = (_attrs = { + style: _extends({ + opacity: opacityFunctor && opacityFunctor(d), + stroke: strokeFunctor && strokeFunctor(d), + fill: fillFunctor && fillFunctor(d) + }, style) + }, _defineProperty(_attrs, linePosAttr, line0Functor(d)), _defineProperty(_attrs, lineSizeAttr, Math.abs(lineFunctor(d) - line0Functor(d))), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { + return _this2._valueClickHandler(d, e); + }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + }), _defineProperty(_attrs, 'key', i), _attrs); + return _react2.default.createElement('rect', attrs); + }) + ); + } + }], [{ + key: 'propTypes', + get: function get() { + return _extends({}, _abstractSeries2.default.propTypes, { + linePosAttr: _propTypes2.default.string, + valuePosAttr: _propTypes2.default.string, + lineSizeAttr: _propTypes2.default.string, + valueSizeAttr: _propTypes2.default.string + }); + } + }]); + + return RectSeries; +}(_abstractSeries2.default); + +RectSeries.displayName = 'RectSeries'; + +exports.default = RectSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series-canvas.js b/dist/plot/series/vertical-bar-series-canvas.js new file mode 100644 index 000000000..c07d69f63 --- /dev/null +++ b/dist/plot/series/vertical-bar-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeriesCanvas = require('./bar-series-canvas'); + +var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalBarSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); + + function HorizontalBarSeriesCanvas() { + _classCallCheck(this, HorizontalBarSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalBarSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'x'; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _barSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalBarSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; +HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series.js b/dist/plot/series/vertical-bar-series.js new file mode 100644 index 000000000..0a0e1de82 --- /dev/null +++ b/dist/plot/series/vertical-bar-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeries = require('./bar-series'); + +var _barSeries2 = _interopRequireDefault(_barSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var VerticalBarSeries = function (_AbstractSeries) { + _inherits(VerticalBarSeries, _AbstractSeries); + + function VerticalBarSeries() { + _classCallCheck(this, VerticalBarSeries); + + return _possibleConstructorReturn(this, (VerticalBarSeries.__proto__ || Object.getPrototypeOf(VerticalBarSeries)).apply(this, arguments)); + } + + _createClass(VerticalBarSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'x'; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return VerticalBarSeries; +}(_abstractSeries2.default); + +VerticalBarSeries.displayName = 'VerticalBarSeries'; + +exports.default = VerticalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series-canvas.js b/dist/plot/series/vertical-rect-series-canvas.js new file mode 100644 index 000000000..a45961e48 --- /dev/null +++ b/dist/plot/series/vertical-rect-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeriesCanvas = require('./rect-series-canvas'); + +var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalRectSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); + + function HorizontalRectSeriesCanvas() { + _classCallCheck(this, HorizontalRectSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalRectSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalRectSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; +HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series.js b/dist/plot/series/vertical-rect-series.js new file mode 100644 index 000000000..e4b09a340 --- /dev/null +++ b/dist/plot/series/vertical-rect-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeries = require('./rect-series'); + +var _rectSeries2 = _interopRequireDefault(_rectSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var VerticalRectSeries = function (_AbstractSeries) { + _inherits(VerticalRectSeries, _AbstractSeries); + + function VerticalRectSeries() { + _classCallCheck(this, VerticalRectSeries); + + return _possibleConstructorReturn(this, (VerticalRectSeries.__proto__ || Object.getPrototypeOf(VerticalRectSeries)).apply(this, arguments)); + } + + _createClass(VerticalRectSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return VerticalRectSeries; +}(_abstractSeries2.default); + +VerticalRectSeries.displayName = 'VerticalRectSeries'; + +exports.default = VerticalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/whisker-series.js b/dist/plot/series/whisker-series.js new file mode 100644 index 000000000..b2c479d8c --- /dev/null +++ b/dist/plot/series/whisker-series.js @@ -0,0 +1,274 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _theme = require('../../theme'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--whisker'; +var DEFAULT_STROKE_WIDTH = 1; +var DEFAULT_CROSS_BAR_WIDTH = 6; + +/** + * Render whisker lines for a data point. + * @param {Object} whiskerMarkProps All the properties of the whisker mark. + * @private + */ +var renderWhiskerMark = function renderWhiskerMark(whiskerMarkProps) { + return function (d, i) { + var crossBarWidth = whiskerMarkProps.crossBarWidth, + opacityFunctor = whiskerMarkProps.opacityFunctor, + sizeFunctor = whiskerMarkProps.sizeFunctor, + strokeFunctor = whiskerMarkProps.strokeFunctor, + strokeWidth = whiskerMarkProps.strokeWidth, + style = whiskerMarkProps.style, + valueClickHandler = whiskerMarkProps.valueClickHandler, + valueMouseOutHandler = whiskerMarkProps.valueMouseOutHandler, + valueMouseOverHandler = whiskerMarkProps.valueMouseOverHandler, + valueRightClickHandler = whiskerMarkProps.valueRightClickHandler, + xFunctor = whiskerMarkProps.xFunctor, + yFunctor = whiskerMarkProps.yFunctor; + + + var r = sizeFunctor ? sizeFunctor(d) : 0; + var cx = xFunctor(d); + var cy = yFunctor(d); + var positiveXVariance = xFunctor({ x: d.x + d.xVariance / 2 }); + var negativeXVariance = xFunctor({ x: d.x - d.xVariance / 2 }); + var positiveYVariance = yFunctor({ y: d.y + d.yVariance / 2 }); + var negativeYVariance = yFunctor({ y: d.y - d.yVariance / 2 }); + /** + * Determine whether on not we should draw whiskers in each direction. + * We need to see an actual variance value, and also have that value extend past the + * radius "buffer" region in which we won't be drawing (if any). + */ + var hasXWhiskers = positiveXVariance && cx + r < positiveXVariance; + var hasYWhiskers = positiveYVariance && cy - r > positiveYVariance; + if (!hasXWhiskers && !hasYWhiskers) { + return null; + } + + var styleAttr = _extends({ + opacity: opacityFunctor ? opacityFunctor(d) : _theme.DEFAULT_OPACITY, + stroke: strokeFunctor && strokeFunctor(d), + strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH + }, style); + var crossBarExtension = crossBarWidth / 2; + + var rightLineAttrs = { + x1: cx + r, + y1: cy, + x2: positiveXVariance, + y2: cy, + style: styleAttr + }; + var leftLineAttrs = { + x1: cx - r, + y1: cy, + x2: negativeXVariance, + y2: cy, + style: styleAttr + }; + var rightCrossBarAttrs = { + x1: positiveXVariance, + y1: cy - crossBarExtension, + x2: positiveXVariance, + y2: cy + crossBarExtension, + style: styleAttr + }; + var leftCrossBarAttrs = { + x1: negativeXVariance, + y1: cy - crossBarExtension, + x2: negativeXVariance, + y2: cy + crossBarExtension, + style: styleAttr + }; + + var upperLineAttrs = { + x1: cx, + y1: cy - r, + x2: cx, + y2: positiveYVariance, + style: styleAttr + }; + var lowerLineAttrs = { + x1: cx, + y1: cy + r, + x2: cx, + y2: negativeYVariance, + style: styleAttr + }; + var upperCrossBarAttrs = { + x1: cx - crossBarExtension, + y1: positiveYVariance, + x2: cx + crossBarExtension, + y2: positiveYVariance, + style: styleAttr + }; + var lowerCrossBarAttrs = { + x1: cx - crossBarExtension, + y1: negativeYVariance, + x2: cx + crossBarExtension, + y2: negativeYVariance, + style: styleAttr + }; + + return _react2.default.createElement( + 'g', + { + className: 'mark-whiskers', + key: i, + onClick: function onClick(e) { + return valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return valueMouseOutHandler(d, e); + } + }, + hasXWhiskers ? _react2.default.createElement( + 'g', + { className: 'x-whiskers' }, + _react2.default.createElement('line', rightLineAttrs), + _react2.default.createElement('line', leftLineAttrs), + _react2.default.createElement('line', rightCrossBarAttrs), + _react2.default.createElement('line', leftCrossBarAttrs) + ) : null, + hasYWhiskers ? _react2.default.createElement( + 'g', + { className: 'y-whiskers' }, + _react2.default.createElement('line', upperLineAttrs), + _react2.default.createElement('line', lowerLineAttrs), + _react2.default.createElement('line', upperCrossBarAttrs), + _react2.default.createElement('line', lowerCrossBarAttrs) + ) : null + ); + }; +}; + +var WhiskerSeries = function (_AbstractSeries) { + _inherits(WhiskerSeries, _AbstractSeries); + + function WhiskerSeries() { + _classCallCheck(this, WhiskerSeries); + + return _possibleConstructorReturn(this, (WhiskerSeries.__proto__ || Object.getPrototypeOf(WhiskerSeries)).apply(this, arguments)); + } + + _createClass(WhiskerSeries, [{ + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + crossBarWidth = _props.crossBarWidth, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + strokeWidth = _props.strokeWidth, + style = _props.style; + + if (!data) { + return null; + } + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(WhiskerSeries, _extends({}, this.props, { animation: null })) + ); + } + + var whiskerMarkProps = { + crossBarWidth: crossBarWidth, + opacityFunctor: this._getAttributeFunctor('opacity'), + sizeFunctor: this._getAttributeFunctor('size'), + strokeFunctor: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), + strokeWidth: strokeWidth, + style: style, + xFunctor: this._getAttributeFunctor('x'), + yFunctor: this._getAttributeFunctor('y'), + valueClickHandler: this._valueClickHandler, + valueRightClickHandler: this._valueRightClickHandler, + valueMouseOverHandler: this._valueMouseOverHandler, + valueMouseOutHandler: this._valueMouseOutHandler + }; + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(renderWhiskerMark(whiskerMarkProps)) + ); + } + }]); + + return WhiskerSeries; +}(_abstractSeries2.default); + +WhiskerSeries.displayName = 'WhiskerSeries'; +WhiskerSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + strokeWidth: _propTypes2.default.number +}); +WhiskerSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + crossBarWidth: DEFAULT_CROSS_BAR_WIDTH, + size: 0, + strokeWidth: DEFAULT_STROKE_WIDTH +}); +exports.default = WhiskerSeries; \ No newline at end of file diff --git a/dist/plot/vertical-grid-lines.js b/dist/plot/vertical-grid-lines.js new file mode 100644 index 000000000..220165193 --- /dev/null +++ b/dist/plot/vertical-grid-lines.js @@ -0,0 +1,64 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _gridLines = require('./grid-lines'); + +var _gridLines2 = _interopRequireDefault(_gridLines); + +var _axisUtils = require('../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var VERTICAL = _axisUtils.DIRECTION.VERTICAL; + + +var propTypes = _extends({}, _gridLines2.default.propTypes, { + direction: _propTypes2.default.oneOf([VERTICAL]) +}); + +var defaultProps = { + direction: VERTICAL, + attr: 'x' +}; + +function VerticalGridLines(props) { + return _react2.default.createElement(_gridLines2.default, props); +} + +VerticalGridLines.displayName = 'VerticalGridLines'; +VerticalGridLines.propTypes = propTypes; +VerticalGridLines.defaultProps = defaultProps; +VerticalGridLines.requiresSVG = true; + +exports.default = VerticalGridLines; \ No newline at end of file diff --git a/dist/plot/voronoi.js b/dist/plot/voronoi.js new file mode 100644 index 000000000..45517bb4f --- /dev/null +++ b/dist/plot/voronoi.js @@ -0,0 +1,148 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Voronoi = require('d3-voronoi'); + +var _scalesUtils = require('../utils/scales-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var NOOP = function NOOP(f) { + return f; +}; + +// Find the index of the node at coordinates of a touch point +function getNodeIndex(evt) { + var _evt$nativeEvent = evt.nativeEvent, + pageX = _evt$nativeEvent.pageX, + pageY = _evt$nativeEvent.pageY; + + var target = document.elementFromPoint(pageX, pageY); + if (!target) { + return -1; + } + var parentNode = target.parentNode; + + return Array.prototype.indexOf.call(parentNode.childNodes, target); +} + +function getExtent(_ref) { + var innerWidth = _ref.innerWidth, + innerHeight = _ref.innerHeight, + marginLeft = _ref.marginLeft, + marginTop = _ref.marginTop; + + return [[marginLeft, marginTop], [innerWidth + marginLeft, innerHeight + marginTop]]; +} + +function Voronoi(props) { + var className = props.className, + extent = props.extent, + nodes = props.nodes, + onBlur = props.onBlur, + _onClick = props.onClick, + _onMouseUp = props.onMouseUp, + _onMouseDown = props.onMouseDown, + onHover = props.onHover, + polygonStyle = props.polygonStyle, + style = props.style, + x = props.x, + y = props.y; + // Create a voronoi with each node center points + + var voronoiInstance = (0, _d3Voronoi.voronoi)().x(x || (0, _scalesUtils.getAttributeFunctor)(props, 'x')).y(y || (0, _scalesUtils.getAttributeFunctor)(props, 'y')).extent(extent || getExtent(props)); + + // Create an array of polygons corresponding to the cells in voronoi + var polygons = voronoiInstance.polygons(nodes); + + // Create helper function to handle special logic for touch events + var handleTouchEvent = function handleTouchEvent(handler) { + return function (evt) { + evt.preventDefault(); + var index = getNodeIndex(evt); + if (index > -1 && index < polygons.length) { + var d = polygons[index]; + handler(d.data); + } + }; + }; + + return _react2.default.createElement( + 'g', + { + className: className + ' rv-voronoi', + style: style + // Because of the nature of how touch events, and more specifically touchmove + // and how it differs from mouseover, we must manage touch events on the parent + , onTouchEnd: handleTouchEvent(_onMouseUp), + onTouchStart: handleTouchEvent(_onMouseDown), + onTouchMove: handleTouchEvent(onHover), + onTouchCancel: handleTouchEvent(onBlur) + }, + polygons.map(function (d, i) { + return _react2.default.createElement('path', { + className: 'rv-voronoi__cell ' + (d.data && d.data.className || ''), + d: 'M' + d.join('L') + 'Z', + onClick: function onClick() { + return _onClick(d.data); + }, + onMouseUp: function onMouseUp() { + return _onMouseUp(d.data); + }, + onMouseDown: function onMouseDown() { + return _onMouseDown(d.data); + }, + onMouseOver: function onMouseOver() { + return onHover(d.data); + }, + onMouseOut: function onMouseOut() { + return onBlur(d.data); + }, + fill: 'none', + style: _extends({ + pointerEvents: 'all' + }, polygonStyle, d.data && d.data.style), + key: i + }); + }) + ); +} + +Voronoi.requiresSVG = true; +Voronoi.displayName = 'Voronoi'; +Voronoi.defaultProps = { + className: '', + onBlur: NOOP, + onClick: NOOP, + onHover: NOOP, + onMouseDown: NOOP, + onMouseUp: NOOP +}; + +Voronoi.propTypes = { + className: _propTypes2.default.string, + extent: _propTypes2.default.arrayOf(_propTypes2.default.arrayOf(_propTypes2.default.number)), + nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + onBlur: _propTypes2.default.func, + onClick: _propTypes2.default.func, + onHover: _propTypes2.default.func, + onMouseDown: _propTypes2.default.func, + onMouseUp: _propTypes2.default.func, + x: _propTypes2.default.func, + y: _propTypes2.default.func +}; + +exports.default = Voronoi; \ No newline at end of file diff --git a/dist/plot/xy-plot.js b/dist/plot/xy-plot.js new file mode 100644 index 000000000..5d5eec470 --- /dev/null +++ b/dist/plot/xy-plot.js @@ -0,0 +1,660 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _deepEqual = require('deep-equal'); + +var _deepEqual2 = _interopRequireDefault(_deepEqual); + +var _scalesUtils = require('../utils/scales-utils'); + +var _seriesUtils = require('../utils/series-utils'); + +var _chartUtils = require('../utils/chart-utils'); + +var _animation = require('../animation'); + +var _theme = require('../theme'); + +var _canvasWrapper = require('./series/canvas-wrapper'); + +var _canvasWrapper2 = _interopRequireDefault(_canvasWrapper); + +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 _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; } + +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; } + +var ATTRIBUTES = ['x', 'y', 'radius', 'angle', 'color', 'fill', 'stroke', 'opacity', 'size']; + +/** + * Remove parents from tree formatted data. deep-equal doesnt play nice with data + * that has circular structures, so we make every node single directional by pruning the parents. + * @param {Array} data - the data object to have circular deps resolved in + * @returns {Array} the sanitized data + */ +function cleanseData(data) { + return data.map(function (series) { + if (!Array.isArray(series)) { + return series; + } + return series.map(function (row) { + return _extends({}, row, { parent: null }); + }); + }); +} + +/** + * Wrapper on the deep-equal method for checking equality of next props vs current props + * @param {Object} scaleMixins - Scale object. + * @param {Object} nextScaleMixins - Scale object. + * @param {Boolean} hasTreeStructure - Whether or not to cleanse the data of possible cyclic structures + * @returns {Boolean} whether or not the two mixins objects are equal + */ +function checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, hasTreeStructure) { + var newMixins = _extends({}, nextScaleMixins, { + _allData: hasTreeStructure ? cleanseData(nextScaleMixins._allData) : nextScaleMixins._allData + }); + var oldMixins = _extends({}, scaleMixins, { + _allData: hasTreeStructure ? cleanseData(scaleMixins._allData) : scaleMixins._allData + }); + // it's hard to say if this function is reasonable? + return (0, _deepEqual2.default)(newMixins, oldMixins); +} + +var XYPlot = function (_React$Component) { + _inherits(XYPlot, _React$Component); + + _createClass(XYPlot, null, [{ + key: 'defaultProps', + get: function get() { + return { + className: '' + }; + } + }, { + key: 'propTypes', + get: function get() { + return { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + dontCheckIfEmpty: _propTypes2.default.bool, + height: _propTypes2.default.number.isRequired, + margin: _chartUtils.MarginPropType, + onClick: _propTypes2.default.func, + onDoubleClick: _propTypes2.default.func, + onMouseDown: _propTypes2.default.func, + onMouseUp: _propTypes2.default.func, + onMouseEnter: _propTypes2.default.func, + onMouseLeave: _propTypes2.default.func, + onMouseMove: _propTypes2.default.func, + onTouchStart: _propTypes2.default.func, + onTouchMove: _propTypes2.default.func, + onTouchEnd: _propTypes2.default.func, + onTouchCancel: _propTypes2.default.func, + onWheel: _propTypes2.default.func, + stackBy: _propTypes2.default.oneOf(ATTRIBUTES), + style: _propTypes2.default.object, + width: _propTypes2.default.number.isRequired + }; + } + }]); + + function XYPlot(props) { + _classCallCheck(this, XYPlot); + + var _this = _possibleConstructorReturn(this, (XYPlot.__proto__ || Object.getPrototypeOf(XYPlot)).call(this, props)); + + _initialiseProps.call(_this); + + var stackBy = props.stackBy; + + var children = (0, _seriesUtils.getSeriesChildren)(props.children); + var data = (0, _seriesUtils.getStackedData)(children, stackBy); + _this.state = { + scaleMixins: _this._getScaleMixins(data, props), + data: data + }; + return _this; + } + + _createClass(XYPlot, [{ + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + var children = (0, _seriesUtils.getSeriesChildren)(nextProps.children); + var nextData = (0, _seriesUtils.getStackedData)(children, nextProps.stackBy); + var scaleMixins = this.state.scaleMixins; + + var nextScaleMixins = this._getScaleMixins(nextData, nextProps); + if (!checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, nextProps.hasTreeStructure)) { + this.setState({ + scaleMixins: nextScaleMixins, + data: nextData + }); + } + } + + /** + * Trigger click related callbacks if they are available. + * @param {React.SyntheticEvent} event Click event. + * @private + */ + + + /** + * Trigger doule-click related callbacks if they are available. + * @param {React.SyntheticEvent} event Double-click event. + * @private + */ + + }, { + key: '_getClonedChildComponents', + + + /** + * Prepare the child components (including series) for rendering. + * @returns {Array} Array of child components. + * @private + */ + value: function _getClonedChildComponents() { + var _this2 = this; + + var props = this.props; + var animation = this.props.animation; + var _state = this.state, + scaleMixins = _state.scaleMixins, + data = _state.data; + + var dimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS); + var children = _react2.default.Children.toArray(this.props.children); + var seriesProps = (0, _seriesUtils.getSeriesPropsFromChildren)(children); + var XYPlotValues = (0, _scalesUtils.getXYPlotValues)(props, children); + return children.map(function (child, index) { + var dataProps = null; + if (seriesProps[index]) { + // Get the index of the series in the list of props and retrieve + // the data property from it. + var seriesIndex = seriesProps[index].seriesIndex; + + dataProps = { data: data[seriesIndex] }; + } + return _react2.default.cloneElement(child, _extends({}, dimensions, { + animation: animation + }, dataProps && child.type.prototype && child.type.prototype.render ? { + ref: function ref(_ref) { + return _this2['series' + seriesProps[index].seriesIndex] = _ref; + } + } : {}, seriesProps[index], scaleMixins, child.props, XYPlotValues[index], dataProps)); + }); + } + /** + * Get the list of scale-related settings that should be applied by default. + * @param {Object} props Object of props. + * @returns {Object} Defaults. + * @private + */ + + }, { + key: '_getDefaultScaleProps', + value: function _getDefaultScaleProps(props) { + var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(props, _chartUtils.DEFAULT_MARGINS), + innerWidth = _getInnerDimensions.innerWidth, + innerHeight = _getInnerDimensions.innerHeight; + + var colorRanges = ['color', 'fill', 'stroke'].reduce(function (acc, attr) { + var range = props[attr + 'Type'] === 'category' ? _theme.EXTENDED_DISCRETE_COLOR_RANGE : _theme.CONTINUOUS_COLOR_RANGE; + return _extends({}, acc, _defineProperty({}, attr + 'Range', range)); + }, {}); + + return _extends({ + xRange: [0, innerWidth], + yRange: [innerHeight, 0] + }, colorRanges, { + opacityType: _theme.OPACITY_TYPE, + sizeRange: _theme.SIZE_RANGE + }); + } + + /** + * Get the map of scales from the props, apply defaults to them and then pass + * them further. + * @param {Object} data Array of all data. + * @param {Object} props Props of the component. + * @returns {Object} Map of scale-related props. + * @private + */ + + }, { + key: '_getScaleMixins', + value: function _getScaleMixins(data, props) { + var _ref2; + + var filteredData = data.filter(function (d) { + return d; + }); + var allData = (_ref2 = []).concat.apply(_ref2, _toConsumableArray(filteredData)); + + var defaultScaleProps = this._getDefaultScaleProps(props); + var optionalScaleProps = (0, _scalesUtils.getOptionalScaleProps)(props); + var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); + var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, optionalScaleProps, userScaleProps), allData, ATTRIBUTES); + var children = (0, _seriesUtils.getSeriesChildren)(props.children); + var zeroBaseProps = {}; + var adjustBy = new Set(); + var adjustWhat = new Set(); + children.forEach(function (child, index) { + if (!child || !data[index]) { + return; + } + ATTRIBUTES.forEach(function (attr) { + var _child$type$getParent = child.type.getParentConfig(attr, child.props), + isDomainAdjustmentNeeded = _child$type$getParent.isDomainAdjustmentNeeded, + zeroBaseValue = _child$type$getParent.zeroBaseValue; + + if (isDomainAdjustmentNeeded) { + adjustBy.add(attr); + adjustWhat.add(index); + } + if (zeroBaseValue) { + var specifiedDomain = props[attr + 'Domain']; + zeroBaseProps[attr + 'BaseValue'] = specifiedDomain ? specifiedDomain[0] : 0; + } + }); + }); + return _extends({}, defaultScaleProps, zeroBaseProps, userScaleProps, missingScaleProps, { + _allData: data, + _adjustBy: Array.from(adjustBy), + _adjustWhat: Array.from(adjustWhat), + _stackBy: props.stackBy + }); + } + + /** + * Checks if the plot is empty or not. + * Currently checks the data only. + * @returns {boolean} True for empty. + * @private + */ + + }, { + key: '_isPlotEmpty', + value: function _isPlotEmpty() { + var data = this.state.data; + + return !data || !data.length || !data.some(function (series) { + return series && series.some(function (d) { + return d; + }); + }); + } + + /** + * Trigger mouse-down related callbacks if they are available. + * @param {React.SyntheticEvent} event Mouse down event. + * @private + */ + + + /** + * Trigger onMouseEnter handler if it was passed in props. + * @param {React.SyntheticEvent} event Mouse enter event. + * @private + */ + + + /** + * Trigger onMouseLeave handler if it was passed in props. + * @param {React.SyntheticEvent} event Mouse leave event. + * @private + */ + + + /** + * Trigger movement-related callbacks if they are available. + * @param {React.SyntheticEvent} event Mouse move event. + * @private + */ + + + /** + * Trigger mouse-up related callbacks if they are available. + * @param {React.SyntheticEvent} event Mouse up event. + * @private + */ + + + /** + * Trigger onTouchCancel handler if it was passed in props. + * @param {React.SyntheticEvent} event Touch Cancel event. + * @private + */ + + + /** + * Trigger onTouchEnd handler if it was passed in props. + * @param {React.SyntheticEvent} event Touch End event. + * @private + */ + + + /** + * Trigger touch movement-related callbacks if they are available. + * @param {React.SyntheticEvent} event Touch move event. + * @private + */ + + + /** + * Trigger touch-start related callbacks if they are available. + * @param {React.SyntheticEvent} event Touch start event. + * @private + */ + + + /** + * Trigger doule-click related callbacks if they are available. + * @param {React.SyntheticEvent} event Double-click event. + * @private + */ + + }, { + key: 'renderCanvasComponents', + value: function renderCanvasComponents(components, props) { + var componentsToRender = components.filter(function (c) { + return c && !c.type.requiresSVG && c.type.isCanvas; + }); + + if (componentsToRender.length === 0) { + return null; + } + var _componentsToRender$ = componentsToRender[0].props, + marginLeft = _componentsToRender$.marginLeft, + marginTop = _componentsToRender$.marginTop, + marginBottom = _componentsToRender$.marginBottom, + marginRight = _componentsToRender$.marginRight, + innerHeight = _componentsToRender$.innerHeight, + innerWidth = _componentsToRender$.innerWidth; + + return _react2.default.createElement( + _canvasWrapper2.default, + { + innerHeight: innerHeight, + innerWidth: innerWidth, + marginLeft: marginLeft, + marginTop: marginTop, + marginBottom: marginBottom, + marginRight: marginRight + }, + componentsToRender + ); + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + className = _props.className, + dontCheckIfEmpty = _props.dontCheckIfEmpty, + style = _props.style, + width = _props.width, + height = _props.height; + + + if (!dontCheckIfEmpty && this._isPlotEmpty()) { + return _react2.default.createElement('div', { + className: 'rv-xy-plot ' + className, + style: _extends({ + width: width + 'px', + height: height + 'px' + }, this.props.style) + }); + } + var components = this._getClonedChildComponents(); + return _react2.default.createElement( + 'div', + { + style: { + width: width + 'px', + height: height + 'px' + }, + className: 'rv-xy-plot ' + className + }, + _react2.default.createElement( + 'svg', + { + className: 'rv-xy-plot__inner', + width: width, + height: height, + style: style, + onClick: this._clickHandler, + onDoubleClick: this._doubleClickHandler, + onMouseDown: this._mouseDownHandler, + onMouseUp: this._mouseUpHandler, + onMouseMove: this._mouseMoveHandler, + onMouseLeave: this._mouseLeaveHandler, + onMouseEnter: this._mouseEnterHandler, + onTouchStart: this._mouseDownHandler, + onTouchMove: this._touchMoveHandler, + onTouchEnd: this._touchEndHandler, + onTouchCancel: this._touchCancelHandler, + onWheel: this._wheelHandler + }, + components.filter(function (c) { + return c && c.type.requiresSVG; + }) + ), + this.renderCanvasComponents(components, this.props), + components.filter(function (c) { + return c && !c.type.requiresSVG && !c.type.isCanvas; + }) + ); + } + }]); + + return XYPlot; +}(_react2.default.Component); + +var _initialiseProps = function _initialiseProps() { + var _this3 = this; + + this._clickHandler = function (event) { + var onClick = _this3.props.onClick; + + if (onClick) { + onClick(event); + } + }; + + this._doubleClickHandler = function (event) { + var onDoubleClick = _this3.props.onDoubleClick; + + if (onDoubleClick) { + onDoubleClick(event); + } + }; + + this._mouseDownHandler = function (event) { + var _props2 = _this3.props, + onMouseDown = _props2.onMouseDown, + children = _props2.children; + + if (onMouseDown) { + onMouseDown(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseDown) { + component.onParentMouseDown(event); + } + }); + }; + + this._mouseEnterHandler = function (event) { + var _props3 = _this3.props, + onMouseEnter = _props3.onMouseEnter, + children = _props3.children; + + if (onMouseEnter) { + onMouseEnter(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseEnter) { + component.onParentMouseEnter(event); + } + }); + }; + + this._mouseLeaveHandler = function (event) { + var _props4 = _this3.props, + onMouseLeave = _props4.onMouseLeave, + children = _props4.children; + + if (onMouseLeave) { + onMouseLeave(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseLeave) { + component.onParentMouseLeave(event); + } + }); + }; + + this._mouseMoveHandler = function (event) { + var _props5 = _this3.props, + onMouseMove = _props5.onMouseMove, + children = _props5.children; + + if (onMouseMove) { + onMouseMove(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseMove) { + component.onParentMouseMove(event); + } + }); + }; + + this._mouseUpHandler = function (event) { + var _props6 = _this3.props, + onMouseUp = _props6.onMouseUp, + children = _props6.children; + + if (onMouseUp) { + onMouseUp(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseUp) { + component.onParentMouseUp(event); + } + }); + }; + + this._touchCancelHandler = function (event) { + var onTouchCancel = _this3.props.onTouchCancel; + + if (onTouchCancel) { + onTouchCancel(event); + } + }; + + this._touchEndHandler = function (event) { + var onTouchEnd = _this3.props.onTouchEnd; + + if (onTouchEnd) { + onTouchEnd(event); + } + }; + + this._touchMoveHandler = function (event) { + var _props7 = _this3.props, + onTouchMove = _props7.onTouchMove, + children = _props7.children; + + if (onTouchMove) { + onTouchMove(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentTouchMove) { + component.onParentTouchMove(event); + } + }); + }; + + this._touchStartHandler = function (event) { + var _props8 = _this3.props, + onTouchStart = _props8.onTouchStart, + children = _props8.children; + + if (onTouchStart) { + onTouchStart(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentTouchStart) { + component.onParentTouchStart(event); + } + }); + }; + + this._wheelHandler = function (event) { + var onWheel = _this3.props.onWheel; + + if (onWheel) { + onWheel(event); + } + }; +}; + +XYPlot.displayName = 'XYPlot'; + +exports.default = XYPlot; \ No newline at end of file diff --git a/dist/radar-chart/index.js b/dist/radar-chart/index.js new file mode 100644 index 000000000..b1f659dfd --- /dev/null +++ b/dist/radar-chart/index.js @@ -0,0 +1,418 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Scale = require('d3-scale'); + +var _d3Format = require('d3-format'); + +var _animation = require('../animation'); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _theme = require('../theme'); + +var _chartUtils = require('../utils/chart-utils'); + +var _markSeries = require('../plot/series/mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +var _polygonSeries = require('../plot/series/polygon-series'); + +var _polygonSeries2 = _interopRequireDefault(_polygonSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _decorativeAxis = require('../plot/axis/decorative-axis'); + +var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var predefinedClassName = 'rv-radar-chart'; +var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); +/** + * Generate axes for each of the domains + * @param {Object} props + - props.animation {Boolean} + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for the whole chart + - props.tickFormat {Function} formatting function for axes + - props.startingAngle {number} the initial angle offset + * @return {Array} the plotted axis components + */ +function getAxes(props) { + var animation = props.animation, + domains = props.domains, + startingAngle = props.startingAngle, + style = props.style, + tickFormat = props.tickFormat, + hideInnerMostValues = props.hideInnerMostValues; + + return domains.map(function (domain, index) { + var angle = index / domains.length * Math.PI * 2 + startingAngle; + var sortedDomain = domain.domain; + + var domainTickFormat = function domainTickFormat(t) { + if (hideInnerMostValues && t === sortedDomain[0]) { + return ''; + } + return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); + }; + + return _react2.default.createElement(_decorativeAxis2.default, { + animation: animation, + key: index + '-axis', + axisStart: { x: 0, y: 0 }, + axisEnd: { + x: getCoordinate(Math.cos(angle)), + y: getCoordinate(Math.sin(angle)) + }, + axisDomain: sortedDomain, + numberOfTicks: 5, + tickValue: domainTickFormat, + style: style.axes + }); + }); +} + +/** + * Generate x or y coordinate for axisEnd + * @param {Number} axisEndPoint + - epsilon is an arbitrarily chosen small number to approximate axisEndPoints + - to true values resulting from trigonometry functions (sin, cos) on angles + * @return {Number} the x or y coordinate accounting for exact trig values + */ +function getCoordinate(axisEndPoint) { + var epsilon = 10e-13; + if (Math.abs(axisEndPoint) <= epsilon) { + axisEndPoint = 0; + } else if (axisEndPoint > 0) { + if (Math.abs(axisEndPoint - 0.5) <= epsilon) { + axisEndPoint = 0.5; + } + } else if (axisEndPoint < 0) { + if (Math.abs(axisEndPoint + 0.5) <= epsilon) { + axisEndPoint = -0.5; + } + } + return axisEndPoint; +} + +/** + * Generate labels for the ends of the axes + * @param {Object} props + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.startingAngle {number} the initial angle offset + - props.style {object} style object for just the labels + * @return {Array} the prepped data for the labelSeries + */ +function getLabels(props) { + var domains = props.domains, + startingAngle = props.startingAngle, + style = props.style; + + return domains.map(function (_ref, index) { + var name = _ref.name; + + var angle = index / domains.length * Math.PI * 2 + startingAngle; + var radius = 1.2; + return { + x: radius * Math.cos(angle), + y: radius * Math.sin(angle), + label: name, + style: style + }; + }); +} + +/** + * Generate the actual polygons to be plotted + * @param {Object} props + - props.animation {Boolean} + - props.data {Array} array of object specifying what values are to be plotted + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.startingAngle {number} the initial angle offset + - props.style {object} style object for the whole chart + * @return {Array} the plotted axis components + */ +function getPolygons(props) { + var animation = props.animation, + colorRange = props.colorRange, + domains = props.domains, + data = props.data, + style = props.style, + startingAngle = props.startingAngle, + onSeriesMouseOver = props.onSeriesMouseOver, + onSeriesMouseOut = props.onSeriesMouseOut; + + var scales = domains.reduce(function (acc, _ref2) { + var domain = _ref2.domain, + name = _ref2.name; + + acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); + return acc; + }, {}); + + return data.map(function (row, rowIndex) { + var mappedData = domains.map(function (_ref3, index) { + var name = _ref3.name, + getValue = _ref3.getValue; + + var dataPoint = getValue ? getValue(row) : row[name]; + // error handling if point doesn't exist + var angle = index / domains.length * Math.PI * 2 + startingAngle; + // dont let the radius become negative + var radius = Math.max(scales[name](dataPoint), 0); + return { x: radius * Math.cos(angle), y: radius * Math.sin(angle), name: row.name }; + }); + + return _react2.default.createElement(_polygonSeries2.default, { + animation: animation, + className: predefinedClassName + '-polygon', + key: rowIndex + '-polygon', + data: mappedData, + style: _extends({ + stroke: row.color || row.stroke || colorRange[rowIndex % colorRange.length], + fill: row.color || row.fill || colorRange[rowIndex % colorRange.length] + }, style.polygons), + onSeriesMouseOver: onSeriesMouseOver, + onSeriesMouseOut: onSeriesMouseOut + }); + }); +} + +/** + * Generate circles at the polygon points for Hover functionality + * @param {Object} props + - props.animation {Boolean} + - props.data {Array} array of object specifying what values are to be plotted + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.startingAngle {number} the initial angle offset + - props.style {object} style object for the whole chart + - props.onValueMouseOver {function} function to call on mouse over a polygon point + - props.onValueMouseOver {function} function to call when mouse leaves a polygon point + * @return {Array} the plotted axis components + */ +function getPolygonPoints(props) { + var animation = props.animation, + domains = props.domains, + data = props.data, + startingAngle = props.startingAngle, + style = props.style, + onValueMouseOver = props.onValueMouseOver, + onValueMouseOut = props.onValueMouseOut; + + if (!onValueMouseOver) { + return; + } + var scales = domains.reduce(function (acc, _ref4) { + var domain = _ref4.domain, + name = _ref4.name; + + acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); + return acc; + }, {}); + return data.map(function (row, rowIndex) { + var mappedData = domains.map(function (_ref5, index) { + var name = _ref5.name, + getValue = _ref5.getValue; + + var dataPoint = getValue ? getValue(row) : row[name]; + // error handling if point doesn't exist + var angle = index / domains.length * Math.PI * 2 + startingAngle; + // dont let the radius become negative + var radius = Math.max(scales[name](dataPoint), 0); + return { + x: radius * Math.cos(angle), + y: radius * Math.sin(angle), + domain: name, + value: dataPoint, + dataName: row.name + }; + }); + + return _react2.default.createElement(_markSeries2.default, { + animation: animation, + className: predefinedClassName + '-polygonPoint', + key: rowIndex + '-polygonPoint', + data: mappedData, + size: 10, + style: _extends({}, style.polygons, { + fill: 'transparent', + stroke: 'transparent' + }), + onValueMouseOver: onValueMouseOver, + onValueMouseOut: onValueMouseOut + }); + }); +} + +function RadarChart(props) { + var animation = props.animation, + className = props.className, + children = props.children, + colorRange = props.colorRange, + data = props.data, + domains = props.domains, + height = props.height, + hideInnerMostValues = props.hideInnerMostValues, + margin = props.margin, + onMouseLeave = props.onMouseLeave, + onMouseEnter = props.onMouseEnter, + startingAngle = props.startingAngle, + style = props.style, + tickFormat = props.tickFormat, + width = props.width, + renderAxesOverPolygons = props.renderAxesOverPolygons, + onValueMouseOver = props.onValueMouseOver, + onValueMouseOut = props.onValueMouseOut, + onSeriesMouseOver = props.onSeriesMouseOver, + onSeriesMouseOut = props.onSeriesMouseOut; + + + var axes = getAxes({ + domains: domains, + animation: animation, + hideInnerMostValues: hideInnerMostValues, + startingAngle: startingAngle, + style: style, + tickFormat: tickFormat + }); + + var polygons = getPolygons({ + animation: animation, + colorRange: colorRange, + domains: domains, + data: data, + startingAngle: startingAngle, + style: style, + onSeriesMouseOver: onSeriesMouseOver, + onSeriesMouseOut: onSeriesMouseOut + }); + + var polygonPoints = getPolygonPoints({ + animation: animation, + colorRange: colorRange, + domains: domains, + data: data, + startingAngle: startingAngle, + style: style, + onValueMouseOver: onValueMouseOver, + onValueMouseOut: onValueMouseOut + }); + + var labelSeries = _react2.default.createElement(_labelSeries2.default, { + animation: animation, + key: className, + className: predefinedClassName + '-label', + data: getLabels({ domains: domains, style: style.labels, startingAngle: startingAngle }) }); + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + width: width, + margin: margin, + dontCheckIfEmpty: true, + className: className + ' ' + predefinedClassName, + onMouseLeave: onMouseLeave, + onMouseEnter: onMouseEnter, + xDomain: [-1, 1], + yDomain: [-1, 1] }, + children, + !renderAxesOverPolygons && axes.concat(polygons).concat(labelSeries).concat(polygonPoints), + renderAxesOverPolygons && polygons.concat(labelSeries).concat(axes).concat(polygonPoints) + ); +} + +RadarChart.displayName = 'RadarChart'; +RadarChart.propTypes = { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), + data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + name: _propTypes2.default.string.isRequired, + domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, + tickFormat: _propTypes2.default.func + })).isRequired, + height: _propTypes2.default.number.isRequired, + hideInnerMostValues: _propTypes2.default.bool, + margin: _chartUtils.MarginPropType, + startingAngle: _propTypes2.default.number, + style: _propTypes2.default.shape({ + axes: _propTypes2.default.object, + labels: _propTypes2.default.object, + polygons: _propTypes2.default.object + }), + tickFormat: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired, + renderAxesOverPolygons: _propTypes2.default.bool, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + onSeriesMouseOver: _propTypes2.default.func, + onSeriesMouseOut: _propTypes2.default.func +}; +RadarChart.defaultProps = { + className: '', + colorType: 'category', + colorRange: _theme.DISCRETE_COLOR_RANGE, + hideInnerMostValues: true, + startingAngle: Math.PI / 2, + style: { + axes: { + line: {}, + ticks: {}, + text: {} + }, + labels: { + fontSize: 10, + textAnchor: 'middle' + }, + polygons: { + strokeWidth: 0.5, + strokeOpacity: 1, + fillOpacity: 0.1 + } + }, + tickFormat: DEFAULT_FORMAT, + renderAxesOverPolygons: false +}; + +exports.default = RadarChart; \ No newline at end of file diff --git a/dist/radial-chart/index.js b/dist/radial-chart/index.js new file mode 100644 index 000000000..a43e58552 --- /dev/null +++ b/dist/radial-chart/index.js @@ -0,0 +1,263 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Shape = require('d3-shape'); + +var _animation = require('../animation'); + +var _arcSeries = require('../plot/series/arc-series'); + +var _arcSeries2 = _interopRequireDefault(_arcSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _theme = require('../theme'); + +var _chartUtils = require('../utils/chart-utils'); + +var _seriesUtils = require('../utils/series-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var predefinedClassName = 'rv-radial-chart'; + +var DEFAULT_RADIUS_MARGIN = 15; + +/** + * Create the list of wedges to render. + * @param {Object} props + props.data {Object} - tree structured data (each node has a name anc an array of children) + * @returns {Array} Array of nodes. + */ +function getWedgesToRender(_ref) { + var data = _ref.data, + getAngle = _ref.getAngle; + + var pie = (0, _d3Shape.pie)().sort(null).value(getAngle); + var pieData = pie(data).reverse(); + return pieData.map(function (row, index) { + return _extends({}, row.data, { + angle0: row.startAngle, + angle: row.endAngle, + radius0: row.data.innerRadius || 0, + radius: row.data.radius || 1, + color: row.data.color || index + }); + }); +} + +function generateLabels(mappedData, accessors) { + var labelsRadiusMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.1; + var getLabel = accessors.getLabel, + getSubLabel = accessors.getSubLabel; + + return mappedData.reduce(function (res, row) { + var angle = row.angle, + angle0 = row.angle0, + radius = row.radius; + + var centeredAngle = (angle + angle0) / 2; + + // unfortunate, but true fact: d3 starts its radians at 12 oclock rather than 3 + // and move clockwise rather than counter clockwise. why why why! + var updatedAngle = -1 * centeredAngle + Math.PI / 2; + var newLabels = []; + if (getLabel(row)) { + newLabels.push({ + angle: updatedAngle, + radius: radius * labelsRadiusMultiplier, + label: getLabel(row) + }); + } + + if (getSubLabel(row)) { + newLabels.push({ + angle: updatedAngle, + radius: radius * labelsRadiusMultiplier, + label: getSubLabel(row), + style: { fontSize: 10 }, + yOffset: 12 + }); + } + return res.concat(newLabels); + }, []); + // could add force direction here to make sure the labels dont overlap +} + +/** + * Get the max radius so the chart can extend to the margin. + * @param {Number} width - container width + * @param {Number} height - container height + * @return {Number} radius + */ +function getMaxRadius(width, height) { + return Math.min(width, height) / 2 - DEFAULT_RADIUS_MARGIN; +} + +function RadialChart(props) { + var animation = props.animation, + className = props.className, + children = props.children, + colorType = props.colorType, + data = props.data, + getAngle = props.getAngle, + getLabel = props.getLabel, + getSubLabel = props.getSubLabel, + height = props.height, + hideRootNode = props.hideRootNode, + innerRadius = props.innerRadius, + labelsAboveChildren = props.labelsAboveChildren, + labelsRadiusMultiplier = props.labelsRadiusMultiplier, + labelsStyle = props.labelsStyle, + margin = props.margin, + onMouseLeave = props.onMouseLeave, + onMouseEnter = props.onMouseEnter, + radius = props.radius, + showLabels = props.showLabels, + style = props.style, + width = props.width; + + var mappedData = getWedgesToRender({ + data: data, + height: height, + hideRootNode: hideRootNode, + width: width, + getAngle: getAngle + }); + var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); + var arcProps = _extends({ + colorType: colorType + }, props, { + animation: animation, + radiusDomain: [0, radialDomain], + data: mappedData, + radiusNoFallBack: true, + style: style, + arcClassName: 'rv-radial-chart__series--pie__slice' + }); + if (radius) { + arcProps.radiusDomain = [0, 1]; + arcProps.radiusRange = [innerRadius || 0, radius]; + arcProps.radiusType = 'linear'; + } + var maxRadius = radius ? radius : getMaxRadius(width, height); + var defaultMargin = (0, _chartUtils.getRadialLayoutMargin)(width, height, maxRadius); + + var labels = generateLabels(mappedData, { + getLabel: getLabel, + getSubLabel: getSubLabel + }, labelsRadiusMultiplier); + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + width: width, + margin: _extends({}, margin, defaultMargin), + className: className + ' ' + predefinedClassName, + onMouseLeave: onMouseLeave, + onMouseEnter: onMouseEnter, + xDomain: [-radialDomain, radialDomain], + yDomain: [-radialDomain, radialDomain] + }, + _react2.default.createElement(_arcSeries2.default, _extends({}, arcProps, { getAngle: function getAngle(d) { + return d.angle; + } })), + showLabels && !labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }), + children, + showLabels && labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }) + ); +} + +RadialChart.displayName = 'RadialChart'; +RadialChart.propTypes = { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + angle: _propTypes2.default.number, + className: _propTypes2.default.string, + label: _propTypes2.default.string, + radius: _propTypes2.default.number, + style: _propTypes2.default.object + })).isRequired, + getAngle: _propTypes2.default.func, + getAngle0: _propTypes2.default.func, + padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]), + getRadius: _propTypes2.default.func, + getRadius0: _propTypes2.default.func, + getLabel: _propTypes2.default.func, + height: _propTypes2.default.number.isRequired, + labelsAboveChildren: _propTypes2.default.bool, + labelsStyle: _propTypes2.default.object, + margin: _chartUtils.MarginPropType, + onValueClick: _propTypes2.default.func, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + showLabels: _propTypes2.default.bool, + style: _propTypes2.default.object, + subLabel: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired +}; +RadialChart.defaultProps = { + className: '', + colorType: 'category', + colorRange: _theme.DISCRETE_COLOR_RANGE, + padAngle: 0, + getAngle: function getAngle(d) { + return d.angle; + }, + getAngle0: function getAngle0(d) { + return d.angle0; + }, + getRadius: function getRadius(d) { + return d.radius; + }, + getRadius0: function getRadius0(d) { + return d.radius0; + }, + getLabel: function getLabel(d) { + return d.label; + }, + getSubLabel: function getSubLabel(d) { + return d.subLabel; + } +}; + +exports.default = RadialChart; \ No newline at end of file diff --git a/dist/sankey/index.js b/dist/sankey/index.js new file mode 100644 index 000000000..55b694d88 --- /dev/null +++ b/dist/sankey/index.js @@ -0,0 +1,238 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Sankey = require('d3-sankey'); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _chartUtils = require('../utils/chart-utils'); + +var _verticalRectSeries = require('../plot/series/vertical-rect-series'); + +var _verticalRectSeries2 = _interopRequireDefault(_verticalRectSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _voronoi = require('../plot/voronoi'); + +var _voronoi2 = _interopRequireDefault(_voronoi); + +var _theme = require('../theme'); + +var _sankeyLink = require('./sankey-link'); + +var _sankeyLink2 = _interopRequireDefault(_sankeyLink); + +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); } } + +var NOOP = function NOOP(f) { + return f; +}; + +var ALIGNMENTS = { + justify: _d3Sankey.sankeyJustify, + center: _d3Sankey.sankeyCenter, + left: _d3Sankey.sankeyLeft, + right: _d3Sankey.sankeyRight +}; + +var DEFAULT_MARGINS = { + top: 20, + left: 20, + right: 20, + bottom: 20 +}; + +function Sankey(props) { + var align = props.align, + animation = props.animation, + children = props.children, + className = props.className, + hasVoronoi = props.hasVoronoi, + height = props.height, + hideLabels = props.hideLabels, + labelRotation = props.labelRotation, + layout = props.layout, + links = props.links, + linkOpacity = props.linkOpacity, + margin = props.margin, + nodePadding = props.nodePadding, + nodes = props.nodes, + nodeWidth = props.nodeWidth, + onValueClick = props.onValueClick, + onValueMouseOver = props.onValueMouseOver, + onValueMouseOut = props.onValueMouseOut, + onLinkClick = props.onLinkClick, + onLinkMouseOver = props.onLinkMouseOver, + onLinkMouseOut = props.onLinkMouseOut, + style = props.style, + width = props.width; + + var nodesCopy = [].concat(_toConsumableArray(new Array(nodes.length))).map(function (e, i) { + return _extends({}, nodes[i]); + }); + var linksCopy = [].concat(_toConsumableArray(new Array(links.length))).map(function (e, i) { + return _extends({}, links[i]); + }); + + var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)({ + margin: margin, + height: height, + width: width + }, DEFAULT_MARGINS), + marginLeft = _getInnerDimensions.marginLeft, + marginTop = _getInnerDimensions.marginTop, + marginRight = _getInnerDimensions.marginRight, + marginBottom = _getInnerDimensions.marginBottom; + + var sankeyInstance = (0, _d3Sankey.sankey)().extent([[marginLeft, marginTop], [width - marginRight, height - marginBottom - marginTop]]).nodeWidth(nodeWidth).nodePadding(nodePadding).nodes(nodesCopy).links(linksCopy).nodeAlign(ALIGNMENTS[align]).iterations(layout); + sankeyInstance(nodesCopy); + + var nWidth = sankeyInstance.nodeWidth(); + var path = (0, _d3Sankey.sankeyLinkHorizontal)(); + + return _react2.default.createElement( + _xyPlot2.default, + _extends({}, props, { yType: 'literal', className: 'rv-sankey ' + className }), + linksCopy.map(function (link, i) { + return _react2.default.createElement(_sankeyLink2.default, { + style: style.links, + data: path(link), + opacity: link.opacity || linkOpacity, + color: link.color, + onLinkClick: onLinkClick, + onLinkMouseOver: onLinkMouseOver, + onLinkMouseOut: onLinkMouseOut, + strokeWidth: Math.max(link.width, 1), + node: link, + nWidth: nWidth, + key: 'link-' + i + }); + }), + _react2.default.createElement(_verticalRectSeries2.default, { + animation: animation, + className: className + ' rv-sankey__node', + data: nodesCopy.map(function (node) { + return _extends({}, node, { + y: node.y1 - marginTop, + y0: node.y0 - marginTop, + x: node.x1, + x0: node.x0, + color: node.color || _theme.DISCRETE_COLOR_RANGE[0], + sourceLinks: null, + targetLinks: null + }); + }), + style: style.rects, + onValueClick: onValueClick, + onValueMouseOver: onValueMouseOver, + onValueMouseOut: onValueMouseOut, + colorType: 'literal' + }), + !hideLabels && _react2.default.createElement(_labelSeries2.default, { + animation: animation, + className: className, + rotation: labelRotation, + labelAnchorY: 'text-before-edge', + data: nodesCopy.map(function (node, i) { + return _extends({ + x: node.x0 + (node.x0 < width / 2 ? nWidth + 10 : -10), + y: (node.y0 + node.y1) / 2 - marginTop, + label: node.name, + style: _extends({ + textAnchor: node.x0 < width / 2 ? 'start' : 'end', + dy: '-.5em' + }, style.labels) + }, nodes[i]); + }) + }), + hasVoronoi && _react2.default.createElement(_voronoi2.default, { + className: 'rv-sankey__voronoi', + extent: [[-marginLeft, -marginTop], [width + marginRight, height + marginBottom]], + nodes: nodesCopy, + onClick: onValueClick, + onHover: onValueMouseOver, + onBlur: onValueMouseOut, + x: function x(d) { + return d.x0 + (d.x1 - d.x0) / 2; + }, + y: function y(d) { + return d.y0 + (d.y1 - d.y0) / 2; + } + }), + children + ); +} + +Sankey.defaultProps = { + align: 'justify', + className: '', + hasVoronoi: false, + hideLabels: false, + labelRotation: 0, + layout: 50, + margin: DEFAULT_MARGINS, + nodePadding: 10, + nodeWidth: 10, + onValueMouseOver: NOOP, + onValueClick: NOOP, + onValueMouseOut: NOOP, + onLinkClick: NOOP, + onLinkMouseOver: NOOP, + onLinkMouseOut: NOOP, + style: { + links: {}, + rects: {}, + labels: {} + } +}; + +Sankey.propTypes = { + align: _propTypes2.default.oneOf(['justify', 'left', 'right', 'center']), + className: _propTypes2.default.string, + hasVoronoi: _propTypes2.default.bool, + height: _propTypes2.default.number.isRequired, + hideLabels: _propTypes2.default.bool, + labelRotation: _propTypes2.default.number, + layout: _propTypes2.default.number, + links: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + source: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired, + target: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired + })).isRequired, + margin: _chartUtils.MarginPropType, + nodePadding: _propTypes2.default.number, + nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + nodeWidth: _propTypes2.default.number, + onValueMouseOver: _propTypes2.default.func, + onValueClick: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + onLinkClick: _propTypes2.default.func, + onLinkMouseOver: _propTypes2.default.func, + onLinkMouseOut: _propTypes2.default.func, + style: _propTypes2.default.shape({ + links: _propTypes2.default.object, + rects: _propTypes2.default.object, + labels: _propTypes2.default.object + }), + width: _propTypes2.default.number.isRequired +}; +exports.default = Sankey; \ No newline at end of file diff --git a/dist/sankey/sankey-link.js b/dist/sankey/sankey-link.js new file mode 100644 index 000000000..d664e22d6 --- /dev/null +++ b/dist/sankey/sankey-link.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _theme = require('../theme'); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../utils/series-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var DEFAULT_LINK_COLOR = _theme.DISCRETE_COLOR_RANGE[1]; +var DEFAULT_LINK_OPACITY = 0.7; + +function SankeyLink(props) { + var animation = props.animation, + data = props.data, + node = props.node, + opacity = props.opacity, + color = props.color, + strokeWidth = props.strokeWidth, + style = props.style, + onLinkClick = props.onLinkClick, + onLinkMouseOver = props.onLinkMouseOver, + onLinkMouseOut = props.onLinkMouseOut; + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(SankeyLink, _extends({}, props, { animation: null })) + ); + } + return _react2.default.createElement('path', _extends({ + d: data + }, style, { + className: 'rv-sankey__link', + opacity: Number.isFinite(opacity) ? opacity : DEFAULT_LINK_OPACITY, + stroke: color || DEFAULT_LINK_COLOR, + onClick: function onClick(e) { + return onLinkClick(node, e); + }, + onMouseOver: function onMouseOver(e) { + return onLinkMouseOver(node, e); + }, + onMouseOut: function onMouseOut(e) { + return onLinkMouseOut(node, e); + }, + strokeWidth: strokeWidth, + fill: 'none' + })); +} + +SankeyLink.displayName = 'SankeyLink'; +SankeyLink.requiresSVG = true; +exports.default = SankeyLink; \ No newline at end of file diff --git a/dist/style.css b/dist/style.css new file mode 100644 index 000000000..42d247c14 --- /dev/null +++ b/dist/style.css @@ -0,0 +1 @@ +.react-vis-magic-css-import-rule{display:inherit}.rv-treemap{font-size:12px;position:relative}.rv-treemap__leaf{overflow:hidden;position:absolute}.rv-treemap__leaf--circle{align-items:center;border-radius:100%;display:flex;justify-content:center}.rv-treemap__leaf__content{overflow:hidden;padding:10px;text-overflow:ellipsis}.rv-xy-plot{color:#c3c3c3;position:relative}.rv-xy-plot canvas{pointer-events:none}.rv-xy-plot .rv-xy-canvas{pointer-events:none;position:absolute}.rv-xy-plot__inner{display:block}.rv-xy-plot__axis__line{fill:none;stroke-width:2px;stroke:#e6e6e9}.rv-xy-plot__axis__tick__line{stroke:#e6e6e9}.rv-xy-plot__axis__tick__text{fill:#6b6b76;font-size:11px}.rv-xy-plot__axis__title text{fill:#6b6b76;font-size:11px}.rv-xy-plot__grid-lines__line{stroke:#e6e6e9}.rv-xy-plot__circular-grid-lines__line{fill-opacity:0;stroke:#e6e6e9}.rv-xy-plot__series,.rv-xy-plot__series path{pointer-events:all}.rv-xy-plot__series--line{fill:none;stroke:#000;stroke-width:2px}.rv-crosshair{position:absolute;font-size:11px;pointer-events:none}.rv-crosshair__line{background:#47d3d9;width:1px}.rv-crosshair__inner{position:absolute;text-align:left;top:0}.rv-crosshair__inner__content{border-radius:4px;background:#3a3a48;color:#fff;font-size:12px;padding:7px 10px;box-shadow:0 2px 4px rgba(0,0,0,0.5)}.rv-crosshair__inner--left{right:4px}.rv-crosshair__inner--right{left:4px}.rv-crosshair__title{font-weight:bold;white-space:nowrap}.rv-crosshair__item{white-space:nowrap}.rv-hint{position:absolute;pointer-events:none}.rv-hint__content{border-radius:4px;padding:7px 10px;font-size:12px;background:#3a3a48;box-shadow:0 2px 4px rgba(0,0,0,0.5);color:#fff;text-align:left;white-space:nowrap}.rv-discrete-color-legend{box-sizing:border-box;overflow-y:auto;font-size:12px}.rv-discrete-color-legend.horizontal{white-space:nowrap}.rv-discrete-color-legend-item{color:#3a3a48;border-radius:1px;padding:9px 10px}.rv-discrete-color-legend-item.horizontal{display:inline-block}.rv-discrete-color-legend-item.horizontal .rv-discrete-color-legend-item__title{margin-left:0;display:block}.rv-discrete-color-legend-item__color{display:inline-block;vertical-align:middle;overflow:visible}.rv-discrete-color-legend-item__color__path{stroke:#dcdcdc;stroke-width:2px}.rv-discrete-color-legend-item__title{margin-left:10px}.rv-discrete-color-legend-item.disabled{color:#b8b8b8}.rv-discrete-color-legend-item.clickable{cursor:pointer}.rv-discrete-color-legend-item.clickable:hover{background:#f9f9f9}.rv-search-wrapper{display:flex;flex-direction:column}.rv-search-wrapper__form{flex:0}.rv-search-wrapper__form__input{width:100%;color:#a6a6a5;border:1px solid #e5e5e4;padding:7px 10px;font-size:12px;box-sizing:border-box;border-radius:2px;margin:0 0 9px;outline:0}.rv-search-wrapper__contents{flex:1;overflow:auto}.rv-continuous-color-legend{font-size:12px}.rv-continuous-color-legend .rv-gradient{height:4px;border-radius:2px;margin-bottom:5px}.rv-continuous-size-legend{font-size:12px}.rv-continuous-size-legend .rv-bubbles{text-align:justify;overflow:hidden;margin-bottom:5px;width:100%}.rv-continuous-size-legend .rv-bubble{background:#d8d9dc;display:inline-block;vertical-align:bottom}.rv-continuous-size-legend .rv-spacer{display:inline-block;font-size:0;line-height:0;width:100%}.rv-legend-titles{height:16px;position:relative}.rv-legend-titles__left,.rv-legend-titles__right,.rv-legend-titles__center{position:absolute;white-space:nowrap;overflow:hidden}.rv-legend-titles__center{display:block;text-align:center;width:100%}.rv-legend-titles__right{right:0}.rv-radial-chart .rv-xy-plot__series--label{pointer-events:none} diff --git a/dist/styles/examples.scss b/dist/styles/examples.scss new file mode 100644 index 000000000..420cb2eb1 --- /dev/null +++ b/dist/styles/examples.scss @@ -0,0 +1,461 @@ +@import '../main.scss'; + +$black: #000; +$white: #fff; + +body { + font-family: Sintony, Helvetica, sans-serif; + font-size: 14px; + margin: 0; + padding: 0; +} + +h1, +h2, +h3, +h4, +h5 { + font-weight: normal; +} + +h1 { + font-size: 36px; + margin: 20px 0; +} + +h2 { + font-size: 24px; + margin: 15px 0; +} + +main { + padding: 40px 0; +} + +header { + background: #f0f0f0; + line-height: 40px; + position: fixed; + top: 0; + width: 100%; + z-index: 1000; +} + +.flex { + display: flex; +} + +.docs-link { + font-weight: 500; + font-size: 11px; + margin-right: 5px; + text-transform: uppercase; + border-left: 1px solid #c0c0c0; + padding-left: 5px; + line-height: 1; +} + +.docs-link:first-child { + border-left: 0px; + padding-left: 0px; +} + +.docs-comment { + display: flex; + max-width: 300px; +} + +.header-contents { + align-items: center; + display: flex; + justify-content: space-between; + padding: 0 20px; +} + +.header-logo { + color: $black; + float: left; + font-size: 20px; + text-decoration: none; +} + +.background-overlay { + bottom: 0; + left: 0; + position: fixed; + right: 0; + top: 0; + z-index: 1; +} + +.dropdown-button { + cursor: pointer; + z-index: 10; +} + +.dropdown-wrapper { + display: flex; + position: relative; + + .dropdown-inner-wrapper { + background: $white; + border: 2px solid $black; + display: flex; + flex-direction: column; + font-size: 11px; + height: auto; + list-style: none; + padding: 10px; + position: absolute; + right: -5px; + top: 25px; + width: 150px; + z-index: 10; + } + + a { + display: flex; + height: auto; + line-height: 15px; + text-decoration: none; + } + + li { + display: flex; + height: 100%; + } + + .subsection-label { + font-weight: 600; + line-height: 15px; + } +} + + +article { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: flex-start; + margin: 0 auto; + max-width: 1200px; + min-width: 650px; + padding: 30px 20px 0; + + h1, + h2 { + flex: 1 100%; + + small { + color: #6b6b76; + font-size: 50%; + } + } + + section { + flex-basis: 400px; + flex-grow: 1; + margin: 0 0 40px; + } + + .section-title { + margin-bottom: 5px; + } + + .section-header { + margin-bottom: 1em; + } +} + +.click-me { + border: 0; + background: #ef5d28; + color: $white; + cursor: pointer; + font-family: Sintony, Helvetica, sans-serif; + font-size: 14px; + outline: none; + padding: 11px 20px; + text-transform: uppercase; + + &:hover { + background: #ff9833; + } + + animation: shake 5s 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite; + transform: translate3d(0, 0, 0); +} + +@keyframes shake { + 1%, + 9% { + transform: translate3d(-1px, 0, 0); + } + + 2%, + 8% { + transform: translate3d(2px, 0, 0); + } + + 3%, + 5%, + 7% { + transform: translate3d(-4px, 0, 0); + } + + 4%, + 6% { + transform: translate3d(4px, 0, 0); + } +} + +.example-with-click-me { + position: relative; + text-align: center; + width: 100%; + + &:hover { + .click-me { + animation: none; + } + } + + .chart { + margin-right: 200px; + .rv-xy-plot__axis__tick__line { + stroke: $rv-xy-plot-axis-font-color; + } + } + + .legend { + position: absolute; + text-align: left; + right: 0; + } +} + +.custom-hint { + background: #f9e7bb; + border-radius: 3px; + border: 1px solid #edaf00; + padding: 10px; + color: #333; + font-size: 10px; + position: relative; + margin: 12px 0 0 -10px; + + &::after { + border-radius: 5px; + border: 2px solid #edaf00; + background: $white; + display: block; + content: ' '; + height: 6px; + width: 6px; + top: -17px; + left: 5px; + position: absolute; + } +} + +.complex-hint { + margin-top: 40px; + + .rv-hint { + /* must be positioned in a parent with relative positioning */ + position: absolute; + width: 0; + height: 100%; + $hint-color: black; + $margin-left: 30px; + $margin-right: 10px; + $margin-top: 10px; + $margin-bottom: 25px; + + & .hint--text-container { + position: absolute; + + /* + * set to 0,0 so that its content (including children) + * can overflow out in vertical and horizontal + */ + width: 0; + height: 0; + + /* + * use flex to place its children (centered) and aligned (bottom). + * As its height is 0, align-items flex-end paints its items from cross-axis + * up. flex-start, its items would paint from cross-axis down. + */ + display: flex; + justify-content: center; + + &.rightEdge-top { + flex-direction: column-reverse; + align-items: flex-start; + } + + &.left-topEdge { + flex-direction: row; + align-items: flex-end; + } + + &.left-bottomEdge { + flex-direction: row; + align-items: flex-start; + } + + &.leftEdge-top { + flex-direction: column; + align-items: flex-end; + } + + & .hint--text { + /* text content uses -micro padding */ + padding: 4px; + border: 2px solid $hint-color; + color: $hint-color; + white-space: nowrap; + } + } + + & .hint--pole { + position: absolute; + + &.rightEdge-top { + top: -1px; + left: -$margin-right; + border-top: 2px solid $hint-color; + width: $margin-right; + height: 0; + } + + &.left-topEdge { + border-left: 2px solid $hint-color; + left: -1px; + height: $margin-top; + width: 0; + top: 0; + } + + &.left-bottomEdge { + border-left: 2px solid $hint-color; + left: -1px; + height: $margin-bottom; + width: 0; + top: -$margin-bottom; + } + + &.leftEdge-top { + top: -1px; + border-top: 2px solid $hint-color; + width: $margin-left; + height: 0; + } + } + } + + .rv-hint--horizontalAlign-rightEdge.rv-hint--verticalAlign-top { + width: 0; + height: 0; + } + + .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-topEdge { + width: 0; + height: 100%; + } + + .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-bottomEdge { + width: 0; + height: 0; + } + + .rv-hint--horizontalAlign-leftEdge.rv-hint--verticalAlign-top { + width: 100%; + height: 0; + } +} + +.centered-and-flexed { + align-items: center; + display: flex; + flex-direction: column; + justify-content: center; + padding: 0 10px; + + .centered-and-flexed-controls { + align-items: center; + display: flex; + justify-content: space-between; + padding: 10px 0; + width: 75%; + } +} + +.dynamic-treemap-example { + .rv-treemap__leaf--circle { + border: thin solid white; + } +} + +.clustered-stacked-bar-chart-example { + .rv-discrete-color-legend { + left: 40px; + position: absolute; + top: 0; + } +} + +.basic-sunburst-example-path-name { + height: 20px; +} + +.showcase-button { + background: $white; + border: thin solid #333; + border-radius: 5px; + cursor: pointer; + font-size: 10px; + font-weight: 600; + padding: 5px 10px; +} + +.donut-chart-example { + .rv-radial-chart__series--pie__slice:hover { + stroke: $black !important; + stroke-width: 2px !important; + } +} + +.parallel-coordinates-example { + .rv-xy-plot__series--line { + stroke: #12939A !important; + + &:hover { + stroke: #F15C17 !important; + } + } +} + + +.canvas-example-controls { + display: flex; +} + +.canvas-wrapper { + align-items: center; + display: flex; + flex-direction: column; + width: 100%; +} + +.highlight-container { + cursor: crosshair; +} + +.no-select { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/dist/styles/legends.scss b/dist/styles/legends.scss new file mode 100644 index 000000000..f79e9c850 --- /dev/null +++ b/dist/styles/legends.scss @@ -0,0 +1,137 @@ +$rv-legend-enabled-color: #3a3a48; +$rv-legend-disabled-color: #b8b8b8; + +.rv-discrete-color-legend { + box-sizing: border-box; + overflow-y: auto; + font-size: 12px; + + &.horizontal { + white-space: nowrap; + } +} + +.rv-discrete-color-legend-item { + color: $rv-legend-enabled-color; + border-radius: 1px; + padding: 9px 10px; + + &.horizontal { + display: inline-block; + + .rv-discrete-color-legend-item__title { + margin-left: 0; + display: block; + } + } +} + +.rv-discrete-color-legend-item__color { + display: inline-block; + vertical-align: middle; + overflow: visible; +} + +.rv-discrete-color-legend-item__color__path { + stroke: #dcdcdc; + stroke-width: 2px; +} + +.rv-discrete-color-legend-item__title { + margin-left: 10px; +} + +.rv-discrete-color-legend-item.disabled { + color: $rv-legend-disabled-color; +} + +.rv-discrete-color-legend-item.clickable { + cursor: pointer; + + &:hover { + background: #f9f9f9; + } +} + +.rv-search-wrapper { + display: flex; + flex-direction: column; +} + +.rv-search-wrapper__form { + flex: 0; +} + +.rv-search-wrapper__form__input { + width: 100%; + color: #a6a6a5; + border: 1px solid #e5e5e4; + padding: 7px 10px; + font-size: 12px; + box-sizing: border-box; + border-radius: 2px; + margin: 0 0 9px; + outline: 0; +} + +.rv-search-wrapper__contents { + flex: 1; + overflow: auto; +} + +.rv-continuous-color-legend { + font-size: 12px; + + .rv-gradient { + height: 4px; + border-radius: 2px; + margin-bottom: 5px; + } +} + +.rv-continuous-size-legend { + font-size: 12px; + + .rv-bubbles { + text-align: justify; + overflow: hidden; + margin-bottom: 5px; + width: 100%; + } + + .rv-bubble { + background: #d8d9dc; + display: inline-block; + vertical-align: bottom; + } + + .rv-spacer { + display: inline-block; + font-size: 0; + line-height: 0; + width: 100%; + } +} + +.rv-legend-titles { + height: 16px; + position: relative; +} + +.rv-legend-titles__left, +.rv-legend-titles__right, +.rv-legend-titles__center { + position: absolute; + white-space: nowrap; + overflow: hidden; +} + +.rv-legend-titles__center { + display: block; + text-align: center; + width: 100%; +} + +.rv-legend-titles__right { + right: 0; +} diff --git a/dist/styles/plot.scss b/dist/styles/plot.scss new file mode 100644 index 000000000..8d1f75ca2 --- /dev/null +++ b/dist/styles/plot.scss @@ -0,0 +1,128 @@ +$rv-xy-plot-axis-font-color: #6b6b76; +$rv-xy-plot-axis-line-color: #e6e6e9; +$rv-xy-plot-axis-font-size: 11px; +$rv-xy-plot-tooltip-background: #3a3a48; +$rv-xy-plot-tooltip-color: #fff; +$rv-xy-plot-tooltip-font-size: 12px; +$rv-xy-plot-tooltip-border-radius: 4px; +$rv-xy-plot-tooltip-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); +$rv-xy-plot-tooltip-padding: 7px 10px; + +.rv-xy-plot { + color: #c3c3c3; + position: relative; + + canvas { + pointer-events: none; + } + + .rv-xy-canvas { + pointer-events: none; + position: absolute; + } +} + +.rv-xy-plot__inner { + display: block; +} + +.rv-xy-plot__axis__line { + fill: none; + stroke-width: 2px; + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__axis__tick__line { + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__axis__tick__text { + fill: $rv-xy-plot-axis-font-color; + font-size: $rv-xy-plot-axis-font-size; +} + +.rv-xy-plot__axis__title { + text { + fill: $rv-xy-plot-axis-font-color; + font-size: $rv-xy-plot-axis-font-size; + } +} + +.rv-xy-plot__grid-lines__line { + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__circular-grid-lines__line { + fill-opacity: 0; + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__series, +.rv-xy-plot__series path { + pointer-events: all; +} + +.rv-xy-plot__series--line { + fill: none; + stroke: #000; + stroke-width: 2px; +} + +.rv-crosshair { + position: absolute; + font-size: 11px; + pointer-events: none; +} + +.rv-crosshair__line { + background: #47d3d9; + width: 1px; +} + +.rv-crosshair__inner { + position: absolute; + text-align: left; + top: 0; +} + +.rv-crosshair__inner__content { + border-radius: $rv-xy-plot-tooltip-border-radius; + background: $rv-xy-plot-tooltip-background; + color: $rv-xy-plot-tooltip-color; + font-size: $rv-xy-plot-tooltip-font-size; + padding: $rv-xy-plot-tooltip-padding; + box-shadow: $rv-xy-plot-tooltip-shadow; +} + +.rv-crosshair__inner--left { + right: 4px; +} + +.rv-crosshair__inner--right { + left: 4px; +} + +.rv-crosshair__title { + font-weight: bold; + white-space: nowrap; +} + +.rv-crosshair__item { + white-space: nowrap; +} + +.rv-hint { + position: absolute; + pointer-events: none; +} + +.rv-hint__content { + border-radius: $rv-xy-plot-tooltip-border-radius; + padding: $rv-xy-plot-tooltip-padding; + font-size: $rv-xy-plot-tooltip-font-size; + background: $rv-xy-plot-tooltip-background; + box-shadow: $rv-xy-plot-tooltip-shadow; + color: $rv-xy-plot-tooltip-color; + text-align: left; + white-space: nowrap; +} diff --git a/dist/styles/radial-chart.scss b/dist/styles/radial-chart.scss new file mode 100644 index 000000000..854a57d4b --- /dev/null +++ b/dist/styles/radial-chart.scss @@ -0,0 +1,6 @@ +.rv-radial-chart { + + .rv-xy-plot__series--label { + pointer-events: none; + } +} diff --git a/dist/styles/treemap.scss b/dist/styles/treemap.scss new file mode 100644 index 000000000..4626d66ea --- /dev/null +++ b/dist/styles/treemap.scss @@ -0,0 +1,22 @@ +.rv-treemap { + font-size: 12px; + position: relative; +} + +.rv-treemap__leaf { + overflow: hidden; + position: absolute; +} + +.rv-treemap__leaf--circle { + align-items: center; + border-radius: 100%; + display: flex; + justify-content: center; +} + +.rv-treemap__leaf__content { + overflow: hidden; + padding: 10px; + text-overflow: ellipsis; +} diff --git a/dist/sunburst/index.js b/dist/sunburst/index.js new file mode 100644 index 000000000..a9c12d6c2 --- /dev/null +++ b/dist/sunburst/index.js @@ -0,0 +1,253 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Hierarchy = require('d3-hierarchy'); + +var _d3Scale = require('d3-scale'); + +var _animation = require('../animation'); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _arcSeries = require('../plot/series/arc-series'); + +var _arcSeries2 = _interopRequireDefault(_arcSeries); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _seriesUtils = require('../utils/series-utils'); + +var _chartUtils = require('../utils/chart-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var predefinedClassName = 'rv-sunburst'; + +var LISTENERS_TO_OVERWRITE = ['onValueMouseOver', 'onValueMouseOut', 'onValueClick', 'onValueRightClick', 'onSeriesMouseOver', 'onSeriesMouseOut', 'onSeriesClick', 'onSeriesRightClick']; + +/** + * Create the list of nodes to render. + * @param {Object} props + props.data {Object} - tree structured data (each node has a name anc an array of children) + props.height {number} - the height of the graphic to be rendered + props.hideRootNode {boolean} - whether or not to hide the root node + props.width {number} - the width of the graphic to be rendered + props.getSize {function} - accessor for the size + * @returns {Array} Array of nodes. + */ +function getNodesToRender(_ref) { + var data = _ref.data, + height = _ref.height, + hideRootNode = _ref.hideRootNode, + width = _ref.width, + getSize = _ref.getSize; + + var partitionFunction = (0, _d3Hierarchy.partition)(); + var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize); + var radius = Math.min(width, height) / 2 - 10; + var x = (0, _d3Scale.scaleLinear)().range([0, 2 * Math.PI]); + var y = (0, _d3Scale.scaleSqrt)().range([0, radius]); + + return partitionFunction(structuredInput).descendants().reduce(function (res, cell, index) { + if (hideRootNode && index === 0) { + return res; + } + + return res.concat([_extends({ + angle0: Math.max(0, Math.min(2 * Math.PI, x(cell.x0))), + angle: Math.max(0, Math.min(2 * Math.PI, x(cell.x1))), + radius0: Math.max(0, y(cell.y0)), + radius: Math.max(0, y(cell.y1)), + depth: cell.depth, + parent: cell.parent + }, cell.data)]); + }, []); +} + +/** + * Convert arc nodes into label rows. + * Important to use mappedData rather than regular data, bc it is already unrolled + * @param {Array} mappedData - Array of nodes. + * @param {Object} accessors - object of accessors + * @returns {Array} array of node for rendering as labels + */ +function buildLabels(mappedData, accessors) { + var getAngle = accessors.getAngle, + getAngle0 = accessors.getAngle0, + getLabel = accessors.getLabel, + getRadius0 = accessors.getRadius0; + + + return mappedData.filter(getLabel).map(function (row) { + var truedAngle = -1 * getAngle(row) + Math.PI / 2; + var truedAngle0 = -1 * getAngle0(row) + Math.PI / 2; + var angle = (truedAngle0 + truedAngle) / 2; + var rotateLabels = !row.dontRotateLabel; + var rotAngle = -angle / (2 * Math.PI) * 360; + + return _extends({}, row, { + children: null, + angle: null, + radius: null, + x: getRadius0(row) * Math.cos(angle), + y: getRadius0(row) * Math.sin(angle), + style: _extends({ + textAnchor: rotAngle > 90 ? 'end' : 'start' + }, row.labelStyle), + rotation: rotateLabels ? rotAngle > 90 ? rotAngle + 180 : rotAngle === 90 ? 90 : rotAngle : null + }); + }); +} + +var NOOP = function NOOP() {}; + +function Sunburst(props) { + var getAngle = props.getAngle, + getAngle0 = props.getAngle0, + animation = props.animation, + className = props.className, + children = props.children, + data = props.data, + height = props.height, + hideRootNode = props.hideRootNode, + getLabel = props.getLabel, + width = props.width, + getSize = props.getSize, + colorType = props.colorType; + + var mappedData = getNodesToRender({ + data: data, + height: height, + hideRootNode: hideRootNode, + width: width, + getSize: getSize + }); + var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); + var margin = (0, _chartUtils.getRadialLayoutMargin)(width, height, radialDomain); + + var labelData = buildLabels(mappedData, { + getAngle: getAngle, + getAngle0: getAngle0, + getLabel: getLabel, + getRadius0: function getRadius0(d) { + return d.radius0; + } + }); + + var hofBuilder = function hofBuilder(f) { + return function (e, i) { + return f ? f(mappedData[e.index], i) : NOOP; + }; + }; + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + hasTreeStructure: true, + width: width, + className: predefinedClassName + ' ' + className, + margin: margin, + xDomain: [-radialDomain, radialDomain], + yDomain: [-radialDomain, radialDomain] + }, + _react2.default.createElement(_arcSeries2.default, _extends({ + colorType: colorType + }, props, { + animation: animation, + radiusDomain: [0, radialDomain], + // need to present a stripped down version for interpolation + data: animation ? mappedData.map(function (row, index) { + return _extends({}, row, { + parent: null, + children: null, + index: index + }); + }) : mappedData, + _data: animation ? mappedData : null, + arcClassName: predefinedClassName + '__series--radial__arc' + }, LISTENERS_TO_OVERWRITE.reduce(function (acc, propName) { + var prop = props[propName]; + acc[propName] = animation ? hofBuilder(prop) : prop; + return acc; + }, {}))), + labelData.length > 0 && _react2.default.createElement(_labelSeries2.default, { data: labelData, getLabel: getLabel }), + children + ); +} + +Sunburst.displayName = 'Sunburst'; +Sunburst.propTypes = { + animation: _animation.AnimationPropType, + getAngle: _propTypes2.default.func, + getAngle0: _propTypes2.default.func, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + data: _propTypes2.default.object.isRequired, + height: _propTypes2.default.number.isRequired, + hideRootNode: _propTypes2.default.bool, + getLabel: _propTypes2.default.func, + onValueClick: _propTypes2.default.func, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + getSize: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired, + padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) +}; +Sunburst.defaultProps = { + getAngle: function getAngle(d) { + return d.angle; + }, + getAngle0: function getAngle0(d) { + return d.angle0; + }, + className: '', + colorType: 'literal', + getColor: function getColor(d) { + return d.color; + }, + hideRootNode: false, + getLabel: function getLabel(d) { + return d.label; + }, + getSize: function getSize(d) { + return d.size; + }, + padAngle: 0 +}; + +exports.default = Sunburst; \ No newline at end of file diff --git a/dist/theme.js b/dist/theme.js new file mode 100644 index 000000000..3807452c3 --- /dev/null +++ b/dist/theme.js @@ -0,0 +1,42 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var DISCRETE_COLOR_RANGE = exports.DISCRETE_COLOR_RANGE = ['#12939A', '#79C7E3', '#1A3177', '#FF9833', '#EF5D28']; + +var EXTENDED_DISCRETE_COLOR_RANGE = exports.EXTENDED_DISCRETE_COLOR_RANGE = ['#19CDD7', '#DDB27C', '#88572C', '#FF991F', '#F15C17', '#223F9A', '#DA70BF', '#125C77', '#4DC19C', '#776E57', '#12939A', '#17B8BE', '#F6D18A', '#B7885E', '#FFCB99', '#F89570', '#829AE3', '#E79FD5', '#1E96BE', '#89DAC1', '#B3AD9E']; + +var CONTINUOUS_COLOR_RANGE = exports.CONTINUOUS_COLOR_RANGE = ['#EF5D28', '#FF9833']; + +var SIZE_RANGE = exports.SIZE_RANGE = [1, 10]; + +var OPACITY_RANGE = exports.OPACITY_RANGE = [0.1, 1]; +var OPACITY_TYPE = exports.OPACITY_TYPE = 'literal'; +var DEFAULT_OPACITY = exports.DEFAULT_OPACITY = 1; + +var DEFAULT_SIZE = exports.DEFAULT_SIZE = 5; + +var DEFAULT_COLOR = exports.DEFAULT_COLOR = DISCRETE_COLOR_RANGE[0]; + +var DEFAULT_TICK_SIZE = exports.DEFAULT_TICK_SIZE = 7; \ No newline at end of file diff --git a/dist/treemap/index.js b/dist/treemap/index.js new file mode 100644 index 000000000..27244fe2d --- /dev/null +++ b/dist/treemap/index.js @@ -0,0 +1,254 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Hierarchy = require('d3-hierarchy'); + +var _theme = require('../theme'); + +var _animation = require('../animation'); + +var _scalesUtils = require('../utils/scales-utils'); + +var _chartUtils = require('../utils/chart-utils'); + +var _treemapDom = require('./treemap-dom'); + +var _treemapDom2 = _interopRequireDefault(_treemapDom); + +var _treemapSvg = require('./treemap-svg'); + +var _treemapSvg2 = _interopRequireDefault(_treemapSvg); + +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; } + +var TREEMAP_TILE_MODES = { + squarify: _d3Hierarchy.treemapSquarify, + resquarify: _d3Hierarchy.treemapResquarify, + slice: _d3Hierarchy.treemapSlice, + dice: _d3Hierarchy.treemapDice, + slicedice: _d3Hierarchy.treemapSliceDice, + binary: _d3Hierarchy.treemapBinary +}; + +var TREEMAP_LAYOUT_MODES = ['circlePack', 'partition', 'partition-pivot']; + +var NOOP = function NOOP(d) { + return d; +}; + +var ATTRIBUTES = ['opacity', 'color']; + +var DEFAULT_MARGINS = { + left: 40, + right: 10, + top: 10, + bottom: 40 +}; + +/** + * Get the map of scale functions from the given props. + * @param {Object} props Props for the component. + * @returns {Object} Map of scale functions. + * @private + */ +function _getScaleFns(props) { + var data = props.data; + + var allData = data.children || []; + + // Adding _allData property to the object to reuse the existing + // getAttributeFunctor function. + var compatibleProps = _extends({}, props, (0, _scalesUtils.getMissingScaleProps)(props, allData, ATTRIBUTES), { + _allData: allData + }); + return { + opacity: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'opacity'), + color: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'color') + }; +} + +var Treemap = function (_React$Component) { + _inherits(Treemap, _React$Component); + + function Treemap(props) { + _classCallCheck(this, Treemap); + + var _this = _possibleConstructorReturn(this, (Treemap.__proto__ || Object.getPrototypeOf(Treemap)).call(this, props)); + + _this.state = _extends({ + scales: _getScaleFns(props) + }, (0, _chartUtils.getInnerDimensions)(props, props.margin)); + return _this; + } + + _createClass(Treemap, [{ + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(props) { + this.setState(_extends({ + scales: _getScaleFns(props) + }, (0, _chartUtils.getInnerDimensions)(props, props.margin))); + } + + /** + * Create the list of nodes to render. + * @returns {Array} Array of nodes. + * @private + */ + + }, { + key: '_getNodesToRender', + value: function _getNodesToRender() { + var _state = this.state, + innerWidth = _state.innerWidth, + innerHeight = _state.innerHeight; + var _props = this.props, + data = _props.data, + mode = _props.mode, + padding = _props.padding, + sortFunction = _props.sortFunction, + getSize = _props.getSize; + + if (!data) { + return []; + } + + if (mode === 'partition' || mode === 'partition-pivot') { + var partitionFunction = (0, _d3Hierarchy.partition)().size(mode === 'partition-pivot' ? [innerHeight, innerWidth] : [innerWidth, innerHeight]).padding(padding); + var _structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { + return sortFunction(a, b, getSize); + }); + var mappedNodes = partitionFunction(_structuredInput).descendants(); + if (mode === 'partition-pivot') { + return mappedNodes.map(function (node) { + return _extends({}, node, { + x0: node.y0, + x1: node.y1, + y0: node.x0, + y1: node.x1 + }); + }); + } + return mappedNodes; + } + if (mode === 'circlePack') { + var packingFunction = (0, _d3Hierarchy.pack)().size([innerWidth, innerHeight]).padding(padding); + var _structuredInput2 = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { + return sortFunction(a, b, getSize); + }); + return packingFunction(_structuredInput2).descendants(); + } + + var tileFn = TREEMAP_TILE_MODES[mode]; + var treemapingFunction = (0, _d3Hierarchy.treemap)(tileFn).tile(tileFn).size([innerWidth, innerHeight]).padding(padding); + var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { + return sortFunction(a, b, getSize); + }); + return treemapingFunction(structuredInput).descendants(); + } + }, { + key: 'render', + value: function render() { + var renderMode = this.props.renderMode; + var scales = this.state.scales; + + var nodes = this._getNodesToRender(); + var TreemapElement = renderMode === 'SVG' ? _treemapSvg2.default : _treemapDom2.default; + return _react2.default.createElement(TreemapElement, _extends({}, this.props, { nodes: nodes, scales: scales })); + } + }]); + + return Treemap; +}(_react2.default.Component); + +Treemap.displayName = 'Treemap'; +Treemap.propTypes = { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + data: _propTypes2.default.object.isRequired, + height: _propTypes2.default.number.isRequired, + hideRootNode: _propTypes2.default.bool, + margin: _chartUtils.MarginPropType, + mode: _propTypes2.default.oneOf(Object.keys(TREEMAP_TILE_MODES).concat(TREEMAP_LAYOUT_MODES)), + onLeafClick: _propTypes2.default.func, + onLeafMouseOver: _propTypes2.default.func, + onLeafMouseOut: _propTypes2.default.func, + useCirclePacking: _propTypes2.default.bool, + padding: _propTypes2.default.number.isRequired, + sortFunction: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired, + getSize: _propTypes2.default.func, + getColor: _propTypes2.default.func +}; + +Treemap.defaultProps = { + className: '', + colorRange: _theme.CONTINUOUS_COLOR_RANGE, + _colorValue: _theme.DEFAULT_COLOR, + data: { + children: [] + }, + hideRootNode: false, + margin: DEFAULT_MARGINS, + mode: 'squarify', + onLeafClick: NOOP, + onLeafMouseOver: NOOP, + onLeafMouseOut: NOOP, + opacityType: _theme.OPACITY_TYPE, + _opacityValue: _theme.DEFAULT_OPACITY, + padding: 1, + sortFunction: function sortFunction(a, b, accessor) { + if (!accessor) { + return 0; + } + return accessor(a) - accessor(b); + }, + getSize: function getSize(d) { + return d.size; + }, + getColor: function getColor(d) { + return d.color; + }, + getLabel: function getLabel(d) { + return d.title; + } +}; +exports.default = Treemap; \ No newline at end of file diff --git a/dist/treemap/treemap-dom.js b/dist/treemap/treemap-dom.js new file mode 100644 index 000000000..b8112f0a9 --- /dev/null +++ b/dist/treemap/treemap-dom.js @@ -0,0 +1,82 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _treemapLeaf = require('./treemap-leaf'); + +var _treemapLeaf2 = _interopRequireDefault(_treemapLeaf); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function TreemapDOM(props) { + var animation = props.animation, + className = props.className, + height = props.height, + hideRootNode = props.hideRootNode, + getLabel = props.getLabel, + mode = props.mode, + nodes = props.nodes, + width = props.width, + scales = props.scales, + style = props.style; + + var useCirclePacking = mode === 'circlePack'; + return _react2.default.createElement( + 'div', + { + className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, + style: { height: height, width: width } + }, + nodes.map(function (node, index) { + // throw out the rootest node + if (hideRootNode && !index) { + return null; + } + + var nodeProps = _extends({ + animation: animation, + node: node, + getLabel: getLabel + }, props, { + x0: useCirclePacking ? node.x : node.x0, + x1: useCirclePacking ? node.x : node.x1, + y0: useCirclePacking ? node.y : node.y0, + y1: useCirclePacking ? node.y : node.y1, + r: useCirclePacking ? node.r : 1, + scales: scales, + style: style + }); + return _react2.default.createElement(_treemapLeaf2.default, _extends({}, nodeProps, { key: 'leaf-' + index })); + }) + ); +} + +TreemapDOM.displayName = 'TreemapDOM'; +exports.default = TreemapDOM; \ No newline at end of file diff --git a/dist/treemap/treemap-leaf.js b/dist/treemap/treemap-leaf.js new file mode 100644 index 000000000..d0a67615f --- /dev/null +++ b/dist/treemap/treemap-leaf.js @@ -0,0 +1,125 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _scalesUtils = require('../utils/scales-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var ANIMATED_PROPS = ['colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'x0', 'x1', 'y0', 'y1', 'r']; + +function TreemapLeaf(props) { + var animation = props.animation, + getLabel = props.getLabel, + mode = props.mode, + node = props.node, + onLeafClick = props.onLeafClick, + onLeafMouseOver = props.onLeafMouseOver, + onLeafMouseOut = props.onLeafMouseOut, + r = props.r, + scales = props.scales, + x0 = props.x0, + x1 = props.x1, + y0 = props.y0, + y1 = props.y1, + style = props.style; + + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, props, { animatedProps: ANIMATED_PROPS }), + _react2.default.createElement(TreemapLeaf, _extends({}, props, { animation: null })) + ); + } + var useCirclePacking = mode === 'circlePack'; + var background = scales.color(node); + var opacity = scales.opacity(node); + var color = (0, _scalesUtils.getFontColorFromBackground)(background); + var data = node.data; + + var title = getLabel(data); + var leafStyle = _extends({ + top: useCirclePacking ? y0 - r : y0, + left: useCirclePacking ? x0 - r : x0, + width: useCirclePacking ? r * 2 : x1 - x0, + height: useCirclePacking ? r * 2 : y1 - y0, + background: background, + opacity: opacity, + color: color + }, style, node.data.style); + + return _react2.default.createElement( + 'div', + { + className: 'rv-treemap__leaf ' + (useCirclePacking ? 'rv-treemap__leaf--circle' : ''), + onMouseEnter: function onMouseEnter(event) { + return onLeafMouseOver(node, event); + }, + onMouseLeave: function onMouseLeave(event) { + return onLeafMouseOut(node, event); + }, + onClick: function onClick(event) { + return onLeafClick(node, event); + }, + style: leafStyle + }, + _react2.default.createElement( + 'div', + { className: 'rv-treemap__leaf__content' }, + title + ) + ); +} + +TreemapLeaf.propTypes = { + animation: _animation.AnimationPropType, + height: _propTypes2.default.number.isRequired, + mode: _propTypes2.default.string, + node: _propTypes2.default.object.isRequired, + onLeafClick: _propTypes2.default.func, + onLeafMouseOver: _propTypes2.default.func, + onLeafMouseOut: _propTypes2.default.func, + scales: _propTypes2.default.object.isRequired, + width: _propTypes2.default.number.isRequired, + r: _propTypes2.default.number.isRequired, + x0: _propTypes2.default.number.isRequired, + x1: _propTypes2.default.number.isRequired, + y0: _propTypes2.default.number.isRequired, + y1: _propTypes2.default.number.isRequired +}; +exports.default = TreemapLeaf; \ No newline at end of file diff --git a/dist/treemap/treemap-svg.js b/dist/treemap/treemap-svg.js new file mode 100644 index 000000000..6255dafbc --- /dev/null +++ b/dist/treemap/treemap-svg.js @@ -0,0 +1,246 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _polygonSeries = require('../plot/series/polygon-series'); + +var _polygonSeries2 = _interopRequireDefault(_polygonSeries); + +var _markSeries = require('../plot/series/mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var MARGIN_ADJUST = 1.2; + +var TreemapSVG = function (_React$Component) { + _inherits(TreemapSVG, _React$Component); + + function TreemapSVG() { + _classCallCheck(this, TreemapSVG); + + return _possibleConstructorReturn(this, (TreemapSVG.__proto__ || Object.getPrototypeOf(TreemapSVG)).apply(this, arguments)); + } + + _createClass(TreemapSVG, [{ + key: 'getCircularNodes', + value: function getCircularNodes() { + var _props = this.props, + animation = _props.animation, + hideRootNode = _props.hideRootNode, + nodes = _props.nodes, + onLeafMouseOver = _props.onLeafMouseOver, + onLeafMouseOut = _props.onLeafMouseOut, + onLeafClick = _props.onLeafClick, + scales = _props.scales, + style = _props.style; + + var _nodes$reduce = nodes.reduce(function (acc, node, index) { + if (!index && hideRootNode) { + return acc; + } + var x = node.x, + y = node.y, + r = node.r; + + return { + maxY: Math.max(y + r, acc.maxY), + minY: Math.min(y - r, acc.minY), + maxX: Math.max(x + MARGIN_ADJUST * r, acc.maxX), + minX: Math.min(x - MARGIN_ADJUST * r, acc.minX), + rows: acc.rows.concat([{ + x: x, + y: y, + size: r, + color: scales.color(node) + }]) + }; + }, { + rows: [], + maxY: -Infinity, + minY: Infinity, + maxX: -Infinity, + minX: Infinity + }), + rows = _nodes$reduce.rows, + minY = _nodes$reduce.minY, + maxY = _nodes$reduce.maxY, + minX = _nodes$reduce.minX, + maxX = _nodes$reduce.maxX; + + return { + updatedNodes: _react2.default.createElement(_markSeries2.default, { + animation: animation, + className: 'rv-treemap__leaf rv-treemap__leaf--circle', + onSeriesMouseEnter: onLeafMouseOver, + onSeriesMouseLeave: onLeafMouseOut, + onSeriesClick: onLeafClick, + data: rows, + colorType: 'literal', + getColor: function getColor(d) { + return d.color; + }, + sizeType: 'literal', + getSize: function getSize(d) { + return d.size; + }, + style: style + }), + minY: minY, + maxY: maxY, + minX: minX, + maxX: maxX + }; + } + }, { + key: 'getNonCircularNodes', + value: function getNonCircularNodes() { + var _props2 = this.props, + animation = _props2.animation, + hideRootNode = _props2.hideRootNode, + nodes = _props2.nodes, + onLeafMouseOver = _props2.onLeafMouseOver, + onLeafMouseOut = _props2.onLeafMouseOut, + onLeafClick = _props2.onLeafClick, + scales = _props2.scales, + style = _props2.style; + var color = scales.color; + + return nodes.reduce(function (acc, node, index) { + if (!index && hideRootNode) { + return acc; + } + var x0 = node.x0, + x1 = node.x1, + y1 = node.y1, + y0 = node.y0; + + var x = x0; + var y = y0; + var nodeHeight = y1 - y0; + var nodeWidth = x1 - x0; + + acc.maxY = Math.max(y + nodeHeight, acc.maxY); + acc.minY = Math.min(y, acc.minY); + acc.maxX = Math.max(x + nodeWidth, acc.maxX); + acc.minX = Math.min(x, acc.minX); + + var data = [{ x: x, y: y }, { x: x, y: y + nodeHeight }, { x: x + nodeWidth, y: y + nodeHeight }, { x: x + nodeWidth, y: y }]; + + acc.updatedNodes = acc.updatedNodes.concat([_react2.default.createElement(_polygonSeries2.default, { + animation: animation, + className: 'rv-treemap__leaf', + key: index, + color: color(node), + type: 'literal', + onSeriesMouseEnter: onLeafMouseOver, + onSeriesMouseLeave: onLeafMouseOut, + onSeriesClick: onLeafClick, + data: data, + style: _extends({}, style, node.style) + })]); + return acc; + }, { + updatedNodes: [], + maxY: -Infinity, + minY: Infinity, + maxX: -Infinity, + minX: Infinity + }); + } + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + className = _props3.className, + height = _props3.height, + mode = _props3.mode, + nodes = _props3.nodes, + width = _props3.width; + + var useCirclePacking = mode === 'circlePack'; + + var _ref = useCirclePacking ? this.getCircularNodes() : this.getNonCircularNodes(), + minY = _ref.minY, + maxY = _ref.maxY, + minX = _ref.minX, + maxX = _ref.maxX, + updatedNodes = _ref.updatedNodes; + + var labels = nodes.reduce(function (acc, node) { + if (!node.data.title) { + return acc; + } + return acc.concat(_extends({}, node.data, { + x: node.x0 || node.x, + y: node.y0 || node.y, + label: '' + node.data.title + })); + }, []); + + return _react2.default.createElement( + _xyPlot2.default, + _extends({ + className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, + width: width, + height: height, + yDomain: [maxY, minY], + xDomain: [minX, maxX], + colorType: 'literal', + hasTreeStructure: true + }, this.props), + updatedNodes, + _react2.default.createElement(_labelSeries2.default, { data: labels }) + ); + } + }]); + + return TreemapSVG; +}(_react2.default.Component); + +TreemapSVG.displayName = 'TreemapSVG'; + +exports.default = TreemapSVG; \ No newline at end of file diff --git a/dist/utils/axis-utils.js b/dist/utils/axis-utils.js new file mode 100644 index 000000000..db9f09fa9 --- /dev/null +++ b/dist/utils/axis-utils.js @@ -0,0 +1,167 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.DIRECTION = exports.ORIENTATION = undefined; +exports.getTicksTotalFromSize = getTicksTotalFromSize; +exports.getTickValues = getTickValues; +exports.generateFit = generateFit; +exports.generatePoints = generatePoints; +exports.getAxisAngle = getAxisAngle; + +var _d3Array = require('d3-array'); + +var _d3Scale = require('d3-scale'); + +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var ORIENTATION = exports.ORIENTATION = { + TOP: 'top', + LEFT: 'left', + RIGHT: 'right', + BOTTOM: 'bottom', + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' +}; + +var DIRECTION = exports.DIRECTION = { + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' +}; + +/** + * Get total amount of ticks from a given size in pixels. + * @param {number} size Size of the axis in pixels. + * @returns {number} Total amount of ticks. + */ +function getTicksTotalFromSize(size) { + if (size < 700) { + if (size > 300) { + return 10; + } + return 5; + } + return 20; +} + +/** + * Get the tick values from a given d3 scale. + * @param {d3.scale} scale Scale function. + * @param {number} tickTotal Total number of ticks + * @param {Array} tickValues Array of tick values if they exist. + * @returns {Array} Array of tick values. + */ +function getTickValues(scale, tickTotal, tickValues) { + return !tickValues ? scale.ticks ? scale.ticks(tickTotal) : scale.domain() : tickValues; +} + +/** + * Generate a description of a decorative axis in terms of a linear equation + * y = slope * x + offset in coordinates + * @param {Object} axisStart Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @param {Object} axisEnd Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @returns {Number} Object describing each the line in coordinates + */ +function generateFit(axisStart, axisEnd) { + // address the special case when the slope is infinite + if (axisStart.x === axisEnd.x) { + return { + left: axisStart.y, + right: axisEnd.y, + slope: 0, + offset: axisStart.x + }; + } + var slope = (axisStart.y - axisEnd.y) / (axisStart.x - axisEnd.x); + return { + left: axisStart.x, + right: axisEnd.x, + // generate the linear projection of the axis direction + slope: slope, + offset: axisStart.y - slope * axisStart.x + }; +} + +/** + * Generate a description of a decorative axis in terms of a linear equation + * y = slope * x + offset in coordinates + * @param props + * props.@param {Object} axisStart Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * props.@param {Object} axisEnd Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * props.@param {Number} numberOfTicks The number of ticks on the axis + * props.@param {Array.Numbers} axisDomain The values to be interpolated across for the axis + * @returns {Number} Object describing the slope and the specific coordinates of the points + */ +function generatePoints(_ref) { + var axisStart = _ref.axisStart, + axisEnd = _ref.axisEnd, + numberOfTicks = _ref.numberOfTicks, + axisDomain = _ref.axisDomain; + + var _generateFit = generateFit(axisStart, axisEnd), + left = _generateFit.left, + right = _generateFit.right, + slope = _generateFit.slope, + offset = _generateFit.offset; + // construct a linear band of points, then map them + + + var pointSlope = (right - left) / numberOfTicks; + var axisScale = (0, _d3Scale.scaleLinear)().domain([left, right]).range(axisDomain); + + var slopeVertical = axisStart.x === axisEnd.x; + return { + slope: slopeVertical ? Infinity : slope, + points: (0, _d3Array.range)(left, right + pointSlope, pointSlope).map(function (val) { + if (slopeVertical) { + return { y: val, x: slope * val + offset, text: axisScale(val) }; + } + return { x: val, y: slope * val + offset, text: axisScale(val) }; + }).slice(0, numberOfTicks + 1) + }; +} + +/** + * Compute the angle (in radians) of a decorative axis + * @param {Object} axisStart Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @param {Object} axisEnd Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @returns {Number} Angle in radials + */ +function getAxisAngle(axisStart, axisEnd) { + if (axisStart.x === axisEnd.x) { + return axisEnd.y > axisStart.y ? Math.PI / 2 : 3 * Math.PI / 2; + } + return Math.atan((axisEnd.y - axisStart.y) / (axisEnd.x - axisStart.x)); +} + +exports.default = { + DIRECTION: DIRECTION, + ORIENTATION: ORIENTATION, + getTicksTotalFromSize: getTicksTotalFromSize, + getTickValues: getTickValues +}; \ No newline at end of file diff --git a/dist/utils/chart-utils.js b/dist/utils/chart-utils.js new file mode 100644 index 000000000..296899ae8 --- /dev/null +++ b/dist/utils/chart-utils.js @@ -0,0 +1,104 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.DEFAULT_MARGINS = exports.MarginPropType = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.getInnerDimensions = getInnerDimensions; +exports.getRadialLayoutMargin = getRadialLayoutMargin; + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Get the dimensions of the component for the future use. + * @param {Object} props Props. + * @param {Object} defaultMargins Object with default margins. + * @returns {Object} Dimensions of the component. + */ +function getInnerDimensions(props, defaultMargins) { + var margin = props.margin, + width = props.width, + height = props.height; + + var marginProps = _extends({}, defaultMargins, typeof margin === 'number' ? { + left: margin, + right: margin, + top: margin, + bottom: margin + } : margin); + var _marginProps$left = marginProps.left, + marginLeft = _marginProps$left === undefined ? 0 : _marginProps$left, + _marginProps$top = marginProps.top, + marginTop = _marginProps$top === undefined ? 0 : _marginProps$top, + _marginProps$right = marginProps.right, + marginRight = _marginProps$right === undefined ? 0 : _marginProps$right, + _marginProps$bottom = marginProps.bottom, + marginBottom = _marginProps$bottom === undefined ? 0 : _marginProps$bottom; + + return { + marginLeft: marginLeft, + marginTop: marginTop, + marginRight: marginRight, + marginBottom: marginBottom, + innerHeight: height - marginBottom - marginTop, + innerWidth: width - marginLeft - marginRight + }; +} + +/** + * Calculate the margin of the sunburst, + * so it can be at the center of the container + * @param {Number} width - the width of the container + * @param {Number} height - the height of the container + * @param {Number} radius - the max radius of the sunburst + * @return {Object} an object includes {bottom, left, right, top} + */ +function getRadialLayoutMargin(width, height, radius) { + var marginX = width / 2 - radius; + var marginY = height / 2 - radius; + return { + bottom: marginY, + left: marginX, + right: marginX, + top: marginY + }; +} + +var MarginPropType = exports.MarginPropType = _propTypes2.default.oneOfType([_propTypes2.default.shape({ + left: _propTypes2.default.number, + top: _propTypes2.default.number, + right: _propTypes2.default.number, + bottom: _propTypes2.default.number +}), _propTypes2.default.number]); + +var DEFAULT_MARGINS = exports.DEFAULT_MARGINS = { + left: 40, + right: 10, + top: 10, + bottom: 40 +}; \ No newline at end of file diff --git a/dist/utils/data-utils.js b/dist/utils/data-utils.js new file mode 100644 index 000000000..af24379d4 --- /dev/null +++ b/dist/utils/data-utils.js @@ -0,0 +1,54 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getUniquePropertyValues = getUniquePropertyValues; +exports.addValueToArray = addValueToArray; +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/** + * Get unique property values from an array. + * @param {Array} arr Array of data. + * @param {string} propertyName Prop name. + * @returns {Array} Array of unique values. + */ +function getUniquePropertyValues(arr, accessor) { + var setOfValues = new Set(arr.map(accessor)); + return Array.from(setOfValues); +} + +/** + * Add zero to the domain. + * @param {Array} arr Add zero to the domain. + * @param {Number} value Add zero to domain. + * @returns {Array} Adjusted domain. + */ +function addValueToArray(arr, value) { + var result = [].concat(arr); + if (result[0] > value) { + result[0] = value; + } + if (result[result.length - 1] < value) { + result[result.length - 1] = value; + } + return result; +} \ No newline at end of file diff --git a/dist/utils/react-utils.js b/dist/utils/react-utils.js new file mode 100644 index 000000000..7bc856814 --- /dev/null +++ b/dist/utils/react-utils.js @@ -0,0 +1,95 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getDOMNode = exports.isReactDOMSupported = undefined; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.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 (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.warning = warning; +exports.warnOnce = warnOnce; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _React$version$split = _react2.default.version.split('.'), + _React$version$split2 = _slicedToArray(_React$version$split, 2), + major = _React$version$split2[0], + minor = _React$version$split2[1]; + +var versionHigherThanThirteen = Number(minor) > 13 || Number(major) > 13; + +var isReactDOMSupported = exports.isReactDOMSupported = function isReactDOMSupported() { + return versionHigherThanThirteen; +}; + +/** + * Support React 0.13 and greater where refs are React components, not DOM + * nodes. + * @param {*} ref React's ref. + * @returns {Element} DOM element. + */ +var getDOMNode = exports.getDOMNode = function getDOMNode(ref) { + if (!isReactDOMSupported()) { + return ref && ref.getDOMNode(); + } + return ref; +}; + +var USED_MESSAGES = {}; +var HIDDEN_PROCESSES = { + test: true, + production: true +}; + +/** + * Warn the user about something + * @param {String} message - the message to be shown + * @param {Boolean} onlyShowMessageOnce - whether or not we allow the + - message to be show multiple times + */ +function warning(message) { + var onlyShowMessageOnce = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + /* eslint-disable no-undef, no-process-env */ + if (global.process && HIDDEN_PROCESSES[process.env.NODE_ENV]) { + return; + } + /* eslint-enable no-undef, no-process-env */ + if (!onlyShowMessageOnce || !USED_MESSAGES[message]) { + /* eslint-disable no-console */ + console.warn(message); + /* eslint-enable no-console */ + USED_MESSAGES[message] = true; + } +} + +/** + * Convience wrapper for warning + * @param {String} message - the message to be shown + */ +function warnOnce(message) { + warning(message, true); +} \ No newline at end of file diff --git a/dist/utils/scales-utils.js b/dist/utils/scales-utils.js new file mode 100644 index 000000000..ea61f3b49 --- /dev/null +++ b/dist/utils/scales-utils.js @@ -0,0 +1,916 @@ +'use strict'; + +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[Symbol.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 (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _SCALE_FUNCTIONS; + +exports._getSmallestDistanceIndex = _getSmallestDistanceIndex; +exports.getScaleFnFromScaleObject = getScaleFnFromScaleObject; +exports.getDomainByAccessor = getDomainByAccessor; +exports._getScaleDistanceAndAdjustedDomain = _getScaleDistanceAndAdjustedDomain; +exports._adjustCategoricalScale = _adjustCategoricalScale; +exports.getScaleObjectFromProps = getScaleObjectFromProps; +exports.getAttributeScale = getAttributeScale; +exports.getAttributeFunctor = getAttributeFunctor; +exports.getAttr0Functor = getAttr0Functor; +exports.getAttributeValue = getAttributeValue; +exports.getScalePropTypesByAttribute = getScalePropTypesByAttribute; +exports.extractScalePropsFromProps = extractScalePropsFromProps; +exports.getMissingScaleProps = getMissingScaleProps; +exports.literalScale = literalScale; +exports.getFontColorFromBackground = getFontColorFromBackground; +exports.getXYPlotValues = getXYPlotValues; +exports.getOptionalScaleProps = getOptionalScaleProps; + +var _d3Scale = require('d3-scale'); + +var _d3Array = require('d3-array'); + +var _d3Collection = require('d3-collection'); + +var _d3Color = require('d3-color'); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _reactUtils = require('./react-utils'); + +var _dataUtils = require('./data-utils'); + +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 _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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/** + * Linear scale name. + * @type {string} + * @const + */ +var LINEAR_SCALE_TYPE = 'linear'; + +/** + * Ordinal scale name. + * @type {string} + * @const + */ +var ORDINAL_SCALE_TYPE = 'ordinal'; + +/** + * Category scale. + * @type {string} + * @const + */ +var CATEGORY_SCALE_TYPE = 'category'; + +/** + * Literal scale. + * Differs slightly from d3's identity scale in that it does not coerce value + * into numbers, it simply returns exactly what you give it + * @type {string} + * @const + */ +var LITERAL_SCALE_TYPE = 'literal'; + +/** + * Log scale name. + * @type {string} + * @const + */ +var LOG_SCALE_TYPE = 'log'; + +/** + * Time scale name. + * @type {string} + * @const + */ +var TIME_SCALE_TYPE = 'time'; + +/** + * Time UTC scale name. + * @type {string} + * @const + */ +var TIME_UTC_SCALE_TYPE = 'time-utc'; + +/** + * Scale functions that are supported in the library. + * @type {Object} + * @const + */ +var SCALE_FUNCTIONS = (_SCALE_FUNCTIONS = {}, _defineProperty(_SCALE_FUNCTIONS, LINEAR_SCALE_TYPE, _d3Scale.scaleLinear), _defineProperty(_SCALE_FUNCTIONS, ORDINAL_SCALE_TYPE, _d3Scale.scalePoint), _defineProperty(_SCALE_FUNCTIONS, CATEGORY_SCALE_TYPE, _d3Scale.scaleOrdinal), _defineProperty(_SCALE_FUNCTIONS, LITERAL_SCALE_TYPE, literalScale), _defineProperty(_SCALE_FUNCTIONS, LOG_SCALE_TYPE, _d3Scale.scaleLog), _defineProperty(_SCALE_FUNCTIONS, TIME_SCALE_TYPE, _d3Scale.scaleTime), _defineProperty(_SCALE_FUNCTIONS, TIME_UTC_SCALE_TYPE, _d3Scale.scaleUtc), _SCALE_FUNCTIONS); + +/** + * Attrs for which a scale can be set up at XYPlot level + * @type {Array} + * @const + */ + +var XYPLOT_ATTR = ['color', 'fill', 'opacity', 'stroke']; + +/** + * Title case a given string + * @param {String} str Array of values. + * @returns {String} titlecased string + */ +function toTitleCase(str) { + return '' + str[0].toUpperCase() + str.slice(1); +} + +/** + * Find the smallest distance between the values on a given scale and return + * the index of the element, where the smallest distance was found. + * It returns the first occurrence of i where + * `scale(value[i]) - scale(value[i - 1])` is minimal + * @param {Array} values Array of values. + * @param {Object} scaleObject Scale object. + * @returns {number} Index of an element where the smallest distance was found. + * @private + */ +function _getSmallestDistanceIndex(values, scaleObject) { + var scaleFn = getScaleFnFromScaleObject(scaleObject); + var result = 0; + if (scaleFn) { + var nextValue = void 0; + var currentValue = scaleFn(values[0]); + var distance = Infinity; + var nextDistance = void 0; + + for (var i = 1; i < values.length; i++) { + nextValue = scaleFn(values[i]); + nextDistance = Math.abs(nextValue - currentValue); + if (nextDistance < distance) { + distance = nextDistance; + result = i; + } + currentValue = nextValue; + } + } + return result; +} + +/** + * This is a workaround for issue that ordinal scale + * does not have invert method implemented in d3-scale. + * @param {Object} Ordinal d3-scale object. + * @returns {void} + * @private + */ + +function addInvertFunctionToOrdinalScaleObject(scale) { + if (scale.invert) return; + + scale.invert = function (_) { + var domainIndex, + n = scale.domain().length, + reverse = scale.range()[1] < scale.range()[0], + start = scale.range()[reverse - 0], + stop = scale.range()[1 - reverse]; + + if (_ < start + scale.padding() * scale.step()) domainIndex = 0;else if (_ > stop - scale.padding() * scale.step()) domainIndex = n - 1;else domainIndex = Math.floor((_ - start - scale.padding() * scale.step()) / scale.step()); + + return scale.domain()[domainIndex]; + }; +} + +/** + * Crate a scale function from the scale object. + * @param {Object} scaleObject Scale object. + - scaleObject.domain {Array} + - scaleObject.range {Array} + - scaleObject.type {string} + - scaleObject.attr {string} + * @returns {*} Scale function. + * @private + */ +function getScaleFnFromScaleObject(scaleObject) { + if (!scaleObject) { + return null; + } + var type = scaleObject.type, + domain = scaleObject.domain, + range = scaleObject.range; + + var modDomain = domain[0] === domain[1] ? domain[0] === 0 ? [-1, 0] : [-domain[0], domain[0]] : domain; + if (type === LITERAL_SCALE_TYPE) { + return literalScale(range[0]); + } + var scale = SCALE_FUNCTIONS[type]().domain(modDomain).range(range); + if (type === ORDINAL_SCALE_TYPE) { + scale.padding(0.5); + addInvertFunctionToOrdinalScaleObject(scale); + } + return scale; +} + +/** + * Get the domain from the array of data. + * @param {Array} allData All data. + * @param {function} accessor - accessor for main value. + * @param {function} accessor0 - accessor for the naught value. + * @param {string} type Scale type. + * @returns {Array} Domain. + * @private + */ +function getDomainByAccessor(allData, accessor, accessor0, type) { + var domain = void 0; + + // Collect both attr and available attr0 values from the array of data. + var values = allData.reduce(function (data, d) { + var value = accessor(d); + var value0 = accessor0(d); + if (_isDefined(value)) { + data.push(value); + } + if (_isDefined(value0)) { + data.push(value0); + } + return data; + }, []); + + if (!values.length) { + return []; + } + + // Create proper domain depending on the type of the scale. + if (type !== ORDINAL_SCALE_TYPE && type !== CATEGORY_SCALE_TYPE) { + domain = (0, _d3Array.extent)(values); + } else { + domain = (0, _d3Collection.set)(values).values(); + } + return domain; +} + +/** + * Create custom scale object from the value. When the scale is created from + * this object, it should return the same value all time. + * @param {string} attr Attribute. + * @param {*} value Value. + * @param {string} type - the type of scale being used + * @param {function} accessor - the accessor function + * @param {function} accessor0 - the accessor function for the potential naught value + * @returns {Object} Custom scale object. + * @private + */ +function _createScaleObjectForValue(attr, value, type, accessor, accessor0) { + if (type === LITERAL_SCALE_TYPE) { + return { + type: LITERAL_SCALE_TYPE, + domain: [], + range: [value], + distance: 0, + attr: attr, + baseValue: undefined, + isValue: true, + accessor: accessor, + accessor0: accessor0 + }; + } + if (typeof value === 'undefined') { + return null; + } + return { + type: CATEGORY_SCALE_TYPE, + range: [value], + domain: [], + distance: 0, + attr: attr, + baseValue: undefined, + isValue: true, + accessor: accessor, + accessor0: accessor0 + }; +} + +/** + * Create a regular scale object for a further use from the existing parameters. + * @param {Array} domain - Domain. + * @param {Array} range - Range. + * @param {string} type - Type. + * @param {number} distance - Distance. + * @param {string} attr - Attribute. + * @param {number} baseValue - Base value. + * @param {function} accessor - Attribute accesor + * @param {function} accessor0 - Attribute accesor for potential naught value + * @returns {Object} Scale object. + * @private + */ +function _createScaleObjectForFunction(_ref) { + var domain = _ref.domain, + range = _ref.range, + type = _ref.type, + distance = _ref.distance, + attr = _ref.attr, + baseValue = _ref.baseValue, + accessor = _ref.accessor, + accessor0 = _ref.accessor0; + + return { + domain: domain, + range: range, + type: type, + distance: distance, + attr: attr, + baseValue: baseValue, + isValue: false, + accessor: accessor, + accessor0: accessor0 + }; +} + +/** + * Get scale object from props. E. g. object like {xRange, xDomain, xDistance, + * xType} is transformed into {range, domain, distance, type}. + * @param {Object} props Props. + * @param {string} attr Attribute. + * @returns {*} Null or an object with the scale. + * @private + */ +function _collectScaleObjectFromProps(props, attr) { + var value = props[attr], + fallbackValue = props['_' + attr + 'Value'], + range = props[attr + 'Range'], + _props$ = props[attr + 'Distance'], + distance = _props$ === undefined ? 0 : _props$, + baseValue = props[attr + 'BaseValue'], + _props$2 = props[attr + 'Type'], + type = _props$2 === undefined ? LINEAR_SCALE_TYPE : _props$2, + noFallBack = props[attr + 'NoFallBack'], + _props$3 = props['get' + toTitleCase(attr)], + accessor = _props$3 === undefined ? function (d) { + return d[attr]; + } : _props$3, + _props$4 = props['get' + toTitleCase(attr) + '0'], + accessor0 = _props$4 === undefined ? function (d) { + return d[attr + '0']; + } : _props$4; + var domain = props[attr + 'Domain']; + // Return value-based scale if the value is assigned. + + if (!noFallBack && typeof value !== 'undefined') { + return _createScaleObjectForValue(attr, value, props[attr + 'Type'], accessor, accessor0); + } + // Pick up the domain from the properties and create a new one if it's not + // available. + if (typeof baseValue !== 'undefined') { + domain = (0, _dataUtils.addValueToArray)(domain, baseValue); + } + + // Make sure that the minimum necessary properties exist. + if (!range || !domain || !domain.length) { + // Try to use the fallback value if it is available. + return _createScaleObjectForValue(attr, fallbackValue, props[attr + 'Type'], accessor, accessor0); + } + + return _createScaleObjectForFunction({ + domain: domain, + range: range, + type: type, + distance: distance, + attr: attr, + baseValue: baseValue, + accessor: accessor, + accessor0: accessor0 + }); +} + +/** + * Compute left domain adjustment for the given values. + * @param {Array} values Array of values. + * @returns {number} Domain adjustment. + * @private + */ +function _computeLeftDomainAdjustment(values) { + if (values.length > 1) { + return (values[1] - values[0]) / 2; + } + if (values.length === 1) { + return values[0] - 0.5; + } + return 0; +} + +/** + * Compute right domain adjustment for the given values. + * @param {Array} values Array of values. + * @returns {number} Domain adjustment. + * @private + */ +function _computeRightDomainAdjustment(values) { + if (values.length > 1) { + return (values[values.length - 1] - values[values.length - 2]) / 2; + } + if (values.length === 1) { + return values[0] - 0.5; + } + return 0; +} + +/** + * Compute distance for the given values. + * @param {Array} values Array of values. + * @param {Array} domain Domain. + * @param {number} bestDistIndex Index of a best distance found. + * @param {function} scaleFn Scale function. + * @returns {number} Domain adjustment. + * @private + */ +function _computeScaleDistance(values, domain, bestDistIndex, scaleFn) { + if (values.length > 1) { + // Avoid zero indexes. + var i = Math.max(bestDistIndex, 1); + return Math.abs(scaleFn(values[i]) - scaleFn(values[i - 1])); + } + if (values.length === 1) { + return Math.abs(scaleFn(domain[1]) - scaleFn(domain[0])); + } + return 0; +} + +/** + * Normilize array of values with a single value. + * @param {Array} arr Array of data. + * @param {Array} values Array of values. + * @param {string} attr Attribute. + * @param {string} type Type. + * @private + */ +function _normalizeValues(data, values, accessor0, type) { + if (type === TIME_SCALE_TYPE && values.length === 1) { + var attr0 = accessor0(data[0]); + + return [attr0].concat(_toConsumableArray(values)); + } + + return values; +} + +/** + * Get the distance, the smallest and the largest value of the domain. + * @param {Array} data Array of data for the single series. + * @param {Object} scaleObject Scale object. + * @returns {{domain0: number, domainN: number, distance: number}} Result. + * @private + */ +function _getScaleDistanceAndAdjustedDomain(data, scaleObject) { + var domain = scaleObject.domain, + type = scaleObject.type, + accessor = scaleObject.accessor, + accessor0 = scaleObject.accessor0; + + + var uniqueValues = (0, _dataUtils.getUniquePropertyValues)(data, accessor); + + // Fix time scale if a data has only one value. + var values = _normalizeValues(data, uniqueValues, accessor0, type); + var index = _getSmallestDistanceIndex(values, scaleObject); + + var adjustedDomain = [].concat(domain); + + adjustedDomain[0] -= _computeLeftDomainAdjustment(values); + adjustedDomain[domain.length - 1] += _computeRightDomainAdjustment(values); + // Fix log scale if it's too small. + if (type === LOG_SCALE_TYPE && domain[0] <= 0) { + adjustedDomain[0] = Math.min(domain[1] / 10, 1); + } + + var adjustedScaleFn = getScaleFnFromScaleObject(_extends({}, scaleObject, { + domain: adjustedDomain + })); + + var distance = _computeScaleDistance(values, adjustedDomain, index, adjustedScaleFn); + + return { + domain0: adjustedDomain[0], + domainN: adjustedDomain[adjustedDomain.length - 1], + distance: distance + }; +} + +/** + * Returns true if scale adjustments are possible for a given scale. + * @param {Object} props Props. + * @param {Object} scaleObject Scale object. + * @returns {boolean} True if scale adjustments possible. + * @private + */ +function _isScaleAdjustmentPossible(props, scaleObject) { + var attr = scaleObject.attr; + var _props$_adjustBy = props._adjustBy, + adjustBy = _props$_adjustBy === undefined ? [] : _props$_adjustBy, + _props$_adjustWhat = props._adjustWhat, + adjustWhat = _props$_adjustWhat === undefined ? [] : _props$_adjustWhat; + + // The scale cannot be adjusted if there's no attributes to adjust, no + // suitable values + + return adjustWhat.length && adjustBy.length && adjustBy.indexOf(attr) !== -1; +} + +/** + * Adjust continuous scales (e.g. 'linear', 'log' and 'time') by adding the + * space from the left and right of them and by computing the best distance. + * @param {Object} props Props. + * @param {Object} scaleObject Scale object. + * @returns {*} Scale object with adjustments. + * @private + */ +function _adjustContinuousScale(props, scaleObject) { + var allSeriesData = props._allData, + _props$_adjustWhat2 = props._adjustWhat, + adjustWhat = _props$_adjustWhat2 === undefined ? [] : _props$_adjustWhat2; + + // Assign the initial values. + + var domainLength = scaleObject.domain.length; + var domain = scaleObject.domain; + + var scaleDomain0 = domain[0]; + var scaleDomainN = domain[domainLength - 1]; + var scaleDistance = scaleObject.distance; + + // Find the smallest left position of the domain, the largest right position + // of the domain and the best distance for them. + allSeriesData.forEach(function (data, index) { + if (adjustWhat.indexOf(index) === -1) { + return; + } + if (data && data.length) { + var _getScaleDistanceAndA = _getScaleDistanceAndAdjustedDomain(data, scaleObject), + domain0 = _getScaleDistanceAndA.domain0, + domainN = _getScaleDistanceAndA.domainN, + distance = _getScaleDistanceAndA.distance; + + scaleDomain0 = Math.min(scaleDomain0, domain0); + scaleDomainN = Math.max(scaleDomainN, domainN); + scaleDistance = Math.max(scaleDistance, distance); + } + }); + + scaleObject.domain = [scaleDomain0].concat(_toConsumableArray(domain.slice(1, -1)), [scaleDomainN]); + + scaleObject.distance = scaleDistance; + + return scaleObject; +} + +/** + * Get an adjusted scale. Suitable for 'category' and 'ordinal' scales. + * @param {Object} scaleObject Scale object. + * @returns {*} Scale object with adjustments. + * @private + */ +function _adjustCategoricalScale(scaleObject) { + var scaleFn = getScaleFnFromScaleObject(scaleObject); + var domain = scaleObject.domain, + range = scaleObject.range; + + if (domain.length > 1) { + scaleObject.distance = Math.abs(scaleFn(domain[1]) - scaleFn(domain[0])); + } else { + scaleObject.distance = Math.abs(range[1] - range[0]); + } + + return scaleObject; +} + +/** + * Retrieve a scale object or a value from the properties passed. + * @param {Object} props Object of props. + * @param {string} attr Attribute. + * @returns {*} Scale object, value or null. + */ +function getScaleObjectFromProps(props, attr) { + // Create the initial scale object. + var scaleObject = _collectScaleObjectFromProps(props, attr); + if (!scaleObject) { + return null; + } + + // Make sure if it's possible to add space to the scale object. If not, + // return the object immediately. + if (!_isScaleAdjustmentPossible(props, scaleObject)) { + return scaleObject; + } + + var type = scaleObject.type; + // Depending on what type the scale is, apply different adjustments. Distances + // for the ordinal and category scales are even, equal domains cannot be + // adjusted. + + if (type === ORDINAL_SCALE_TYPE || type === CATEGORY_SCALE_TYPE) { + return _adjustCategoricalScale(scaleObject); + } + return _adjustContinuousScale(props, scaleObject); +} + +/** + * Get d3 scale for a given prop. + * @param {Object} props Props. + * @param {string} attr Attribute. + * @returns {function} d3 scale function. + */ +function getAttributeScale(props, attr) { + var scaleObject = getScaleObjectFromProps(props, attr); + return getScaleFnFromScaleObject(scaleObject); +} + +/** + * Get the value of `attr` from the object. + * @param {Object} d - data Object. + * @param {Function} accessor - accessor function. + * @returns {*} Value of the point. + * @private + */ +function _getAttrValue(d, accessor) { + return accessor(d.data ? d.data : d); +} + +function _isDefined(value) { + return typeof value !== 'undefined'; +} + +/* + * Adds a percentage of padding to a given domain + * @param {Array} domain X or Y domain to pad. + * @param {Number} padding Percentage of padding to add to domain + * @returns {Array} Padded Domain + */ +function _padDomain(domain, padding) { + if (!domain) { + return domain; + } + if (isNaN(parseFloat(domain[0])) || isNaN(parseFloat(domain[1]))) { + return domain; + } + + var _domain = _slicedToArray(domain, 2), + min = _domain[0], + max = _domain[1]; + + var domainPadding = (max - min) * (padding * 0.01); + return [min - domainPadding, max + domainPadding]; +} + +/** + * Get prop functor (either a value or a function) for a given attribute. + * @param {Object} props Series props. + * @param {Function} accessor - Property accessor. + * @returns {*} Function or value. + */ +function getAttributeFunctor(props, attr) { + var scaleObject = getScaleObjectFromProps(props, attr); + if (scaleObject) { + var scaleFn = getScaleFnFromScaleObject(scaleObject); + return function (d) { + return scaleFn(_getAttrValue(d, scaleObject.accessor)); + }; + } + return null; +} + +/** + * Get the functor which extracts value form [attr]0 property. Use baseValue if + * no attr0 property for a given object is defined. Fall back to domain[0] if no + * base value is available. + * @param {Object} props Object of props. + * @param {string} attr Attribute name. + * @returns {*} Function which returns value or null if no values available. + */ +function getAttr0Functor(props, attr) { + var scaleObject = getScaleObjectFromProps(props, attr); + if (scaleObject) { + var domain = scaleObject.domain; + var _scaleObject$baseValu = scaleObject.baseValue, + baseValue = _scaleObject$baseValu === undefined ? domain[0] : _scaleObject$baseValu; + + var scaleFn = getScaleFnFromScaleObject(scaleObject); + return function (d) { + var value = _getAttrValue(d, scaleObject.accessor0); + return scaleFn(_isDefined(value) ? value : baseValue); + }; + } + return null; +} + +/** + * Tries to get the string|number value of the attr and falls back to + * a fallback property in case if the value is a scale. + * @param {Object} props Series props. + * @param {string} attr Property name. + * @returns {*} Function or value. + */ +function getAttributeValue(props, attr) { + var scaleObject = getScaleObjectFromProps(props, attr); + if (scaleObject) { + if (!scaleObject.isValue && props['_' + attr + 'Value'] === undefined) { + (0, _reactUtils.warning)('[React-vis] Cannot use data defined ' + attr + ' for this ' + 'series type. Using fallback value instead.'); + } + return props['_' + attr + 'Value'] || scaleObject.range[0]; + } + return null; +} + +/** + * Get prop types by the attribute. + * @param {string} attr Attribute. + * @returns {Object} Object of xDomain, xRange, xType, xDistance and _xValue, + * where x is an attribute passed to the function. + */ +function getScalePropTypesByAttribute(attr) { + var _ref2; + + return _ref2 = {}, _defineProperty(_ref2, '_' + attr + 'Value', _propTypes2.default.any), _defineProperty(_ref2, attr + 'Domain', _propTypes2.default.array), _defineProperty(_ref2, 'get' + toTitleCase(attr), _propTypes2.default.func), _defineProperty(_ref2, 'get' + toTitleCase(attr) + '0', _propTypes2.default.func), _defineProperty(_ref2, attr + 'Range', _propTypes2.default.array), _defineProperty(_ref2, attr + 'Type', _propTypes2.default.oneOf(Object.keys(SCALE_FUNCTIONS))), _defineProperty(_ref2, attr + 'Distance', _propTypes2.default.number), _defineProperty(_ref2, attr + 'BaseValue', _propTypes2.default.any), _ref2; +} + +/** + * Extract the list of scale properties from the entire props object. + * @param {Object} props Props. + * @param {Array} attributes Array of attributes for the given + * components (for instance, `['x', 'y', 'color']`). + * @returns {Object} Collected props. + */ +function extractScalePropsFromProps(props, attributes) { + var result = {}; + Object.keys(props).forEach(function (key) { + // this filtering is critical for extracting the correct accessors! + var attr = attributes.find(function (a) { + // width + var isPlainSet = key.indexOf(a) === 0; + // Ex: _data + var isUnderscoreSet = key.indexOf('_' + a) === 0; + // EX: getX + var usesGet = key.indexOf('get' + toTitleCase(a)) === 0; + return isPlainSet || isUnderscoreSet || usesGet; + }); + if (!attr) { + return; + } + result[key] = props[key]; + }); + return result; +} + +/** + * Extract the missing scale props from the given data and return them as + * an object. + * @param {Object} props Props. + * @param {Array} data Array of all data. + * @param {Array} attributes Array of attributes for the given + * components (for instance, `['x', 'y', 'color']`). + * @returns {Object} Collected props. + */ +function getMissingScaleProps(props, data, attributes) { + var result = {}; + // Make sure that the domain is set pad it if specified + attributes.forEach(function (attr) { + if (!props['get' + toTitleCase(attr)]) { + result['get' + toTitleCase(attr)] = function (d) { + return d[attr]; + }; + } + if (!props['get' + toTitleCase(attr) + '0']) { + result['get' + toTitleCase(attr) + '0'] = function (d) { + return d[attr + '0']; + }; + } + if (!props[attr + 'Domain']) { + result[attr + 'Domain'] = getDomainByAccessor(data, props['get' + toTitleCase(attr)] || result['get' + toTitleCase(attr)], props['get' + toTitleCase(attr) + '0'] || result['get' + toTitleCase(attr) + '0'], props[attr + 'Type']); + if (props[attr + 'Padding']) { + result[attr + 'Domain'] = _padDomain(result[attr + 'Domain'], props[attr + 'Padding']); + } + } + }); + + return result; +} + +/** + * Return a d3 scale that returns the literal value that was given to it + * @returns {function} literal scale. + */ +function literalScale(defaultValue) { + function scale(d) { + if (d === undefined) { + return defaultValue; + } + return d; + } + + function response() { + return scale; + } + + scale.domain = response; + scale.range = response; + scale.unknown = response; + scale.copy = response; + + return scale; +} + +function getFontColorFromBackground(background) { + if (background) { + return (0, _d3Color.hsl)(background).l > 0.57 ? '#222' : '#fff'; + } + return null; +} + +/** + * Creates fallback values for series from scales defined at XYPlot level. + * @param {Object} props Props of the XYPlot object. + * @param {Array} children Array of components, children of XYPlot + * @returns {Array} Collected props. + */ + +function getXYPlotValues(props, children) { + var XYPlotScales = XYPLOT_ATTR.reduce(function (prev, attr) { + var domain = props[attr + 'Domain'], + range = props[attr + 'Range'], + type = props[attr + 'Type']; + + + if (domain && range && type) { + return _extends({}, prev, _defineProperty({}, attr, SCALE_FUNCTIONS[type]().domain(domain).range(range))); + } + return prev; + }, {}); + + return children.map(function (child) { + return XYPLOT_ATTR.reduce(function (prev, attr) { + if (child.props && child.props[attr] !== undefined) { + var scaleInput = child.props[attr]; + var scale = XYPlotScales[attr]; + var fallbackValue = scale ? scale(scaleInput) : scaleInput; + return _extends({}, prev, _defineProperty({}, '_' + attr + 'Value', fallbackValue)); + } + return prev; + }, {}); + }); +} + +var OPTIONAL_SCALE_PROPS = ['Padding']; +var OPTIONAL_SCALE_PROPS_REGS = OPTIONAL_SCALE_PROPS.map(function (str) { + return new RegExp(str + '$', 'i'); +}); +/** + * Get the list of optional scale-related settings for XYPlot + * mostly just used to find padding properties + * @param {Object} props Object of props. + * @returns {Object} Optional Props. + * @private + */ +function getOptionalScaleProps(props) { + return Object.keys(props).reduce(function (acc, prop) { + var propIsNotOptional = OPTIONAL_SCALE_PROPS_REGS.every(function (reg) { + return !prop.match(reg); + }); + if (propIsNotOptional) { + return acc; + } + acc[prop] = props[prop]; + return acc; + }, {}); +} + +exports.default = { + extractScalePropsFromProps: extractScalePropsFromProps, + getAttributeScale: getAttributeScale, + getAttributeFunctor: getAttributeFunctor, + getAttr0Functor: getAttr0Functor, + getAttributeValue: getAttributeValue, + getDomainByAccessor: getDomainByAccessor, + getFontColorFromBackground: getFontColorFromBackground, + getMissingScaleProps: getMissingScaleProps, + getOptionalScaleProps: getOptionalScaleProps, + getScaleObjectFromProps: getScaleObjectFromProps, + getScalePropTypesByAttribute: getScalePropTypesByAttribute, + getXYPlotValues: getXYPlotValues, + literalScale: literalScale +}; \ No newline at end of file diff --git a/dist/utils/series-utils.js b/dist/utils/series-utils.js new file mode 100644 index 000000000..7e1796dbe --- /dev/null +++ b/dist/utils/series-utils.js @@ -0,0 +1,268 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ANIMATED_SERIES_PROPS = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.isSeriesChild = isSeriesChild; +exports.getSeriesChildren = getSeriesChildren; +exports.getStackedData = getStackedData; +exports.getSeriesPropsFromChildren = getSeriesPropsFromChildren; +exports.getRadialDomain = getRadialDomain; +exports.getStackParams = getStackParams; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _abstractSeries = require('../plot/series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _theme = require('../theme'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +/** + * Check if the component is series or not. + * @param {React.Component} child Component. + * @returns {boolean} True if the child is series, false otherwise. + */ +function isSeriesChild(child) { + var prototype = child.type.prototype; + + return prototype instanceof _abstractSeries2.default; +} + +/** + * Get all series from the 'children' object of the component. + * @param {Object} children Children. + * @returns {Array} Array of children. + */ +function getSeriesChildren(children) { + return _react2.default.Children.toArray(children).filter(function (child) { + return child && isSeriesChild(child); + }); +} + +/** + * Collect the map of repetitions of the series type for all children. + * @param {Array} children Array of children. + * @returns {{}} Map of repetitions where sameTypeTotal is the total amount and + * sameTypeIndex is always 0. + */ +function collectSeriesTypesInfo(children) { + var result = {}; + children.filter(isSeriesChild).forEach(function (child) { + var displayName = child.type.displayName; + var cluster = child.props.cluster; + + if (!result[displayName]) { + result[displayName] = { + sameTypeTotal: 0, + sameTypeIndex: 0, + clusters: new Set() + }; + } + result[displayName].clusters.add(cluster); + result[displayName].sameTypeTotal++; + }); + return result; +} + +/** + * Check series to see if it has angular data that needs to be converted + * @param {Array} data - an array of objects to check + * @returns {Boolean} whether or not this series contains polar configuration + */ +function seriesHasAngleRadius() { + var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (!data) { + return false; + } + return data.some(function (row) { + return row.radius && row.angle; + }); +} + +/** + * Possibly convert polar coordinates to x/y for computing domain + * @param {Array} data - an array of objects to check + * @param {String} attr - the property being checked + * @returns {Boolean} whether or not this series contains polar configuration + */ +function prepareData(data) { + if (!seriesHasAngleRadius(data)) { + return data; + } + + return data.map(function (row) { + return _extends({}, row, { + x: row.radius * Math.cos(row.angle), + y: row.radius * Math.sin(row.angle) + }); + }); +} + +/** + * Collect the stacked data for all children in use. If the children don't have + * the data (e.g. the child is invalid series or something else), then the child + * is skipped. + * Each next value of attr is equal to the previous value plus the difference + * between attr0 and attr. + * @param {Array} children Array of children. + * @param {string} attr Attribute to stack by. + * @returns {Array} New array of children for the series. + */ +function getStackedData(children, attr) { + var areSomeSeriesStacked = children.some(function (series) { + return series && series.props.stack; + }); + // It stores the last segment position added to each bar, separated by cluster. + var latestAttrPositions = {}; + + return children.reduce(function (accumulator, series, seriesIndex) { + // Skip the children that are not series (e.g. don't have any data). + if (!series) { + accumulator.push(null); + return accumulator; + } + + var _series$props = series.props, + data = _series$props.data, + _series$props$cluster = _series$props.cluster, + cluster = _series$props$cluster === undefined ? 'default' : _series$props$cluster, + stack = _series$props.stack; + + var preppedData = prepareData(data, attr); + + if (!attr || !preppedData || !preppedData.length || areSomeSeriesStacked && !stack) { + accumulator.push(preppedData); + return accumulator; + } + + var attr0 = attr + '0'; + var baseAttr = attr === 'y' ? 'x' : 'y'; + + accumulator.push(preppedData.map(function (d, dIndex) { + var _extends2, _latestAttrPositions$2; + + if (!latestAttrPositions[cluster]) { + latestAttrPositions[cluster] = {}; + } + + var prevD = latestAttrPositions[cluster][d[baseAttr]]; + // It is the first segment of a bar. + if (!prevD) { + var _latestAttrPositions$; + + latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$ = {}, _defineProperty(_latestAttrPositions$, attr0, d[attr0]), _defineProperty(_latestAttrPositions$, attr, d[attr]), _latestAttrPositions$); + + return _extends({}, d); + } + + // Calculate the position of the next segment in a bar. + var nextD = _extends({}, d, (_extends2 = {}, _defineProperty(_extends2, attr0, prevD[attr]), _defineProperty(_extends2, attr, prevD[attr] + d[attr] - (d[attr0] || 0)), _extends2)); + + latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$2 = {}, _defineProperty(_latestAttrPositions$2, attr0, nextD[attr0]), _defineProperty(_latestAttrPositions$2, attr, nextD[attr]), _latestAttrPositions$2); + + return nextD; + })); + + return accumulator; + }, []); +} + +/** + * Get the list of series props for a child. + * @param {Array} children Array of all children. + * @returns {Array} Array of series props for each child. If a child is not a + * series, than it's undefined. + */ +function getSeriesPropsFromChildren(children) { + var result = []; + var seriesTypesInfo = collectSeriesTypesInfo(children); + var seriesIndex = 0; + var _opacityValue = _theme.DEFAULT_OPACITY; + children.forEach(function (child) { + var props = void 0; + if (isSeriesChild(child)) { + var seriesTypeInfo = seriesTypesInfo[child.type.displayName]; + var _colorValue = _theme.DISCRETE_COLOR_RANGE[seriesIndex % _theme.DISCRETE_COLOR_RANGE.length]; + props = _extends({}, seriesTypeInfo, { + seriesIndex: seriesIndex, + _colorValue: _colorValue, + _opacityValue: _opacityValue + }); + seriesTypeInfo.sameTypeIndex++; + seriesIndex++; + if (child.props.cluster) { + props.cluster = child.props.cluster; + // Using Array.from() so we can use .indexOf + props.clusters = Array.from(seriesTypeInfo.clusters); + props.sameTypeTotal = props.clusters.length; + props.sameTypeIndex = props.clusters.indexOf(child.props.cluster); + } + } + result.push(props); + }); + return result; +} + +/** + * Find the max radius value from the nodes to be rendered after they have been + * transformed into an array + * @param {Array} data - the tree data after it has been broken into a iterable + * it is an array of objects! + * @returns {number} the maximum value in coordinates for the radial variable + */ +function getRadialDomain(data) { + return data.reduce(function (res, row) { + return Math.max(row.radius, res); + }, 0); +} + +var ANIMATED_SERIES_PROPS = exports.ANIMATED_SERIES_PROPS = ['xRange', 'xDomain', 'x', 'yRange', 'yDomain', 'y', 'colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'strokeRange', 'strokeDomain', 'stroke', 'fillRange', 'fillDomain', 'fill', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'data', 'angleDomain', 'angleRange', 'angle', 'radiusDomain', 'radiusRange', 'radius', 'innerRadiusDomain', 'innerRadiusRange', 'innerRadius']; + +function getStackParams(props) { + var _stackBy = props._stackBy, + valuePosAttr = props.valuePosAttr, + cluster = props.cluster; + var _props$sameTypeTotal = props.sameTypeTotal, + sameTypeTotal = _props$sameTypeTotal === undefined ? 1 : _props$sameTypeTotal, + _props$sameTypeIndex = props.sameTypeIndex, + sameTypeIndex = _props$sameTypeIndex === undefined ? 0 : _props$sameTypeIndex; + + // If bars are stacked, but not clustering, override `sameTypeTotal` and + // `sameTypeIndex` such that bars are stacked and not staggered. + + if (_stackBy === valuePosAttr && !cluster) { + sameTypeTotal = 1; + sameTypeIndex = 0; + } + return { sameTypeTotal: sameTypeTotal, sameTypeIndex: sameTypeIndex }; +} \ No newline at end of file From 60071ca119f40ce9e8aa0e230af334fb76d83556 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Tue, 20 Nov 2018 12:20:50 +0100 Subject: [PATCH 03/10] Fixing linting errors. --- dist/dist.min.js | 24 ++++++++++++------------ dist/index.js | 15 ++++++++++++++- dist/plot/series/label-series.js | 4 ++-- dist/utils/scales-utils.js | 16 ++++++++-------- src/utils/scales-utils.js | 18 +++++++++--------- 5 files changed, 45 insertions(+), 32 deletions(-) diff --git a/dist/dist.min.js b/dist/dist.min.js index 5785693d1..7e2599c21 100644 --- a/dist/dist.min.js +++ b/dist/dist.min.js @@ -9,15 +9,15 @@ Y:parseFullYear,Z:parseZone,"%":parseLiteralPercent};formats.x=newFormat(locale_ ;setEdgeEnd(rArc.edge,lSite,rSite,vertex);newArc.edge=createEdge(lSite,site,null,vertex);rArc.edge=createEdge(site,rSite,null,vertex);attachCircle(lArc);attachCircle(rArc)}function leftBreakPoint(arc,directrix){var site=arc.site,rfocx=site[0],rfocy=site[1],pby2=rfocy-directrix;if(!pby2)return rfocx;var lArc=arc.P;if(!lArc)return-Infinity;site=lArc.site;var lfocx=site[0],lfocy=site[1],plby2=lfocy-directrix;if(!plby2)return lfocx;var hl=lfocx-rfocx,aby2=1/pby2-1/plby2,b=hl/plby2;if(aby2)return(-b+Math.sqrt(b*b-2*aby2*(hl*hl/(-2*plby2)-lfocy+plby2/2+rfocy-pby2/2)))/aby2+rfocx;return(rfocx+lfocx)/2}function rightBreakPoint(arc,directrix){var rArc=arc.N;if(rArc)return leftBreakPoint(rArc,directrix);var site=arc.site;return site[1]===directrix?site[0]:Infinity}var epsilon=1e-6;var epsilon2=1e-12;var beaches;var cells;var circles;var edges;function triangleArea(a,b,c){return(a[0]-c[0])*(b[1]-a[1])-(a[0]-b[0])*(c[1]-a[1])}function lexicographic(a,b){return b[1]-a[1]||b[0]-a[0]}function Diagram(sites,extent){var site=sites.sort(lexicographic).pop(),x,y,circle;edges=[];cells=new Array(sites.length);beaches=new RedBlackTree;circles=new RedBlackTree;while(true){circle=firstCircle;if(site&&(!circle||site[1]=n)return null;var dx=x-cell.site[0],dy=y-cell.site[1],d2=dx*dx+dy*dy;do{cell=that.cells[i0=i1],i1=null;cell.halfedges.forEach(function(e){var edge=that.edges[e],v=edge.left;if((v===cell.site||!v)&&!(v=edge.right))return;var vx=x-v[0],vy=y-v[1],v2=vx*vx+vy*vy;if(v20&&typeof x[0]!=="number")return false;return true}function objEquiv(a,b,opts){var i,key;if(isUndefinedOrNull(a)||isUndefinedOrNull(b))return false;if(a.prototype!==b.prototype)return false;if(isArguments(a)){if(!isArguments(b)){return false}a=pSlice.call(a);b=pSlice.call(b);return deepEqual(a,b,opts)}if(isBuffer(a)){if(!isBuffer(b)){return false}if(a.length!==b.length)return false;for(i=0;i=0;i--){if(ka[i]!=kb[i])return false}for(i=ka.length-1;i>=0;i--){key=ka[i];if(!deepEqual(a[key],b[key],opts))return false}return typeof a===typeof b}},{"./lib/is_arguments.js":20,"./lib/keys.js":21}],20:[function(require,module,exports){var supportsArgumentsClass=function(){return Object.prototype.toString.call(arguments)}()=="[object Arguments]";exports=module.exports=supportsArgumentsClass?supported:unsupported;exports.supported=supported;function supported(object){return Object.prototype.toString.call(object)=="[object Arguments]"}exports.unsupported=unsupported;function unsupported(object){return object&&typeof object=="object"&&typeof object.length=="number"&&Object.prototype.hasOwnProperty.call(object,"callee")&&!Object.prototype.propertyIsEnumerable.call(object,"callee")||false}},{}],21:[function(require,module,exports){exports=module.exports=typeof Object.keys==="function"?Object.keys:shim;exports.shim=shim;function shim(obj){var keys=[];for(var key in obj)keys.push(key);return keys}},{}],22:[function(require,module,exports){"use strict";function makeEmptyFunction(arg){return function(){return arg}}var emptyFunction=function emptyFunction(){};emptyFunction.thatReturns=makeEmptyFunction;emptyFunction.thatReturnsFalse=makeEmptyFunction(false);emptyFunction.thatReturnsTrue=makeEmptyFunction(true);emptyFunction.thatReturnsNull=makeEmptyFunction(null);emptyFunction.thatReturnsThis=function(){return this};emptyFunction.thatReturnsArgument=function(arg){return arg};module.exports=emptyFunction},{}],23:[function(require,module,exports){(function(process){"use strict";var emptyObject={};if(process.env.NODE_ENV!=="production"){Object.freeze(emptyObject)}module.exports=emptyObject}).call(this,require("_process"))},{_process:1}],24:[function(require,module,exports){(function(process){"use strict";var validateFormat=function validateFormat(format){};if(process.env.NODE_ENV!=="production"){validateFormat=function validateFormat(format){if(format===undefined){throw new Error("invariant requires an error message argument")}}}function invariant(condition,format,a,b,c,d,e,f){validateFormat(format);if(!condition){var error;if(format===undefined){error=new Error("Minified exception occurred; use the non-minified dev environment "+"for the full error message and additional helpful warnings.")}else{var args=[a,b,c,d,e,f];var argIndex=0;error=new Error(format.replace(/%s/g,function(){return args[argIndex++]}));error.name="Invariant Violation"}error.framesToPop=1;throw error}}module.exports=invariant}).call(this,require("_process"))},{_process:1}],25:[function(require,module,exports){(function(process){"use strict";var emptyFunction=require("./emptyFunction");var warning=emptyFunction;if(process.env.NODE_ENV!=="production"){var printWarning=function printWarning(format){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.error(message)}try{throw new Error(message)}catch(x){}};warning=function warning(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(format.indexOf("Failed Composite propType: ")===0){return}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=warning}).call(this,require("_process"))},{"./emptyFunction":22,_process:1}],26:[function(require,module,exports){(function(global){var win;if(typeof window!=="undefined"){win=window}else if(typeof global!=="undefined"){win=global}else if(typeof self!=="undefined"){win=self}else{win={}}module.exports=win}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],27:[function(require,module,exports){"use strict";var getOwnPropertySymbols=Object.getOwnPropertySymbols;var hasOwnProperty=Object.prototype.hasOwnProperty;var propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(val===null||val===undefined){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(val)}function shouldUseNative(){try{if(!Object.assign){return false}var test1=new String("abc");test1[5]="de";if(Object.getOwnPropertyNames(test1)[0]==="5"){return false}var test2={};for(var i=0;i<10;i++){test2["_"+String.fromCharCode(i)]=i}var order2=Object.getOwnPropertyNames(test2).map(function(n){return test2[n]});if(order2.join("")!=="0123456789"){return false}var test3={};"abcdefghijklmnopqrst".split("").forEach(function(letter){test3[letter]=letter});if(Object.keys(Object.assign({},test3)).join("")!=="abcdefghijklmnopqrst"){return false}return true}catch(err){return false}}module.exports=shouldUseNative()?Object.assign:function(target,source){var from;var to=toObject(target);var symbols;for(var s=1;smsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var newLastIdealStyle={};var newLastIdealVelocity={};var newCurrentStyle={};var newCurrentVelocity={};for(var key in propsStyle){if(!Object.prototype.hasOwnProperty.call(propsStyle,key)){continue}var styleValue=propsStyle[key];if(typeof styleValue==="number"){newCurrentStyle[key]=styleValue;newCurrentVelocity[key]=0;newLastIdealStyle[key]=styleValue;newLastIdealVelocity[key]=0}else{var newLastIdealStyleValue=_this.state.lastIdealStyle[key];var newLastIdealVelocityValue=_this.state.lastIdealVelocity[key];for(var i=0;imsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var newLastIdealStyles=[];var newLastIdealVelocities=[];var newCurrentStyles=[];var newCurrentVelocities=[];for(var i=0;imsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var _mergeAndSync2=mergeAndSync(_this.props.willEnter,_this.props.willLeave,_this.props.didLeave,_this.state.mergedPropsStyles,destStyles,_this.state.currentStyles,_this.state.currentVelocities,_this.state.lastIdealStyles,_this.state.lastIdealVelocities);var newMergedPropsStyles=_mergeAndSync2[0];var newCurrentStyles=_mergeAndSync2[1];var newCurrentVelocities=_mergeAndSync2[2];var newLastIdealStyles=_mergeAndSync2[3];var newLastIdealVelocities=_mergeAndSync2[4];for(var i=0;iprevKeyIndex[pivot]){return-1}else if(nextOrderA>nextKeyIndex[pivot]&&prevOrderBprevKeyIndex[pivot]){return 1}else if(nextOrderB>nextKeyIndex[pivot]&&prevOrderA1){var childArray=Array(childrenLength);for(var i=0;i1){var childArray=Array(childrenLength);for(var i=0;i."}}return info}function validateExplicitKey(element,parentType){if(!element._store||element._store.validated||element.key!=null){return}element._store.validated=true;var memoizer=ownerHasKeyUseWarning.uniqueKey||(ownerHasKeyUseWarning.uniqueKey={});var currentComponentErrorInfo=getCurrentComponentErrorInfo(parentType);if(memoizer[currentComponentErrorInfo]){return}memoizer[currentComponentErrorInfo]=true;var childOwner="";if(element&&element._owner&&element._owner!==ReactCurrentOwner.current){childOwner=" It was passed a child from "+element._owner.getName()+"."}process.env.NODE_ENV!=="production"?warning(false,'Each child in an array or iterator should have a unique "key" prop.'+"%s%s See https://fb.me/react-warning-keys for more information.%s",currentComponentErrorInfo,childOwner,ReactComponentTreeHook.getCurrentStackAddendum(element)):void 0}function validateChildKeys(node,parentType){if(typeof node!=="object"){return}if(Array.isArray(node)){for(var i=0;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.warn(message)}try{throw new Error(message)}catch(x){}};lowPriorityWarning=function(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=lowPriorityWarning}).call(this,require("_process"))},{_process:1}],70:[function(require,module,exports){(function(process){"use strict";var _prodInvariant=require("./reactProdInvariant");var ReactElement=require("./ReactElement");var invariant=require("fbjs/lib/invariant");function onlyChild(children){!ReactElement.isValidElement(children)?process.env.NODE_ENV!=="production"?invariant(false,"React.Children.only expected to receive a single React element child."):_prodInvariant("143"):void 0;return children}module.exports=onlyChild}).call(this,require("_process"))},{"./ReactElement":57,"./reactProdInvariant":71,_process:1,"fbjs/lib/invariant":24}],71:[function(require,module,exports){"use strict";function reactProdInvariant(code){var argCount=arguments.length-1;var message="Minified React error #"+code+"; visit "+"http://facebook.github.io/react/docs/error-decoder.html?invariant="+code;for(var argIdx=0;argIdx=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}var ANIMATION_PROPTYPES=_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.shape({stiffness:_propTypes2.default.number,nonAnimatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string),damping:_propTypes2.default.number}),_propTypes2.default.bool]);var propTypes={animatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string).isRequired,animation:ANIMATION_PROPTYPES,onStart:_propTypes2.default.func,onEnd:_propTypes2.default.func};function getAnimationStyle(){var animationStyle=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_reactMotion.presets.noWobble;if(typeof animationStyle==="string"){return _reactMotion.presets[animationStyle]||_reactMotion.presets.noWobble}var damping=animationStyle.damping,stiffness=animationStyle.stiffness;return _extends({damping:damping||_reactMotion.presets.noWobble.damping,stiffness:stiffness||_reactMotion.presets.noWobble.stiffness},animationStyle)}function extractAnimatedPropValues(props){var animatedProps=props.animatedProps,otherProps=_objectWithoutProperties(props,["animatedProps"]);return animatedProps.reduce(function(result,animatedPropName){if(otherProps.hasOwnProperty(animatedPropName)){result[animatedPropName]=otherProps[animatedPropName]}return result},{})}var Animation=function(_PureComponent){_inherits(Animation,_PureComponent);function Animation(props){_classCallCheck(this,Animation);var _this=_possibleConstructorReturn(this,(Animation.__proto__||Object.getPrototypeOf(Animation)).call(this,props));_this._motionEndHandler=function(){if(_this.props.onEnd){_this.props.onEnd()}};_this._renderChildren=function(_ref){var i=_ref.i;var children=_this.props.children;var interpolator=_this._interpolator;var child=_react2.default.Children.only(children);var interpolatedProps=interpolator?interpolator(i):interpolator;var data=interpolatedProps&&interpolatedProps.data||null;if(data&&child.props._data){data=data.map(function(row,index){var correspondingCell=child.props._data[index];return _extends({},row,{parent:correspondingCell.parent,children:correspondingCell.children})})}return _react2.default.cloneElement(child,_extends({},child.props,interpolatedProps,{data:data||child.props.data||null,_animation:Math.random()}))};_this._updateInterpolator(props);return _this}_createClass(Animation,[{key:"componentWillUpdate",value:function componentWillUpdate(props){this._updateInterpolator(this.props,props);if(props.onStart){props.onStart()}}},{key:"_updateInterpolator",value:function _updateInterpolator(oldProps,newProps){this._interpolator=(0,_d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps),newProps?extractAnimatedPropValues(newProps):null)}},{key:"render",value:function render(){var animationStyle=getAnimationStyle(this.props.animation);var defaultStyle={i:0};var style={i:(0,_reactMotion.spring)(1,animationStyle)};var key=Math.random();return _react2.default.createElement(_reactMotion.Motion,_extends({defaultStyle:defaultStyle,style:style,key:key},{onRest:this._motionEndHandler}),this._renderChildren)}}]);return Animation}(_react.PureComponent);Animation.propTypes=propTypes;Animation.displayName="Animation";exports.default=Animation;var AnimationPropType=exports.AnimationPropType=ANIMATION_PROPTYPES},{"d3-interpolate":11,"prop-types":33,react:73,"react-motion":43}],75:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ScaleUtils=exports.AxisUtils=exports.FlexibleHeightXYPlot=exports.FlexibleWidthXYPlot=exports.FlexibleXYPlot=exports.makeWidthFlexible=exports.makeVisFlexible=exports.makeHeightFlexible=exports.Sunburst=exports.Sankey=exports.ParallelCoordinates=exports.RadarChart=exports.RadialChart=exports.Treemap=exports.ContinuousSizeLegend=exports.ContinuousColorLegend=exports.SearchableDiscreteColorLegend=exports.DiscreteColorLegend=exports.Highlight=exports.Voronoi=exports.HorizontalGridLines=exports.VerticalGridLines=exports.GradientDefs=exports.GridLines=exports.CircularGridLines=exports.YAxis=exports.XAxis=exports.DecorativeAxis=exports.XYPlot=exports.Crosshair=exports.Borders=exports.Hint=exports.LineMarkSeriesCanvas=exports.LineMarkSeries=exports.ArcSeries=exports.AreaSeries=exports.CustomSVGSeries=exports.ContourSeries=exports.HexbinSeries=exports.HeatmapSeries=exports.WhiskerSeries=exports.MarkSeriesCanvas=exports.MarkSeries=exports.RectSeriesCanvas=exports.RectSeries=exports.PolygonSeries=exports.LabelSeries=exports.HorizontalRectSeriesCanvas=exports.HorizontalRectSeries=exports.VerticalRectSeriesCanvas=exports.VerticalRectSeries=exports.VerticalBarSeriesCanvas=exports.VerticalBarSeries=exports.HorizontalBarSeriesCanvas=exports.HorizontalBarSeries=exports.LineSeriesCanvas=exports.LineSeries=exports.AbstractSeries=undefined;var _makeVisFlexible=require("./make-vis-flexible");Object.defineProperty(exports,"makeHeightFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeHeightFlexible}});Object.defineProperty(exports,"makeVisFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeVisFlexible}});Object.defineProperty(exports,"makeWidthFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeWidthFlexible}});Object.defineProperty(exports,"FlexibleXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleXYPlot}});Object.defineProperty(exports,"FlexibleWidthXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleWidthXYPlot}});Object.defineProperty(exports,"FlexibleHeightXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleHeightXYPlot}});var _abstractSeries=require("./plot/series/abstract-series");var _abstractSeries2=_interopRequireDefault(_abstractSeries);var _lineSeries=require("./plot/series/line-series");var _lineSeries2=_interopRequireDefault(_lineSeries);var _lineSeriesCanvas=require("./plot/series/line-series-canvas");var _lineSeriesCanvas2=_interopRequireDefault(_lineSeriesCanvas);var _horizontalBarSeries=require("./plot/series/horizontal-bar-series");var _horizontalBarSeries2=_interopRequireDefault(_horizontalBarSeries);var _horizontalBarSeriesCanvas=require("./plot/series/horizontal-bar-series-canvas");var _horizontalBarSeriesCanvas2=_interopRequireDefault(_horizontalBarSeriesCanvas);var _verticalBarSeries=require("./plot/series/vertical-bar-series");var _verticalBarSeries2=_interopRequireDefault(_verticalBarSeries);var _verticalBarSeriesCanvas=require("./plot/series/vertical-bar-series-canvas");var _verticalBarSeriesCanvas2=_interopRequireDefault(_verticalBarSeriesCanvas);var _verticalRectSeries=require("./plot/series/vertical-rect-series");var _verticalRectSeries2=_interopRequireDefault(_verticalRectSeries);var _verticalRectSeriesCanvas=require("./plot/series/vertical-rect-series-canvas");var _verticalRectSeriesCanvas2=_interopRequireDefault(_verticalRectSeriesCanvas);var _horizontalRectSeries=require("./plot/series/horizontal-rect-series");var _horizontalRectSeries2=_interopRequireDefault(_horizontalRectSeries);var _horizontalRectSeriesCanvas=require("./plot/series/horizontal-rect-series-canvas");var _horizontalRectSeriesCanvas2=_interopRequireDefault(_horizontalRectSeriesCanvas);var _labelSeries=require("./plot/series/label-series");var _labelSeries2=_interopRequireDefault(_labelSeries);var _polygonSeries=require("./plot/series/polygon-series");var _polygonSeries2=_interopRequireDefault(_polygonSeries);var _rectSeries=require("./plot/series/rect-series");var _rectSeries2=_interopRequireDefault(_rectSeries);var _rectSeriesCanvas=require("./plot/series/rect-series-canvas");var _rectSeriesCanvas2=_interopRequireDefault(_rectSeriesCanvas);var _markSeries=require("./plot/series/mark-series");var _markSeries2=_interopRequireDefault(_markSeries);var _markSeriesCanvas=require("./plot/series/mark-series-canvas");var _markSeriesCanvas2=_interopRequireDefault(_markSeriesCanvas);var _whiskerSeries=require("./plot/series/whisker-series");var _whiskerSeries2=_interopRequireDefault(_whiskerSeries);var _heatmapSeries=require("./plot/series/heatmap-series");var _heatmapSeries2=_interopRequireDefault(_heatmapSeries);var _hexbinSeries=require("./plot/series/hexbin-series");var _hexbinSeries2=_interopRequireDefault(_hexbinSeries);var _contourSeries=require("./plot/series/contour-series");var _contourSeries2=_interopRequireDefault(_contourSeries);var _customSvgSeries=require("./plot/series/custom-svg-series");var _customSvgSeries2=_interopRequireDefault(_customSvgSeries);var _areaSeries=require("./plot/series/area-series");var _areaSeries2=_interopRequireDefault(_areaSeries);var _arcSeries=require("./plot/series/arc-series");var _arcSeries2=_interopRequireDefault(_arcSeries);var _lineMarkSeries=require("./plot/series/line-mark-series");var _lineMarkSeries2=_interopRequireDefault(_lineMarkSeries);var _lineMarkSeriesCanvas=require("./plot/series/line-mark-series-canvas");var _lineMarkSeriesCanvas2=_interopRequireDefault(_lineMarkSeriesCanvas);var _hint=require("./plot/hint");var _hint2=_interopRequireDefault(_hint);var _borders=require("./plot/borders");var _borders2=_interopRequireDefault(_borders);var _crosshair=require("./plot/crosshair");var _crosshair2=_interopRequireDefault(_crosshair);var _xyPlot=require("./plot/xy-plot");var _xyPlot2=_interopRequireDefault(_xyPlot);var _decorativeAxis=require("./plot/axis/decorative-axis");var _decorativeAxis2=_interopRequireDefault(_decorativeAxis);var _xAxis=require("./plot/axis/x-axis");var _xAxis2=_interopRequireDefault(_xAxis);var _yAxis=require("./plot/axis/y-axis");var _yAxis2=_interopRequireDefault(_yAxis);var _circularGridLines=require("./plot/circular-grid-lines");var _circularGridLines2=_interopRequireDefault(_circularGridLines);var _gridLines=require("./plot/grid-lines");var _gridLines2=_interopRequireDefault(_gridLines);var _gradientDefs=require("./plot/gradient-defs");var _gradientDefs2=_interopRequireDefault(_gradientDefs);var _verticalGridLines=require("./plot/vertical-grid-lines");var _verticalGridLines2=_interopRequireDefault(_verticalGridLines);var _horizontalGridLines=require("./plot/horizontal-grid-lines");var _horizontalGridLines2=_interopRequireDefault(_horizontalGridLines);var _voronoi=require("./plot/voronoi");var _voronoi2=_interopRequireDefault(_voronoi);var _highlight=require("./plot/highlight");var _highlight2=_interopRequireDefault(_highlight);var _discreteColorLegend=require("./legends/discrete-color-legend");var _discreteColorLegend2=_interopRequireDefault(_discreteColorLegend);var _searchableDiscreteColorLegend=require("./legends/searchable-discrete-color-legend");var _searchableDiscreteColorLegend2=_interopRequireDefault(_searchableDiscreteColorLegend);var _continuousColorLegend=require("./legends/continuous-color-legend");var _continuousColorLegend2=_interopRequireDefault(_continuousColorLegend);var _continuousSizeLegend=require("./legends/continuous-size-legend");var _continuousSizeLegend2=_interopRequireDefault(_continuousSizeLegend);var _treemap=require("./treemap");var _treemap2=_interopRequireDefault(_treemap) -;var _radialChart=require("./radial-chart");var _radialChart2=_interopRequireDefault(_radialChart);var _radarChart=require("./radar-chart");var _radarChart2=_interopRequireDefault(_radarChart);var _parallelCoordinates=require("./parallel-coordinates");var _parallelCoordinates2=_interopRequireDefault(_parallelCoordinates);var _sankey=require("./sankey");var _sankey2=_interopRequireDefault(_sankey);var _sunburst=require("./sunburst");var _sunburst2=_interopRequireDefault(_sunburst);var _axisUtils=require("./utils/axis-utils");var _axisUtils2=_interopRequireDefault(_axisUtils);var _scalesUtils=require("./utils/scales-utils");var _scalesUtils2=_interopRequireDefault(_scalesUtils);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.AbstractSeries=_abstractSeries2.default;exports.LineSeries=_lineSeries2.default;exports.LineSeriesCanvas=_lineSeriesCanvas2.default;exports.HorizontalBarSeries=_horizontalBarSeries2.default;exports.HorizontalBarSeriesCanvas=_horizontalBarSeriesCanvas2.default;exports.VerticalBarSeries=_verticalBarSeries2.default;exports.VerticalBarSeriesCanvas=_verticalBarSeriesCanvas2.default;exports.VerticalRectSeries=_verticalRectSeries2.default;exports.VerticalRectSeriesCanvas=_verticalRectSeriesCanvas2.default;exports.HorizontalRectSeries=_horizontalRectSeries2.default;exports.HorizontalRectSeriesCanvas=_horizontalRectSeriesCanvas2.default;exports.LabelSeries=_labelSeries2.default;exports.PolygonSeries=_polygonSeries2.default;exports.RectSeries=_rectSeries2.default;exports.RectSeriesCanvas=_rectSeriesCanvas2.default;exports.MarkSeries=_markSeries2.default;exports.MarkSeriesCanvas=_markSeriesCanvas2.default;exports.WhiskerSeries=_whiskerSeries2.default;exports.HeatmapSeries=_heatmapSeries2.default;exports.HexbinSeries=_hexbinSeries2.default;exports.ContourSeries=_contourSeries2.default;exports.CustomSVGSeries=_customSvgSeries2.default;exports.AreaSeries=_areaSeries2.default;exports.ArcSeries=_arcSeries2.default;exports.LineMarkSeries=_lineMarkSeries2.default;exports.LineMarkSeriesCanvas=_lineMarkSeriesCanvas2.default;exports.Hint=_hint2.default;exports.Borders=_borders2.default;exports.Crosshair=_crosshair2.default;exports.XYPlot=_xyPlot2.default;exports.DecorativeAxis=_decorativeAxis2.default;exports.XAxis=_xAxis2.default;exports.YAxis=_yAxis2.default;exports.CircularGridLines=_circularGridLines2.default;exports.GridLines=_gridLines2.default;exports.GradientDefs=_gradientDefs2.default;exports.VerticalGridLines=_verticalGridLines2.default;exports.HorizontalGridLines=_horizontalGridLines2.default;exports.Voronoi=_voronoi2.default;exports.Highlight=_highlight2.default;exports.DiscreteColorLegend=_discreteColorLegend2.default;exports.SearchableDiscreteColorLegend=_searchableDiscreteColorLegend2.default;exports.ContinuousColorLegend=_continuousColorLegend2.default;exports.ContinuousSizeLegend=_continuousSizeLegend2.default;exports.Treemap=_treemap2.default;exports.RadialChart=_radialChart2.default;exports.RadarChart=_radarChart2.default;exports.ParallelCoordinates=_parallelCoordinates2.default;exports.Sankey=_sankey2.default;exports.Sunburst=_sunburst2.default;exports.AxisUtils=_axisUtils2.default;exports.ScaleUtils=_scalesUtils2.default},{"./legends/continuous-color-legend":76,"./legends/continuous-size-legend":77,"./legends/discrete-color-legend":79,"./legends/searchable-discrete-color-legend":80,"./make-vis-flexible":81,"./parallel-coordinates":82,"./plot/axis/decorative-axis":88,"./plot/axis/x-axis":89,"./plot/axis/y-axis":90,"./plot/borders":91,"./plot/circular-grid-lines":92,"./plot/crosshair":93,"./plot/gradient-defs":94,"./plot/grid-lines":95,"./plot/highlight":96,"./plot/hint":97,"./plot/horizontal-grid-lines":98,"./plot/series/abstract-series":99,"./plot/series/arc-series":100,"./plot/series/area-series":101,"./plot/series/contour-series":105,"./plot/series/custom-svg-series":106,"./plot/series/heatmap-series":107,"./plot/series/hexbin-series":108,"./plot/series/horizontal-bar-series":110,"./plot/series/horizontal-bar-series-canvas":109,"./plot/series/horizontal-rect-series":112,"./plot/series/horizontal-rect-series-canvas":111,"./plot/series/label-series":113,"./plot/series/line-mark-series":115,"./plot/series/line-mark-series-canvas":114,"./plot/series/line-series":117,"./plot/series/line-series-canvas":116,"./plot/series/mark-series":119,"./plot/series/mark-series-canvas":118,"./plot/series/polygon-series":120,"./plot/series/rect-series":122,"./plot/series/rect-series-canvas":121,"./plot/series/vertical-bar-series":124,"./plot/series/vertical-bar-series-canvas":123,"./plot/series/vertical-rect-series":126,"./plot/series/vertical-rect-series-canvas":125,"./plot/series/whisker-series":127,"./plot/vertical-grid-lines":128,"./plot/voronoi":129,"./plot/xy-plot":130,"./radar-chart":131,"./radial-chart":132,"./sankey":133,"./sunburst":135,"./treemap":137,"./utils/axis-utils":141,"./utils/scales-utils":145}],76:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _theme=require("../theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,height:_propTypes2.default.number,endColor:_propTypes2.default.string,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,midColor:_propTypes2.default.string,midTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]),startColor:_propTypes2.default.string,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={className:"",startColor:_theme.CONTINUOUS_COLOR_RANGE[0],endColor:_theme.CONTINUOUS_COLOR_RANGE[1]};function ContinuousColorLegend(_ref){var startColor=_ref.startColor,midColor=_ref.midColor,endColor=_ref.endColor,startTitle=_ref.startTitle,midTitle=_ref.midTitle,endTitle=_ref.endTitle,height=_ref.height,width=_ref.width,className=_ref.className;var colors=[startColor];if(midColor){colors.push(midColor)}colors.push(endColor);return _react2.default.createElement("div",{className:"rv-continuous-color-legend "+className,style:{width:width,height:height}},_react2.default.createElement("div",{className:"rv-gradient",style:{background:"linear-gradient(to right, "+colors.join(",")+")"}}),_react2.default.createElement("div",{className:"rv-legend-titles"},_react2.default.createElement("span",{className:"rv-legend-titles__left"},startTitle),_react2.default.createElement("span",{className:"rv-legend-titles__right"},endTitle),midTitle?_react2.default.createElement("span",{className:"rv-legend-titles__center"},midTitle):null))}ContinuousColorLegend.displayName="ContinuousColorLegend";ContinuousColorLegend.propTypes=propTypes;ContinuousColorLegend.defaultProps=defaultProps;exports.default=ContinuousColorLegend},{"../theme":136,"prop-types":33,react:73}],77:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,circlesTotal:_propTypes2.default.number,endSize:_propTypes2.default.number,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,height:_propTypes2.default.number,startSize:_propTypes2.default.number,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={circlesTotal:10,className:"",endSize:20,startSize:2};function ContinuousSizeLegend(_ref){var startTitle=_ref.startTitle,endTitle=_ref.endTitle,startSize=_ref.startSize,endSize=_ref.endSize,circlesTotal=_ref.circlesTotal,height=_ref.height,width=_ref.width,className=_ref.className;var circles=[];var step=(endSize-startSize)/(circlesTotal-1);for(var i=0;i=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}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}var CONTAINER_REF="container";var resizeSubscribers=[];var DEBOUNCE_DURATION=100;var timeoutId=null;function debounceEmitResize(){_window2.default.clearTimeout(timeoutId);timeoutId=_window2.default.setTimeout(emitResize,DEBOUNCE_DURATION)}function emitResize(){resizeSubscribers.forEach(function(cb){return cb()})}function subscribeToDebouncedResize(cb){resizeSubscribers.push(cb);if(resizeSubscribers.length===1){_window2.default.addEventListener("resize",debounceEmitResize)}return function unsubscribe(){removeSubscriber(cb);if(resizeSubscribers.length===0){_window2.default.clearTimeout(timeoutId);_window2.default.removeEventListener("resize",debounceEmitResize)}}}function removeSubscriber(cb){var index=resizeSubscribers.indexOf(cb);if(index>-1){resizeSubscribers.splice(index,1)}}function getDisplayName(Component){return Component.displayName||Component.name||"Component"}function makeFlexible(Component,isWidthFlexible,isHeightFlexible){var ResultClass=function(_React$Component){_inherits(ResultClass,_React$Component);_createClass(ResultClass,null,[{key:"propTypes",get:function get(){var _Component$propTypes=Component.propTypes,height=_Component$propTypes.height,width=_Component$propTypes.width,otherPropTypes=_objectWithoutProperties(_Component$propTypes,["height","width"]);return otherPropTypes}}]);function ResultClass(props){_classCallCheck(this,ResultClass);var _this=_possibleConstructorReturn(this,(ResultClass.__proto__||Object.getPrototypeOf(ResultClass)).call(this,props));_this._onResize=function(){var containerElement=(0,_reactUtils.getDOMNode)(_this[CONTAINER_REF]);var offsetHeight=containerElement.offsetHeight,offsetWidth=containerElement.offsetWidth;var newHeight=_this.state.height===offsetHeight?{}:{height:offsetHeight};var newWidth=_this.state.width===offsetWidth?{}:{width:offsetWidth};_this.setState(_extends({},newHeight,newWidth))};_this.state={height:0,width:0};return _this}_createClass(ResultClass,[{key:"componentDidMount",value:function componentDidMount(){this._onResize();this.cancelSubscription=subscribeToDebouncedResize(this._onResize)}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(){this._onResize()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.cancelSubscription()}},{key:"render",value:function render(){var _this2=this;var _state=this.state,height=_state.height,width=_state.width;var props=_extends({},this.props,{animation:height===0&&width===0?null:this.props.animation});var updatedDimensions=_extends({},isHeightFlexible?{height:height}:{},isWidthFlexible?{width:width}:{});return _react2.default.createElement("div",{ref:function ref(_ref){return _this2[CONTAINER_REF]=_ref},style:{width:"100%",height:"100%"}},_react2.default.createElement(Component,_extends({},updatedDimensions,props)))}}]);return ResultClass}(_react2.default.Component);ResultClass.displayName="Flexible"+getDisplayName(Component);return ResultClass}function makeHeightFlexible(component){return makeFlexible(component,false,true)}function makeVisFlexible(component){return makeFlexible(component,true,true)}function makeWidthFlexible(component){return makeFlexible(component,true,false)}var FlexibleWidthXYPlot=exports.FlexibleWidthXYPlot=makeWidthFlexible(_xyPlot2.default);var FlexibleHeightXYPlot=exports.FlexibleHeightXYPlot=makeHeightFlexible(_xyPlot2.default);var FlexibleXYPlot=exports.FlexibleXYPlot=makeVisFlexible(_xyPlot2.default)},{"./plot/xy-plot":130,"./utils/react-utils":144,"global/window":26,react:73}],82:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;ifilter.max)){withinFilteredRange=false}return{x:name,y:yVal}});var selectedName=predefinedClassName+"-line";var unselectedName=selectedName+" "+predefinedClassName+"-line-unselected";var lineProps={animation:animation,className:withinFilteredRange?selectedName:unselectedName,key:rowIndex+"-polygon",data:mappedData,color:row.color||colorRange[rowIndex%colorRange.length],style:_extends({},style.lines,row.style||{})};if(!withinFilteredRange){lineProps.style=_extends({},lineProps.style,style.deselectedLineStyle)}return showMarks?_react2.default.createElement(_lineMarkSeries2.default,lineProps):_react2.default.createElement(_lineSeries2.default,lineProps)})}var ParallelCoordinates=function(_Component){_inherits(ParallelCoordinates,_Component);function ParallelCoordinates(){var _ref2;var _temp,_this,_ret;_classCallCheck(this,ParallelCoordinates);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}return _ret=(_temp=(_this=_possibleConstructorReturn(this,(_ref2=ParallelCoordinates.__proto__||Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2,[this].concat(args))),_this),_this.state={brushFilters:{}},_temp),_possibleConstructorReturn(_this,_ret)}_createClass(ParallelCoordinates,[{key:"render",value:function render(){var _this2=this;var brushFilters=this.state.brushFilters;var _props=this.props,animation=_props.animation,brushing=_props.brushing,className=_props.className,children=_props.children,colorRange=_props.colorRange,data=_props.data,domains=_props.domains,height=_props.height,hideInnerMostValues=_props.hideInnerMostValues,margin=_props.margin,onMouseLeave=_props.onMouseLeave,onMouseEnter=_props.onMouseEnter,showMarks=_props.showMarks,style=_props.style,tickFormat=_props.tickFormat,width=_props.width;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,style:style,tickFormat:tickFormat});var lines=getLines({animation:animation,brushFilters:brushFilters,colorRange:colorRange,domains:domains,data:data,showMarks:showMarks,style:style});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:true,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels})});var _getInnerDimensions=(0,_chartUtils.getInnerDimensions)(this.props,_chartUtils.DEFAULT_MARGINS),marginLeft=_getInnerDimensions.marginLeft,marginRight=_getInnerDimensions.marginRight;return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xType:"ordinal",yDomain:[0,1]},children,axes.concat(lines).concat(labelSeries),brushing&&domains.map(function(d){var trigger=function trigger(row){_this2.setState({brushFilters:_extends({},brushFilters,_defineProperty({},d.name,row?{min:row.bottom,max:row.top}:null))})};return _react2.default.createElement(_highlight2.default,{key:d.name,drag:true,highlightX:d.name,onBrushEnd:trigger,onDragEnd:trigger,highlightWidth:(width-marginLeft-marginRight)/domains.length,enableX:false})}))}}]);return ParallelCoordinates}(_react.Component);ParallelCoordinates.displayName="ParallelCoordinates";ParallelCoordinates.propTypes={animation:_animation.AnimationPropType,brushing:_propTypes2.default.bool,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,margin:_chartUtils.MarginPropType,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,lines:_propTypes2.default.object}),showMarks:_propTypes2.default.bool,tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};ParallelCoordinates.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},lines:{strokeWidth:1,strokeOpacity:1},deselectedLineStyle:{strokeOpacity:.1}},tickFormat:DEFAULT_FORMAT};exports.default=ParallelCoordinates},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/highlight":96,"../plot/series/label-series":113,"../plot/series/line-mark-series":115,"../plot/series/line-series":117,"../plot/xy-plot":130,"../theme":136,"../utils/chart-utils":142,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],83:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{ -value:true});var _extends=Object.assign||function(target){for(var i=1;i-1;var axisClassName=isVertical?VERTICAL_CLASS_NAME:HORIZONTAL_CLASS_NAME;var leftPos=left;var topPos=top;if(on0){var scale=(0,_scalesUtils.getAttributeScale)(props,attrAxis);if(isVertical){leftPos=scale(0)}else{topPos=marginTop+scale(0)}}return _react2.default.createElement("g",{transform:"translate("+leftPos+","+topPos+")",className:predefinedClassName+" "+axisClassName+" "+className,style:style},!hideLine&&_react2.default.createElement(_axisLine2.default,{height:height,width:width,orientation:orientation,style:_extends({},style,style.line)}),!hideTicks&&_react2.default.createElement(_axisTicks2.default,_extends({},props,{style:_extends({},style,style.ticks)})),title?_react2.default.createElement(_axisTitle2.default,{position:position,title:title,height:height,width:width,style:_extends({},style,style.title),orientation:orientation}):null)}}]);return Axis}(_react.PureComponent);Axis.displayName="Axis";Axis.propTypes=propTypes;Axis.defaultProps=defaultProps;Axis.requiresSVG=true;exports.default=Axis},{"../../animation":74,"../../utils/axis-utils":141,"../../utils/scales-utils":145,"./axis-line":83,"./axis-ticks":84,"./axis-title":85,"prop-types":33,react:73}],87:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;irRange[1])){return res}return res.concat([_react2.default.createElement("circle",_extends({cx:0,cy:0,r:radius},{key:index,className:"rv-xy-plot__circular-grid-lines__line",style:style}))])},[]))}}]);return CircularGridLines}(_react.PureComponent);CircularGridLines.displayName="CircularGridLines";CircularGridLines.propTypes={centerX:_propTypes2.default.number,centerY:_propTypes2.default.number,width:_propTypes2.default.number,height:_propTypes2.default.number,top:_propTypes2.default.number,left:_propTypes2.default.number,rRange:_propTypes2.default.arrayOf(_propTypes2.default.number),style:_propTypes2.default.object,tickValues:_propTypes2.default.arrayOf(_propTypes2.default.number),tickTotal:_propTypes2.default.number,animation:_animation.AnimationPropType,marginTop:_propTypes2.default.number,marginBottom:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginRight:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number};CircularGridLines.defaultProps={centerX:0,centerY:0};CircularGridLines.requiresSVG=true;exports.default=CircularGridLines},{"../animation":74,"../utils/axis-utils":141,"../utils/scales-utils":145,"prop-types":33,react:73}],93:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?"left":"right":_props$orientation;var left=marginLeft+innerLeft;var top=marginTop;var innerClassName="rv-crosshair__inner rv-crosshair__inner--"+orientation;return _react2.default.createElement("div",{className:"rv-crosshair "+className,style:{left:left+"px",top:top+"px"}},_react2.default.createElement("div",{className:"rv-crosshair__line",style:_extends({height:innerHeight+"px"},style.line)}),_react2.default.createElement("div",{className:innerClassName},children?children:_react2.default.createElement("div",{className:"rv-crosshair__inner__content",style:style.box},_react2.default.createElement("div",null,this._renderCrosshairTitle(),this._renderCrosshairItems()))))}}],[{key:"defaultProps",get:function get(){return{titleFormat:defaultTitleFormat,itemsFormat:defaultItemsFormat,style:{line:{},title:{},box:{}}}}},{key:"propTypes",get:function get(){return{className:_propTypes2.default.string,values:_propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string,_propTypes2.default.object])),series:_propTypes2.default.object,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,orientation:_propTypes2.default.oneOf(["left","right"]),itemsFormat:_propTypes2.default.func,titleFormat:_propTypes2.default.func,style:_propTypes2.default.shape({line:_propTypes2.default.object,title:_propTypes2.default.object,box:_propTypes2.default.object})}}}]);return Crosshair}(_react.PureComponent);Crosshair.displayName="Crosshair";exports.default=Crosshair},{"../utils/scales-utils":145,"prop-types":33,react:73}],94:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var predefinedClassName="rv-gradient-defs";function GradientDefs(props){var className=props.className;return _react2.default.createElement("defs",{className:predefinedClassName+" "+className},props.children)}GradientDefs.displayName="GradientDefs";GradientDefs.requiresSVG=true;GradientDefs.propTypes={className:_propTypes2.default.string};GradientDefs.defaultProps={className:""};exports.default=GradientDefs},{"prop-types":33,react:73}],95:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iright);var clickedOutsideDragY=dragArea&&(yLocbottom);if(enableX&&enableY){return clickedOutsideDragX||clickedOutsideDragY}if(enableX){return clickedOutsideDragX}if(enableY){return clickedOutsideDragY}return true}},{key:"_convertAreaToCoordinates",value:function _convertAreaToCoordinates(brushArea){var _props4=this.props,enableX=_props4.enableX,enableY=_props4.enableY,marginLeft=_props4.marginLeft,marginTop=_props4.marginTop;var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");if(enableX&&enableY){return{bottom:yScale.invert(brushArea.bottom),left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft),top:yScale.invert(brushArea.top)}}if(enableY){return{bottom:yScale.invert(brushArea.bottom-marginTop),top:yScale.invert(brushArea.top-marginTop)}}if(enableX){return{left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft)}}return{}}},{key:"startBrushing",value:function startBrushing(e){var _this2=this;var _props5=this.props,onBrushStart=_props5.onBrushStart,onDragStart=_props5.onDragStart,drag=_props5.drag;var dragArea=this.state.dragArea;var _getLocs=getLocs(e.nativeEvent),xLoc=_getLocs.xLoc,yLoc=_getLocs.yLoc;var startArea=function startArea(dragging,resetDrag){var emptyBrush={bottom:yLoc,left:xLoc,right:xLoc,top:yLoc};_this2.setState({dragging:dragging,brushArea:dragArea&&!resetDrag?dragArea:emptyBrush,brushing:!dragging,startLocX:xLoc,startLocY:yLoc})};var clickedOutsideDrag=this._clickedOutsideDrag(xLoc,yLoc);if(drag&&!dragArea||!drag||clickedOutsideDrag){startArea(false,clickedOutsideDrag);if(onBrushStart){onBrushStart(e)}return}if(drag&&dragArea){startArea(true,clickedOutsideDrag);if(onDragStart){onDragStart(e)}}}},{key:"stopBrushing",value:function stopBrushing(e){var _state4=this.state,brushing=_state4.brushing,dragging=_state4.dragging,brushArea=_state4.brushArea;if(!brushing&&!dragging){return}var _props6=this.props,onBrushEnd=_props6.onBrushEnd,onDragEnd=_props6.onDragEnd,drag=_props6.drag;var noHorizontal=Math.abs(brushArea.right-brushArea.left)<5;var noVertical=Math.abs(brushArea.top-brushArea.bottom)<5;var isNulled=noVertical||noHorizontal;this.setState({brushing:false,dragging:false,brushArea:drag?brushArea:{top:0,right:0,bottom:0,left:0},startLocX:0,startLocY:0,dragArea:drag&&!isNulled&&brushArea});if(brushing&&onBrushEnd){onBrushEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}if(drag&&onDragEnd){onDragEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}}},{key:"onBrush",value:function onBrush(e){var _props7=this.props,onBrush=_props7.onBrush,onDrag=_props7.onDrag,drag=_props7.drag;var _state5=this.state,brushing=_state5.brushing,dragging=_state5.dragging;var _getLocs2=getLocs(e.nativeEvent),xLoc=_getLocs2.xLoc,yLoc=_getLocs2.yLoc;if(brushing){var brushArea=this._getDrawArea(xLoc,yLoc);this.setState({brushArea:brushArea});if(onBrush){onBrush(this._convertAreaToCoordinates(brushArea))}}if(drag&&dragging){var _brushArea=this._getDragArea(xLoc,yLoc);this.setState({brushArea:_brushArea});if(onDrag){onDrag(this._convertAreaToCoordinates(_brushArea))}}}},{key:"render",value:function render(){var _this3=this;var _props8=this.props,color=_props8.color,className=_props8.className,highlightHeight=_props8.highlightHeight,highlightWidth=_props8.highlightWidth,highlightX=_props8.highlightX,highlightY=_props8.highlightY,innerWidth=_props8.innerWidth,innerHeight=_props8.innerHeight,marginLeft=_props8.marginLeft,marginRight=_props8.marginRight,marginTop=_props8.marginTop,marginBottom=_props8.marginBottom,opacity=_props8.opacity;var _state$brushArea=this.state.brushArea,left=_state$brushArea.left,right=_state$brushArea.right,top=_state$brushArea.top,bottom=_state$brushArea.bottom;var leftPos=0;if(highlightX){var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");leftPos=xScale(highlightX)}var topPos=0;if(highlightY){var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");topPos=yScale(highlightY)}var plotWidth=marginLeft+marginRight+innerWidth;var plotHeight=marginTop+marginBottom+innerHeight;var touchWidth=highlightWidth||plotWidth;var touchHeight=highlightHeight||plotHeight;return _react2.default.createElement("g",{transform:"translate("+leftPos+", "+topPos+")",className:className+" rv-highlight-container"},_react2.default.createElement("rect",{className:"rv-mouse-target",fill:"black",opacity:"0",x:"0",y:"0",width:Math.max(touchWidth,0),height:Math.max(touchHeight,0),onMouseDown:function onMouseDown(e){return _this3.startBrushing(e)},onMouseMove:function onMouseMove(e){return _this3.onBrush(e)},onMouseUp:function onMouseUp(e){return _this3.stopBrushing(e)},onMouseLeave:function onMouseLeave(e){return _this3.stopBrushing(e)},onTouchEnd:function onTouchEnd(e){e.preventDefault();_this3.stopBrushing(e)},onTouchCancel:function onTouchCancel(e){e.preventDefault();_this3.stopBrushing(e)},onContextMenu:function onContextMenu(e){return e.preventDefault()},onContextMenuCapture:function onContextMenuCapture(e){return e.preventDefault()}}),_react2.default.createElement("rect",{className:"rv-highlight",pointerEvents:"none",opacity:opacity,fill:color,x:left,y:top,width:Math.min(Math.max(0,right-left),touchWidth),height:Math.min(Math.max(0,bottom-top),touchHeight)}))}}]);return Highlight}(_abstractSeries2.default);Highlight.displayName="HighlightOverlay";Highlight.defaultProps={color:"rgb(77, 182, 172)",className:"",enableX:true,enableY:true,opacity:.3};Highlight.propTypes=_extends({},_abstractSeries2.default.propTypes,{enableX:_propTypes2.default.bool,enableY:_propTypes2.default.bool,highlightHeight:_propTypes2.default.number,highlightWidth:_propTypes2.default.number,highlightX:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),highlightY:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),onBrushStart:_propTypes2.default.func,onDragStart:_propTypes2.default.func,onBrush:_propTypes2.default.func,onDrag:_propTypes2.default.func,onBrushEnd:_propTypes2.default.func,onDragEnd:_propTypes2.default.func});exports.default=Highlight},{"../utils/scales-utils":145,"./series/abstract-series":99,"prop-types":33,react:73}],97:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?ALIGN.LEFT:ALIGN.RIGHT}if(vertical===ALIGN.AUTO){align.vertical=y>innerHeight/2?ALIGN.TOP:ALIGN.BOTTOM}return align}},{key:"_getAlignClassNames",value:function _getAlignClassNames(align){var orientation=this.props.orientation;var orientationClass=orientation?"rv-hint--orientation-"+orientation:"";return orientationClass+" rv-hint--horizontalAlign-"+align.horizontal+"\n rv-hint--verticalAlign-"+align.vertical}},{key:"_getAlignStyle",value:function _getAlignStyle(align,x,y){return _extends({},this._getXCSS(align.horizontal,x),this._getYCSS(align.vertical,y))}},{key:"_getCSSBottom",value:function _getCSSBottom(y){if(y===undefined||y===null){return{bottom:0}}var _props2=this.props,innerHeight=_props2.innerHeight,marginBottom=_props2.marginBottom;return{bottom:marginBottom+innerHeight-y}}},{key:"_getCSSLeft",value:function _getCSSLeft(x){if(x===undefined||x===null){return{left:0}}var marginLeft=this.props.marginLeft;return{left:marginLeft+x}}},{key:"_getCSSRight",value:function _getCSSRight(x){if(x===undefined||x===null){return{right:0}}var _props3=this.props,innerWidth=_props3.innerWidth,marginRight=_props3.marginRight;return{right:marginRight+innerWidth-x}}},{key:"_getCSSTop",value:function _getCSSTop(y){if(y===undefined||y===null){return{top:0}}var marginTop=this.props.marginTop;return{top:marginTop+y}}},{key:"_getPositionInfo",value:function _getPositionInfo(){var _props4=this.props,value=_props4.value,getAlignStyle=_props4.getAlignStyle -;var x=(0,_scalesUtils.getAttributeFunctor)(this.props,"x")(value);var y=(0,_scalesUtils.getAttributeFunctor)(this.props,"y")(value);var align=this._getAlign(x,y);return{position:getAlignStyle?getAlignStyle(align,x,y):this._getAlignStyle(align,x,y),className:this._getAlignClassNames(align)}}},{key:"_getXCSS",value:function _getXCSS(horizontal,x){switch(horizontal){case ALIGN.LEFT_EDGE:return this._getCSSLeft(null);case ALIGN.RIGHT_EDGE:return this._getCSSRight(null);case ALIGN.LEFT:return this._getCSSRight(x);case ALIGN.RIGHT:default:return this._getCSSLeft(x)}}},{key:"_getYCSS",value:function _getYCSS(verticalAlign,y){switch(verticalAlign){case ALIGN.TOP_EDGE:return this._getCSSTop(null);case ALIGN.BOTTOM_EDGE:return this._getCSSBottom(null);case ALIGN.BOTTOM:return this._getCSSTop(y);case ALIGN.TOP:default:return this._getCSSBottom(y)}}},{key:"_mapOrientationToAlign",value:function _mapOrientationToAlign(orientation){switch(orientation){case ORIENTATION.BOTTOM_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.BOTTOM};case ORIENTATION.BOTTOM_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.BOTTOM};case ORIENTATION.TOP_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.TOP};case ORIENTATION.TOP_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.TOP};default:break}}},{key:"render",value:function render(){var _props5=this.props,value=_props5.value,format=_props5.format,children=_props5.children,style=_props5.style;var _getPositionInfo2=this._getPositionInfo(),position=_getPositionInfo2.position,className=_getPositionInfo2.className;return _react2.default.createElement("div",{className:"rv-hint "+className,style:_extends({},style,position,{position:"absolute"})},children?children:_react2.default.createElement("div",{className:"rv-hint__content",style:style.content},format(value).map(function(formattedProp,i){return _react2.default.createElement("div",{key:"rv-hint"+i,style:style.row},_react2.default.createElement("span",{className:"rv-hint__title",style:style.title},formattedProp.title),": ",_react2.default.createElement("span",{className:"rv-hint__value",style:style.value},formattedProp.value))})))}}],[{key:"defaultProps",get:function get(){return{format:defaultFormat,align:{horizontal:ALIGN.AUTO,vertical:ALIGN.AUTO},style:{}}}},{key:"propTypes",get:function get(){return{marginTop:_propTypes2.default.number,marginLeft:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,scales:_propTypes2.default.object,value:_propTypes2.default.object,format:_propTypes2.default.func,style:_propTypes2.default.object,align:_propTypes2.default.shape({horizontal:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.LEFT,ALIGN.RIGHT,ALIGN.LEFT_EDGE,ALIGN.RIGHT_EDGE]),vertical:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.BOTTOM,ALIGN.TOP,ALIGN.BOTTOM_EDGE,ALIGN.TOP_EDGE])}),getAlignStyle:_propTypes2.default.func,orientation:_propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT,ORIENTATION.BOTTOM_RIGHT,ORIENTATION.TOP_LEFT,ORIENTATION.TOP_RIGHT])}}}]);return Hint}(_react.PureComponent);Hint.displayName="Hint";Hint.ORIENTATION=ORIENTATION;Hint.ALIGN=ALIGN;exports.default=Hint},{"../utils/scales-utils":145,"prop-types":33,react:73}],98:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iMAX_DRAWS){clearInterval(drawCycle)}drawIteration+=1},1)}function drawLayers(ctx,height,width,layers,drawIteration){ctx.clearRect(0,0,width,height);layers.forEach(function(layer){var interpolator=layer.interpolator,newProps=layer.newProps,animation=layer.animation;var interpolatedProps=animation?interpolator?interpolator(drawIteration/MAX_DRAWS):interpolator:function(){return{}};layer.renderLayer(_extends({},newProps,interpolatedProps),ctx)})}function buildLayers(newChildren,oldChildren){return newChildren.map(function(child,index){var oldProps=oldChildren[index]?oldChildren[index].props:{};var newProps=child.props;var oldAnimatedProps=(0,_animation.extractAnimatedPropValues)(_extends({},oldProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}));var newAnimatedProps=newProps?(0,_animation.extractAnimatedPropValues)(_extends({},newProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS})):null;var interpolator=(0,_d3Interpolate.interpolate)(oldAnimatedProps,newAnimatedProps);return{renderLayer:child.type.renderLayer,newProps:child.props,animation:child.props.animation,interpolator:interpolator}})}var CanvasWrapper=function(_Component){_inherits(CanvasWrapper,_Component);function CanvasWrapper(){_classCallCheck(this,CanvasWrapper);return _possibleConstructorReturn(this,(CanvasWrapper.__proto__||Object.getPrototypeOf(CanvasWrapper)).apply(this,arguments))}_createClass(CanvasWrapper,[{key:"componentDidMount",value:function componentDidMount(){var ctx=this.canvas.getContext("2d");if(!ctx){return}var pixelRatio=this.props.pixelRatio;if(!ctx){return}ctx.scale(pixelRatio,pixelRatio);this.drawChildren(null,this.props,ctx)}},{key:"componentDidUpdate",value:function componentDidUpdate(oldProps){this.drawChildren(oldProps,this.props,this.canvas.getContext("2d"))}},{key:"drawChildren",value:function drawChildren(oldProps,newProps,ctx){var children=newProps.children,innerHeight=newProps.innerHeight,innerWidth=newProps.innerWidth,marginBottom=newProps.marginBottom,marginLeft=newProps.marginLeft,marginRight=newProps.marginRight,marginTop=newProps.marginTop;if(!ctx){return}var childrenShouldAnimate=children.find(function(child){return child.props.animation});var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;var layers=buildLayers(newProps.children,oldProps?oldProps.children:[]);if(!childrenShouldAnimate){drawLayers(ctx,height,width,layers);return}engageDrawLoop(ctx,height,width,layers)}},{key:"render",value:function render(){var _this2=this;var _props=this.props,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginBottom=_props.marginBottom,marginLeft=_props.marginLeft,marginRight=_props.marginRight,marginTop=_props.marginTop,pixelRatio=_props.pixelRatio;var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;return _react2.default.createElement("div",{style:{left:0,top:0},className:"rv-xy-canvas"},_react2.default.createElement("canvas",{className:"rv-xy-canvas-element",height:height*pixelRatio,width:width*pixelRatio,style:{height:height+"px",width:width+"px"},ref:function ref(_ref){return _this2.canvas=_ref}}),this.props.children)}}],[{key:"defaultProps",get:function get(){return{pixelRatio:window&&window.devicePixelRatio||1}}}]);return CanvasWrapper}(_react.Component);CanvasWrapper.displayName="CanvasWrapper";CanvasWrapper.propTypes={marginBottom:_propTypes2.default.number.isRequired,marginLeft:_propTypes2.default.number.isRequired,marginRight:_propTypes2.default.number.isRequired,marginTop:_propTypes2.default.number.isRequired,innerHeight:_propTypes2.default.number.isRequired,innerWidth:_propTypes2.default.number.isRequired,pixelRatio:_propTypes2.default.number.isRequired};exports.default=CanvasWrapper},{"../../animation":74,"../../utils/series-utils":146,"d3-interpolate":11,"prop-types":33,react:73}],105:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i1&&arguments[1]!==undefined?arguments[1]:2;var style=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_STYLE;switch(type){case"diamond":return _react2.default.createElement("polygon",{style:style,points:"0 0 "+size/2+" "+size/2+" 0 "+size+" "+-size/2+" "+size/2+" 0 0"});case"star":var starPoints=[].concat(_toConsumableArray(new Array(5))).map(function(c,index){var angle=index/5*Math.PI*2;var innerAngle=angle+Math.PI/10;var outerAngle=angle-Math.PI/10;var innerRadius=size/2.61;return"\n "+Math.cos(outerAngle)*size+" "+Math.sin(outerAngle)*size+"\n "+Math.cos(innerAngle)*innerRadius+" "+Math.sin(innerAngle)*innerRadius+"\n "}).join(" ");return _react2.default.createElement("polygon",{points:starPoints,x:"0",y:"0",height:size,width:size,style:style});case"square":return _react2.default.createElement("rect",{x:""+-size/2,y:""+-size/2,height:size,width:size,style:style});default:case"circle":return _react2.default.createElement("circle",{cx:"0",cy:"0",r:size/2,style:style})}}function getInnerComponent(_ref){var customComponent=_ref.customComponent,defaultType=_ref.defaultType,positionInPixels=_ref.positionInPixels,positionFunctions=_ref.positionFunctions,style=_ref.style,propsSize=_ref.propsSize;var size=customComponent.size;var aggStyle=_extends({},style,customComponent.style||{});var innerComponent=customComponent.customComponent;if(!innerComponent&&typeof defaultType==="string"){return predefinedComponents(defaultType,size||propsSize,aggStyle)}if(!innerComponent){return defaultType(customComponent,positionInPixels,aggStyle)}if(typeof innerComponent==="string"){return predefinedComponents(innerComponent||defaultType,size,aggStyle)}return innerComponent(customComponent,positionInPixels,aggStyle)}var CustomSVGSeries=function(_AbstractSeries){_inherits(CustomSVGSeries,_AbstractSeries);function CustomSVGSeries(){_classCallCheck(this,CustomSVGSeries);return _possibleConstructorReturn(this,(CustomSVGSeries.__proto__||Object.getPrototypeOf(CustomSVGSeries)).apply(this,arguments))}_createClass(CustomSVGSeries,[{key:"render",value:function render(){var _this2=this;var _props=this.props,animation=_props.animation,className=_props.className,customComponent=_props.customComponent,data=_props.data,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginLeft=_props.marginLeft,marginTop=_props.marginTop,style=_props.style,size=_props.size;if(!data||!innerWidth||!innerHeight){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(CustomSVGSeries,_extends({},this.props,{animation:false})))}var x=this._getAttributeFunctor("x");var y=this._getAttributeFunctor("y");var contents=data.map(function(seriesComponent,index){var positionInPixels={x:x({x:seriesComponent.x}),y:y({y:seriesComponent.y})};var innerComponent=getInnerComponent({customComponent:seriesComponent,positionInPixels:positionInPixels,defaultType:customComponent,positionFunctions:{x:x,y:y},style:style,propsSize:size});return _react2.default.createElement("g",{className:"rv-xy-plot__series--custom-svg",key:"rv-xy-plot__series--custom-svg-"+index,transform:"translate("+positionInPixels.x+","+positionInPixels.y+")",onMouseEnter:function onMouseEnter(e){return _this2._valueMouseOverHandler(seriesComponent,e)},onMouseLeave:function onMouseLeave(e){return _this2._valueMouseOutHandler(seriesComponent,e)}},innerComponent)});return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},contents)}}]);return CustomSVGSeries}(_abstractSeries2.default);CustomSVGSeries.propTypes={animation:_propTypes2.default.bool,className:_propTypes2.default.string,customComponent:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.func]),data:_propTypes2.default.arrayOf(_propTypes2.default.shape({x:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired,y:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired})).isRequired,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,style:_propTypes2.default.object,size:_propTypes2.default.number,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func};CustomSVGSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{animation:false,customComponent:"circle",style:{},size:2});exports.default=CustomSVGSeries},{"../../animation":74,"../../utils/series-utils":146,"./abstract-series":99,"prop-types":33,react:73}],107:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;ipositiveYVariance;if(!hasXWhiskers&&!hasYWhiskers){return null}var styleAttr=_extends({opacity:opacityFunctor?opacityFunctor(d):_theme.DEFAULT_OPACITY,stroke:strokeFunctor&&strokeFunctor(d),strokeWidth:strokeWidth||DEFAULT_STROKE_WIDTH},style);var crossBarExtension=crossBarWidth/2;var rightLineAttrs={x1:cx+r,y1:cy,x2:positiveXVariance,y2:cy,style:styleAttr};var leftLineAttrs={x1:cx-r,y1:cy,x2:negativeXVariance,y2:cy,style:styleAttr};var rightCrossBarAttrs={x1:positiveXVariance,y1:cy-crossBarExtension,x2:positiveXVariance,y2:cy+crossBarExtension,style:styleAttr};var leftCrossBarAttrs={x1:negativeXVariance,y1:cy-crossBarExtension,x2:negativeXVariance,y2:cy+crossBarExtension,style:styleAttr};var upperLineAttrs={x1:cx,y1:cy-r,x2:cx,y2:positiveYVariance,style:styleAttr};var lowerLineAttrs={x1:cx,y1:cy+r,x2:cx,y2:negativeYVariance,style:styleAttr};var upperCrossBarAttrs={x1:cx-crossBarExtension,y1:positiveYVariance,x2:cx+crossBarExtension,y2:positiveYVariance,style:styleAttr};var lowerCrossBarAttrs={x1:cx-crossBarExtension,y1:negativeYVariance,x2:cx+crossBarExtension,y2:negativeYVariance,style:styleAttr};return _react2.default.createElement("g",{className:"mark-whiskers",key:i,onClick:function onClick(e){return valueClickHandler(d,e)},onContextMenu:function onContextMenu(e){return valueRightClickHandler(d,e)},onMouseOver:function onMouseOver(e){return valueMouseOverHandler(d,e)},onMouseOut:function onMouseOut(e){return valueMouseOutHandler(d,e)}},hasXWhiskers?_react2.default.createElement("g",{className:"x-whiskers"},_react2.default.createElement("line",rightLineAttrs),_react2.default.createElement("line",leftLineAttrs),_react2.default.createElement("line",rightCrossBarAttrs),_react2.default.createElement("line",leftCrossBarAttrs)):null,hasYWhiskers?_react2.default.createElement("g",{className:"y-whiskers"},_react2.default.createElement("line",upperLineAttrs),_react2.default.createElement("line",lowerLineAttrs),_react2.default.createElement("line",upperCrossBarAttrs),_react2.default.createElement("line",lowerCrossBarAttrs)):null)}};var WhiskerSeries=function(_AbstractSeries){_inherits(WhiskerSeries,_AbstractSeries);function WhiskerSeries(){_classCallCheck(this,WhiskerSeries);return _possibleConstructorReturn(this,(WhiskerSeries.__proto__||Object.getPrototypeOf(WhiskerSeries)).apply(this,arguments))}_createClass(WhiskerSeries,[{key:"render",value:function render(){var _props=this.props,animation=_props.animation,className=_props.className,crossBarWidth=_props.crossBarWidth,data=_props.data,marginLeft=_props.marginLeft,marginTop=_props.marginTop,strokeWidth=_props.strokeWidth,style=_props.style;if(!data){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(WhiskerSeries,_extends({},this.props,{animation:null})))}var whiskerMarkProps={crossBarWidth:crossBarWidth,opacityFunctor:this._getAttributeFunctor("opacity"),sizeFunctor:this._getAttributeFunctor("size"),strokeFunctor:this._getAttributeFunctor("stroke")||this._getAttributeFunctor("color"),strokeWidth:strokeWidth,style:style,xFunctor:this._getAttributeFunctor("x"),yFunctor:this._getAttributeFunctor("y"),valueClickHandler:this._valueClickHandler,valueRightClickHandler:this._valueRightClickHandler,valueMouseOverHandler:this._valueMouseOverHandler,valueMouseOutHandler:this._valueMouseOutHandler};return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},data.map(renderWhiskerMark(whiskerMarkProps)))}}]);return WhiskerSeries}(_abstractSeries2.default);WhiskerSeries.displayName="WhiskerSeries";WhiskerSeries.propTypes=_extends({},_abstractSeries2.default.propTypes,{strokeWidth:_propTypes2.default.number});WhiskerSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{crossBarWidth:DEFAULT_CROSS_BAR_WIDTH,size:0,strokeWidth:DEFAULT_STROKE_WIDTH});exports.default=WhiskerSeries},{"../../animation":74,"../../theme":136,"../../utils/series-utils":146,"./abstract-series":99,"prop-types":33,react:73}],128:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i-1&&index0){if(Math.abs(axisEndPoint-.5)<=epsilon){axisEndPoint=.5}}else if(axisEndPoint<0){if(Math.abs(axisEndPoint+.5)<=epsilon){axisEndPoint=-.5}}return axisEndPoint}function getLabels(props){var domains=props.domains,startingAngle=props.startingAngle,style=props.style;return domains.map(function(_ref,index){var name=_ref.name;var angle=index/domains.length*Math.PI*2+startingAngle;var radius=1.2;return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),label:name,style:style}})}function getPolygons(props){var animation=props.animation,colorRange=props.colorRange,domains=props.domains,data=props.data,style=props.style,startingAngle=props.startingAngle,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var scales=domains.reduce(function(acc,_ref2){var domain=_ref2.domain,name=_ref2.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref3,index){var name=_ref3.name,getValue=_ref3.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),name:row.name}});return _react2.default.createElement(_polygonSeries2.default,{animation:animation,className:predefinedClassName+"-polygon",key:rowIndex+"-polygon",data:mappedData,style:_extends({stroke:row.color||row.stroke||colorRange[rowIndex%colorRange.length],fill:row.color||row.fill||colorRange[rowIndex%colorRange.length]},style.polygons),onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut})})}function getPolygonPoints(props){var animation=props.animation,domains=props.domains,data=props.data,startingAngle=props.startingAngle,style=props.style,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut;if(!onValueMouseOver){return}var scales=domains.reduce(function(acc,_ref4){var domain=_ref4.domain,name=_ref4.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref5,index){var name=_ref5.name,getValue=_ref5.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),domain:name,value:dataPoint,dataName:row.name}});return _react2.default.createElement(_markSeries2.default,{animation:animation,className:predefinedClassName+"-polygonPoint",key:rowIndex+"-polygonPoint",data:mappedData,size:10,style:_extends({},style.polygons,{fill:"transparent",stroke:"transparent"}),onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut})})}function RadarChart(props){var animation=props.animation,className=props.className,children=props.children,colorRange=props.colorRange,data=props.data,domains=props.domains,height=props.height,hideInnerMostValues=props.hideInnerMostValues,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,startingAngle=props.startingAngle,style=props.style,tickFormat=props.tickFormat,width=props.width,renderAxesOverPolygons=props.renderAxesOverPolygons,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,startingAngle:startingAngle,style:style,tickFormat:tickFormat});var polygons=getPolygons({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut});var polygonPoints=getPolygonPoints({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:animation,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels,startingAngle:startingAngle})});return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-1,1],yDomain:[-1,1]},children,!renderAxesOverPolygons&&axes.concat(polygons).concat(labelSeries).concat(polygonPoints),renderAxesOverPolygons&&polygons.concat(labelSeries).concat(axes).concat(polygonPoints))}RadarChart.displayName="RadarChart";RadarChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,hideInnerMostValues:_propTypes2.default.bool,margin:_chartUtils.MarginPropType,startingAngle:_propTypes2.default.number,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,polygons:_propTypes2.default.object}),tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,renderAxesOverPolygons:_propTypes2.default.bool,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,onSeriesMouseOver:_propTypes2.default.func,onSeriesMouseOut:_propTypes2.default.func};RadarChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,hideInnerMostValues:true,startingAngle:Math.PI/2,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},polygons:{strokeWidth:.5,strokeOpacity:1,fillOpacity:.1}},tickFormat:DEFAULT_FORMAT,renderAxesOverPolygons:false};exports.default=RadarChart},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/series/label-series":113,"../plot/series/mark-series":119,"../plot/series/polygon-series":120,"../plot/xy-plot":130,"../theme":136,"../utils/chart-utils":142,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],132:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i2&&arguments[2]!==undefined?arguments[2]:1.1;var getLabel=accessors.getLabel,getSubLabel=accessors.getSubLabel;return mappedData.reduce(function(res,row){var angle=row.angle,angle0=row.angle0,radius=row.radius;var centeredAngle=(angle+angle0)/2;var updatedAngle=-1*centeredAngle+Math.PI/2;var newLabels=[];if(getLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getLabel(row)})}if(getSubLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getSubLabel(row),style:{fontSize:10},yOffset:12})}return res.concat(newLabels)},[])}function getMaxRadius(width,height){return Math.min(width,height)/2-DEFAULT_RADIUS_MARGIN}function RadialChart(props){var animation=props.animation,className=props.className,children=props.children,colorType=props.colorType,data=props.data,getAngle=props.getAngle,getLabel=props.getLabel,getSubLabel=props.getSubLabel,height=props.height,hideRootNode=props.hideRootNode,innerRadius=props.innerRadius,labelsAboveChildren=props.labelsAboveChildren,labelsRadiusMultiplier=props.labelsRadiusMultiplier,labelsStyle=props.labelsStyle,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,radius=props.radius,showLabels=props.showLabels,style=props.style,width=props.width;var mappedData=getWedgesToRender({data:data,height:height,hideRootNode:hideRootNode,width:width,getAngle:getAngle});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var arcProps=_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:mappedData,radiusNoFallBack:true,style:style,arcClassName:"rv-radial-chart__series--pie__slice"});if(radius){arcProps.radiusDomain=[0,1];arcProps.radiusRange=[innerRadius||0,radius];arcProps.radiusType="linear"}var maxRadius=radius?radius:getMaxRadius(width,height);var defaultMargin=(0,_chartUtils.getRadialLayoutMargin)(width,height,maxRadius);var labels=generateLabels(mappedData,{getLabel:getLabel,getSubLabel:getSubLabel},labelsRadiusMultiplier);return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:_extends({},margin,defaultMargin),className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({},arcProps,{getAngle:function getAngle(d){return d.angle}})),showLabels&&!labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}),children,showLabels&&labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}))}RadialChart.displayName="RadialChart";RadialChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.arrayOf(_propTypes2.default.shape({angle:_propTypes2.default.number,className:_propTypes2.default.string,label:_propTypes2.default.string,radius:_propTypes2.default.number,style:_propTypes2.default.object})).isRequired,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number]),getRadius:_propTypes2.default.func,getRadius0:_propTypes2.default.func,getLabel:_propTypes2.default.func,height:_propTypes2.default.number.isRequired,labelsAboveChildren:_propTypes2.default.bool,labelsStyle:_propTypes2.default.object,margin:_chartUtils.MarginPropType,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,showLabels:_propTypes2.default.bool,style:_propTypes2.default.object,subLabel:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};RadialChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,padAngle:0,getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},getRadius:function getRadius(d){return d.radius},getRadius0:function getRadius0(d){return d.radius0},getLabel:function getLabel(d){return d.label},getSubLabel:function getSubLabel(d){return d.subLabel}};exports.default=RadialChart},{"../animation":74,"../plot/series/arc-series":100,"../plot/series/label-series":113,"../plot/xy-plot":130,"../theme":136,"../utils/chart-utils":142,"../utils/series-utils":146,"d3-shape":15,"prop-types":33,react:73}],133:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i90?"end":"start"},row.labelStyle),rotation:rotateLabels?rotAngle>90?rotAngle+180:rotAngle===90?90:rotAngle:null})})}var NOOP=function NOOP(){};function Sunburst(props){var getAngle=props.getAngle,getAngle0=props.getAngle0,animation=props.animation,className=props.className,children=props.children,data=props.data,height=props.height,hideRootNode=props.hideRootNode,getLabel=props.getLabel,width=props.width,getSize=props.getSize,colorType=props.colorType;var mappedData=getNodesToRender({data:data,height:height,hideRootNode:hideRootNode,width:width,getSize:getSize});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var margin=(0,_chartUtils.getRadialLayoutMargin)(width,height,radialDomain);var labelData=buildLabels(mappedData,{getAngle:getAngle,getAngle0:getAngle0,getLabel:getLabel,getRadius0:function getRadius0(d){return d.radius0}});var hofBuilder=function hofBuilder(f){return function(e,i){return f?f(mappedData[e.index],i):NOOP}};return _react2.default.createElement(_xyPlot2.default,{height:height,hasTreeStructure:true,width:width,className:predefinedClassName+" "+className,margin:margin,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:animation?mappedData.map(function(row,index){return _extends({},row,{parent:null,children:null,index:index})}):mappedData,_data:animation?mappedData:null,arcClassName:predefinedClassName+"__series--radial__arc"},LISTENERS_TO_OVERWRITE.reduce(function(acc,propName){var prop=props[propName];acc[propName]=animation?hofBuilder(prop):prop;return acc},{}))),labelData.length>0&&_react2.default.createElement(_labelSeries2.default,{data:labelData,getLabel:getLabel}),children)}Sunburst.displayName="Sunburst";Sunburst.propTypes={animation:_animation.AnimationPropType,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.object.isRequired,height:_propTypes2.default.number.isRequired,hideRootNode:_propTypes2.default.bool,getLabel:_propTypes2.default.func,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,getSize:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number])};Sunburst.defaultProps={getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},className:"",colorType:"literal",getColor:function getColor(d){return d.color},hideRootNode:false,getLabel:function getLabel(d){return d.label},getSize:function getSize(d){return d.size},padAngle:0};exports.default=Sunburst},{"../animation":74,"../plot/series/arc-series":100,"../plot/series/label-series":113,"../plot/xy-plot":130,"../utils/chart-utils":142,"../utils/series-utils":146,"d3-hierarchy":10,"d3-scale":14,"prop-types":33,react:73}],136:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var DISCRETE_COLOR_RANGE=exports.DISCRETE_COLOR_RANGE=["#12939A","#79C7E3","#1A3177","#FF9833","#EF5D28"];var EXTENDED_DISCRETE_COLOR_RANGE=exports.EXTENDED_DISCRETE_COLOR_RANGE=["#19CDD7","#DDB27C","#88572C","#FF991F","#F15C17","#223F9A","#DA70BF","#125C77","#4DC19C","#776E57","#12939A","#17B8BE","#F6D18A","#B7885E","#FFCB99","#F89570","#829AE3","#E79FD5","#1E96BE","#89DAC1","#B3AD9E"];var CONTINUOUS_COLOR_RANGE=exports.CONTINUOUS_COLOR_RANGE=["#EF5D28","#FF9833"];var SIZE_RANGE=exports.SIZE_RANGE=[1,10];var OPACITY_RANGE=exports.OPACITY_RANGE=[.1,1];var OPACITY_TYPE=exports.OPACITY_TYPE="literal";var DEFAULT_OPACITY=exports.DEFAULT_OPACITY=1;var DEFAULT_SIZE=exports.DEFAULT_SIZE=5;var DEFAULT_COLOR=exports.DEFAULT_COLOR=DISCRETE_COLOR_RANGE[0];var DEFAULT_TICK_SIZE=exports.DEFAULT_TICK_SIZE=7},{}],137:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i300){return 10}return 5}return 20}function getTickValues(scale,tickTotal,tickValues){return!tickValues?scale.ticks?scale.ticks(tickTotal):scale.domain():tickValues}function generateFit(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return{left:axisStart.y,right:axisEnd.y,slope:0,offset:axisStart.x}}var slope=(axisStart.y-axisEnd.y)/(axisStart.x-axisEnd.x);return{left:axisStart.x,right:axisEnd.x,slope:slope,offset:axisStart.y-slope*axisStart.x}}function generatePoints(_ref){var axisStart=_ref.axisStart,axisEnd=_ref.axisEnd,numberOfTicks=_ref.numberOfTicks,axisDomain=_ref.axisDomain;var _generateFit=generateFit(axisStart,axisEnd),left=_generateFit.left,right=_generateFit.right,slope=_generateFit.slope,offset=_generateFit.offset;var pointSlope=(right-left)/numberOfTicks;var axisScale=(0,_d3Scale.scaleLinear)().domain([left,right]).range(axisDomain);var slopeVertical=axisStart.x===axisEnd.x;return{slope:slopeVertical?Infinity:slope,points:(0,_d3Array.range)(left,right+pointSlope,pointSlope).map(function(val){if(slopeVertical){return{y:val,x:slope*val+offset,text:axisScale(val)}}return{x:val,y:slope*val+offset,text:axisScale(val)}}).slice(0,numberOfTicks+1)}}function getAxisAngle(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return axisEnd.y>axisStart.y?Math.PI/2:3*Math.PI/2}return Math.atan((axisEnd.y-axisStart.y)/(axisEnd.x-axisStart.x))}exports.default={DIRECTION:DIRECTION,ORIENTATION:ORIENTATION,getTicksTotalFromSize:getTicksTotalFromSize,getTickValues:getTickValues}},{"d3-array":3,"d3-scale":14}],142:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_MARGINS=exports.MarginPropType=undefined;var _extends=Object.assign||function(target){for(var i=1;ivalue){result[0]=value}if(result[result.length-1]13||Number(major)>13;var isReactDOMSupported=exports.isReactDOMSupported=function isReactDOMSupported(){return versionHigherThanThirteen};var getDOMNode=exports.getDOMNode=function getDOMNode(ref){if(!isReactDOMSupported()){return ref&&ref.getDOMNode()}return ref};var USED_MESSAGES={};var HIDDEN_PROCESSES={test:true,production:true};function warning(message){var onlyShowMessageOnce=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(global.process&&HIDDEN_PROCESSES[process.env.NODE_ENV]){return}if(!onlyShowMessageOnce||!USED_MESSAGES[message]){console.warn(message);USED_MESSAGES[message]=true}}function warnOnce(message){warning(message,true)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:1,react:73}],145:[function(require,module,exports){"use strict";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[Symbol.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(Symbol.iterator in Object(arr)){return sliceIterator(arr,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();var _extends=Object.assign||function(target){for(var i=1;istop-scale.padding()*scale.step())domainIndex=n-1;else domainIndex=Math.floor((_-start-scale.padding()*scale.step())/scale.step());return scale.domain()[domainIndex]}}function getScaleFnFromScaleObject(scaleObject){if(!scaleObject){return null}var type=scaleObject.type,domain=scaleObject.domain,range=scaleObject.range;var modDomain=domain[0]===domain[1]?domain[0]===0?[-1,0]:[-domain[0],domain[0]]:domain;if(type===LITERAL_SCALE_TYPE){return literalScale(range[0])}var scale=SCALE_FUNCTIONS[type]().domain(modDomain).range(range);if(type===ORDINAL_SCALE_TYPE){scale.padding(.5);addInvertFunctionToOrdinalScaleObject(scale)}return scale}function getDomainByAccessor(allData,accessor,accessor0,type){var domain=void 0;var values=allData.reduce(function(data,d){var value=accessor(d);var value0=accessor0(d);if(_isDefined(value)){data.push(value)}if(_isDefined(value0)){data.push(value0)}return data},[]);if(!values.length){return[]}if(type!==ORDINAL_SCALE_TYPE&&type!==CATEGORY_SCALE_TYPE){domain=(0,_d3Array.extent)(values)}else{domain=(0,_d3Collection.set)(values).values()}return domain}function _createScaleObjectForValue(attr,value,type,accessor,accessor0){if(type===LITERAL_SCALE_TYPE){return{type:LITERAL_SCALE_TYPE,domain:[],range:[value],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}if(typeof value==="undefined"){return null}return{type:CATEGORY_SCALE_TYPE,range:[value],domain:[],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}function _createScaleObjectForFunction(_ref){var domain=_ref.domain,range=_ref.range,type=_ref.type,distance=_ref.distance,attr=_ref.attr,baseValue=_ref.baseValue,accessor=_ref.accessor,accessor0=_ref.accessor0;return{domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,isValue:false,accessor:accessor,accessor0:accessor0}}function _collectScaleObjectFromProps(props,attr){var value=props[attr],fallbackValue=props["_"+attr+"Value"],range=props[attr+"Range"],_props$=props[attr+"Distance"],distance=_props$===undefined?0:_props$,baseValue=props[attr+"BaseValue"],_props$2=props[attr+"Type"],type=_props$2===undefined?LINEAR_SCALE_TYPE:_props$2,noFallBack=props[attr+"NoFallBack"],_props$3=props["get"+toTitleCase(attr)],accessor=_props$3===undefined?function(d){return d[attr]}:_props$3,_props$4=props["get"+toTitleCase(attr)+"0"],accessor0=_props$4===undefined?function(d){return d[attr+"0"]}:_props$4;var domain=props[attr+"Domain"];if(!noFallBack&&typeof value!=="undefined"){return _createScaleObjectForValue(attr,value,props[attr+"Type"],accessor,accessor0)}if(typeof baseValue!=="undefined"){domain=(0,_dataUtils.addValueToArray)(domain,baseValue)}if(!range||!domain||!domain.length){return _createScaleObjectForValue(attr,fallbackValue,props[attr+"Type"],accessor,accessor0)}return _createScaleObjectForFunction({domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,accessor:accessor,accessor0:accessor0})}function _computeLeftDomainAdjustment(values){if(values.length>1){return(values[1]-values[0])/2}if(values.length===1){return values[0]-.5}return 0}function _computeRightDomainAdjustment(values){if(values.length>1){return(values[values.length-1]-values[values.length-2])/2}if(values.length===1){return values[0]-.5}return 0}function _computeScaleDistance(values,domain,bestDistIndex,scaleFn){if(values.length>1){var i=Math.max(bestDistIndex,1);return Math.abs(scaleFn(values[i])-scaleFn(values[i-1]))}if(values.length===1){return Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}return 0}function _normalizeValues(data,values,accessor0,type){ -if(type===TIME_SCALE_TYPE&&values.length===1){var attr0=accessor0(data[0]);return[attr0].concat(_toConsumableArray(values))}return values}function _getScaleDistanceAndAdjustedDomain(data,scaleObject){var domain=scaleObject.domain,type=scaleObject.type,accessor=scaleObject.accessor,accessor0=scaleObject.accessor0;var uniqueValues=(0,_dataUtils.getUniquePropertyValues)(data,accessor);var values=_normalizeValues(data,uniqueValues,accessor0,type);var index=_getSmallestDistanceIndex(values,scaleObject);var adjustedDomain=[].concat(domain);adjustedDomain[0]-=_computeLeftDomainAdjustment(values);adjustedDomain[domain.length-1]+=_computeRightDomainAdjustment(values);if(type===LOG_SCALE_TYPE&&domain[0]<=0){adjustedDomain[0]=Math.min(domain[1]/10,1)}var adjustedScaleFn=getScaleFnFromScaleObject(_extends({},scaleObject,{domain:adjustedDomain}));var distance=_computeScaleDistance(values,adjustedDomain,index,adjustedScaleFn);return{domain0:adjustedDomain[0],domainN:adjustedDomain[adjustedDomain.length-1],distance:distance}}function _isScaleAdjustmentPossible(props,scaleObject){var attr=scaleObject.attr;var _props$_adjustBy=props._adjustBy,adjustBy=_props$_adjustBy===undefined?[]:_props$_adjustBy,_props$_adjustWhat=props._adjustWhat,adjustWhat=_props$_adjustWhat===undefined?[]:_props$_adjustWhat;return adjustWhat.length&&adjustBy.length&&adjustBy.indexOf(attr)!==-1}function _adjustContinuousScale(props,scaleObject){var allSeriesData=props._allData,_props$_adjustWhat2=props._adjustWhat,adjustWhat=_props$_adjustWhat2===undefined?[]:_props$_adjustWhat2;var domainLength=scaleObject.domain.length;var domain=scaleObject.domain;var scaleDomain0=domain[0];var scaleDomainN=domain[domainLength-1];var scaleDistance=scaleObject.distance;allSeriesData.forEach(function(data,index){if(adjustWhat.indexOf(index)===-1){return}if(data&&data.length){var _getScaleDistanceAndA=_getScaleDistanceAndAdjustedDomain(data,scaleObject),domain0=_getScaleDistanceAndA.domain0,domainN=_getScaleDistanceAndA.domainN,distance=_getScaleDistanceAndA.distance;scaleDomain0=Math.min(scaleDomain0,domain0);scaleDomainN=Math.max(scaleDomainN,domainN);scaleDistance=Math.max(scaleDistance,distance)}});scaleObject.domain=[scaleDomain0].concat(_toConsumableArray(domain.slice(1,-1)),[scaleDomainN]);scaleObject.distance=scaleDistance;return scaleObject}function _adjustCategoricalScale(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);var domain=scaleObject.domain,range=scaleObject.range;if(domain.length>1){scaleObject.distance=Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}else{scaleObject.distance=Math.abs(range[1]-range[0])}return scaleObject}function getScaleObjectFromProps(props,attr){var scaleObject=_collectScaleObjectFromProps(props,attr);if(!scaleObject){return null}if(!_isScaleAdjustmentPossible(props,scaleObject)){return scaleObject}var type=scaleObject.type;if(type===ORDINAL_SCALE_TYPE||type===CATEGORY_SCALE_TYPE){return _adjustCategoricalScale(scaleObject)}return _adjustContinuousScale(props,scaleObject)}function getAttributeScale(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);return getScaleFnFromScaleObject(scaleObject)}function _getAttrValue(d,accessor){return accessor(d.data?d.data:d)}function _isDefined(value){return typeof value!=="undefined"}function _padDomain(domain,padding){if(!domain){return domain}if(isNaN(parseFloat(domain[0]))||isNaN(parseFloat(domain[1]))){return domain}var _domain=_slicedToArray(domain,2),min=_domain[0],max=_domain[1];var domainPadding=(max-min)*(padding*.01);return[min-domainPadding,max+domainPadding]}function getAttributeFunctor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){return scaleFn(_getAttrValue(d,scaleObject.accessor))}}return null}function getAttr0Functor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var domain=scaleObject.domain;var _scaleObject$baseValu=scaleObject.baseValue,baseValue=_scaleObject$baseValu===undefined?domain[0]:_scaleObject$baseValu;var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){var value=_getAttrValue(d,scaleObject.accessor0);return scaleFn(_isDefined(value)?value:baseValue)}}return null}function getAttributeValue(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){if(!scaleObject.isValue&&props["_"+attr+"Value"]===undefined){(0,_reactUtils.warning)("[React-vis] Cannot use data defined "+attr+" for this "+"series type. Using fallback value instead.")}return props["_"+attr+"Value"]||scaleObject.range[0]}return null}function getScalePropTypesByAttribute(attr){var _ref2;return _ref2={},_defineProperty(_ref2,"_"+attr+"Value",_propTypes2.default.any),_defineProperty(_ref2,attr+"Domain",_propTypes2.default.array),_defineProperty(_ref2,"get"+toTitleCase(attr),_propTypes2.default.func),_defineProperty(_ref2,"get"+toTitleCase(attr)+"0",_propTypes2.default.func),_defineProperty(_ref2,attr+"Range",_propTypes2.default.array),_defineProperty(_ref2,attr+"Type",_propTypes2.default.oneOf(Object.keys(SCALE_FUNCTIONS))),_defineProperty(_ref2,attr+"Distance",_propTypes2.default.number),_defineProperty(_ref2,attr+"BaseValue",_propTypes2.default.any),_ref2}function extractScalePropsFromProps(props,attributes){var result={};Object.keys(props).forEach(function(key){var attr=attributes.find(function(a){var isPlainSet=key.indexOf(a)===0;var isUnderscoreSet=key.indexOf("_"+a)===0;var usesGet=key.indexOf("get"+toTitleCase(a))===0;return isPlainSet||isUnderscoreSet||usesGet});if(!attr){return}result[key]=props[key]});return result}function getMissingScaleProps(props,data,attributes){var result={};attributes.forEach(function(attr){if(!props["get"+toTitleCase(attr)]){result["get"+toTitleCase(attr)]=function(d){return d[attr]}}if(!props["get"+toTitleCase(attr)+"0"]){result["get"+toTitleCase(attr)+"0"]=function(d){return d[attr+"0"]}}if(!props[attr+"Domain"]){result[attr+"Domain"]=getDomainByAccessor(data,props["get"+toTitleCase(attr)]||result["get"+toTitleCase(attr)],props["get"+toTitleCase(attr)+"0"]||result["get"+toTitleCase(attr)+"0"],props[attr+"Type"]);if(props[attr+"Padding"]){result[attr+"Domain"]=_padDomain(result[attr+"Domain"],props[attr+"Padding"])}}});return result}function literalScale(defaultValue){function scale(d){if(d===undefined){return defaultValue}return d}function response(){return scale}scale.domain=response;scale.range=response;scale.unknown=response;scale.copy=response;return scale}function getFontColorFromBackground(background){if(background){return(0,_d3Color.hsl)(background).l>.57?"#222":"#fff"}return null}function getXYPlotValues(props,children){var XYPlotScales=XYPLOT_ATTR.reduce(function(prev,attr){var domain=props[attr+"Domain"],range=props[attr+"Range"],type=props[attr+"Type"];if(domain&&range&&type){return _extends({},prev,_defineProperty({},attr,SCALE_FUNCTIONS[type]().domain(domain).range(range)))}return prev},{});return children.map(function(child){return XYPLOT_ATTR.reduce(function(prev,attr){if(child.props&&child.props[attr]!==undefined){var scaleInput=child.props[attr];var scale=XYPlotScales[attr];var fallbackValue=scale?scale(scaleInput):scaleInput;return _extends({},prev,_defineProperty({},"_"+attr+"Value",fallbackValue))}return prev},{})})}var OPTIONAL_SCALE_PROPS=["Padding"];var OPTIONAL_SCALE_PROPS_REGS=OPTIONAL_SCALE_PROPS.map(function(str){return new RegExp(str+"$","i")});function getOptionalScaleProps(props){return Object.keys(props).reduce(function(acc,prop){var propIsNotOptional=OPTIONAL_SCALE_PROPS_REGS.every(function(reg){return!prop.match(reg)});if(propIsNotOptional){return acc}acc[prop]=props[prop];return acc},{})}exports.default={extractScalePropsFromProps:extractScalePropsFromProps,getAttributeScale:getAttributeScale,getAttributeFunctor:getAttributeFunctor,getAttr0Functor:getAttr0Functor,getAttributeValue:getAttributeValue,getDomainByAccessor:getDomainByAccessor,getFontColorFromBackground:getFontColorFromBackground,getMissingScaleProps:getMissingScaleProps,getOptionalScaleProps:getOptionalScaleProps,getScaleObjectFromProps:getScaleObjectFromProps,getScalePropTypesByAttribute:getScalePropTypesByAttribute,getXYPlotValues:getXYPlotValues,literalScale:literalScale}},{"./data-utils":143,"./react-utils":144,"d3-array":3,"d3-collection":4,"d3-color":5,"d3-scale":14,"prop-types":33}],146:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ANIMATED_SERIES_PROPS=undefined;var _extends=Object.assign||function(target){for(var i=1;i0&&arguments[0]!==undefined?arguments[0]:[];if(!data){return false}return data.some(function(row){return row.radius&&row.angle})}function prepareData(data){if(!seriesHasAngleRadius(data)){return data}return data.map(function(row){return _extends({},row,{x:row.radius*Math.cos(row.angle),y:row.radius*Math.sin(row.angle)})})}function getStackedData(children,attr){var areSomeSeriesStacked=children.some(function(series){return series&&series.props.stack});var latestAttrPositions={};return children.reduce(function(accumulator,series,seriesIndex){if(!series){accumulator.push(null);return accumulator}var _series$props=series.props,data=_series$props.data,_series$props$cluster=_series$props.cluster,cluster=_series$props$cluster===undefined?"default":_series$props$cluster,stack=_series$props.stack;var preppedData=prepareData(data,attr);if(!attr||!preppedData||!preppedData.length||areSomeSeriesStacked&&!stack){accumulator.push(preppedData);return accumulator}var attr0=attr+"0";var baseAttr=attr==="y"?"x":"y";accumulator.push(preppedData.map(function(d,dIndex){var _extends2,_latestAttrPositions$2;if(!latestAttrPositions[cluster]){latestAttrPositions[cluster]={}}var prevD=latestAttrPositions[cluster][d[baseAttr]];if(!prevD){var _latestAttrPositions$;latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$={},_defineProperty(_latestAttrPositions$,attr0,d[attr0]),_defineProperty(_latestAttrPositions$,attr,d[attr]),_latestAttrPositions$);return _extends({},d)}var nextD=_extends({},d,(_extends2={},_defineProperty(_extends2,attr0,prevD[attr]),_defineProperty(_extends2,attr,prevD[attr]+d[attr]-(d[attr0]||0)),_extends2));latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$2={},_defineProperty(_latestAttrPositions$2,attr0,nextD[attr0]),_defineProperty(_latestAttrPositions$2,attr,nextD[attr]),_latestAttrPositions$2);return nextD}));return accumulator},[])}function getSeriesPropsFromChildren(children){var result=[];var seriesTypesInfo=collectSeriesTypesInfo(children);var seriesIndex=0;var _opacityValue=_theme.DEFAULT_OPACITY;children.forEach(function(child){var props=void 0;if(isSeriesChild(child)){var seriesTypeInfo=seriesTypesInfo[child.type.displayName];var _colorValue=_theme.DISCRETE_COLOR_RANGE[seriesIndex%_theme.DISCRETE_COLOR_RANGE.length];props=_extends({},seriesTypeInfo,{seriesIndex:seriesIndex,_colorValue:_colorValue,_opacityValue:_opacityValue});seriesTypeInfo.sameTypeIndex++;seriesIndex++;if(child.props.cluster){props.cluster=child.props.cluster;props.clusters=Array.from(seriesTypeInfo.clusters);props.sameTypeTotal=props.clusters.length;props.sameTypeIndex=props.clusters.indexOf(child.props.cluster)}}result.push(props)});return result}function getRadialDomain(data){return data.reduce(function(res,row){return Math.max(row.radius,res)},0)}var ANIMATED_SERIES_PROPS=exports.ANIMATED_SERIES_PROPS=["xRange","xDomain","x","yRange","yDomain","y","colorRange","colorDomain","color","opacityRange","opacityDomain","opacity","strokeRange","strokeDomain","stroke","fillRange","fillDomain","fill","width","height","marginLeft","marginTop","marginRight","marginBottom","data","angleDomain","angleRange","angle","radiusDomain","radiusRange","radius","innerRadiusDomain","innerRadiusRange","innerRadius"];function getStackParams(props){var _stackBy=props._stackBy,valuePosAttr=props.valuePosAttr,cluster=props.cluster;var _props$sameTypeTotal=props.sameTypeTotal,sameTypeTotal=_props$sameTypeTotal===undefined?1:_props$sameTypeTotal,_props$sameTypeIndex=props.sameTypeIndex,sameTypeIndex=_props$sameTypeIndex===undefined?0:_props$sameTypeIndex;if(_stackBy===valuePosAttr&&!cluster){sameTypeTotal=1;sameTypeIndex=0}return{sameTypeTotal:sameTypeTotal,sameTypeIndex:sameTypeIndex}}},{"../plot/series/abstract-series":99,"../theme":136,react:73}]},{},[75])(75)}); +;var key=element.key;var ref=element.ref;var self=element._self;var source=element._source;var owner=element._owner;if(config!=null){if(hasValidRef(config)){ref=config.ref;owner=ReactCurrentOwner.current}if(hasValidKey(config)){key=""+config.key}var defaultProps;if(element.type&&element.type.defaultProps){defaultProps=element.type.defaultProps}for(propName in config){if(hasOwnProperty.call(config,propName)&&!RESERVED_PROPS.hasOwnProperty(propName)){if(config[propName]===undefined&&defaultProps!==undefined){props[propName]=defaultProps[propName]}else{props[propName]=config[propName]}}}}var childrenLength=arguments.length-2;if(childrenLength===1){props.children=children}else if(childrenLength>1){var childArray=Array(childrenLength);for(var i=0;i."}}return info}function validateExplicitKey(element,parentType){if(!element._store||element._store.validated||element.key!=null){return}element._store.validated=true;var memoizer=ownerHasKeyUseWarning.uniqueKey||(ownerHasKeyUseWarning.uniqueKey={});var currentComponentErrorInfo=getCurrentComponentErrorInfo(parentType);if(memoizer[currentComponentErrorInfo]){return}memoizer[currentComponentErrorInfo]=true;var childOwner="";if(element&&element._owner&&element._owner!==ReactCurrentOwner.current){childOwner=" It was passed a child from "+element._owner.getName()+"."}process.env.NODE_ENV!=="production"?warning(false,'Each child in an array or iterator should have a unique "key" prop.'+"%s%s See https://fb.me/react-warning-keys for more information.%s",currentComponentErrorInfo,childOwner,ReactComponentTreeHook.getCurrentStackAddendum(element)):void 0}function validateChildKeys(node,parentType){if(typeof node!=="object"){return}if(Array.isArray(node)){for(var i=0;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.warn(message)}try{throw new Error(message)}catch(x){}};lowPriorityWarning=function(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=lowPriorityWarning}).call(this,require("_process"))},{_process:1}],70:[function(require,module,exports){(function(process){"use strict";var _prodInvariant=require("./reactProdInvariant");var ReactElement=require("./ReactElement");var invariant=require("fbjs/lib/invariant");function onlyChild(children){!ReactElement.isValidElement(children)?process.env.NODE_ENV!=="production"?invariant(false,"React.Children.only expected to receive a single React element child."):_prodInvariant("143"):void 0;return children}module.exports=onlyChild}).call(this,require("_process"))},{"./ReactElement":57,"./reactProdInvariant":71,_process:1,"fbjs/lib/invariant":24}],71:[function(require,module,exports){"use strict";function reactProdInvariant(code){var argCount=arguments.length-1;var message="Minified React error #"+code+"; visit "+"http://facebook.github.io/react/docs/error-decoder.html?invariant="+code;for(var argIdx=0;argIdx=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}var ANIMATION_PROPTYPES=_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.shape({stiffness:_propTypes2.default.number,nonAnimatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string),damping:_propTypes2.default.number}),_propTypes2.default.bool]);var propTypes={animatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string).isRequired,animation:ANIMATION_PROPTYPES,onStart:_propTypes2.default.func,onEnd:_propTypes2.default.func};function getAnimationStyle(){var animationStyle=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_reactMotion.presets.noWobble;if(typeof animationStyle==="string"){return _reactMotion.presets[animationStyle]||_reactMotion.presets.noWobble}var damping=animationStyle.damping,stiffness=animationStyle.stiffness;return _extends({damping:damping||_reactMotion.presets.noWobble.damping,stiffness:stiffness||_reactMotion.presets.noWobble.stiffness},animationStyle)}function extractAnimatedPropValues(props){var animatedProps=props.animatedProps,otherProps=_objectWithoutProperties(props,["animatedProps"]);return animatedProps.reduce(function(result,animatedPropName){if(otherProps.hasOwnProperty(animatedPropName)){result[animatedPropName]=otherProps[animatedPropName]}return result},{})}var Animation=function(_PureComponent){_inherits(Animation,_PureComponent);function Animation(props){_classCallCheck(this,Animation);var _this=_possibleConstructorReturn(this,(Animation.__proto__||Object.getPrototypeOf(Animation)).call(this,props));_this._motionEndHandler=function(){if(_this.props.onEnd){_this.props.onEnd()}};_this._renderChildren=function(_ref){var i=_ref.i;var children=_this.props.children;var interpolator=_this._interpolator;var child=_react2.default.Children.only(children);var interpolatedProps=interpolator?interpolator(i):interpolator;var data=interpolatedProps&&interpolatedProps.data||null;if(data&&child.props._data){data=data.map(function(row,index){var correspondingCell=child.props._data[index];return _extends({},row,{parent:correspondingCell.parent,children:correspondingCell.children})})}return _react2.default.cloneElement(child,_extends({},child.props,interpolatedProps,{data:data||child.props.data||null,_animation:Math.random()}))};_this._updateInterpolator(props);return _this}_createClass(Animation,[{key:"componentWillUpdate",value:function componentWillUpdate(props){this._updateInterpolator(this.props,props);if(props.onStart){props.onStart()}}},{key:"_updateInterpolator",value:function _updateInterpolator(oldProps,newProps){this._interpolator=(0,_d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps),newProps?extractAnimatedPropValues(newProps):null)}},{key:"render",value:function render(){var animationStyle=getAnimationStyle(this.props.animation);var defaultStyle={i:0};var style={i:(0,_reactMotion.spring)(1,animationStyle)};var key=Math.random();return _react2.default.createElement(_reactMotion.Motion,_extends({defaultStyle:defaultStyle,style:style,key:key},{onRest:this._motionEndHandler}),this._renderChildren)}}]);return Animation}(_react.PureComponent);Animation.propTypes=propTypes;Animation.displayName="Animation";exports.default=Animation;var AnimationPropType=exports.AnimationPropType=ANIMATION_PROPTYPES},{"d3-interpolate":11,"prop-types":33,react:73,"react-motion":43}],75:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ScaleUtils=exports.AxisUtils=exports.FlexibleHeightXYPlot=exports.FlexibleWidthXYPlot=exports.FlexibleXYPlot=exports.makeWidthFlexible=exports.makeVisFlexible=exports.makeHeightFlexible=exports.Sunburst=exports.Sankey=exports.ParallelCoordinates=exports.RadarChart=exports.RadialChart=exports.Treemap=exports.ContinuousSizeLegend=exports.ContinuousColorLegend=exports.SearchableDiscreteColorLegend=exports.DiscreteColorLegend=exports.Highlight=exports.Voronoi=exports.HorizontalGridLines=exports.VerticalGridLines=exports.GradientDefs=exports.GridLines=exports.ChartLabel=exports.CircularGridLines=exports.YAxis=exports.XAxis=exports.DecorativeAxis=exports.XYPlot=exports.Crosshair=exports.Borders=exports.Hint=exports.LineMarkSeriesCanvas=exports.LineMarkSeries=exports.ArcSeries=exports.AreaSeries=exports.CustomSVGSeries=exports.ContourSeries=exports.HexbinSeries=exports.HeatmapSeries=exports.WhiskerSeries=exports.MarkSeriesCanvas=exports.MarkSeries=exports.RectSeriesCanvas=exports.RectSeries=exports.PolygonSeries=exports.LabelSeries=exports.HorizontalRectSeriesCanvas=exports.HorizontalRectSeries=exports.VerticalRectSeriesCanvas=exports.VerticalRectSeries=exports.VerticalBarSeriesCanvas=exports.VerticalBarSeries=exports.HorizontalBarSeriesCanvas=exports.HorizontalBarSeries=exports.LineSeriesCanvas=exports.LineSeries=exports.AbstractSeries=undefined;var _makeVisFlexible=require("./make-vis-flexible");Object.defineProperty(exports,"makeHeightFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeHeightFlexible}});Object.defineProperty(exports,"makeVisFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeVisFlexible}});Object.defineProperty(exports,"makeWidthFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeWidthFlexible}});Object.defineProperty(exports,"FlexibleXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleXYPlot}});Object.defineProperty(exports,"FlexibleWidthXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleWidthXYPlot}});Object.defineProperty(exports,"FlexibleHeightXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleHeightXYPlot}});var _abstractSeries=require("./plot/series/abstract-series");var _abstractSeries2=_interopRequireDefault(_abstractSeries);var _lineSeries=require("./plot/series/line-series");var _lineSeries2=_interopRequireDefault(_lineSeries);var _lineSeriesCanvas=require("./plot/series/line-series-canvas");var _lineSeriesCanvas2=_interopRequireDefault(_lineSeriesCanvas);var _horizontalBarSeries=require("./plot/series/horizontal-bar-series");var _horizontalBarSeries2=_interopRequireDefault(_horizontalBarSeries);var _horizontalBarSeriesCanvas=require("./plot/series/horizontal-bar-series-canvas");var _horizontalBarSeriesCanvas2=_interopRequireDefault(_horizontalBarSeriesCanvas);var _verticalBarSeries=require("./plot/series/vertical-bar-series");var _verticalBarSeries2=_interopRequireDefault(_verticalBarSeries);var _verticalBarSeriesCanvas=require("./plot/series/vertical-bar-series-canvas");var _verticalBarSeriesCanvas2=_interopRequireDefault(_verticalBarSeriesCanvas);var _verticalRectSeries=require("./plot/series/vertical-rect-series");var _verticalRectSeries2=_interopRequireDefault(_verticalRectSeries);var _verticalRectSeriesCanvas=require("./plot/series/vertical-rect-series-canvas");var _verticalRectSeriesCanvas2=_interopRequireDefault(_verticalRectSeriesCanvas);var _horizontalRectSeries=require("./plot/series/horizontal-rect-series");var _horizontalRectSeries2=_interopRequireDefault(_horizontalRectSeries);var _horizontalRectSeriesCanvas=require("./plot/series/horizontal-rect-series-canvas");var _horizontalRectSeriesCanvas2=_interopRequireDefault(_horizontalRectSeriesCanvas);var _labelSeries=require("./plot/series/label-series");var _labelSeries2=_interopRequireDefault(_labelSeries);var _polygonSeries=require("./plot/series/polygon-series");var _polygonSeries2=_interopRequireDefault(_polygonSeries);var _rectSeries=require("./plot/series/rect-series");var _rectSeries2=_interopRequireDefault(_rectSeries);var _rectSeriesCanvas=require("./plot/series/rect-series-canvas");var _rectSeriesCanvas2=_interopRequireDefault(_rectSeriesCanvas);var _markSeries=require("./plot/series/mark-series");var _markSeries2=_interopRequireDefault(_markSeries);var _markSeriesCanvas=require("./plot/series/mark-series-canvas");var _markSeriesCanvas2=_interopRequireDefault(_markSeriesCanvas);var _whiskerSeries=require("./plot/series/whisker-series");var _whiskerSeries2=_interopRequireDefault(_whiskerSeries);var _heatmapSeries=require("./plot/series/heatmap-series");var _heatmapSeries2=_interopRequireDefault(_heatmapSeries);var _hexbinSeries=require("./plot/series/hexbin-series");var _hexbinSeries2=_interopRequireDefault(_hexbinSeries);var _contourSeries=require("./plot/series/contour-series");var _contourSeries2=_interopRequireDefault(_contourSeries);var _customSvgSeries=require("./plot/series/custom-svg-series");var _customSvgSeries2=_interopRequireDefault(_customSvgSeries);var _areaSeries=require("./plot/series/area-series");var _areaSeries2=_interopRequireDefault(_areaSeries);var _arcSeries=require("./plot/series/arc-series");var _arcSeries2=_interopRequireDefault(_arcSeries);var _lineMarkSeries=require("./plot/series/line-mark-series");var _lineMarkSeries2=_interopRequireDefault(_lineMarkSeries);var _lineMarkSeriesCanvas=require("./plot/series/line-mark-series-canvas");var _lineMarkSeriesCanvas2=_interopRequireDefault(_lineMarkSeriesCanvas);var _hint=require("./plot/hint");var _hint2=_interopRequireDefault(_hint);var _borders=require("./plot/borders");var _borders2=_interopRequireDefault(_borders);var _crosshair=require("./plot/crosshair");var _crosshair2=_interopRequireDefault(_crosshair);var _xyPlot=require("./plot/xy-plot");var _xyPlot2=_interopRequireDefault(_xyPlot);var _decorativeAxis=require("./plot/axis/decorative-axis");var _decorativeAxis2=_interopRequireDefault(_decorativeAxis);var _xAxis=require("./plot/axis/x-axis");var _xAxis2=_interopRequireDefault(_xAxis);var _yAxis=require("./plot/axis/y-axis");var _yAxis2=_interopRequireDefault(_yAxis);var _circularGridLines=require("./plot/circular-grid-lines");var _circularGridLines2=_interopRequireDefault(_circularGridLines);var _chartLabel=require("./plot/chart-label");var _chartLabel2=_interopRequireDefault(_chartLabel);var _gridLines=require("./plot/grid-lines");var _gridLines2=_interopRequireDefault(_gridLines);var _gradientDefs=require("./plot/gradient-defs");var _gradientDefs2=_interopRequireDefault(_gradientDefs);var _verticalGridLines=require("./plot/vertical-grid-lines");var _verticalGridLines2=_interopRequireDefault(_verticalGridLines);var _horizontalGridLines=require("./plot/horizontal-grid-lines");var _horizontalGridLines2=_interopRequireDefault(_horizontalGridLines);var _voronoi=require("./plot/voronoi");var _voronoi2=_interopRequireDefault(_voronoi);var _highlight=require("./plot/highlight");var _highlight2=_interopRequireDefault(_highlight);var _discreteColorLegend=require("./legends/discrete-color-legend");var _discreteColorLegend2=_interopRequireDefault(_discreteColorLegend);var _searchableDiscreteColorLegend=require("./legends/searchable-discrete-color-legend");var _searchableDiscreteColorLegend2=_interopRequireDefault(_searchableDiscreteColorLegend);var _continuousColorLegend=require("./legends/continuous-color-legend");var _continuousColorLegend2=_interopRequireDefault(_continuousColorLegend);var _continuousSizeLegend=require("./legends/continuous-size-legend") +;var _continuousSizeLegend2=_interopRequireDefault(_continuousSizeLegend);var _treemap=require("./treemap");var _treemap2=_interopRequireDefault(_treemap);var _radialChart=require("./radial-chart");var _radialChart2=_interopRequireDefault(_radialChart);var _radarChart=require("./radar-chart");var _radarChart2=_interopRequireDefault(_radarChart);var _parallelCoordinates=require("./parallel-coordinates");var _parallelCoordinates2=_interopRequireDefault(_parallelCoordinates);var _sankey=require("./sankey");var _sankey2=_interopRequireDefault(_sankey);var _sunburst=require("./sunburst");var _sunburst2=_interopRequireDefault(_sunburst);var _axisUtils=require("./utils/axis-utils");var _axisUtils2=_interopRequireDefault(_axisUtils);var _scalesUtils=require("./utils/scales-utils");var _scalesUtils2=_interopRequireDefault(_scalesUtils);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.AbstractSeries=_abstractSeries2.default;exports.LineSeries=_lineSeries2.default;exports.LineSeriesCanvas=_lineSeriesCanvas2.default;exports.HorizontalBarSeries=_horizontalBarSeries2.default;exports.HorizontalBarSeriesCanvas=_horizontalBarSeriesCanvas2.default;exports.VerticalBarSeries=_verticalBarSeries2.default;exports.VerticalBarSeriesCanvas=_verticalBarSeriesCanvas2.default;exports.VerticalRectSeries=_verticalRectSeries2.default;exports.VerticalRectSeriesCanvas=_verticalRectSeriesCanvas2.default;exports.HorizontalRectSeries=_horizontalRectSeries2.default;exports.HorizontalRectSeriesCanvas=_horizontalRectSeriesCanvas2.default;exports.LabelSeries=_labelSeries2.default;exports.PolygonSeries=_polygonSeries2.default;exports.RectSeries=_rectSeries2.default;exports.RectSeriesCanvas=_rectSeriesCanvas2.default;exports.MarkSeries=_markSeries2.default;exports.MarkSeriesCanvas=_markSeriesCanvas2.default;exports.WhiskerSeries=_whiskerSeries2.default;exports.HeatmapSeries=_heatmapSeries2.default;exports.HexbinSeries=_hexbinSeries2.default;exports.ContourSeries=_contourSeries2.default;exports.CustomSVGSeries=_customSvgSeries2.default;exports.AreaSeries=_areaSeries2.default;exports.ArcSeries=_arcSeries2.default;exports.LineMarkSeries=_lineMarkSeries2.default;exports.LineMarkSeriesCanvas=_lineMarkSeriesCanvas2.default;exports.Hint=_hint2.default;exports.Borders=_borders2.default;exports.Crosshair=_crosshair2.default;exports.XYPlot=_xyPlot2.default;exports.DecorativeAxis=_decorativeAxis2.default;exports.XAxis=_xAxis2.default;exports.YAxis=_yAxis2.default;exports.CircularGridLines=_circularGridLines2.default;exports.ChartLabel=_chartLabel2.default;exports.GridLines=_gridLines2.default;exports.GradientDefs=_gradientDefs2.default;exports.VerticalGridLines=_verticalGridLines2.default;exports.HorizontalGridLines=_horizontalGridLines2.default;exports.Voronoi=_voronoi2.default;exports.Highlight=_highlight2.default;exports.DiscreteColorLegend=_discreteColorLegend2.default;exports.SearchableDiscreteColorLegend=_searchableDiscreteColorLegend2.default;exports.ContinuousColorLegend=_continuousColorLegend2.default;exports.ContinuousSizeLegend=_continuousSizeLegend2.default;exports.Treemap=_treemap2.default;exports.RadialChart=_radialChart2.default;exports.RadarChart=_radarChart2.default;exports.ParallelCoordinates=_parallelCoordinates2.default;exports.Sankey=_sankey2.default;exports.Sunburst=_sunburst2.default;exports.AxisUtils=_axisUtils2.default;exports.ScaleUtils=_scalesUtils2.default},{"./legends/continuous-color-legend":76,"./legends/continuous-size-legend":77,"./legends/discrete-color-legend":79,"./legends/searchable-discrete-color-legend":80,"./make-vis-flexible":81,"./parallel-coordinates":82,"./plot/axis/decorative-axis":88,"./plot/axis/x-axis":89,"./plot/axis/y-axis":90,"./plot/borders":91,"./plot/chart-label":92,"./plot/circular-grid-lines":93,"./plot/crosshair":94,"./plot/gradient-defs":95,"./plot/grid-lines":96,"./plot/highlight":97,"./plot/hint":98,"./plot/horizontal-grid-lines":99,"./plot/series/abstract-series":100,"./plot/series/arc-series":101,"./plot/series/area-series":102,"./plot/series/contour-series":106,"./plot/series/custom-svg-series":107,"./plot/series/heatmap-series":108,"./plot/series/hexbin-series":109,"./plot/series/horizontal-bar-series":111,"./plot/series/horizontal-bar-series-canvas":110,"./plot/series/horizontal-rect-series":113,"./plot/series/horizontal-rect-series-canvas":112,"./plot/series/label-series":114,"./plot/series/line-mark-series":116,"./plot/series/line-mark-series-canvas":115,"./plot/series/line-series":118,"./plot/series/line-series-canvas":117,"./plot/series/mark-series":120,"./plot/series/mark-series-canvas":119,"./plot/series/polygon-series":121,"./plot/series/rect-series":123,"./plot/series/rect-series-canvas":122,"./plot/series/vertical-bar-series":125,"./plot/series/vertical-bar-series-canvas":124,"./plot/series/vertical-rect-series":127,"./plot/series/vertical-rect-series-canvas":126,"./plot/series/whisker-series":128,"./plot/vertical-grid-lines":129,"./plot/voronoi":130,"./plot/xy-plot":131,"./radar-chart":132,"./radial-chart":133,"./sankey":134,"./sunburst":136,"./treemap":138,"./utils/axis-utils":142,"./utils/scales-utils":146}],76:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _theme=require("../theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,height:_propTypes2.default.number,endColor:_propTypes2.default.string,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,midColor:_propTypes2.default.string,midTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]),startColor:_propTypes2.default.string,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={className:"",startColor:_theme.CONTINUOUS_COLOR_RANGE[0],endColor:_theme.CONTINUOUS_COLOR_RANGE[1]};function ContinuousColorLegend(_ref){var startColor=_ref.startColor,midColor=_ref.midColor,endColor=_ref.endColor,startTitle=_ref.startTitle,midTitle=_ref.midTitle,endTitle=_ref.endTitle,height=_ref.height,width=_ref.width,className=_ref.className;var colors=[startColor];if(midColor){colors.push(midColor)}colors.push(endColor);return _react2.default.createElement("div",{className:"rv-continuous-color-legend "+className,style:{width:width,height:height}},_react2.default.createElement("div",{className:"rv-gradient",style:{background:"linear-gradient(to right, "+colors.join(",")+")"}}),_react2.default.createElement("div",{className:"rv-legend-titles"},_react2.default.createElement("span",{className:"rv-legend-titles__left"},startTitle),_react2.default.createElement("span",{className:"rv-legend-titles__right"},endTitle),midTitle?_react2.default.createElement("span",{className:"rv-legend-titles__center"},midTitle):null))}ContinuousColorLegend.displayName="ContinuousColorLegend";ContinuousColorLegend.propTypes=propTypes;ContinuousColorLegend.defaultProps=defaultProps;exports.default=ContinuousColorLegend},{"../theme":137,"prop-types":33,react:73}],77:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,circlesTotal:_propTypes2.default.number,endSize:_propTypes2.default.number,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,height:_propTypes2.default.number,startSize:_propTypes2.default.number,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={circlesTotal:10,className:"",endSize:20,startSize:2};function ContinuousSizeLegend(_ref){var startTitle=_ref.startTitle,endTitle=_ref.endTitle,startSize=_ref.startSize,endSize=_ref.endSize,circlesTotal=_ref.circlesTotal,height=_ref.height,width=_ref.width,className=_ref.className;var circles=[];var step=(endSize-startSize)/(circlesTotal-1);for(var i=0;i=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}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}var CONTAINER_REF="container";var resizeSubscribers=[];var DEBOUNCE_DURATION=100;var timeoutId=null;function debounceEmitResize(){_window2.default.clearTimeout(timeoutId);timeoutId=_window2.default.setTimeout(emitResize,DEBOUNCE_DURATION)}function emitResize(){resizeSubscribers.forEach(function(cb){return cb()})}function subscribeToDebouncedResize(cb){resizeSubscribers.push(cb);if(resizeSubscribers.length===1){_window2.default.addEventListener("resize",debounceEmitResize)}return function unsubscribe(){removeSubscriber(cb);if(resizeSubscribers.length===0){_window2.default.clearTimeout(timeoutId);_window2.default.removeEventListener("resize",debounceEmitResize)}}}function removeSubscriber(cb){var index=resizeSubscribers.indexOf(cb);if(index>-1){resizeSubscribers.splice(index,1)}}function getDisplayName(Component){return Component.displayName||Component.name||"Component"}function makeFlexible(Component,isWidthFlexible,isHeightFlexible){var ResultClass=function(_React$Component){_inherits(ResultClass,_React$Component);_createClass(ResultClass,null,[{key:"propTypes",get:function get(){var _Component$propTypes=Component.propTypes,height=_Component$propTypes.height,width=_Component$propTypes.width,otherPropTypes=_objectWithoutProperties(_Component$propTypes,["height","width"]);return otherPropTypes}}]);function ResultClass(props){_classCallCheck(this,ResultClass);var _this=_possibleConstructorReturn(this,(ResultClass.__proto__||Object.getPrototypeOf(ResultClass)).call(this,props));_this._onResize=function(){var containerElement=(0,_reactUtils.getDOMNode)(_this[CONTAINER_REF]);var offsetHeight=containerElement.offsetHeight,offsetWidth=containerElement.offsetWidth;var newHeight=_this.state.height===offsetHeight?{}:{height:offsetHeight};var newWidth=_this.state.width===offsetWidth?{}:{width:offsetWidth};_this.setState(_extends({},newHeight,newWidth))};_this.state={height:0,width:0};return _this}_createClass(ResultClass,[{key:"componentDidMount",value:function componentDidMount(){this._onResize();this.cancelSubscription=subscribeToDebouncedResize(this._onResize)}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(){this._onResize()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.cancelSubscription()}},{key:"render",value:function render(){var _this2=this;var _state=this.state,height=_state.height,width=_state.width;var props=_extends({},this.props,{animation:height===0&&width===0?null:this.props.animation});var updatedDimensions=_extends({},isHeightFlexible?{height:height}:{},isWidthFlexible?{width:width}:{});return _react2.default.createElement("div",{ref:function ref(_ref){return _this2[CONTAINER_REF]=_ref},style:{width:"100%",height:"100%"}},_react2.default.createElement(Component,_extends({},updatedDimensions,props)))}}]);return ResultClass}(_react2.default.Component);ResultClass.displayName="Flexible"+getDisplayName(Component);return ResultClass}function makeHeightFlexible(component){return makeFlexible(component,false,true)}function makeVisFlexible(component){return makeFlexible(component,true,true)}function makeWidthFlexible(component){return makeFlexible(component,true,false)}var FlexibleWidthXYPlot=exports.FlexibleWidthXYPlot=makeWidthFlexible(_xyPlot2.default);var FlexibleHeightXYPlot=exports.FlexibleHeightXYPlot=makeHeightFlexible(_xyPlot2.default);var FlexibleXYPlot=exports.FlexibleXYPlot=makeVisFlexible(_xyPlot2.default)},{"./plot/xy-plot":131,"./utils/react-utils":145,"global/window":26,react:73}],82:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;ifilter.max)){withinFilteredRange=false}return{x:name,y:yVal}});var selectedName=predefinedClassName+"-line";var unselectedName=selectedName+" "+predefinedClassName+"-line-unselected";var lineProps={animation:animation,className:withinFilteredRange?selectedName:unselectedName,key:rowIndex+"-polygon",data:mappedData,color:row.color||colorRange[rowIndex%colorRange.length],style:_extends({},style.lines,row.style||{})};if(!withinFilteredRange){lineProps.style=_extends({},lineProps.style,style.deselectedLineStyle)}return showMarks?_react2.default.createElement(_lineMarkSeries2.default,lineProps):_react2.default.createElement(_lineSeries2.default,lineProps)})}var ParallelCoordinates=function(_Component){_inherits(ParallelCoordinates,_Component);function ParallelCoordinates(){var _ref2;var _temp,_this,_ret;_classCallCheck(this,ParallelCoordinates);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}return _ret=(_temp=(_this=_possibleConstructorReturn(this,(_ref2=ParallelCoordinates.__proto__||Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2,[this].concat(args))),_this),_this.state={brushFilters:{}},_temp),_possibleConstructorReturn(_this,_ret)}_createClass(ParallelCoordinates,[{key:"render",value:function render(){var _this2=this;var brushFilters=this.state.brushFilters;var _props=this.props,animation=_props.animation,brushing=_props.brushing,className=_props.className,children=_props.children,colorRange=_props.colorRange,data=_props.data,domains=_props.domains,height=_props.height,hideInnerMostValues=_props.hideInnerMostValues,margin=_props.margin,onMouseLeave=_props.onMouseLeave,onMouseEnter=_props.onMouseEnter,showMarks=_props.showMarks,style=_props.style,tickFormat=_props.tickFormat,width=_props.width;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,style:style,tickFormat:tickFormat});var lines=getLines({animation:animation,brushFilters:brushFilters,colorRange:colorRange,domains:domains,data:data,showMarks:showMarks,style:style});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:true,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels})});var _getInnerDimensions=(0,_chartUtils.getInnerDimensions)(this.props,_chartUtils.DEFAULT_MARGINS),marginLeft=_getInnerDimensions.marginLeft,marginRight=_getInnerDimensions.marginRight;return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xType:"ordinal",yDomain:[0,1]},children,axes.concat(lines).concat(labelSeries),brushing&&domains.map(function(d){var trigger=function trigger(row){_this2.setState({brushFilters:_extends({},brushFilters,_defineProperty({},d.name,row?{min:row.bottom,max:row.top}:null))})};return _react2.default.createElement(_highlight2.default,{key:d.name,drag:true,highlightX:d.name,onBrushEnd:trigger,onDragEnd:trigger,highlightWidth:(width-marginLeft-marginRight)/domains.length,enableX:false})}))}}]);return ParallelCoordinates}(_react.Component);ParallelCoordinates.displayName="ParallelCoordinates";ParallelCoordinates.propTypes={animation:_animation.AnimationPropType,brushing:_propTypes2.default.bool,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,margin:_chartUtils.MarginPropType,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,lines:_propTypes2.default.object}),showMarks:_propTypes2.default.bool,tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};ParallelCoordinates.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},lines:{strokeWidth:1,strokeOpacity:1},deselectedLineStyle:{strokeOpacity:.1}},tickFormat:DEFAULT_FORMAT};exports.default=ParallelCoordinates},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/highlight":97,"../plot/series/label-series":114,"../plot/series/line-mark-series":116, +"../plot/series/line-series":118,"../plot/xy-plot":131,"../theme":137,"../utils/chart-utils":143,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],83:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i-1;var axisClassName=isVertical?VERTICAL_CLASS_NAME:HORIZONTAL_CLASS_NAME;var leftPos=left;var topPos=top;if(on0){var scale=(0,_scalesUtils.getAttributeScale)(props,attrAxis);if(isVertical){leftPos=scale(0)}else{topPos=marginTop+scale(0)}}return _react2.default.createElement("g",{transform:"translate("+leftPos+","+topPos+")",className:predefinedClassName+" "+axisClassName+" "+className,style:style},!hideLine&&_react2.default.createElement(_axisLine2.default,{height:height,width:width,orientation:orientation,style:_extends({},style,style.line)}),!hideTicks&&_react2.default.createElement(_axisTicks2.default,_extends({},props,{style:_extends({},style,style.ticks)})),title?_react2.default.createElement(_axisTitle2.default,{position:position,title:title,height:height,width:width,style:_extends({},style,style.title),orientation:orientation}):null)}}]);return Axis}(_react.PureComponent);Axis.displayName="Axis";Axis.propTypes=propTypes;Axis.defaultProps=defaultProps;Axis.requiresSVG=true;exports.default=Axis},{"../../animation":74,"../../utils/axis-utils":142,"../../utils/scales-utils":146,"./axis-line":83,"./axis-ticks":84,"./axis-title":85,"prop-types":33,react:73}],87:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;irRange[1])){return res}return res.concat([_react2.default.createElement("circle",_extends({cx:0,cy:0,r:radius},{key:index,className:"rv-xy-plot__circular-grid-lines__line",style:style}))])},[]))}}]);return CircularGridLines}(_react.PureComponent);CircularGridLines.displayName="CircularGridLines";CircularGridLines.propTypes={centerX:_propTypes2.default.number,centerY:_propTypes2.default.number,width:_propTypes2.default.number,height:_propTypes2.default.number,top:_propTypes2.default.number,left:_propTypes2.default.number,rRange:_propTypes2.default.arrayOf(_propTypes2.default.number),style:_propTypes2.default.object,tickValues:_propTypes2.default.arrayOf(_propTypes2.default.number),tickTotal:_propTypes2.default.number,animation:_animation.AnimationPropType,marginTop:_propTypes2.default.number,marginBottom:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginRight:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number};CircularGridLines.defaultProps={centerX:0,centerY:0};CircularGridLines.requiresSVG=true;exports.default=CircularGridLines},{"../animation":74,"../utils/axis-utils":142,"../utils/scales-utils":146,"prop-types":33,react:73}],94:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?"left":"right":_props$orientation;var left=marginLeft+innerLeft;var top=marginTop;var innerClassName="rv-crosshair__inner rv-crosshair__inner--"+orientation;return _react2.default.createElement("div",{className:"rv-crosshair "+className,style:{left:left+"px",top:top+"px"}},_react2.default.createElement("div",{className:"rv-crosshair__line",style:_extends({height:innerHeight+"px"},style.line)}),_react2.default.createElement("div",{className:innerClassName},children?children:_react2.default.createElement("div",{className:"rv-crosshair__inner__content",style:style.box},_react2.default.createElement("div",null,this._renderCrosshairTitle(),this._renderCrosshairItems()))))}}],[{key:"defaultProps",get:function get(){return{titleFormat:defaultTitleFormat,itemsFormat:defaultItemsFormat,style:{line:{},title:{},box:{}}}}},{key:"propTypes",get:function get(){return{className:_propTypes2.default.string,values:_propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string,_propTypes2.default.object])),series:_propTypes2.default.object,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,orientation:_propTypes2.default.oneOf(["left","right"]),itemsFormat:_propTypes2.default.func,titleFormat:_propTypes2.default.func,style:_propTypes2.default.shape({line:_propTypes2.default.object,title:_propTypes2.default.object,box:_propTypes2.default.object})}}}]);return Crosshair}(_react.PureComponent);Crosshair.displayName="Crosshair";exports.default=Crosshair},{"../utils/scales-utils":146,"prop-types":33,react:73}],95:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var predefinedClassName="rv-gradient-defs";function GradientDefs(props){var className=props.className;return _react2.default.createElement("defs",{className:predefinedClassName+" "+className},props.children)}GradientDefs.displayName="GradientDefs";GradientDefs.requiresSVG=true;GradientDefs.propTypes={className:_propTypes2.default.string};GradientDefs.defaultProps={className:""};exports.default=GradientDefs},{"prop-types":33,react:73}],96:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iright);var clickedOutsideDragY=dragArea&&(yLocbottom);if(enableX&&enableY){return clickedOutsideDragX||clickedOutsideDragY}if(enableX){return clickedOutsideDragX}if(enableY){return clickedOutsideDragY}return true}},{key:"_convertAreaToCoordinates",value:function _convertAreaToCoordinates(brushArea){var _props4=this.props,enableX=_props4.enableX,enableY=_props4.enableY,marginLeft=_props4.marginLeft,marginTop=_props4.marginTop;var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");if(enableX&&enableY){return{bottom:yScale.invert(brushArea.bottom),left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft),top:yScale.invert(brushArea.top)}}if(enableY){return{bottom:yScale.invert(brushArea.bottom-marginTop),top:yScale.invert(brushArea.top-marginTop)}}if(enableX){return{left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft)}}return{}}},{key:"startBrushing",value:function startBrushing(e){var _this2=this;var _props5=this.props,onBrushStart=_props5.onBrushStart,onDragStart=_props5.onDragStart,drag=_props5.drag;var dragArea=this.state.dragArea;var _getLocs=getLocs(e.nativeEvent),xLoc=_getLocs.xLoc,yLoc=_getLocs.yLoc;var startArea=function startArea(dragging,resetDrag){var emptyBrush={bottom:yLoc,left:xLoc,right:xLoc,top:yLoc};_this2.setState({dragging:dragging,brushArea:dragArea&&!resetDrag?dragArea:emptyBrush,brushing:!dragging,startLocX:xLoc,startLocY:yLoc})};var clickedOutsideDrag=this._clickedOutsideDrag(xLoc,yLoc);if(drag&&!dragArea||!drag||clickedOutsideDrag){startArea(false,clickedOutsideDrag);if(onBrushStart){onBrushStart(e)}return}if(drag&&dragArea){startArea(true,clickedOutsideDrag);if(onDragStart){onDragStart(e)}}}},{key:"stopBrushing",value:function stopBrushing(e){var _state4=this.state,brushing=_state4.brushing,dragging=_state4.dragging,brushArea=_state4.brushArea;if(!brushing&&!dragging){return}var _props6=this.props,onBrushEnd=_props6.onBrushEnd,onDragEnd=_props6.onDragEnd,drag=_props6.drag;var noHorizontal=Math.abs(brushArea.right-brushArea.left)<5;var noVertical=Math.abs(brushArea.top-brushArea.bottom)<5;var isNulled=noVertical||noHorizontal;this.setState({brushing:false,dragging:false,brushArea:drag?brushArea:{top:0,right:0,bottom:0,left:0},startLocX:0,startLocY:0,dragArea:drag&&!isNulled&&brushArea});if(brushing&&onBrushEnd){onBrushEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}if(drag&&onDragEnd){onDragEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}}},{key:"onBrush",value:function onBrush(e){var _props7=this.props,onBrush=_props7.onBrush,onDrag=_props7.onDrag,drag=_props7.drag;var _state5=this.state,brushing=_state5.brushing,dragging=_state5.dragging;var _getLocs2=getLocs(e.nativeEvent),xLoc=_getLocs2.xLoc,yLoc=_getLocs2.yLoc;if(brushing){var brushArea=this._getDrawArea(xLoc,yLoc);this.setState({brushArea:brushArea});if(onBrush){onBrush(this._convertAreaToCoordinates(brushArea))}}if(drag&&dragging){var _brushArea=this._getDragArea(xLoc,yLoc);this.setState({brushArea:_brushArea});if(onDrag){onDrag(this._convertAreaToCoordinates(_brushArea))}}}},{key:"render",value:function render(){var _this3=this;var _props8=this.props,color=_props8.color,className=_props8.className,highlightHeight=_props8.highlightHeight,highlightWidth=_props8.highlightWidth,highlightX=_props8.highlightX,highlightY=_props8.highlightY,innerWidth=_props8.innerWidth,innerHeight=_props8.innerHeight,marginLeft=_props8.marginLeft,marginRight=_props8.marginRight,marginTop=_props8.marginTop,marginBottom=_props8.marginBottom,opacity=_props8.opacity;var _state$brushArea=this.state.brushArea,left=_state$brushArea.left,right=_state$brushArea.right,top=_state$brushArea.top,bottom=_state$brushArea.bottom;var leftPos=0;if(highlightX){var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");leftPos=xScale(highlightX)}var topPos=0;if(highlightY){var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");topPos=yScale(highlightY)}var plotWidth=marginLeft+marginRight+innerWidth;var plotHeight=marginTop+marginBottom+innerHeight;var touchWidth=highlightWidth||plotWidth;var touchHeight=highlightHeight||plotHeight;return _react2.default.createElement("g",{transform:"translate("+leftPos+", "+topPos+")",className:className+" rv-highlight-container"},_react2.default.createElement("rect",{className:"rv-mouse-target",fill:"black",opacity:"0",x:"0",y:"0",width:Math.max(touchWidth,0),height:Math.max(touchHeight,0),onMouseDown:function onMouseDown(e){return _this3.startBrushing(e)},onMouseMove:function onMouseMove(e){return _this3.onBrush(e)},onMouseUp:function onMouseUp(e){return _this3.stopBrushing(e)},onMouseLeave:function onMouseLeave(e){return _this3.stopBrushing(e)},onTouchEnd:function onTouchEnd(e){e.preventDefault();_this3.stopBrushing(e)},onTouchCancel:function onTouchCancel(e){e.preventDefault();_this3.stopBrushing(e)},onContextMenu:function onContextMenu(e){return e.preventDefault()},onContextMenuCapture:function onContextMenuCapture(e){return e.preventDefault()}}),_react2.default.createElement("rect",{className:"rv-highlight",pointerEvents:"none",opacity:opacity,fill:color,x:left,y:top,width:Math.min(Math.max(0,right-left),touchWidth),height:Math.min(Math.max(0,bottom-top),touchHeight)}))}}]);return Highlight}(_abstractSeries2.default);Highlight.displayName="HighlightOverlay";Highlight.defaultProps={color:"rgb(77, 182, 172)",className:"",enableX:true,enableY:true,opacity:.3};Highlight.propTypes=_extends({},_abstractSeries2.default.propTypes,{enableX:_propTypes2.default.bool,enableY:_propTypes2.default.bool,highlightHeight:_propTypes2.default.number,highlightWidth:_propTypes2.default.number,highlightX:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),highlightY:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),onBrushStart:_propTypes2.default.func,onDragStart:_propTypes2.default.func,onBrush:_propTypes2.default.func,onDrag:_propTypes2.default.func,onBrushEnd:_propTypes2.default.func,onDragEnd:_propTypes2.default.func});exports.default=Highlight},{"../utils/scales-utils":146,"./series/abstract-series":100,"prop-types":33,react:73}],98:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?ALIGN.LEFT:ALIGN.RIGHT}if(vertical===ALIGN.AUTO){align.vertical=y>innerHeight/2?ALIGN.TOP:ALIGN.BOTTOM}return align}},{key:"_getAlignClassNames",value:function _getAlignClassNames(align){var orientation=this.props.orientation;var orientationClass=orientation?"rv-hint--orientation-"+orientation:"";return orientationClass+" rv-hint--horizontalAlign-"+align.horizontal+"\n rv-hint--verticalAlign-"+align.vertical}},{key:"_getAlignStyle",value:function _getAlignStyle(align,x,y){return _extends({},this._getXCSS(align.horizontal,x),this._getYCSS(align.vertical,y))}},{key:"_getCSSBottom",value:function _getCSSBottom(y){if(y===undefined||y===null){return{bottom:0}}var _props2=this.props,innerHeight=_props2.innerHeight,marginBottom=_props2.marginBottom;return{bottom:marginBottom+innerHeight-y}}},{key:"_getCSSLeft",value:function _getCSSLeft(x){if(x===undefined||x===null){return{left:0}}var marginLeft=this.props.marginLeft;return{left:marginLeft+x}}},{key:"_getCSSRight",value:function _getCSSRight(x){if(x===undefined||x===null){return{right:0}}var _props3=this.props,innerWidth=_props3.innerWidth,marginRight=_props3.marginRight;return{right:marginRight+innerWidth-x}}},{key:"_getCSSTop",value:function _getCSSTop(y){if(y===undefined||y===null){return{top:0}}var marginTop=this.props.marginTop;return{top:marginTop+y}}},{key:"_getPositionInfo",value:function _getPositionInfo(){var _props4=this.props,value=_props4.value,getAlignStyle=_props4.getAlignStyle;var x=(0,_scalesUtils.getAttributeFunctor)(this.props,"x")(value);var y=(0,_scalesUtils.getAttributeFunctor)(this.props,"y")(value);var align=this._getAlign(x,y);return{position:getAlignStyle?getAlignStyle(align,x,y):this._getAlignStyle(align,x,y),className:this._getAlignClassNames(align)}}},{key:"_getXCSS",value:function _getXCSS(horizontal,x){switch(horizontal){case ALIGN.LEFT_EDGE:return this._getCSSLeft(null);case ALIGN.RIGHT_EDGE:return this._getCSSRight(null);case ALIGN.LEFT:return this._getCSSRight(x);case ALIGN.RIGHT:default:return this._getCSSLeft(x)}}},{key:"_getYCSS",value:function _getYCSS(verticalAlign,y){switch(verticalAlign){case ALIGN.TOP_EDGE:return this._getCSSTop(null);case ALIGN.BOTTOM_EDGE:return this._getCSSBottom(null);case ALIGN.BOTTOM:return this._getCSSTop(y);case ALIGN.TOP:default:return this._getCSSBottom(y)}}},{key:"_mapOrientationToAlign",value:function _mapOrientationToAlign(orientation){switch(orientation){case ORIENTATION.BOTTOM_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.BOTTOM};case ORIENTATION.BOTTOM_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.BOTTOM};case ORIENTATION.TOP_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.TOP};case ORIENTATION.TOP_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.TOP};default:break}}},{key:"render",value:function render(){var _props5=this.props,value=_props5.value,format=_props5.format,children=_props5.children,style=_props5.style;var _getPositionInfo2=this._getPositionInfo(),position=_getPositionInfo2.position,className=_getPositionInfo2.className;return _react2.default.createElement("div",{className:"rv-hint "+className,style:_extends({},style,position,{position:"absolute"})},children?children:_react2.default.createElement("div",{className:"rv-hint__content",style:style.content},format(value).map(function(formattedProp,i){return _react2.default.createElement("div",{key:"rv-hint"+i,style:style.row},_react2.default.createElement("span",{className:"rv-hint__title",style:style.title},formattedProp.title),": ",_react2.default.createElement("span",{className:"rv-hint__value",style:style.value},formattedProp.value))})))}}],[{key:"defaultProps",get:function get(){return{format:defaultFormat,align:{horizontal:ALIGN.AUTO,vertical:ALIGN.AUTO},style:{}}}},{key:"propTypes",get:function get(){return{marginTop:_propTypes2.default.number,marginLeft:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,scales:_propTypes2.default.object,value:_propTypes2.default.object,format:_propTypes2.default.func,style:_propTypes2.default.object,align:_propTypes2.default.shape({horizontal:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.LEFT,ALIGN.RIGHT,ALIGN.LEFT_EDGE,ALIGN.RIGHT_EDGE]),vertical:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.BOTTOM,ALIGN.TOP,ALIGN.BOTTOM_EDGE,ALIGN.TOP_EDGE])}),getAlignStyle:_propTypes2.default.func,orientation:_propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT,ORIENTATION.BOTTOM_RIGHT,ORIENTATION.TOP_LEFT,ORIENTATION.TOP_RIGHT])}}}]);return Hint}(_react.PureComponent);Hint.displayName="Hint";Hint.ORIENTATION=ORIENTATION;Hint.ALIGN=ALIGN;exports.default=Hint},{"../utils/scales-utils":146,"prop-types":33,react:73}],99:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iMAX_DRAWS){clearInterval(drawCycle)}drawIteration+=1},1)}function drawLayers(ctx,height,width,layers,drawIteration){ctx.clearRect(0,0,width,height);layers.forEach(function(layer){var interpolator=layer.interpolator,newProps=layer.newProps,animation=layer.animation;var interpolatedProps=animation?interpolator?interpolator(drawIteration/MAX_DRAWS):interpolator:function(){return{}};layer.renderLayer(_extends({},newProps,interpolatedProps),ctx)})}function buildLayers(newChildren,oldChildren){return newChildren.map(function(child,index){var oldProps=oldChildren[index]?oldChildren[index].props:{};var newProps=child.props;var oldAnimatedProps=(0,_animation.extractAnimatedPropValues)(_extends({},oldProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}));var newAnimatedProps=newProps?(0,_animation.extractAnimatedPropValues)(_extends({},newProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS})):null;var interpolator=(0,_d3Interpolate.interpolate)(oldAnimatedProps,newAnimatedProps);return{renderLayer:child.type.renderLayer,newProps:child.props,animation:child.props.animation,interpolator:interpolator}})}var CanvasWrapper=function(_Component){_inherits(CanvasWrapper,_Component);function CanvasWrapper(){_classCallCheck(this,CanvasWrapper);return _possibleConstructorReturn(this,(CanvasWrapper.__proto__||Object.getPrototypeOf(CanvasWrapper)).apply(this,arguments))}_createClass(CanvasWrapper,[{key:"componentDidMount",value:function componentDidMount(){var ctx=this.canvas.getContext("2d");if(!ctx){return}var pixelRatio=this.props.pixelRatio;if(!ctx){return}ctx.scale(pixelRatio,pixelRatio);this.drawChildren(null,this.props,ctx)}},{key:"componentDidUpdate",value:function componentDidUpdate(oldProps){this.drawChildren(oldProps,this.props,this.canvas.getContext("2d"))}},{key:"drawChildren",value:function drawChildren(oldProps,newProps,ctx){var children=newProps.children,innerHeight=newProps.innerHeight,innerWidth=newProps.innerWidth,marginBottom=newProps.marginBottom,marginLeft=newProps.marginLeft,marginRight=newProps.marginRight,marginTop=newProps.marginTop;if(!ctx){return}var childrenShouldAnimate=children.find(function(child){return child.props.animation});var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;var layers=buildLayers(newProps.children,oldProps?oldProps.children:[]);if(!childrenShouldAnimate){drawLayers(ctx,height,width,layers);return}engageDrawLoop(ctx,height,width,layers)}},{key:"render",value:function render(){var _this2=this;var _props=this.props,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginBottom=_props.marginBottom,marginLeft=_props.marginLeft,marginRight=_props.marginRight,marginTop=_props.marginTop,pixelRatio=_props.pixelRatio;var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;return _react2.default.createElement("div",{style:{left:0,top:0},className:"rv-xy-canvas"},_react2.default.createElement("canvas",{className:"rv-xy-canvas-element",height:height*pixelRatio,width:width*pixelRatio,style:{height:height+"px",width:width+"px"},ref:function ref(_ref){return _this2.canvas=_ref}}),this.props.children)}}],[{key:"defaultProps",get:function get(){return{pixelRatio:window&&window.devicePixelRatio||1}}}]);return CanvasWrapper}(_react.Component);CanvasWrapper.displayName="CanvasWrapper";CanvasWrapper.propTypes={marginBottom:_propTypes2.default.number.isRequired,marginLeft:_propTypes2.default.number.isRequired,marginRight:_propTypes2.default.number.isRequired,marginTop:_propTypes2.default.number.isRequired,innerHeight:_propTypes2.default.number.isRequired,innerWidth:_propTypes2.default.number.isRequired,pixelRatio:_propTypes2.default.number.isRequired};exports.default=CanvasWrapper},{"../../animation":74,"../../utils/series-utils":147,"d3-interpolate":11,"prop-types":33,react:73}],106:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i1&&arguments[1]!==undefined?arguments[1]:2;var style=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_STYLE;switch(type){case"diamond":return _react2.default.createElement("polygon",{style:style,points:"0 0 "+size/2+" "+size/2+" 0 "+size+" "+-size/2+" "+size/2+" 0 0"});case"star":var starPoints=[].concat(_toConsumableArray(new Array(5))).map(function(c,index){var angle=index/5*Math.PI*2;var innerAngle=angle+Math.PI/10;var outerAngle=angle-Math.PI/10;var innerRadius=size/2.61;return"\n "+Math.cos(outerAngle)*size+" "+Math.sin(outerAngle)*size+"\n "+Math.cos(innerAngle)*innerRadius+" "+Math.sin(innerAngle)*innerRadius+"\n "}).join(" ");return _react2.default.createElement("polygon",{points:starPoints,x:"0",y:"0",height:size,width:size,style:style});case"square":return _react2.default.createElement("rect",{x:""+-size/2,y:""+-size/2,height:size,width:size,style:style});default:case"circle":return _react2.default.createElement("circle",{cx:"0",cy:"0",r:size/2,style:style})}}function getInnerComponent(_ref){var customComponent=_ref.customComponent,defaultType=_ref.defaultType,positionInPixels=_ref.positionInPixels,positionFunctions=_ref.positionFunctions,style=_ref.style,propsSize=_ref.propsSize;var size=customComponent.size;var aggStyle=_extends({},style,customComponent.style||{});var innerComponent=customComponent.customComponent;if(!innerComponent&&typeof defaultType==="string"){return predefinedComponents(defaultType,size||propsSize,aggStyle)}if(!innerComponent){return defaultType(customComponent,positionInPixels,aggStyle)}if(typeof innerComponent==="string"){return predefinedComponents(innerComponent||defaultType,size,aggStyle)}return innerComponent(customComponent,positionInPixels,aggStyle)}var CustomSVGSeries=function(_AbstractSeries){_inherits(CustomSVGSeries,_AbstractSeries);function CustomSVGSeries(){_classCallCheck(this,CustomSVGSeries);return _possibleConstructorReturn(this,(CustomSVGSeries.__proto__||Object.getPrototypeOf(CustomSVGSeries)).apply(this,arguments))}_createClass(CustomSVGSeries,[{key:"render",value:function render(){var _this2=this;var _props=this.props,animation=_props.animation,className=_props.className,customComponent=_props.customComponent,data=_props.data,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginLeft=_props.marginLeft,marginTop=_props.marginTop,style=_props.style,size=_props.size;if(!data||!innerWidth||!innerHeight){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(CustomSVGSeries,_extends({},this.props,{animation:false})))}var x=this._getAttributeFunctor("x");var y=this._getAttributeFunctor("y");var contents=data.map(function(seriesComponent,index){var positionInPixels={x:x({x:seriesComponent.x}),y:y({y:seriesComponent.y})};var innerComponent=getInnerComponent({customComponent:seriesComponent,positionInPixels:positionInPixels,defaultType:customComponent,positionFunctions:{x:x,y:y},style:style,propsSize:size});return _react2.default.createElement("g",{className:"rv-xy-plot__series--custom-svg",key:"rv-xy-plot__series--custom-svg-"+index,transform:"translate("+positionInPixels.x+","+positionInPixels.y+")",onMouseEnter:function onMouseEnter(e){return _this2._valueMouseOverHandler(seriesComponent,e)},onMouseLeave:function onMouseLeave(e){return _this2._valueMouseOutHandler(seriesComponent,e)}},innerComponent)});return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},contents)}}]);return CustomSVGSeries}(_abstractSeries2.default);CustomSVGSeries.propTypes={animation:_propTypes2.default.bool,className:_propTypes2.default.string,customComponent:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.func]),data:_propTypes2.default.arrayOf(_propTypes2.default.shape({x:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired,y:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired})).isRequired,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,style:_propTypes2.default.object,size:_propTypes2.default.number,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func};CustomSVGSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{animation:false,customComponent:"circle",style:{},size:2});exports.default=CustomSVGSeries},{"../../animation":74,"../../utils/series-utils":147,"./abstract-series":100,"prop-types":33,react:73}],108:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;ipositiveYVariance;if(!hasXWhiskers&&!hasYWhiskers){return null}var styleAttr=_extends({opacity:opacityFunctor?opacityFunctor(d):_theme.DEFAULT_OPACITY,stroke:strokeFunctor&&strokeFunctor(d),strokeWidth:strokeWidth||DEFAULT_STROKE_WIDTH},style);var crossBarExtension=crossBarWidth/2;var rightLineAttrs={x1:cx+r,y1:cy,x2:positiveXVariance,y2:cy,style:styleAttr};var leftLineAttrs={x1:cx-r,y1:cy,x2:negativeXVariance,y2:cy,style:styleAttr};var rightCrossBarAttrs={x1:positiveXVariance,y1:cy-crossBarExtension,x2:positiveXVariance,y2:cy+crossBarExtension,style:styleAttr};var leftCrossBarAttrs={x1:negativeXVariance,y1:cy-crossBarExtension,x2:negativeXVariance,y2:cy+crossBarExtension,style:styleAttr};var upperLineAttrs={x1:cx,y1:cy-r,x2:cx,y2:positiveYVariance,style:styleAttr};var lowerLineAttrs={x1:cx,y1:cy+r,x2:cx,y2:negativeYVariance,style:styleAttr};var upperCrossBarAttrs={x1:cx-crossBarExtension,y1:positiveYVariance,x2:cx+crossBarExtension,y2:positiveYVariance,style:styleAttr};var lowerCrossBarAttrs={x1:cx-crossBarExtension,y1:negativeYVariance,x2:cx+crossBarExtension,y2:negativeYVariance,style:styleAttr};return _react2.default.createElement("g",{className:"mark-whiskers",key:i,onClick:function onClick(e){return valueClickHandler(d,e)},onContextMenu:function onContextMenu(e){return valueRightClickHandler(d,e)},onMouseOver:function onMouseOver(e){return valueMouseOverHandler(d,e)},onMouseOut:function onMouseOut(e){return valueMouseOutHandler(d,e)}},hasXWhiskers?_react2.default.createElement("g",{className:"x-whiskers"},_react2.default.createElement("line",rightLineAttrs),_react2.default.createElement("line",leftLineAttrs),_react2.default.createElement("line",rightCrossBarAttrs),_react2.default.createElement("line",leftCrossBarAttrs)):null,hasYWhiskers?_react2.default.createElement("g",{className:"y-whiskers"},_react2.default.createElement("line",upperLineAttrs),_react2.default.createElement("line",lowerLineAttrs),_react2.default.createElement("line",upperCrossBarAttrs),_react2.default.createElement("line",lowerCrossBarAttrs)):null)}};var WhiskerSeries=function(_AbstractSeries){_inherits(WhiskerSeries,_AbstractSeries);function WhiskerSeries(){_classCallCheck(this,WhiskerSeries);return _possibleConstructorReturn(this,(WhiskerSeries.__proto__||Object.getPrototypeOf(WhiskerSeries)).apply(this,arguments))}_createClass(WhiskerSeries,[{key:"render",value:function render(){var _props=this.props,animation=_props.animation,className=_props.className,crossBarWidth=_props.crossBarWidth,data=_props.data,marginLeft=_props.marginLeft,marginTop=_props.marginTop,strokeWidth=_props.strokeWidth,style=_props.style;if(!data){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(WhiskerSeries,_extends({},this.props,{animation:null})))}var whiskerMarkProps={crossBarWidth:crossBarWidth,opacityFunctor:this._getAttributeFunctor("opacity"),sizeFunctor:this._getAttributeFunctor("size"),strokeFunctor:this._getAttributeFunctor("stroke")||this._getAttributeFunctor("color"),strokeWidth:strokeWidth,style:style,xFunctor:this._getAttributeFunctor("x"),yFunctor:this._getAttributeFunctor("y"),valueClickHandler:this._valueClickHandler,valueRightClickHandler:this._valueRightClickHandler,valueMouseOverHandler:this._valueMouseOverHandler,valueMouseOutHandler:this._valueMouseOutHandler};return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},data.map(renderWhiskerMark(whiskerMarkProps)))}}]);return WhiskerSeries}(_abstractSeries2.default);WhiskerSeries.displayName="WhiskerSeries";WhiskerSeries.propTypes=_extends({},_abstractSeries2.default.propTypes,{strokeWidth:_propTypes2.default.number});WhiskerSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{crossBarWidth:DEFAULT_CROSS_BAR_WIDTH,size:0,strokeWidth:DEFAULT_STROKE_WIDTH});exports.default=WhiskerSeries},{"../../animation":74,"../../theme":137,"../../utils/series-utils":147,"./abstract-series":100,"prop-types":33,react:73}],129:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i-1&&index0){if(Math.abs(axisEndPoint-.5)<=epsilon){axisEndPoint=.5}}else if(axisEndPoint<0){if(Math.abs(axisEndPoint+.5)<=epsilon){axisEndPoint=-.5}}return axisEndPoint}function getLabels(props){var domains=props.domains,startingAngle=props.startingAngle,style=props.style;return domains.map(function(_ref,index){var name=_ref.name;var angle=index/domains.length*Math.PI*2+startingAngle;var radius=1.2;return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),label:name,style:style}})}function getPolygons(props){var animation=props.animation,colorRange=props.colorRange,domains=props.domains,data=props.data,style=props.style,startingAngle=props.startingAngle,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var scales=domains.reduce(function(acc,_ref2){var domain=_ref2.domain,name=_ref2.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref3,index){var name=_ref3.name,getValue=_ref3.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),name:row.name}});return _react2.default.createElement(_polygonSeries2.default,{animation:animation,className:predefinedClassName+"-polygon",key:rowIndex+"-polygon",data:mappedData,style:_extends({stroke:row.color||row.stroke||colorRange[rowIndex%colorRange.length],fill:row.color||row.fill||colorRange[rowIndex%colorRange.length]},style.polygons),onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut})})}function getPolygonPoints(props){var animation=props.animation,domains=props.domains,data=props.data,startingAngle=props.startingAngle,style=props.style,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut;if(!onValueMouseOver){return}var scales=domains.reduce(function(acc,_ref4){var domain=_ref4.domain,name=_ref4.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref5,index){var name=_ref5.name,getValue=_ref5.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),domain:name,value:dataPoint,dataName:row.name}});return _react2.default.createElement(_markSeries2.default,{animation:animation,className:predefinedClassName+"-polygonPoint",key:rowIndex+"-polygonPoint",data:mappedData,size:10,style:_extends({},style.polygons,{fill:"transparent",stroke:"transparent"}),onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut})})}function RadarChart(props){var animation=props.animation,className=props.className,children=props.children,colorRange=props.colorRange,data=props.data,domains=props.domains,height=props.height,hideInnerMostValues=props.hideInnerMostValues,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,startingAngle=props.startingAngle,style=props.style,tickFormat=props.tickFormat,width=props.width,renderAxesOverPolygons=props.renderAxesOverPolygons,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,startingAngle:startingAngle,style:style,tickFormat:tickFormat});var polygons=getPolygons({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut});var polygonPoints=getPolygonPoints({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:animation,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels,startingAngle:startingAngle})});return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-1,1],yDomain:[-1,1]},children,!renderAxesOverPolygons&&axes.concat(polygons).concat(labelSeries).concat(polygonPoints),renderAxesOverPolygons&&polygons.concat(labelSeries).concat(axes).concat(polygonPoints))}RadarChart.displayName="RadarChart";RadarChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,hideInnerMostValues:_propTypes2.default.bool,margin:_chartUtils.MarginPropType,startingAngle:_propTypes2.default.number,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,polygons:_propTypes2.default.object}),tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,renderAxesOverPolygons:_propTypes2.default.bool,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,onSeriesMouseOver:_propTypes2.default.func,onSeriesMouseOut:_propTypes2.default.func};RadarChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,hideInnerMostValues:true,startingAngle:Math.PI/2,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},polygons:{strokeWidth:.5,strokeOpacity:1,fillOpacity:.1}},tickFormat:DEFAULT_FORMAT,renderAxesOverPolygons:false};exports.default=RadarChart},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/series/label-series":114,"../plot/series/mark-series":120,"../plot/series/polygon-series":121,"../plot/xy-plot":131,"../theme":137,"../utils/chart-utils":143,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],133:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i2&&arguments[2]!==undefined?arguments[2]:1.1;var getLabel=accessors.getLabel,getSubLabel=accessors.getSubLabel;return mappedData.reduce(function(res,row){var angle=row.angle,angle0=row.angle0,radius=row.radius;var centeredAngle=(angle+angle0)/2;var updatedAngle=-1*centeredAngle+Math.PI/2;var newLabels=[];if(getLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getLabel(row)})}if(getSubLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getSubLabel(row),style:{fontSize:10},yOffset:12})}return res.concat(newLabels)},[])}function getMaxRadius(width,height){return Math.min(width,height)/2-DEFAULT_RADIUS_MARGIN}function RadialChart(props){var animation=props.animation,className=props.className,children=props.children,colorType=props.colorType,data=props.data,getAngle=props.getAngle,getLabel=props.getLabel,getSubLabel=props.getSubLabel,height=props.height,hideRootNode=props.hideRootNode,innerRadius=props.innerRadius,labelsAboveChildren=props.labelsAboveChildren,labelsRadiusMultiplier=props.labelsRadiusMultiplier,labelsStyle=props.labelsStyle,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,radius=props.radius,showLabels=props.showLabels,style=props.style,width=props.width;var mappedData=getWedgesToRender({data:data,height:height,hideRootNode:hideRootNode,width:width,getAngle:getAngle});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var arcProps=_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:mappedData,radiusNoFallBack:true,style:style,arcClassName:"rv-radial-chart__series--pie__slice"});if(radius){arcProps.radiusDomain=[0,1];arcProps.radiusRange=[innerRadius||0,radius];arcProps.radiusType="linear"}var maxRadius=radius?radius:getMaxRadius(width,height);var defaultMargin=(0,_chartUtils.getRadialLayoutMargin)(width,height,maxRadius);var labels=generateLabels(mappedData,{getLabel:getLabel,getSubLabel:getSubLabel},labelsRadiusMultiplier);return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:_extends({},margin,defaultMargin),className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({},arcProps,{getAngle:function getAngle(d){return d.angle}})),showLabels&&!labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}),children,showLabels&&labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}))}RadialChart.displayName="RadialChart";RadialChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.arrayOf(_propTypes2.default.shape({angle:_propTypes2.default.number,className:_propTypes2.default.string,label:_propTypes2.default.string,radius:_propTypes2.default.number,style:_propTypes2.default.object})).isRequired,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number]),getRadius:_propTypes2.default.func,getRadius0:_propTypes2.default.func,getLabel:_propTypes2.default.func,height:_propTypes2.default.number.isRequired,labelsAboveChildren:_propTypes2.default.bool,labelsStyle:_propTypes2.default.object,margin:_chartUtils.MarginPropType,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,showLabels:_propTypes2.default.bool,style:_propTypes2.default.object,subLabel:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};RadialChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,padAngle:0,getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},getRadius:function getRadius(d){return d.radius},getRadius0:function getRadius0(d){return d.radius0},getLabel:function getLabel(d){return d.label},getSubLabel:function getSubLabel(d){return d.subLabel}};exports.default=RadialChart},{"../animation":74,"../plot/series/arc-series":101,"../plot/series/label-series":114,"../plot/xy-plot":131,"../theme":137,"../utils/chart-utils":143,"../utils/series-utils":147,"d3-shape":15,"prop-types":33,react:73}],134:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i90?"end":"start"},row.labelStyle),rotation:rotateLabels?rotAngle>90?rotAngle+180:rotAngle===90?90:rotAngle:null})})}var NOOP=function NOOP(){};function Sunburst(props){var getAngle=props.getAngle,getAngle0=props.getAngle0,animation=props.animation,className=props.className,children=props.children,data=props.data,height=props.height,hideRootNode=props.hideRootNode,getLabel=props.getLabel,width=props.width,getSize=props.getSize,colorType=props.colorType;var mappedData=getNodesToRender({data:data,height:height, +hideRootNode:hideRootNode,width:width,getSize:getSize});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var margin=(0,_chartUtils.getRadialLayoutMargin)(width,height,radialDomain);var labelData=buildLabels(mappedData,{getAngle:getAngle,getAngle0:getAngle0,getLabel:getLabel,getRadius0:function getRadius0(d){return d.radius0}});var hofBuilder=function hofBuilder(f){return function(e,i){return f?f(mappedData[e.index],i):NOOP}};return _react2.default.createElement(_xyPlot2.default,{height:height,hasTreeStructure:true,width:width,className:predefinedClassName+" "+className,margin:margin,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:animation?mappedData.map(function(row,index){return _extends({},row,{parent:null,children:null,index:index})}):mappedData,_data:animation?mappedData:null,arcClassName:predefinedClassName+"__series--radial__arc"},LISTENERS_TO_OVERWRITE.reduce(function(acc,propName){var prop=props[propName];acc[propName]=animation?hofBuilder(prop):prop;return acc},{}))),labelData.length>0&&_react2.default.createElement(_labelSeries2.default,{data:labelData,getLabel:getLabel}),children)}Sunburst.displayName="Sunburst";Sunburst.propTypes={animation:_animation.AnimationPropType,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.object.isRequired,height:_propTypes2.default.number.isRequired,hideRootNode:_propTypes2.default.bool,getLabel:_propTypes2.default.func,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,getSize:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number])};Sunburst.defaultProps={getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},className:"",colorType:"literal",getColor:function getColor(d){return d.color},hideRootNode:false,getLabel:function getLabel(d){return d.label},getSize:function getSize(d){return d.size},padAngle:0};exports.default=Sunburst},{"../animation":74,"../plot/series/arc-series":101,"../plot/series/label-series":114,"../plot/xy-plot":131,"../utils/chart-utils":143,"../utils/series-utils":147,"d3-hierarchy":10,"d3-scale":14,"prop-types":33,react:73}],137:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var DISCRETE_COLOR_RANGE=exports.DISCRETE_COLOR_RANGE=["#12939A","#79C7E3","#1A3177","#FF9833","#EF5D28"];var EXTENDED_DISCRETE_COLOR_RANGE=exports.EXTENDED_DISCRETE_COLOR_RANGE=["#19CDD7","#DDB27C","#88572C","#FF991F","#F15C17","#223F9A","#DA70BF","#125C77","#4DC19C","#776E57","#12939A","#17B8BE","#F6D18A","#B7885E","#FFCB99","#F89570","#829AE3","#E79FD5","#1E96BE","#89DAC1","#B3AD9E"];var CONTINUOUS_COLOR_RANGE=exports.CONTINUOUS_COLOR_RANGE=["#EF5D28","#FF9833"];var SIZE_RANGE=exports.SIZE_RANGE=[1,10];var OPACITY_RANGE=exports.OPACITY_RANGE=[.1,1];var OPACITY_TYPE=exports.OPACITY_TYPE="literal";var DEFAULT_OPACITY=exports.DEFAULT_OPACITY=1;var DEFAULT_SIZE=exports.DEFAULT_SIZE=5;var DEFAULT_COLOR=exports.DEFAULT_COLOR=DISCRETE_COLOR_RANGE[0];var DEFAULT_TICK_SIZE=exports.DEFAULT_TICK_SIZE=7},{}],138:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i300){return 10}return 5}return 20}function getTickValues(scale,tickTotal,tickValues){return!tickValues?scale.ticks?scale.ticks(tickTotal):scale.domain():tickValues}function generateFit(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return{left:axisStart.y,right:axisEnd.y,slope:0,offset:axisStart.x}}var slope=(axisStart.y-axisEnd.y)/(axisStart.x-axisEnd.x);return{left:axisStart.x,right:axisEnd.x,slope:slope,offset:axisStart.y-slope*axisStart.x}}function generatePoints(_ref){var axisStart=_ref.axisStart,axisEnd=_ref.axisEnd,numberOfTicks=_ref.numberOfTicks,axisDomain=_ref.axisDomain;var _generateFit=generateFit(axisStart,axisEnd),left=_generateFit.left,right=_generateFit.right,slope=_generateFit.slope,offset=_generateFit.offset;var pointSlope=(right-left)/numberOfTicks;var axisScale=(0,_d3Scale.scaleLinear)().domain([left,right]).range(axisDomain);var slopeVertical=axisStart.x===axisEnd.x;return{slope:slopeVertical?Infinity:slope,points:(0,_d3Array.range)(left,right+pointSlope,pointSlope).map(function(val){if(slopeVertical){return{y:val,x:slope*val+offset,text:axisScale(val)}}return{x:val,y:slope*val+offset,text:axisScale(val)}}).slice(0,numberOfTicks+1)}}function getAxisAngle(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return axisEnd.y>axisStart.y?Math.PI/2:3*Math.PI/2}return Math.atan((axisEnd.y-axisStart.y)/(axisEnd.x-axisStart.x))}exports.default={DIRECTION:DIRECTION,ORIENTATION:ORIENTATION,getTicksTotalFromSize:getTicksTotalFromSize,getTickValues:getTickValues}},{"d3-array":3,"d3-scale":14}],143:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_MARGINS=exports.MarginPropType=undefined;var _extends=Object.assign||function(target){for(var i=1;ivalue){result[0]=value}if(result[result.length-1]13||Number(major)>13;var isReactDOMSupported=exports.isReactDOMSupported=function isReactDOMSupported(){return versionHigherThanThirteen};var getDOMNode=exports.getDOMNode=function getDOMNode(ref){if(!isReactDOMSupported()){return ref&&ref.getDOMNode()}return ref};var USED_MESSAGES={};var HIDDEN_PROCESSES={test:true,production:true};function warning(message){var onlyShowMessageOnce=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(global.process&&HIDDEN_PROCESSES[process.env.NODE_ENV]){return}if(!onlyShowMessageOnce||!USED_MESSAGES[message]){console.warn(message);USED_MESSAGES[message]=true}}function warnOnce(message){warning(message,true)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:1,react:73}],146:[function(require,module,exports){"use strict";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[Symbol.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(Symbol.iterator in Object(arr)){return sliceIterator(arr,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();var _extends=Object.assign||function(target){for(var i=1;istop-scale.padding()*scale.step())domainIndex=n-1;else domainIndex=Math.floor((value-start-scale.padding()*scale.step())/scale.step());return scale.domain()[domainIndex]}}function getScaleFnFromScaleObject(scaleObject){if(!scaleObject){return null}var type=scaleObject.type,domain=scaleObject.domain,range=scaleObject.range;var modDomain=domain[0]===domain[1]?domain[0]===0?[-1,0]:[-domain[0],domain[0]]:domain;if(type===LITERAL_SCALE_TYPE){return literalScale(range[0])}var scale=SCALE_FUNCTIONS[type]().domain(modDomain).range(range);if(type===ORDINAL_SCALE_TYPE){scale.padding(.5);addInvertFunctionToOrdinalScaleObject(scale)}return scale}function getDomainByAccessor(allData,accessor,accessor0,type){var domain=void 0;var values=allData.reduce(function(data,d){var value=accessor(d);var value0=accessor0(d);if(_isDefined(value)){data.push(value)}if(_isDefined(value0)){data.push(value0)}return data},[]);if(!values.length){return[]}if(type!==ORDINAL_SCALE_TYPE&&type!==CATEGORY_SCALE_TYPE){domain=(0,_d3Array.extent)(values)}else{domain=(0,_d3Collection.set)(values).values()}return domain}function _createScaleObjectForValue(attr,value,type,accessor,accessor0){if(type===LITERAL_SCALE_TYPE){return{type:LITERAL_SCALE_TYPE,domain:[],range:[value],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}if(typeof value==="undefined"){return null}return{type:CATEGORY_SCALE_TYPE,range:[value],domain:[],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}function _createScaleObjectForFunction(_ref){var domain=_ref.domain,range=_ref.range,type=_ref.type,distance=_ref.distance,attr=_ref.attr,baseValue=_ref.baseValue,accessor=_ref.accessor,accessor0=_ref.accessor0;return{domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,isValue:false,accessor:accessor,accessor0:accessor0}}function _collectScaleObjectFromProps(props,attr){var value=props[attr],fallbackValue=props["_"+attr+"Value"],range=props[attr+"Range"],_props$=props[attr+"Distance"],distance=_props$===undefined?0:_props$,baseValue=props[attr+"BaseValue"],_props$2=props[attr+"Type"],type=_props$2===undefined?LINEAR_SCALE_TYPE:_props$2,noFallBack=props[attr+"NoFallBack"],_props$3=props["get"+toTitleCase(attr)],accessor=_props$3===undefined?function(d){return d[attr]}:_props$3,_props$4=props["get"+toTitleCase(attr)+"0"],accessor0=_props$4===undefined?function(d){return d[attr+"0"]}:_props$4;var domain=props[attr+"Domain"];if(!noFallBack&&typeof value!=="undefined"){return _createScaleObjectForValue(attr,value,props[attr+"Type"],accessor,accessor0)}if(typeof baseValue!=="undefined"){domain=(0,_dataUtils.addValueToArray)(domain,baseValue)}if(!range||!domain||!domain.length){return _createScaleObjectForValue(attr,fallbackValue,props[attr+"Type"],accessor,accessor0)}return _createScaleObjectForFunction({domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,accessor:accessor,accessor0:accessor0})}function _computeLeftDomainAdjustment(values){if(values.length>1){return(values[1]-values[0])/2}if(values.length===1){return values[0]-.5}return 0}function _computeRightDomainAdjustment(values){if(values.length>1){return(values[values.length-1]-values[values.length-2])/2}if(values.length===1){return values[0]-.5}return 0}function _computeScaleDistance(values,domain,bestDistIndex,scaleFn){if(values.length>1){var i=Math.max(bestDistIndex,1);return Math.abs(scaleFn(values[i])-scaleFn(values[i-1]))}if(values.length===1){return Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}return 0}function _normalizeValues(data,values,accessor0,type){if(type===TIME_SCALE_TYPE&&values.length===1){var attr0=accessor0(data[0]);return[attr0].concat(_toConsumableArray(values))}return values}function _getScaleDistanceAndAdjustedDomain(data,scaleObject){var domain=scaleObject.domain,type=scaleObject.type,accessor=scaleObject.accessor,accessor0=scaleObject.accessor0;var uniqueValues=(0,_dataUtils.getUniquePropertyValues)(data,accessor);var values=_normalizeValues(data,uniqueValues,accessor0,type);var index=_getSmallestDistanceIndex(values,scaleObject);var adjustedDomain=[].concat(domain);adjustedDomain[0]-=_computeLeftDomainAdjustment(values);adjustedDomain[domain.length-1]+=_computeRightDomainAdjustment(values);if(type===LOG_SCALE_TYPE&&domain[0]<=0){adjustedDomain[0]=Math.min(domain[1]/10,1)}var adjustedScaleFn=getScaleFnFromScaleObject(_extends({},scaleObject,{domain:adjustedDomain}));var distance=_computeScaleDistance(values,adjustedDomain,index,adjustedScaleFn);return{domain0:adjustedDomain[0],domainN:adjustedDomain[adjustedDomain.length-1],distance:distance}}function _isScaleAdjustmentPossible(props,scaleObject){var attr=scaleObject.attr;var _props$_adjustBy=props._adjustBy,adjustBy=_props$_adjustBy===undefined?[]:_props$_adjustBy,_props$_adjustWhat=props._adjustWhat,adjustWhat=_props$_adjustWhat===undefined?[]:_props$_adjustWhat;return adjustWhat.length&&adjustBy.length&&adjustBy.indexOf(attr)!==-1}function _adjustContinuousScale(props,scaleObject){var allSeriesData=props._allData,_props$_adjustWhat2=props._adjustWhat,adjustWhat=_props$_adjustWhat2===undefined?[]:_props$_adjustWhat2;var domainLength=scaleObject.domain.length;var domain=scaleObject.domain;var scaleDomain0=domain[0];var scaleDomainN=domain[domainLength-1];var scaleDistance=scaleObject.distance;allSeriesData.forEach(function(data,index){if(adjustWhat.indexOf(index)===-1){return}if(data&&data.length){var _getScaleDistanceAndA=_getScaleDistanceAndAdjustedDomain(data,scaleObject),domain0=_getScaleDistanceAndA.domain0,domainN=_getScaleDistanceAndA.domainN,distance=_getScaleDistanceAndA.distance;scaleDomain0=Math.min(scaleDomain0,domain0);scaleDomainN=Math.max(scaleDomainN,domainN);scaleDistance=Math.max(scaleDistance,distance)}});scaleObject.domain=[scaleDomain0].concat(_toConsumableArray(domain.slice(1,-1)),[scaleDomainN]);scaleObject.distance=scaleDistance;return scaleObject}function _adjustCategoricalScale(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);var domain=scaleObject.domain,range=scaleObject.range;if(domain.length>1){scaleObject.distance=Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}else{scaleObject.distance=Math.abs(range[1]-range[0])}return scaleObject}function getScaleObjectFromProps(props,attr){var scaleObject=_collectScaleObjectFromProps(props,attr);if(!scaleObject){return null}if(!_isScaleAdjustmentPossible(props,scaleObject)){return scaleObject}var type=scaleObject.type;if(type===ORDINAL_SCALE_TYPE||type===CATEGORY_SCALE_TYPE){return _adjustCategoricalScale(scaleObject)}return _adjustContinuousScale(props,scaleObject)}function getAttributeScale(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);return getScaleFnFromScaleObject(scaleObject)}function _getAttrValue(d,accessor){return accessor(d.data?d.data:d)}function _isDefined(value){return typeof value!=="undefined"}function _padDomain(domain,padding){if(!domain){return domain}if(isNaN(parseFloat(domain[0]))||isNaN(parseFloat(domain[1]))){return domain}var _domain=_slicedToArray(domain,2),min=_domain[0],max=_domain[1];var domainPadding=(max-min)*(padding*.01);return[min-domainPadding,max+domainPadding]}function getAttributeFunctor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){return scaleFn(_getAttrValue(d,scaleObject.accessor))}}return null}function getAttr0Functor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var domain=scaleObject.domain;var _scaleObject$baseValu=scaleObject.baseValue,baseValue=_scaleObject$baseValu===undefined?domain[0]:_scaleObject$baseValu;var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){var value=_getAttrValue(d,scaleObject.accessor0);return scaleFn(_isDefined(value)?value:baseValue)}}return null}function getAttributeValue(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){if(!scaleObject.isValue&&props["_"+attr+"Value"]===undefined){(0,_reactUtils.warning)("[React-vis] Cannot use data defined "+attr+" for this "+"series type. Using fallback value instead.")}return props["_"+attr+"Value"]||scaleObject.range[0]}return null}function getScalePropTypesByAttribute(attr){var _ref2;return _ref2={},_defineProperty(_ref2,"_"+attr+"Value",_propTypes2.default.any),_defineProperty(_ref2,attr+"Domain",_propTypes2.default.array),_defineProperty(_ref2,"get"+toTitleCase(attr),_propTypes2.default.func),_defineProperty(_ref2,"get"+toTitleCase(attr)+"0",_propTypes2.default.func),_defineProperty(_ref2,attr+"Range",_propTypes2.default.array),_defineProperty(_ref2,attr+"Type",_propTypes2.default.oneOf(Object.keys(SCALE_FUNCTIONS))),_defineProperty(_ref2,attr+"Distance",_propTypes2.default.number),_defineProperty(_ref2,attr+"BaseValue",_propTypes2.default.any),_ref2}function extractScalePropsFromProps(props,attributes){var result={};Object.keys(props).forEach(function(key){var attr=attributes.find(function(a){var isPlainSet=key.indexOf(a)===0;var isUnderscoreSet=key.indexOf("_"+a)===0;var usesGet=key.indexOf("get"+toTitleCase(a))===0;return isPlainSet||isUnderscoreSet||usesGet});if(!attr){return}result[key]=props[key]});return result}function getMissingScaleProps(props,data,attributes){var result={};attributes.forEach(function(attr){if(!props["get"+toTitleCase(attr)]){result["get"+toTitleCase(attr)]=function(d){return d[attr]}}if(!props["get"+toTitleCase(attr)+"0"]){result["get"+toTitleCase(attr)+"0"]=function(d){return d[attr+"0"]}}if(!props[attr+"Domain"]){result[attr+"Domain"]=getDomainByAccessor(data,props["get"+toTitleCase(attr)]||result["get"+toTitleCase(attr)],props["get"+toTitleCase(attr)+"0"]||result["get"+toTitleCase(attr)+"0"],props[attr+"Type"]);if(props[attr+"Padding"]){result[attr+"Domain"]=_padDomain(result[attr+"Domain"],props[attr+"Padding"])}}});return result}function literalScale(defaultValue){function scale(d){if(d===undefined){return defaultValue}return d}function response(){return scale}scale.domain=response;scale.range=response;scale.unknown=response;scale.copy=response;return scale}function getFontColorFromBackground(background){if(background){return(0,_d3Color.hsl)(background).l>.57?"#222":"#fff"}return null}function getXYPlotValues(props,children){var XYPlotScales=XYPLOT_ATTR.reduce(function(prev,attr){var domain=props[attr+"Domain"],range=props[attr+"Range"],type=props[attr+"Type"];if(domain&&range&&type){return _extends({},prev,_defineProperty({},attr,SCALE_FUNCTIONS[type]().domain(domain).range(range)))}return prev},{});return children.map(function(child){return XYPLOT_ATTR.reduce(function(prev,attr){if(child.props&&child.props[attr]!==undefined){var scaleInput=child.props[attr];var scale=XYPlotScales[attr];var fallbackValue=scale?scale(scaleInput):scaleInput;return _extends({},prev,_defineProperty({},"_"+attr+"Value",fallbackValue))}return prev},{})})}var OPTIONAL_SCALE_PROPS=["Padding"];var OPTIONAL_SCALE_PROPS_REGS=OPTIONAL_SCALE_PROPS.map(function(str){return new RegExp(str+"$","i")});function getOptionalScaleProps(props){return Object.keys(props).reduce(function(acc,prop){var propIsNotOptional=OPTIONAL_SCALE_PROPS_REGS.every(function(reg){return!prop.match(reg)});if(propIsNotOptional){return acc}acc[prop]=props[prop];return acc},{})}exports.default={extractScalePropsFromProps:extractScalePropsFromProps,getAttributeScale:getAttributeScale,getAttributeFunctor:getAttributeFunctor,getAttr0Functor:getAttr0Functor,getAttributeValue:getAttributeValue,getDomainByAccessor:getDomainByAccessor,getFontColorFromBackground:getFontColorFromBackground,getMissingScaleProps:getMissingScaleProps,getOptionalScaleProps:getOptionalScaleProps,getScaleObjectFromProps:getScaleObjectFromProps,getScalePropTypesByAttribute:getScalePropTypesByAttribute,getXYPlotValues:getXYPlotValues,literalScale:literalScale}},{"./data-utils":144,"./react-utils":145,"d3-array":3,"d3-collection":4,"d3-color":5,"d3-scale":14,"prop-types":33}],147:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ANIMATED_SERIES_PROPS=undefined;var _extends=Object.assign||function(target){for(var i=1;i0&&arguments[0]!==undefined?arguments[0]:[];if(!data){return false}return data.some(function(row){return row.radius&&row.angle})}function prepareData(data){if(!seriesHasAngleRadius(data)){return data}return data.map(function(row){return _extends({},row,{x:row.radius*Math.cos(row.angle),y:row.radius*Math.sin(row.angle)})})}function getStackedData(children,attr){var areSomeSeriesStacked=children.some(function(series){return series&&series.props.stack});var latestAttrPositions={};return children.reduce(function(accumulator,series,seriesIndex){if(!series){accumulator.push(null);return accumulator}var _series$props=series.props,data=_series$props.data,_series$props$cluster=_series$props.cluster,cluster=_series$props$cluster===undefined?"default":_series$props$cluster,stack=_series$props.stack;var preppedData=prepareData(data,attr);if(!attr||!preppedData||!preppedData.length||areSomeSeriesStacked&&!stack){accumulator.push(preppedData);return accumulator}var attr0=attr+"0";var baseAttr=attr==="y"?"x":"y";accumulator.push(preppedData.map(function(d,dIndex){var _extends2,_latestAttrPositions$2;if(!latestAttrPositions[cluster]){latestAttrPositions[cluster]={}}var prevD=latestAttrPositions[cluster][d[baseAttr]];if(!prevD){var _latestAttrPositions$;latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$={},_defineProperty(_latestAttrPositions$,attr0,d[attr0]),_defineProperty(_latestAttrPositions$,attr,d[attr]),_latestAttrPositions$);return _extends({},d)}var nextD=_extends({},d,(_extends2={},_defineProperty(_extends2,attr0,prevD[attr]),_defineProperty(_extends2,attr,prevD[attr]+d[attr]-(d[attr0]||0)),_extends2));latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$2={},_defineProperty(_latestAttrPositions$2,attr0,nextD[attr0]),_defineProperty(_latestAttrPositions$2,attr,nextD[attr]),_latestAttrPositions$2);return nextD}));return accumulator},[])}function getSeriesPropsFromChildren(children){var result=[];var seriesTypesInfo=collectSeriesTypesInfo(children);var seriesIndex=0;var _opacityValue=_theme.DEFAULT_OPACITY;children.forEach(function(child){var props=void 0;if(isSeriesChild(child)){var seriesTypeInfo=seriesTypesInfo[child.type.displayName];var _colorValue=_theme.DISCRETE_COLOR_RANGE[seriesIndex%_theme.DISCRETE_COLOR_RANGE.length];props=_extends({},seriesTypeInfo,{seriesIndex:seriesIndex,_colorValue:_colorValue,_opacityValue:_opacityValue});seriesTypeInfo.sameTypeIndex++;seriesIndex++;if(child.props.cluster){props.cluster=child.props.cluster;props.clusters=Array.from(seriesTypeInfo.clusters);props.sameTypeTotal=props.clusters.length;props.sameTypeIndex=props.clusters.indexOf(child.props.cluster)}}result.push(props)});return result}function getRadialDomain(data){return data.reduce(function(res,row){return Math.max(row.radius,res)},0)}var ANIMATED_SERIES_PROPS=exports.ANIMATED_SERIES_PROPS=["xRange","xDomain","x","yRange","yDomain","y","colorRange","colorDomain","color","opacityRange","opacityDomain","opacity","strokeRange","strokeDomain","stroke","fillRange","fillDomain","fill","width","height","marginLeft","marginTop","marginRight","marginBottom","data","angleDomain","angleRange","angle","radiusDomain","radiusRange","radius","innerRadiusDomain","innerRadiusRange","innerRadius"];function getStackParams(props){var _stackBy=props._stackBy,valuePosAttr=props.valuePosAttr,cluster=props.cluster;var _props$sameTypeTotal=props.sameTypeTotal,sameTypeTotal=_props$sameTypeTotal===undefined?1:_props$sameTypeTotal,_props$sameTypeIndex=props.sameTypeIndex,sameTypeIndex=_props$sameTypeIndex===undefined?0:_props$sameTypeIndex;if(_stackBy===valuePosAttr&&!cluster){sameTypeTotal=1;sameTypeIndex=0}return{sameTypeTotal:sameTypeTotal,sameTypeIndex:sameTypeIndex}}},{"../plot/series/abstract-series":100,"../theme":137,react:73}]},{},[75])(75)}); diff --git a/dist/index.js b/dist/index.js index 0920cac8e..e5b37734c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.ScaleUtils = exports.AxisUtils = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = exports.FlexibleXYPlot = exports.makeWidthFlexible = exports.makeVisFlexible = exports.makeHeightFlexible = exports.Sunburst = exports.Sankey = exports.ParallelCoordinates = exports.RadarChart = exports.RadialChart = exports.Treemap = exports.ContinuousSizeLegend = exports.ContinuousColorLegend = exports.SearchableDiscreteColorLegend = exports.DiscreteColorLegend = exports.Highlight = exports.Voronoi = exports.HorizontalGridLines = exports.VerticalGridLines = exports.GradientDefs = exports.GridLines = exports.CircularGridLines = exports.YAxis = exports.XAxis = exports.DecorativeAxis = exports.XYPlot = exports.Crosshair = exports.Borders = exports.Hint = exports.LineMarkSeriesCanvas = exports.LineMarkSeries = exports.ArcSeries = exports.AreaSeries = exports.CustomSVGSeries = exports.ContourSeries = exports.HexbinSeries = exports.HeatmapSeries = exports.WhiskerSeries = exports.MarkSeriesCanvas = exports.MarkSeries = exports.RectSeriesCanvas = exports.RectSeries = exports.PolygonSeries = exports.LabelSeries = exports.HorizontalRectSeriesCanvas = exports.HorizontalRectSeries = exports.VerticalRectSeriesCanvas = exports.VerticalRectSeries = exports.VerticalBarSeriesCanvas = exports.VerticalBarSeries = exports.HorizontalBarSeriesCanvas = exports.HorizontalBarSeries = exports.LineSeriesCanvas = exports.LineSeries = exports.AbstractSeries = undefined; +exports.ScaleUtils = exports.AxisUtils = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = exports.FlexibleXYPlot = exports.makeWidthFlexible = exports.makeVisFlexible = exports.makeHeightFlexible = exports.Sunburst = exports.Sankey = exports.ParallelCoordinates = exports.RadarChart = exports.RadialChart = exports.Treemap = exports.ContinuousSizeLegend = exports.ContinuousColorLegend = exports.SearchableDiscreteColorLegend = exports.DiscreteColorLegend = exports.Highlight = exports.Voronoi = exports.HorizontalGridLines = exports.VerticalGridLines = exports.GradientDefs = exports.GridLines = exports.ChartLabel = exports.CircularGridLines = exports.YAxis = exports.XAxis = exports.DecorativeAxis = exports.XYPlot = exports.Crosshair = exports.Borders = exports.Hint = exports.LineMarkSeriesCanvas = exports.LineMarkSeries = exports.ArcSeries = exports.AreaSeries = exports.CustomSVGSeries = exports.ContourSeries = exports.HexbinSeries = exports.HeatmapSeries = exports.WhiskerSeries = exports.MarkSeriesCanvas = exports.MarkSeries = exports.RectSeriesCanvas = exports.RectSeries = exports.PolygonSeries = exports.LabelSeries = exports.HorizontalRectSeriesCanvas = exports.HorizontalRectSeries = exports.VerticalRectSeriesCanvas = exports.VerticalRectSeries = exports.VerticalBarSeriesCanvas = exports.VerticalBarSeries = exports.HorizontalBarSeriesCanvas = exports.HorizontalBarSeries = exports.LineSeriesCanvas = exports.LineSeries = exports.AbstractSeries = undefined; var _makeVisFlexible = require('./make-vis-flexible'); @@ -180,6 +180,10 @@ var _circularGridLines = require('./plot/circular-grid-lines'); var _circularGridLines2 = _interopRequireDefault(_circularGridLines); +var _chartLabel = require('./plot/chart-label'); + +var _chartLabel2 = _interopRequireDefault(_chartLabel); + var _gridLines = require('./plot/grid-lines'); var _gridLines2 = _interopRequireDefault(_gridLines); @@ -274,6 +278,8 @@ exports.AbstractSeries = _abstractSeries2.default; // Copyright (c) 2016 - 2017 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +// TODO alphabetize + exports.LineSeries = _lineSeries2.default; exports.LineSeriesCanvas = _lineSeriesCanvas2.default; exports.HorizontalBarSeries = _horizontalBarSeries2.default; @@ -307,16 +313,23 @@ exports.DecorativeAxis = _decorativeAxis2.default; exports.XAxis = _xAxis2.default; exports.YAxis = _yAxis2.default; exports.CircularGridLines = _circularGridLines2.default; +exports.ChartLabel = _chartLabel2.default; exports.GridLines = _gridLines2.default; exports.GradientDefs = _gradientDefs2.default; exports.VerticalGridLines = _verticalGridLines2.default; exports.HorizontalGridLines = _horizontalGridLines2.default; exports.Voronoi = _voronoi2.default; exports.Highlight = _highlight2.default; + +// TODO alphabetize + exports.DiscreteColorLegend = _discreteColorLegend2.default; exports.SearchableDiscreteColorLegend = _searchableDiscreteColorLegend2.default; exports.ContinuousColorLegend = _continuousColorLegend2.default; exports.ContinuousSizeLegend = _continuousSizeLegend2.default; + +// TODO alphabetize + exports.Treemap = _treemap2.default; exports.RadialChart = _radialChart2.default; exports.RadarChart = _radarChart2.default; diff --git a/dist/plot/series/label-series.js b/dist/plot/series/label-series.js index 62e335748..5b2da150d 100644 --- a/dist/plot/series/label-series.js +++ b/dist/plot/series/label-series.js @@ -57,7 +57,7 @@ var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--label'; var getTextAnchor = function getTextAnchor(labelAnchorX, leftOfMiddle) { return labelAnchorX ? labelAnchorX : leftOfMiddle ? 'start' : 'end'; }; -var getAlignmentBaseline = function getAlignmentBaseline(labelAnchorY, aboveMiddle) { +var getDominantBaseline = function getDominantBaseline(labelAnchorY, aboveMiddle) { return labelAnchorY ? labelAnchorY : aboveMiddle ? 'text-before-edge' : 'text-after-edge'; }; @@ -132,7 +132,7 @@ var LabelSeries = function (_AbstractSeries) { var hasRotationValueSet = d.rotation === 0 || d.rotation; var labelRotation = hasRotationValueSet ? d.rotation : rotation; var attrs = _extends({ - alignmentBaseline: getAlignmentBaseline(labelAnchorY, aboveMiddle), + dominantBaseline: getDominantBaseline(labelAnchorY, aboveMiddle), className: 'rv-xy-plot__series--label-text', key: i, onClick: function onClick(e) { diff --git a/dist/utils/scales-utils.js b/dist/utils/scales-utils.js index ea61f3b49..1af42b6cc 100644 --- a/dist/utils/scales-utils.js +++ b/dist/utils/scales-utils.js @@ -186,14 +186,14 @@ function _getSmallestDistanceIndex(values, scaleObject) { function addInvertFunctionToOrdinalScaleObject(scale) { if (scale.invert) return; - scale.invert = function (_) { - var domainIndex, - n = scale.domain().length, - reverse = scale.range()[1] < scale.range()[0], - start = scale.range()[reverse - 0], - stop = scale.range()[1 - reverse]; - - if (_ < start + scale.padding() * scale.step()) domainIndex = 0;else if (_ > stop - scale.padding() * scale.step()) domainIndex = n - 1;else domainIndex = Math.floor((_ - start - scale.padding() * scale.step()) / scale.step()); + scale.invert = function invert(value) { + var domainIndex = 0; + var n = scale.domain().length; + var reverse = scale.range()[1] < scale.range()[0]; + var start = scale.range()[reverse - 0]; + var stop = scale.range()[1 - reverse]; + + if (value < start + scale.padding() * scale.step()) domainIndex = 0;else if (value > stop - scale.padding() * scale.step()) domainIndex = n - 1;else domainIndex = Math.floor((value - start - scale.padding() * scale.step()) / scale.step()); return scale.domain()[domainIndex]; }; diff --git a/src/utils/scales-utils.js b/src/utils/scales-utils.js index 220fa721d..249dc8788 100644 --- a/src/utils/scales-utils.js +++ b/src/utils/scales-utils.js @@ -161,16 +161,16 @@ export function _getSmallestDistanceIndex(values, scaleObject) { function addInvertFunctionToOrdinalScaleObject(scale) { if (scale.invert) return; - scale.invert = function(_) { - var domainIndex, - n = scale.domain().length, - reverse = scale.range()[1] < scale.range()[0], - start = scale.range()[reverse - 0], - stop = scale.range()[1 - reverse]; + scale.invert = function invert(value) { + let domainIndex = 0; + const n = scale.domain().length; + const reverse = scale.range()[1] < scale.range()[0]; + const start = scale.range()[reverse - 0]; + const stop = scale.range()[1 - reverse]; - if (_ < start + scale.padding() * scale.step()) domainIndex = 0; - else if (_ > stop - scale.padding() * scale.step()) domainIndex = n - 1; - else domainIndex = Math.floor((_ - start - scale.padding() * scale.step()) / scale.step()); + if (value < start + scale.padding() * scale.step()) domainIndex = 0; + else if (value > stop - scale.padding() * scale.step()) domainIndex = n - 1; + else domainIndex = Math.floor((value - start - scale.padding() * scale.step()) / scale.step()); return scale.domain()[domainIndex]; } From d0906d4483c4f50df723228d28e2f6ad996be7d9 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Tue, 20 Nov 2018 12:34:08 +0100 Subject: [PATCH 04/10] Adding forgotten file. --- dist/plot/chart-label.js | 112 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 dist/plot/chart-label.js diff --git a/dist/plot/chart-label.js b/dist/plot/chart-label.js new file mode 100644 index 000000000..cc614ad38 --- /dev/null +++ b/dist/plot/chart-label.js @@ -0,0 +1,112 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +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; } // Copyright (c) 2018 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var ChartLabel = function (_React$PureComponent) { + _inherits(ChartLabel, _React$PureComponent); + + function ChartLabel() { + _classCallCheck(this, ChartLabel); + + return _possibleConstructorReturn(this, (ChartLabel.__proto__ || Object.getPrototypeOf(ChartLabel)).apply(this, arguments)); + } + + _createClass(ChartLabel, [{ + key: 'render', + value: function render() { + var _props = this.props, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginBottom = _props.marginBottom, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + marginTop = _props.marginTop, + className = _props.className, + includeMargin = _props.includeMargin, + style = _props.style, + text = _props.text, + xPercent = _props.xPercent, + yPercent = _props.yPercent; + + var width = innerWidth + (includeMargin ? marginLeft + marginRight : 0); + var height = innerHeight + (includeMargin ? marginTop + marginBottom : 0); + var xPos = width * xPercent + (includeMargin ? 0 : marginLeft); + var yPos = height * yPercent + (includeMargin ? marginLeft : 0); + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + xPos + ', ' + yPos + ')', + className: 'rv-xy-plot__axis__title ' + className }, + _react2.default.createElement( + 'text', + style, + text + ) + ); + } + }], [{ + key: 'requiresSVG', + get: function get() { + return true; + } + }]); + + return ChartLabel; +}(_react2.default.PureComponent); + +ChartLabel.displayName = 'ChartLabel'; +ChartLabel.propTypes = { + className: _propTypes2.default.string, + includeMargin: _propTypes2.default.bool, + style: _propTypes2.default.object, + text: _propTypes2.default.string.isRequired, + xPercent: _propTypes2.default.number.isRequired, + yPercent: _propTypes2.default.number.isRequired +}; +ChartLabel.defaultProps = { + className: '', + includeMargin: true, + text: '', + xPercent: 0, + yPercent: 0, + style: {} +}; +exports.default = ChartLabel; \ No newline at end of file From 9bf6279abdde65b06309fc3f604bc833ebb06990 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Tue, 20 Nov 2018 18:30:06 +0100 Subject: [PATCH 05/10] Adding tests for invert functionality of ordinal scale. --- src/utils/scales-utils.js | 4 ++-- tests/utils/scales-utils-tests.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/utils/scales-utils.js b/src/utils/scales-utils.js index 249dc8788..6d4cbc887 100644 --- a/src/utils/scales-utils.js +++ b/src/utils/scales-utils.js @@ -171,7 +171,7 @@ function addInvertFunctionToOrdinalScaleObject(scale) { if (value < start + scale.padding() * scale.step()) domainIndex = 0; else if (value > stop - scale.padding() * scale.step()) domainIndex = n - 1; else domainIndex = Math.floor((value - start - scale.padding() * scale.step()) / scale.step()); - + return scale.domain()[domainIndex]; } } @@ -205,7 +205,7 @@ export function getScaleFnFromScaleObject(scaleObject) { .range(range); if (type === ORDINAL_SCALE_TYPE) { scale.padding(0.5); - addInvertFunctionToOrdinalScaleObject(scale); + addInvertFunctionToOrdinalScaleObject(scale); } return scale; } diff --git a/tests/utils/scales-utils-tests.js b/tests/utils/scales-utils-tests.js index 7c5f559d5..842ba4fde 100644 --- a/tests/utils/scales-utils-tests.js +++ b/tests/utils/scales-utils-tests.js @@ -505,6 +505,22 @@ test('scales-utils #getScaleFnFromScaleObject', t => { [-1, 1], 'should build a generic domain that reflects about zero' ); + + const ordinalScale = getScaleFnFromScaleObject({ + type: 'ordinal', + domain: ["a", "b", "c", "d", "e"], + range: [20, 120] + }); + + t.equal(ordinalScale.invert(-10), "a"); + t.equal(ordinalScale.invert(25), "a"); + t.equal(ordinalScale.invert(40), "a"); + t.equal(ordinalScale.invert(60), "b"); + t.equal(ordinalScale.invert(80), "c"); + t.equal(ordinalScale.invert(100), "d"); + t.equal(ordinalScale.invert(115), "e"); + t.equal(ordinalScale.invert(130), "e"); + t.end(); }); From aa5c7401462b4a6350fb8976cb13341ba3af7f55 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Wed, 21 Nov 2018 11:41:56 +0100 Subject: [PATCH 06/10] Revert "Adding temp dist for my fork." This reverts commit 2077f18b85045e7feef55455dec1fefad0068fe8. --- dist/animation.js | 188 ----- dist/legends/continuous-color-legend.js | 107 --- dist/legends/continuous-size-legend.js | 116 --- dist/legends/discrete-color-legend-item.js | 103 --- dist/legends/discrete-color-legend.js | 107 --- .../searchable-discrete-color-legend.js | 107 --- dist/main.scss | 9 - dist/make-vis-flexible.js | 250 ------- dist/parallel-coordinates/index.js | 360 ---------- dist/plot/axis/axis-line.js | 99 --- dist/plot/axis/axis-ticks.js | 271 ------- dist/plot/axis/axis-title.js | 186 ----- dist/plot/axis/axis.js | 264 ------- dist/plot/axis/decorative-axis-ticks.js | 99 --- dist/plot/axis/decorative-axis.js | 174 ----- dist/plot/axis/x-axis.js | 66 -- dist/plot/axis/y-axis.js | 66 -- dist/plot/borders.js | 125 ---- dist/plot/circular-grid-lines.js | 165 ----- dist/plot/crosshair.js | 262 ------- dist/plot/gradient-defs.js | 58 -- dist/plot/grid-lines.js | 178 ----- dist/plot/highlight.js | 426 ----------- dist/plot/hint.js | 454 ------------ dist/plot/horizontal-grid-lines.js | 64 -- dist/plot/series/abstract-series.js | 415 ----------- dist/plot/series/arc-series.js | 279 -------- dist/plot/series/area-series.js | 160 ----- dist/plot/series/bar-series-canvas.js | 161 ----- dist/plot/series/bar-series.js | 180 ----- dist/plot/series/canvas-wrapper.js | 256 ------- dist/plot/series/contour-series.js | 164 ----- dist/plot/series/custom-svg-series.js | 237 ------- dist/plot/series/heatmap-series.js | 147 ---- dist/plot/series/hexbin-series.js | 180 ----- .../series/horizontal-bar-series-canvas.js | 97 --- dist/plot/series/horizontal-bar-series.js | 85 --- .../series/horizontal-rect-series-canvas.js | 97 --- dist/plot/series/horizontal-rect-series.js | 85 --- dist/plot/series/line-mark-series-canvas.js | 87 --- dist/plot/series/line-mark-series.js | 102 --- dist/plot/series/line-series-canvas.js | 146 ---- dist/plot/series/line-series.js | 177 ----- dist/plot/series/mark-series-canvas.js | 109 --- dist/plot/series/mark-series.js | 179 ----- dist/plot/series/polygon-series.js | 126 ---- dist/plot/series/rect-series-canvas.js | 136 ---- dist/plot/series/rect-series.js | 151 ---- .../plot/series/vertical-bar-series-canvas.js | 97 --- dist/plot/series/vertical-bar-series.js | 85 --- .../series/vertical-rect-series-canvas.js | 97 --- dist/plot/series/vertical-rect-series.js | 85 --- dist/plot/series/whisker-series.js | 274 -------- dist/plot/vertical-grid-lines.js | 64 -- dist/plot/voronoi.js | 148 ---- dist/plot/xy-plot.js | 660 ------------------ dist/radar-chart/index.js | 418 ----------- dist/radial-chart/index.js | 263 ------- dist/sankey/index.js | 238 ------- dist/sankey/sankey-link.js | 85 --- dist/style.css | 1 - dist/styles/examples.scss | 461 ------------ dist/styles/legends.scss | 137 ---- dist/styles/plot.scss | 128 ---- dist/styles/radial-chart.scss | 6 - dist/styles/treemap.scss | 22 - dist/sunburst/index.js | 253 ------- dist/theme.js | 42 -- dist/treemap/index.js | 254 ------- dist/treemap/treemap-dom.js | 82 --- dist/treemap/treemap-leaf.js | 125 ---- dist/treemap/treemap-svg.js | 246 ------- dist/utils/axis-utils.js | 167 ----- dist/utils/chart-utils.js | 104 --- dist/utils/data-utils.js | 54 -- dist/utils/react-utils.js | 95 --- dist/utils/series-utils.js | 268 ------- 77 files changed, 13019 deletions(-) delete mode 100644 dist/animation.js delete mode 100644 dist/legends/continuous-color-legend.js delete mode 100644 dist/legends/continuous-size-legend.js delete mode 100644 dist/legends/discrete-color-legend-item.js delete mode 100644 dist/legends/discrete-color-legend.js delete mode 100644 dist/legends/searchable-discrete-color-legend.js delete mode 100644 dist/main.scss delete mode 100644 dist/make-vis-flexible.js delete mode 100644 dist/parallel-coordinates/index.js delete mode 100644 dist/plot/axis/axis-line.js delete mode 100644 dist/plot/axis/axis-ticks.js delete mode 100644 dist/plot/axis/axis-title.js delete mode 100644 dist/plot/axis/axis.js delete mode 100644 dist/plot/axis/decorative-axis-ticks.js delete mode 100644 dist/plot/axis/decorative-axis.js delete mode 100644 dist/plot/axis/x-axis.js delete mode 100644 dist/plot/axis/y-axis.js delete mode 100644 dist/plot/borders.js delete mode 100644 dist/plot/circular-grid-lines.js delete mode 100644 dist/plot/crosshair.js delete mode 100644 dist/plot/gradient-defs.js delete mode 100644 dist/plot/grid-lines.js delete mode 100644 dist/plot/highlight.js delete mode 100644 dist/plot/hint.js delete mode 100644 dist/plot/horizontal-grid-lines.js delete mode 100644 dist/plot/series/abstract-series.js delete mode 100644 dist/plot/series/arc-series.js delete mode 100644 dist/plot/series/area-series.js delete mode 100644 dist/plot/series/bar-series-canvas.js delete mode 100644 dist/plot/series/bar-series.js delete mode 100644 dist/plot/series/canvas-wrapper.js delete mode 100644 dist/plot/series/contour-series.js delete mode 100644 dist/plot/series/custom-svg-series.js delete mode 100644 dist/plot/series/heatmap-series.js delete mode 100644 dist/plot/series/hexbin-series.js delete mode 100644 dist/plot/series/horizontal-bar-series-canvas.js delete mode 100644 dist/plot/series/horizontal-bar-series.js delete mode 100644 dist/plot/series/horizontal-rect-series-canvas.js delete mode 100644 dist/plot/series/horizontal-rect-series.js delete mode 100644 dist/plot/series/line-mark-series-canvas.js delete mode 100644 dist/plot/series/line-mark-series.js delete mode 100644 dist/plot/series/line-series-canvas.js delete mode 100644 dist/plot/series/line-series.js delete mode 100644 dist/plot/series/mark-series-canvas.js delete mode 100644 dist/plot/series/mark-series.js delete mode 100644 dist/plot/series/polygon-series.js delete mode 100644 dist/plot/series/rect-series-canvas.js delete mode 100644 dist/plot/series/rect-series.js delete mode 100644 dist/plot/series/vertical-bar-series-canvas.js delete mode 100644 dist/plot/series/vertical-bar-series.js delete mode 100644 dist/plot/series/vertical-rect-series-canvas.js delete mode 100644 dist/plot/series/vertical-rect-series.js delete mode 100644 dist/plot/series/whisker-series.js delete mode 100644 dist/plot/vertical-grid-lines.js delete mode 100644 dist/plot/voronoi.js delete mode 100644 dist/plot/xy-plot.js delete mode 100644 dist/radar-chart/index.js delete mode 100644 dist/radial-chart/index.js delete mode 100644 dist/sankey/index.js delete mode 100644 dist/sankey/sankey-link.js delete mode 100644 dist/style.css delete mode 100644 dist/styles/examples.scss delete mode 100644 dist/styles/legends.scss delete mode 100644 dist/styles/plot.scss delete mode 100644 dist/styles/radial-chart.scss delete mode 100644 dist/styles/treemap.scss delete mode 100644 dist/sunburst/index.js delete mode 100644 dist/theme.js delete mode 100644 dist/treemap/index.js delete mode 100644 dist/treemap/treemap-dom.js delete mode 100644 dist/treemap/treemap-leaf.js delete mode 100644 dist/treemap/treemap-svg.js delete mode 100644 dist/utils/axis-utils.js delete mode 100644 dist/utils/chart-utils.js delete mode 100644 dist/utils/data-utils.js delete mode 100644 dist/utils/react-utils.js delete mode 100644 dist/utils/series-utils.js diff --git a/dist/animation.js b/dist/animation.js deleted file mode 100644 index 9638ef2d6..000000000 --- a/dist/animation.js +++ /dev/null @@ -1,188 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.AnimationPropType = undefined; - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -exports.extractAnimatedPropValues = extractAnimatedPropValues; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Interpolate = require('d3-interpolate'); - -var _reactMotion = require('react-motion'); - -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; } - -function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - -var ANIMATION_PROPTYPES = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({ - stiffness: _propTypes2.default.number, - nonAnimatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string), - damping: _propTypes2.default.number -}), _propTypes2.default.bool]); - -var propTypes = { - animatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string).isRequired, - animation: ANIMATION_PROPTYPES, - onStart: _propTypes2.default.func, - onEnd: _propTypes2.default.func -}; - -/** - * Format the animation style object - * @param {Object|String} animationStyle - The animation style property, either the name of a - * presets are one of noWobble, gentle, wobbly, stiff - */ -function getAnimationStyle() { - var animationStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _reactMotion.presets.noWobble; - - if (typeof animationStyle === 'string') { - return _reactMotion.presets[animationStyle] || _reactMotion.presets.noWobble; - } - var damping = animationStyle.damping, - stiffness = animationStyle.stiffness; - - return _extends({ - damping: damping || _reactMotion.presets.noWobble.damping, - stiffness: stiffness || _reactMotion.presets.noWobble.stiffness - }, animationStyle); -} - -/** - * Extract the animated props from the entire props object. - * @param {Object} props Props. - * @returns {Object} Object of animated props. - */ -function extractAnimatedPropValues(props) { - var animatedProps = props.animatedProps, - otherProps = _objectWithoutProperties(props, ['animatedProps']); - - return animatedProps.reduce(function (result, animatedPropName) { - if (otherProps.hasOwnProperty(animatedPropName)) { - result[animatedPropName] = otherProps[animatedPropName]; - } - return result; - }, {}); -} - -var Animation = function (_PureComponent) { - _inherits(Animation, _PureComponent); - - function Animation(props) { - _classCallCheck(this, Animation); - - var _this = _possibleConstructorReturn(this, (Animation.__proto__ || Object.getPrototypeOf(Animation)).call(this, props)); - - _this._motionEndHandler = function () { - if (_this.props.onEnd) { - _this.props.onEnd(); - } - }; - - _this._renderChildren = function (_ref) { - var i = _ref.i; - var children = _this.props.children; - - var interpolator = _this._interpolator; - var child = _react2.default.Children.only(children); - var interpolatedProps = interpolator ? interpolator(i) : interpolator; - - // interpolator doesnt play nice with deeply nested objected - // so we expose an additional prop for situations like these, soit _data, - // which stores the full tree and can be recombined with the sanitized version - // after interpolation - var data = interpolatedProps && interpolatedProps.data || null; - if (data && child.props._data) { - data = data.map(function (row, index) { - var correspondingCell = child.props._data[index]; - return _extends({}, row, { - parent: correspondingCell.parent, - children: correspondingCell.children - }); - }); - } - - return _react2.default.cloneElement(child, _extends({}, child.props, interpolatedProps, { - data: data || child.props.data || null, - // enforce re-rendering - _animation: Math.random() - })); - }; - - _this._updateInterpolator(props); - return _this; - } - - _createClass(Animation, [{ - key: 'componentWillUpdate', - value: function componentWillUpdate(props) { - this._updateInterpolator(this.props, props); - if (props.onStart) { - props.onStart(); - } - } - - /** - * Render the child into the parent. - * @param {Number} i Number generated by the spring. - * @returns {React.Component} Rendered react element. - * @private - */ - - }, { - key: '_updateInterpolator', - - - /** - * Update the interpolator function and assign it to this._interpolator. - * @param {Object} oldProps Old props. - * @param {Object} newProps New props. - * @private - */ - value: function _updateInterpolator(oldProps, newProps) { - this._interpolator = (0, _d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps), newProps ? extractAnimatedPropValues(newProps) : null); - } - }, { - key: 'render', - value: function render() { - var animationStyle = getAnimationStyle(this.props.animation); - var defaultStyle = { i: 0 }; - var style = { i: (0, _reactMotion.spring)(1, animationStyle) }; - // In order to make Motion re-run animations each time, the random key is - // always passed. - // TODO: find a better solution for the spring. - var key = Math.random(); - return _react2.default.createElement( - _reactMotion.Motion, - _extends({ defaultStyle: defaultStyle, style: style, key: key }, { onRest: this._motionEndHandler }), - this._renderChildren - ); - } - }]); - - return Animation; -}(_react.PureComponent); - -Animation.propTypes = propTypes; -Animation.displayName = 'Animation'; - -exports.default = Animation; -var AnimationPropType = exports.AnimationPropType = ANIMATION_PROPTYPES; \ No newline at end of file diff --git a/dist/legends/continuous-color-legend.js b/dist/legends/continuous-color-legend.js deleted file mode 100644 index 8784a3dcc..000000000 --- a/dist/legends/continuous-color-legend.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _theme = require('../theme'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var propTypes = { - className: _propTypes2.default.string, - height: _propTypes2.default.number, - endColor: _propTypes2.default.string, - endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - midColor: _propTypes2.default.string, - midTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - startColor: _propTypes2.default.string, - startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - width: _propTypes2.default.number -}; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var defaultProps = { - className: '', - startColor: _theme.CONTINUOUS_COLOR_RANGE[0], - endColor: _theme.CONTINUOUS_COLOR_RANGE[1] -}; - -function ContinuousColorLegend(_ref) { - var startColor = _ref.startColor, - midColor = _ref.midColor, - endColor = _ref.endColor, - startTitle = _ref.startTitle, - midTitle = _ref.midTitle, - endTitle = _ref.endTitle, - height = _ref.height, - width = _ref.width, - className = _ref.className; - - var colors = [startColor]; - if (midColor) { - colors.push(midColor); - } - colors.push(endColor); - return _react2.default.createElement( - 'div', - { - className: 'rv-continuous-color-legend ' + className, - style: { width: width, height: height } - }, - _react2.default.createElement('div', { - className: 'rv-gradient', - style: { background: 'linear-gradient(to right, ' + colors.join(',') + ')' } - }), - _react2.default.createElement( - 'div', - { className: 'rv-legend-titles' }, - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__left' }, - startTitle - ), - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__right' }, - endTitle - ), - midTitle ? _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__center' }, - midTitle - ) : null - ) - ); -} - -ContinuousColorLegend.displayName = 'ContinuousColorLegend'; -ContinuousColorLegend.propTypes = propTypes; -ContinuousColorLegend.defaultProps = defaultProps; - -exports.default = ContinuousColorLegend; \ No newline at end of file diff --git a/dist/legends/continuous-size-legend.js b/dist/legends/continuous-size-legend.js deleted file mode 100644 index 91f072d5e..000000000 --- a/dist/legends/continuous-size-legend.js +++ /dev/null @@ -1,116 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var propTypes = { - className: _propTypes2.default.string, - circlesTotal: _propTypes2.default.number, - endSize: _propTypes2.default.number, - endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - height: _propTypes2.default.number, - startSize: _propTypes2.default.number, - startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - width: _propTypes2.default.number -}; - -var defaultProps = { - circlesTotal: 10, - className: '', - endSize: 20, - startSize: 2 -}; - -function ContinuousSizeLegend(_ref) { - var startTitle = _ref.startTitle, - endTitle = _ref.endTitle, - startSize = _ref.startSize, - endSize = _ref.endSize, - circlesTotal = _ref.circlesTotal, - height = _ref.height, - width = _ref.width, - className = _ref.className; - - var circles = []; - var step = (endSize - startSize) / (circlesTotal - 1); - - for (var i = 0; i < circlesTotal; i++) { - var size = step * i + startSize; - circles.push(_react2.default.createElement('div', { - key: i, - className: 'rv-bubble', - style: { - width: size, - height: size, - borderRadius: size / 2 - } - })); - // Add the separator in order to justify the content (otherwise the tags - // will be stacked together without any margins around). - circles.push(' '); - } - return _react2.default.createElement( - 'div', - { - className: 'rv-continuous-size-legend ' + className, - style: { width: width, height: height } - }, - _react2.default.createElement( - 'div', - { className: 'rv-bubbles', style: { height: endSize } }, - circles, - _react2.default.createElement('div', { className: 'rv-spacer' }) - ), - _react2.default.createElement( - 'div', - { className: 'rv-legend-titles' }, - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__left' }, - startTitle - ), - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__right' }, - endTitle - ) - ) - ); -} - -ContinuousSizeLegend.displayName = 'ContinuousSizeLegend'; -ContinuousSizeLegend.propTypes = propTypes; -ContinuousSizeLegend.defaultProps = defaultProps; - -exports.default = ContinuousSizeLegend; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend-item.js b/dist/legends/discrete-color-legend-item.js deleted file mode 100644 index 4b12b4428..000000000 --- a/dist/legends/discrete-color-legend-item.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var STROKE_STYLES = { - dashed: '6, 2', - solid: null -}; - -function DiscreteColorLegendItem(_ref) { - var color = _ref.color, - strokeDasharray = _ref.strokeDasharray, - strokeStyle = _ref.strokeStyle, - strokeWidth = _ref.strokeWidth, - disabled = _ref.disabled, - onClick = _ref.onClick, - orientation = _ref.orientation, - onMouseEnter = _ref.onMouseEnter, - onMouseLeave = _ref.onMouseLeave, - title = _ref.title; - - var className = 'rv-discrete-color-legend-item ' + orientation; - if (disabled) { - className += ' disabled'; - } - if (onClick) { - className += ' clickable'; - } - var strokeDasharrayStyle = STROKE_STYLES[strokeStyle] || strokeDasharray; - return _react2.default.createElement( - 'div', - { className: className, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, - _react2.default.createElement( - 'svg', - { className: 'rv-discrete-color-legend-item__color', height: 2, width: 14 }, - _react2.default.createElement('path', { - className: 'rv-discrete-color-legend-item__color__path', - d: 'M 0, 1 L 14, 1', - style: _extends({}, strokeWidth ? { strokeWidth: strokeWidth } : {}, strokeDasharrayStyle ? { strokeDasharray: strokeDasharrayStyle } : {}, { - stroke: disabled ? null : color - }) - - }) - ), - _react2.default.createElement( - 'span', - { className: 'rv-discrete-color-legend-item__title' }, - title - ) - ); -} - -DiscreteColorLegendItem.propTypes = { - color: _propTypes2.default.string.isRequired, - disabled: _propTypes2.default.bool, - title: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]).isRequired, - onClick: _propTypes2.default.func, - onMouseEnter: _propTypes2.default.func, - onMouseLeave: _propTypes2.default.func, - orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']).isRequired, - strokeDasharray: _propTypes2.default.string, - strokeWidth: _propTypes2.default.number, - strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)) -}; -DiscreteColorLegendItem.defaultProps = { - disabled: false, - strokeStyle: 'solid' -}; -DiscreteColorLegendItem.displayName = 'DiscreteColorLegendItem'; - -exports.default = DiscreteColorLegendItem; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend.js b/dist/legends/discrete-color-legend.js deleted file mode 100644 index 76424e745..000000000 --- a/dist/legends/discrete-color-legend.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _discreteColorLegendItem = require('./discrete-color-legend-item'); - -var _discreteColorLegendItem2 = _interopRequireDefault(_discreteColorLegendItem); - -var _theme = require('../theme'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function DiscreteColorLegend(_ref) { - var className = _ref.className, - colors = _ref.colors, - height = _ref.height, - items = _ref.items, - onItemClick = _ref.onItemClick, - onItemMouseEnter = _ref.onItemMouseEnter, - onItemMouseLeave = _ref.onItemMouseLeave, - orientation = _ref.orientation, - style = _ref.style, - width = _ref.width; - - return _react2.default.createElement( - 'div', - { - className: 'rv-discrete-color-legend ' + orientation + ' ' + className, - style: _extends({ width: width, height: height }, style) - }, - items.map(function (item, i) { - return _react2.default.createElement(_discreteColorLegendItem2.default, { - title: item.title ? item.title : item, - color: item.color ? item.color : colors[i % colors.length], - strokeDasharray: item.strokeDasharray, - strokeStyle: item.strokeStyle, - strokeWidth: item.strokeWidth, - disabled: Boolean(item.disabled), - orientation: orientation, - key: i, - onClick: onItemClick ? function (e) { - return onItemClick(item, i, e); - } : null, - onMouseEnter: onItemMouseEnter ? function (e) { - return onItemMouseEnter(item, i, e); - } : null, - onMouseLeave: onItemMouseEnter ? function (e) { - return onItemMouseLeave(item, i, e); - } : null - }); - }) - ); -} - -DiscreteColorLegend.displayName = 'DiscreteColorLegendItem'; -DiscreteColorLegend.propTypes = { - className: _propTypes2.default.string, - items: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.shape({ - title: _propTypes2.default.string.isRequired, - color: _propTypes2.default.string, - disabled: _propTypes2.default.bool - }), _propTypes2.default.string.isRequired, _propTypes2.default.element])).isRequired, - onItemClick: _propTypes2.default.func, - onItemMouseEnter: _propTypes2.default.func, - onItemMouseLeave: _propTypes2.default.func, - height: _propTypes2.default.number, - width: _propTypes2.default.number, - orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']) -}; - -DiscreteColorLegend.defaultProps = { - className: '', - colors: _theme.DISCRETE_COLOR_RANGE, - orientation: 'vertical' -}; - -exports.default = DiscreteColorLegend; \ No newline at end of file diff --git a/dist/legends/searchable-discrete-color-legend.js b/dist/legends/searchable-discrete-color-legend.js deleted file mode 100644 index 49e081ef0..000000000 --- a/dist/legends/searchable-discrete-color-legend.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _discreteColorLegend = require('./discrete-color-legend'); - -var _discreteColorLegend2 = _interopRequireDefault(_discreteColorLegend); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var propTypes = _extends({}, _discreteColorLegend2.default.propTypes, { - searchText: _propTypes2.default.string, - onSearchChange: _propTypes2.default.func, - searchPlaceholder: _propTypes2.default.string, - searchFn: _propTypes2.default.func -}); - -var defaultProps = { - className: '', - searchText: '', - searchFn: function searchFn(items, s) { - return items.filter(function (item) { - return String(item.title || item).toLowerCase().indexOf(s) !== -1; - }); - } -}; - -function SearchableDiscreteColorLegend(props) { - var className = props.className, - colors = props.colors, - height = props.height, - items = props.items, - onItemClick = props.onItemClick, - onSearchChange = props.onSearchChange, - orientation = props.orientation, - searchFn = props.searchFn, - searchPlaceholder = props.searchPlaceholder, - searchText = props.searchText, - width = props.width; - - var onChange = onSearchChange ? function (_ref) { - var value = _ref.target.value; - return onSearchChange(value); - } : null; - var filteredItems = searchFn(items, searchText); - return _react2.default.createElement( - 'div', - { className: 'rv-search-wrapper ' + className, style: { width: width, height: height } }, - _react2.default.createElement( - 'form', - { className: 'rv-search-wrapper__form' }, - _react2.default.createElement('input', { - type: 'search', - placeholder: searchPlaceholder, - className: 'rv-search-wrapper__form__input', - value: searchText, - onChange: onChange - }) - ), - _react2.default.createElement( - 'div', - { className: 'rv-search-wrapper__contents' }, - _react2.default.createElement(_discreteColorLegend2.default, { - colors: colors, - items: filteredItems, - onItemClick: onItemClick, - orientation: orientation - }) - ) - ); -} - -SearchableDiscreteColorLegend.propTypes = propTypes; -SearchableDiscreteColorLegend.defaultProps = defaultProps; -SearchableDiscreteColorLegend.displayName = 'SearchableDiscreteColorLegend'; - -exports.default = SearchableDiscreteColorLegend; \ No newline at end of file diff --git a/dist/main.scss b/dist/main.scss deleted file mode 100644 index 30bac3dc2..000000000 --- a/dist/main.scss +++ /dev/null @@ -1,9 +0,0 @@ -// special tag for using to check if the style file has been imported -.react-vis-magic-css-import-rule { - display: inherit; -} - -@import 'styles/treemap'; -@import 'styles/plot'; -@import 'styles/legends'; -@import 'styles/radial-chart'; diff --git a/dist/make-vis-flexible.js b/dist/make-vis-flexible.js deleted file mode 100644 index c99808b61..000000000 --- a/dist/make-vis-flexible.js +++ /dev/null @@ -1,250 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.FlexibleXYPlot = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = undefined; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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; }; }(); - -exports.makeHeightFlexible = makeHeightFlexible; -exports.makeVisFlexible = makeVisFlexible; -exports.makeWidthFlexible = makeWidthFlexible; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _window = require('global/window'); - -var _window2 = _interopRequireDefault(_window); - -var _xyPlot = require('./plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _reactUtils = require('./utils/react-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var CONTAINER_REF = 'container'; - -// As a performance enhancement, we want to only listen once -var resizeSubscribers = []; -var DEBOUNCE_DURATION = 100; -var timeoutId = null; - -/** - * Calls each subscriber, debounced to the - */ -function debounceEmitResize() { - _window2.default.clearTimeout(timeoutId); - timeoutId = _window2.default.setTimeout(emitResize, DEBOUNCE_DURATION); -} - -/** - * Calls each subscriber once syncronously. - */ -function emitResize() { - resizeSubscribers.forEach(function (cb) { - return cb(); - }); -} - -/** - * Add the given callback to the list of subscribers to be caled when the - * window resizes. Returns a function that, when called, removes the given - * callback from the list of subscribers. This function is also resposible for - * adding and removing the resize listener on `window`. - * - * @param {Function} cb - Subscriber callback function - * @returns {Function} Unsubscribe function - */ -function subscribeToDebouncedResize(cb) { - resizeSubscribers.push(cb); - - // if we go from zero to one Flexible components instances, add the listener - if (resizeSubscribers.length === 1) { - _window2.default.addEventListener('resize', debounceEmitResize); - } - return function unsubscribe() { - removeSubscriber(cb); - - // if we have no Flexible components, remove the listener - if (resizeSubscribers.length === 0) { - _window2.default.clearTimeout(timeoutId); - _window2.default.removeEventListener('resize', debounceEmitResize); - } - }; -} - -/** - * Helper for removing the given callback from the list of subscribers. - * - * @param {Function} cb - Subscriber callback function - */ -function removeSubscriber(cb) { - var index = resizeSubscribers.indexOf(cb); - if (index > -1) { - resizeSubscribers.splice(index, 1); - } -} - -/** - * Helper for getting a display name for the child component - * @param {*} Component React class for the child component. - * @returns {String} The child components name - */ -function getDisplayName(Component) { - return Component.displayName || Component.name || 'Component'; -} - -/** - * Add the ability to stretch the visualization on window resize. - * @param {*} Component React class for the child component. - * @returns {*} Flexible component. - */ - -function makeFlexible(Component, isWidthFlexible, isHeightFlexible) { - var ResultClass = function (_React$Component) { - _inherits(ResultClass, _React$Component); - - _createClass(ResultClass, null, [{ - key: 'propTypes', - get: function get() { - var _Component$propTypes = Component.propTypes, - height = _Component$propTypes.height, - width = _Component$propTypes.width, - otherPropTypes = _objectWithoutProperties(_Component$propTypes, ['height', 'width']); // eslint-disable-line no-unused-vars - - - return otherPropTypes; - } - }]); - - function ResultClass(props) { - _classCallCheck(this, ResultClass); - - var _this = _possibleConstructorReturn(this, (ResultClass.__proto__ || Object.getPrototypeOf(ResultClass)).call(this, props)); - - _this._onResize = function () { - var containerElement = (0, _reactUtils.getDOMNode)(_this[CONTAINER_REF]); - var offsetHeight = containerElement.offsetHeight, - offsetWidth = containerElement.offsetWidth; - - - var newHeight = _this.state.height === offsetHeight ? {} : { height: offsetHeight }; - - var newWidth = _this.state.width === offsetWidth ? {} : { width: offsetWidth }; - - _this.setState(_extends({}, newHeight, newWidth)); - }; - - _this.state = { - height: 0, - width: 0 - }; - return _this; - } - - /** - * Get the width of the container and assign the width. - * @private - */ - - - _createClass(ResultClass, [{ - key: 'componentDidMount', - value: function componentDidMount() { - this._onResize(); - this.cancelSubscription = subscribeToDebouncedResize(this._onResize); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps() { - this._onResize(); - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.cancelSubscription(); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _state = this.state, - height = _state.height, - width = _state.width; - - var props = _extends({}, this.props, { - animation: height === 0 && width === 0 ? null : this.props.animation - }); - - var updatedDimensions = _extends({}, isHeightFlexible ? { height: height } : {}, isWidthFlexible ? { width: width } : {}); - - return _react2.default.createElement( - 'div', - { - ref: function ref(_ref) { - return _this2[CONTAINER_REF] = _ref; - }, - style: { width: '100%', height: '100%' } - }, - _react2.default.createElement(Component, _extends({}, updatedDimensions, props)) - ); - } - }]); - - return ResultClass; - }(_react2.default.Component); - - ResultClass.displayName = 'Flexible' + getDisplayName(Component); - - return ResultClass; -} - -function makeHeightFlexible(component) { - return makeFlexible(component, false, true); -} - -function makeVisFlexible(component) { - return makeFlexible(component, true, true); -} - -function makeWidthFlexible(component) { - return makeFlexible(component, true, false); -} - -var FlexibleWidthXYPlot = exports.FlexibleWidthXYPlot = makeWidthFlexible(_xyPlot2.default); -var FlexibleHeightXYPlot = exports.FlexibleHeightXYPlot = makeHeightFlexible(_xyPlot2.default); -var FlexibleXYPlot = exports.FlexibleXYPlot = makeVisFlexible(_xyPlot2.default); \ No newline at end of file diff --git a/dist/parallel-coordinates/index.js b/dist/parallel-coordinates/index.js deleted file mode 100644 index 6b39942e9..000000000 --- a/dist/parallel-coordinates/index.js +++ /dev/null @@ -1,360 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Scale = require('d3-scale'); - -var _d3Format = require('d3-format'); - -var _animation = require('../animation'); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _theme = require('../theme'); - -var _chartUtils = require('../utils/chart-utils'); - -var _lineSeries = require('../plot/series/line-series'); - -var _lineSeries2 = _interopRequireDefault(_lineSeries); - -var _lineMarkSeries = require('../plot/series/line-mark-series'); - -var _lineMarkSeries2 = _interopRequireDefault(_lineMarkSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _decorativeAxis = require('../plot/axis/decorative-axis'); - -var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); - -var _highlight = require('../plot/highlight'); - -var _highlight2 = _interopRequireDefault(_highlight); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } - -var predefinedClassName = 'rv-parallel-coordinates-chart'; -var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); -/** - * Generate axes for each of the domains - * @param {Object} props - - props.animation {Boolean} - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for the whole chart - - props.tickFormat {Function} formatting function for axes - * @return {Array} the plotted axis components - */ -function getAxes(props) { - var animation = props.animation, - domains = props.domains, - style = props.style, - tickFormat = props.tickFormat; - - return domains.map(function (domain, index) { - var sortedDomain = domain.domain; - - var domainTickFormat = function domainTickFormat(t) { - return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); - }; - - return _react2.default.createElement(_decorativeAxis2.default, { - animation: animation, - key: index + '-axis', - axisStart: { x: domain.name, y: 0 }, - axisEnd: { x: domain.name, y: 1 }, - axisDomain: sortedDomain, - numberOfTicks: 5, - tickValue: domainTickFormat, - style: style.axes - }); - }); -} - -/** - * Generate labels for the ends of the axes - * @param {Object} props - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for just the labels - * @return {Array} the prepped data for the labelSeries - */ -function getLabels(props) { - var domains = props.domains, - style = props.style; - - return domains.map(function (domain, index) { - return { - x: domain.name, - y: 1.1, - label: domain.name, - style: style - }; - }); -} - -/** - * Generate the actual lines to be plotted - * @param {Object} props - - props.animation {Boolean} - - props.data {Array} array of object specifying what values are to be plotted - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for the whole chart - - props.showMarks {Bool} whether or not to use the line mark series - * @return {Array} the plotted axis components - */ -function getLines(props) { - var animation = props.animation, - brushFilters = props.brushFilters, - colorRange = props.colorRange, - domains = props.domains, - data = props.data, - style = props.style, - showMarks = props.showMarks; - - var scales = domains.reduce(function (acc, _ref) { - var domain = _ref.domain, - name = _ref.name; - - acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); - return acc; - }, {}); - // const - - return data.map(function (row, rowIndex) { - var withinFilteredRange = true; - var mappedData = domains.map(function (domain, index) { - var getValue = domain.getValue, - name = domain.name; - - // watch out! Gotcha afoot - // yVal after being scale is in [0, 1] range - - var yVal = scales[name](getValue ? getValue(row) : row[name]); - var filter = brushFilters[name]; - // filter value after being scale back from pixel space is also in [0, 1] - if (filter && (yVal < filter.min || yVal > filter.max)) { - withinFilteredRange = false; - } - return { x: name, y: yVal }; - }); - var selectedName = predefinedClassName + '-line'; - var unselectedName = selectedName + ' ' + predefinedClassName + '-line-unselected'; - var lineProps = { - animation: animation, - className: withinFilteredRange ? selectedName : unselectedName, - key: rowIndex + '-polygon', - data: mappedData, - color: row.color || colorRange[rowIndex % colorRange.length], - style: _extends({}, style.lines, row.style || {}) - }; - if (!withinFilteredRange) { - lineProps.style = _extends({}, lineProps.style, style.deselectedLineStyle); - } - return showMarks ? _react2.default.createElement(_lineMarkSeries2.default, lineProps) : _react2.default.createElement(_lineSeries2.default, lineProps); - }); -} - -var ParallelCoordinates = function (_Component) { - _inherits(ParallelCoordinates, _Component); - - function ParallelCoordinates() { - var _ref2; - - var _temp, _this, _ret; - - _classCallCheck(this, ParallelCoordinates); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = ParallelCoordinates.__proto__ || Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2, [this].concat(args))), _this), _this.state = { - brushFilters: {} - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(ParallelCoordinates, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var brushFilters = this.state.brushFilters; - var _props = this.props, - animation = _props.animation, - brushing = _props.brushing, - className = _props.className, - children = _props.children, - colorRange = _props.colorRange, - data = _props.data, - domains = _props.domains, - height = _props.height, - hideInnerMostValues = _props.hideInnerMostValues, - margin = _props.margin, - onMouseLeave = _props.onMouseLeave, - onMouseEnter = _props.onMouseEnter, - showMarks = _props.showMarks, - style = _props.style, - tickFormat = _props.tickFormat, - width = _props.width; - - - var axes = getAxes({ - domains: domains, - animation: animation, - hideInnerMostValues: hideInnerMostValues, - style: style, - tickFormat: tickFormat - }); - - var lines = getLines({ - animation: animation, - brushFilters: brushFilters, - colorRange: colorRange, - domains: domains, - data: data, - showMarks: showMarks, - style: style - }); - var labelSeries = _react2.default.createElement(_labelSeries2.default, { - animation: true, - key: className, - className: predefinedClassName + '-label', - data: getLabels({ domains: domains, style: style.labels }) - }); - - var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS), - marginLeft = _getInnerDimensions.marginLeft, - marginRight = _getInnerDimensions.marginRight; - - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - width: width, - margin: margin, - dontCheckIfEmpty: true, - className: className + ' ' + predefinedClassName, - onMouseLeave: onMouseLeave, - onMouseEnter: onMouseEnter, - xType: 'ordinal', - yDomain: [0, 1] - }, - children, - axes.concat(lines).concat(labelSeries), - brushing && domains.map(function (d) { - var trigger = function trigger(row) { - _this2.setState({ - brushFilters: _extends({}, brushFilters, _defineProperty({}, d.name, row ? { min: row.bottom, max: row.top } : null)) - }); - }; - return _react2.default.createElement(_highlight2.default, { - key: d.name, - drag: true, - highlightX: d.name, - onBrushEnd: trigger, - onDragEnd: trigger, - highlightWidth: (width - marginLeft - marginRight) / domains.length, - enableX: false - }); - }) - ); - } - }]); - - return ParallelCoordinates; -}(_react.Component); - -ParallelCoordinates.displayName = 'ParallelCoordinates'; -ParallelCoordinates.propTypes = { - animation: _animation.AnimationPropType, - brushing: _propTypes2.default.bool, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), - data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - name: _propTypes2.default.string.isRequired, - domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, - tickFormat: _propTypes2.default.func - })).isRequired, - height: _propTypes2.default.number.isRequired, - margin: _chartUtils.MarginPropType, - style: _propTypes2.default.shape({ - axes: _propTypes2.default.object, - labels: _propTypes2.default.object, - lines: _propTypes2.default.object - }), - showMarks: _propTypes2.default.bool, - tickFormat: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired -}; -ParallelCoordinates.defaultProps = { - className: '', - colorType: 'category', - colorRange: _theme.DISCRETE_COLOR_RANGE, - style: { - axes: { - line: {}, - ticks: {}, - text: {} - }, - labels: { - fontSize: 10, - textAnchor: 'middle' - }, - lines: { - strokeWidth: 1, - strokeOpacity: 1 - }, - deselectedLineStyle: { - strokeOpacity: 0.1 - } - }, - tickFormat: DEFAULT_FORMAT -}; - -exports.default = ParallelCoordinates; \ No newline at end of file diff --git a/dist/plot/axis/axis-line.js b/dist/plot/axis/axis-line.js deleted file mode 100644 index 23b8f0d9c..000000000 --- a/dist/plot/axis/axis-line.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = { - height: _propTypes2.default.number.isRequired, - style: _propTypes2.default.object, - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, - width: _propTypes2.default.number.isRequired -}; - -var defaultProps = { - style: {} -}; - -function AxisLine(_ref) { - var orientation = _ref.orientation, - width = _ref.width, - height = _ref.height, - style = _ref.style; - - var lineProps = void 0; - if (orientation === LEFT) { - lineProps = { - x1: width, - x2: width, - y1: 0, - y2: height - }; - } else if (orientation === RIGHT) { - lineProps = { - x1: 0, - x2: 0, - y1: 0, - y2: height - }; - } else if (orientation === TOP) { - lineProps = { - x1: 0, - x2: width, - y1: height, - y2: height - }; - } else { - lineProps = { - x1: 0, - x2: width, - y1: 0, - y2: 0 - }; - } - return _react2.default.createElement('line', _extends({}, lineProps, { className: 'rv-xy-plot__axis__line', style: style })); -} - -AxisLine.defaultProps = defaultProps; -AxisLine.displayName = 'AxisLine'; -AxisLine.propTypes = propTypes; - -exports.default = AxisLine; \ No newline at end of file diff --git a/dist/plot/axis/axis-ticks.js b/dist/plot/axis/axis-ticks.js deleted file mode 100644 index f0d0b8e91..000000000 --- a/dist/plot/axis/axis-ticks.js +++ /dev/null @@ -1,271 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -var _scalesUtils = require('../../utils/scales-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = { - height: _propTypes2.default.number.isRequired, - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, - style: _propTypes2.default.object, - width: _propTypes2.default.number.isRequired -}; - -var defaultProps = { - style: {} -}; - -function _getTickFormatFn(scale, tickTotal, tickFormat) { - return !tickFormat ? scale.tickFormat ? scale.tickFormat(tickTotal) : function (v) { - return v; - } : tickFormat; -} - -var AxisTicks = function (_React$Component) { - _inherits(AxisTicks, _React$Component); - - function AxisTicks() { - _classCallCheck(this, AxisTicks); - - return _possibleConstructorReturn(this, (AxisTicks.__proto__ || Object.getPrototypeOf(AxisTicks)).apply(this, arguments)); - } - - _createClass(AxisTicks, [{ - key: '_areTicksWrapped', - - /** - * Check if axis ticks should be mirrored (for the right and top positions. - * @returns {boolean} True if mirrored. - * @private - */ - value: function _areTicksWrapped() { - var orientation = this.props.orientation; - - return orientation === LEFT || orientation === TOP; - } - }, { - key: '_getTickContainerPropsGetterFn', - value: function _getTickContainerPropsGetterFn() { - if (this._isAxisVertical()) { - return function (pos) { - return { transform: 'translate(0, ' + pos + ')' }; - }; - } - return function (pos) { - return { transform: 'translate(' + pos + ', 0)' }; - }; - } - - /** - * Get attributes for the label of the tick. - * @returns {Object} Object with properties. - * @private - */ - - }, { - key: '_getTickLabelProps', - value: function _getTickLabelProps() { - var _props = this.props, - orientation = _props.orientation, - tickLabelAngle = _props.tickLabelAngle, - tickSize = _props.tickSize, - _props$tickSizeOuter = _props.tickSizeOuter, - tickSizeOuter = _props$tickSizeOuter === undefined ? tickSize : _props$tickSizeOuter, - _props$tickPadding = _props.tickPadding, - tickPadding = _props$tickPadding === undefined ? tickSize : _props$tickPadding; - - // Assign the text orientation inside the label of the tick mark. - - var textAnchor = void 0; - if (orientation === LEFT || orientation === BOTTOM && tickLabelAngle) { - textAnchor = 'end'; - } else if (orientation === RIGHT || orientation === TOP && tickLabelAngle) { - textAnchor = 'start'; - } else { - textAnchor = 'middle'; - } - - // The label's position is translated to the given padding and then the - // label is rotated to the given angle. - var isVertical = this._isAxisVertical(); - var wrap = this._areTicksWrapped() ? -1 : 1; - - var labelOffset = wrap * (tickSizeOuter + tickPadding); - var transform = (isVertical ? 'translate(' + labelOffset + ', 0)' : 'translate(0, ' + labelOffset + ')') + (tickLabelAngle ? ' rotate(' + tickLabelAngle + ')' : ''); - - // Set the vertical offset of the label according to the position of - // the axis. - var dy = orientation === TOP || tickLabelAngle ? '0' : orientation === BOTTOM ? '0.72em' : '0.32em'; - - return { - textAnchor: textAnchor, - dy: dy, - transform: transform - }; - } - - /** - * Get the props of the tick line. - * @returns {Object} Props. - * @private - */ - - }, { - key: '_getTickLineProps', - value: function _getTickLineProps() { - var _ref; - - var _props2 = this.props, - tickSize = _props2.tickSize, - _props2$tickSizeOuter = _props2.tickSizeOuter, - tickSizeOuter = _props2$tickSizeOuter === undefined ? tickSize : _props2$tickSizeOuter, - _props2$tickSizeInner = _props2.tickSizeInner, - tickSizeInner = _props2$tickSizeInner === undefined ? tickSize : _props2$tickSizeInner; - - var isVertical = this._isAxisVertical(); - var tickXAttr = isVertical ? 'y' : 'x'; - var tickYAttr = isVertical ? 'x' : 'y'; - var wrap = this._areTicksWrapped() ? -1 : 1; - return _ref = {}, _defineProperty(_ref, tickXAttr + '1', 0), _defineProperty(_ref, tickXAttr + '2', 0), _defineProperty(_ref, tickYAttr + '1', -wrap * tickSizeInner), _defineProperty(_ref, tickYAttr + '2', wrap * tickSizeOuter), _ref; - } - - /** - * Gets if the axis is vertical. - * @returns {boolean} True if vertical. - * @private - */ - - }, { - key: '_isAxisVertical', - value: function _isAxisVertical() { - var orientation = this.props.orientation; - - return orientation === LEFT || orientation === RIGHT; - } - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - attr = _props3.attr, - orientation = _props3.orientation, - width = _props3.width, - height = _props3.height, - style = _props3.style, - tickFormat = _props3.tickFormat, - tickTotal = _props3.tickTotal, - tickValues = _props3.tickValues; - - - var x = orientation === LEFT ? width : 0; - var y = orientation === TOP ? height : 0; - - var scale = (0, _scalesUtils.getAttributeScale)(this.props, attr); - - var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); - var tickFormatFn = _getTickFormatFn(scale, tickTotal, tickFormat); - - var translateFn = this._getTickContainerPropsGetterFn(); - var pathProps = this._getTickLineProps(); - var textProps = this._getTickLabelProps(); - - var ticks = values.map(function (v, i) { - var pos = scale(v); - var labelNode = tickFormatFn(v, i, scale, tickTotal); - var shouldRenderAsOwnNode = _react2.default.isValidElement(labelNode) && !['tspan', 'textPath'].includes(labelNode.type); - var shouldAddProps = labelNode && typeof labelNode.type !== 'string'; - return _react2.default.createElement( - 'g', - _extends({ - key: i - }, translateFn(pos, 0), { - className: 'rv-xy-plot__axis__tick', - style: style - }), - _react2.default.createElement('line', _extends({}, pathProps, { - className: 'rv-xy-plot__axis__tick__line', - style: _extends({}, style, style.line) - })), - shouldRenderAsOwnNode ? _react2.default.cloneElement(labelNode, shouldAddProps ? _extends({}, textProps, { - containerWidth: width, - tickCount: values.length - }) : undefined) : _react2.default.createElement( - 'text', - _extends({}, textProps, { - className: 'rv-xy-plot__axis__tick__text', - style: _extends({}, style, style.text) - }), - labelNode - ) - ); - }); - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + x + ', ' + y + ')', - className: 'rv-xy-plot__axis__ticks' - }, - ticks - ); - } - }]); - - return AxisTicks; -}(_react2.default.Component); - -AxisTicks.defaultProps = defaultProps; -AxisTicks.displayName = 'AxisTicks'; -AxisTicks.propTypes = propTypes; -AxisTicks.requiresSVG = true; - -exports.default = AxisTicks; \ No newline at end of file diff --git a/dist/plot/axis/axis-title.js b/dist/plot/axis/axis-title.js deleted file mode 100644 index 619a31ec1..000000000 --- a/dist/plot/axis/axis-title.js +++ /dev/null @@ -1,186 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// Assuming that 16px = 1em -var ADJUSTMENT_FOR_TEXT_SIZE = 16; -var MARGIN = 6; -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - -var defaultProps = { - position: 'end' -}; - -/** - * Compute transformations, keyed by orientation - * @param {number} width - width of axis - * @param {number} height - height of axis - * @returns {Object} Object of transformations, keyed by orientation - */ -var transformation = function transformation(width, height) { - var _ref; - - return _ref = {}, _defineProperty(_ref, LEFT, { - end: { - x: ADJUSTMENT_FOR_TEXT_SIZE, - y: MARGIN, - rotation: -90, - textAnchor: 'end' - }, - middle: { - x: ADJUSTMENT_FOR_TEXT_SIZE, - y: height / 2 - MARGIN, - rotation: -90, - textAnchor: 'middle' - }, - start: { - x: ADJUSTMENT_FOR_TEXT_SIZE, - y: height - MARGIN, - rotation: -90, - textAnchor: 'start' - } - }), _defineProperty(_ref, RIGHT, { - end: { - x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, - y: MARGIN, - rotation: -90, - textAnchor: 'end' - }, - middle: { - x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, - y: height / 2 - MARGIN, - rotation: -90, - textAnchor: 'middle' - }, - start: { - x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, - y: height - MARGIN, - rotation: -90, - textAnchor: 'start' - } - }), _defineProperty(_ref, TOP, { - start: { - x: MARGIN, - y: ADJUSTMENT_FOR_TEXT_SIZE, - rotation: 0, - textAnchor: 'start' - }, - middle: { - x: width / 2 - MARGIN, - y: ADJUSTMENT_FOR_TEXT_SIZE, - rotation: 0, - textAnchor: 'middle' - }, - end: { - x: width - MARGIN, - y: ADJUSTMENT_FOR_TEXT_SIZE, - rotation: 0, - textAnchor: 'end' - } - }), _defineProperty(_ref, BOTTOM, { - start: { - x: MARGIN, - y: -MARGIN, - rotation: 0, - textAnchor: 'start' - }, - middle: { - x: width / 2 - MARGIN, - y: -MARGIN, - rotation: 0, - textAnchor: 'middle' - }, - end: { - x: width - MARGIN, - y: -MARGIN, - rotation: 0, - textAnchor: 'end' - } - }), _ref; -}; - -var propTypes = { - width: _propTypes2.default.number.isRequired, - height: _propTypes2.default.number.isRequired, - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, - style: _propTypes2.default.object, - title: _propTypes2.default.string.isRequired -}; - -function AxisTitle(_ref2) { - var orientation = _ref2.orientation, - position = _ref2.position, - width = _ref2.width, - height = _ref2.height, - style = _ref2.style, - title = _ref2.title; - - var outerGroupTranslateX = orientation === LEFT ? width : 0; - var outerGroupTranslateY = orientation === TOP ? height : 0; - var outerGroupTransform = 'translate(' + outerGroupTranslateX + ', ' + outerGroupTranslateY + ')'; - var _transformation$orien = transformation(width, height)[orientation][position], - x = _transformation$orien.x, - y = _transformation$orien.y, - rotation = _transformation$orien.rotation, - textAnchor = _transformation$orien.textAnchor; - - var innerGroupTransform = 'translate(' + x + ', ' + y + ') rotate(' + rotation + ')'; - - return _react2.default.createElement( - 'g', - { transform: outerGroupTransform, className: 'rv-xy-plot__axis__title' }, - _react2.default.createElement( - 'g', - { style: _extends({ textAnchor: textAnchor }, style), transform: innerGroupTransform }, - _react2.default.createElement( - 'text', - { style: style }, - title - ) - ) - ); -} - -AxisTitle.displayName = 'AxisTitle'; -AxisTitle.propTypes = propTypes; -AxisTitle.defaultProps = defaultProps; -exports.default = AxisTitle; \ No newline at end of file diff --git a/dist/plot/axis/axis.js b/dist/plot/axis/axis.js deleted file mode 100644 index e41a8d82b..000000000 --- a/dist/plot/axis/axis.js +++ /dev/null @@ -1,264 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _axisUtils = require('../../utils/axis-utils'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _axisLine = require('./axis-line'); - -var _axisLine2 = _interopRequireDefault(_axisLine); - -var _axisTicks = require('./axis-ticks'); - -var _axisTicks2 = _interopRequireDefault(_axisTicks); - -var _axisTitle = require('./axis-title'); - -var _axisTitle2 = _interopRequireDefault(_axisTitle); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var defaultAnimatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = { - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]), - attr: _propTypes2.default.string.isRequired, - attrAxis: _propTypes2.default.string, - width: _propTypes2.default.number, - height: _propTypes2.default.number, - top: _propTypes2.default.number, - left: _propTypes2.default.number, - title: _propTypes2.default.string, - - style: _propTypes2.default.object, - - className: _propTypes2.default.string, - hideTicks: _propTypes2.default.bool, - hideLine: _propTypes2.default.bool, - on0: _propTypes2.default.bool, - tickLabelAngle: _propTypes2.default.number, - tickSize: _propTypes2.default.number, - tickSizeInner: _propTypes2.default.number, - tickSizeOuter: _propTypes2.default.number, - tickPadding: _propTypes2.default.number, - tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), - tickFormat: _propTypes2.default.func, - tickTotal: _propTypes2.default.number, - - // Not expected to be used by the users. - // TODO: Add underscore to these properties later. - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; - -var defaultProps = { - className: '', - on0: false, - style: {}, - tickSize: 6, - tickPadding: 8, - orientation: BOTTOM -}; - -var predefinedClassName = 'rv-xy-plot__axis'; -var VERTICAL_CLASS_NAME = 'rv-xy-plot__axis--vertical'; -var HORIZONTAL_CLASS_NAME = 'rv-xy-plot__axis--horizontal'; - -var Axis = function (_PureComponent) { - _inherits(Axis, _PureComponent); - - function Axis() { - _classCallCheck(this, Axis); - - return _possibleConstructorReturn(this, (Axis.__proto__ || Object.getPrototypeOf(Axis)).apply(this, arguments)); - } - - _createClass(Axis, [{ - key: '_getDefaultAxisProps', - - /** - * Define the default values depending on the data passed from the outside. - * @returns {*} Object of default properties. - * @private - */ - value: function _getDefaultAxisProps() { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginTop = _props.marginTop, - marginBottom = _props.marginBottom, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - orientation = _props.orientation; - - if (orientation === BOTTOM) { - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), - top: innerHeight + marginTop, - left: marginLeft, - width: innerWidth, - height: marginBottom - }; - } else if (orientation === TOP) { - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), - top: 0, - left: marginLeft, - width: innerWidth, - height: marginTop - }; - } else if (orientation === LEFT) { - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), - top: marginTop, - left: 0, - width: marginLeft, - height: innerHeight - }; - } - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), - top: marginTop, - left: marginLeft + innerWidth, - width: marginRight, - height: innerHeight - }; - } - }, { - key: 'render', - value: function render() { - var animation = this.props.animation; - - - if (animation) { - var animatedProps = animation.nonAnimatedProps ? defaultAnimatedProps.filter(function (prop) { - return animation.nonAnimatedProps.indexOf(prop) < 0; - }) : defaultAnimatedProps; - - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(Axis, _extends({}, this.props, { animation: null })) - ); - } - - var props = _extends({}, this._getDefaultAxisProps(), this.props); - - var attrAxis = props.attrAxis, - className = props.className, - height = props.height, - hideLine = props.hideLine, - hideTicks = props.hideTicks, - left = props.left, - marginTop = props.marginTop, - on0 = props.on0, - orientation = props.orientation, - position = props.position, - style = props.style, - title = props.title, - top = props.top, - width = props.width; - - var isVertical = [LEFT, RIGHT].indexOf(orientation) > -1; - var axisClassName = isVertical ? VERTICAL_CLASS_NAME : HORIZONTAL_CLASS_NAME; - - var leftPos = left; - var topPos = top; - if (on0) { - var scale = (0, _scalesUtils.getAttributeScale)(props, attrAxis); - if (isVertical) { - leftPos = scale(0); - } else { - topPos = marginTop + scale(0); - } - } - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + leftPos + ',' + topPos + ')', - className: predefinedClassName + ' ' + axisClassName + ' ' + className, - style: style - }, - !hideLine && _react2.default.createElement(_axisLine2.default, { - height: height, - width: width, - orientation: orientation, - style: _extends({}, style, style.line) - }), - !hideTicks && _react2.default.createElement(_axisTicks2.default, _extends({}, props, { style: _extends({}, style, style.ticks) })), - title ? _react2.default.createElement(_axisTitle2.default, { - position: position, - title: title, - height: height, - width: width, - style: _extends({}, style, style.title), - orientation: orientation - }) : null - ); - } - }]); - - return Axis; -}(_react.PureComponent); - -Axis.displayName = 'Axis'; -Axis.propTypes = propTypes; -Axis.defaultProps = defaultProps; -Axis.requiresSVG = true; - -exports.default = Axis; \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis-ticks.js b/dist/plot/axis/decorative-axis-ticks.js deleted file mode 100644 index f070bea88..000000000 --- a/dist/plot/axis/decorative-axis-ticks.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.default = decorativeAxisTick; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _axisUtils = require('../../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Generate the actual polygons to be plotted - * @param {Object} props - - props.animation {Boolean} - - props.axisDomain {Array} a pair of values specifying the domain of the axis - - props.numberOfTicks{Number} the number of ticks on the axis - - props.axisStart {Object} a object specify in cartesian space the start of the axis - example: {x: 0, y: 0} - - props.axisEnd {Object} a object specify in cartesian space the start of the axis - - props.tickValue {Func} a formatting function for the tick values - - props.tickSize {Number} a pixel size of the axis - - props.style {Object} The style object for the axis - * @return {Component} the plotted axis - */ -function decorativeAxisTick(props) { - var axisDomain = props.axisDomain, - numberOfTicks = props.numberOfTicks, - axisStart = props.axisStart, - axisEnd = props.axisEnd, - tickValue = props.tickValue, - tickSize = props.tickSize, - style = props.style; - - var _generatePoints = (0, _axisUtils.generatePoints)({ - axisStart: axisStart, - axisEnd: axisEnd, - numberOfTicks: numberOfTicks, - axisDomain: axisDomain - }), - points = _generatePoints.points; - // add a quarter rotation to make ticks orthogonal to axis - - - var tickAngle = (0, _axisUtils.getAxisAngle)(axisStart, axisEnd) + Math.PI / 2; - return points.map(function (point, index) { - var tickProps = _extends({ - x1: 0, - y1: 0, - x2: tickSize * Math.cos(tickAngle), - y2: tickSize * Math.sin(tickAngle) - }, style.ticks); - - var textProps = _extends({ - x: tickSize * Math.cos(tickAngle), - y: tickSize * Math.sin(tickAngle), - textAnchor: 'start' - }, style.text); - return _react2.default.createElement( - 'g', - { - key: index, - transform: 'translate(' + point.x + ', ' + point.y + ')', - className: 'rv-xy-plot__axis__tick' - }, - _react2.default.createElement('line', _extends({}, tickProps, { className: 'rv-xy-plot__axis__tick__line' })), - _react2.default.createElement( - 'text', - _extends({}, textProps, { className: 'rv-xy-plot__axis__tick__text' }), - tickValue(point.text) - ) - ); - }); -} \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis.js b/dist/plot/axis/decorative-axis.js deleted file mode 100644 index 809b9dfec..000000000 --- a/dist/plot/axis/decorative-axis.js +++ /dev/null @@ -1,174 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _d3Format = require('d3-format'); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('../series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _decorativeAxisTicks = require('./decorative-axis-ticks'); - -var _decorativeAxisTicks2 = _interopRequireDefault(_decorativeAxisTicks); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-manipulable-axis rv-xy-plot__axis'; - -var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; - -var DecorativeAxis = function (_AbstractSeries) { - _inherits(DecorativeAxis, _AbstractSeries); - - function DecorativeAxis() { - _classCallCheck(this, DecorativeAxis); - - return _possibleConstructorReturn(this, (DecorativeAxis.__proto__ || Object.getPrototypeOf(DecorativeAxis)).apply(this, arguments)); - } - - _createClass(DecorativeAxis, [{ - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - axisStart = _props.axisStart, - axisEnd = _props.axisEnd, - axisDomain = _props.axisDomain, - numberOfTicks = _props.numberOfTicks, - tickValue = _props.tickValue, - tickSize = _props.tickSize, - style = _props.style; - - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(DecorativeAxis, _extends({}, this.props, { animation: null })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - _react2.default.createElement('line', _extends({}, _extends({ - x1: x({ x: axisStart.x }), - x2: x({ x: axisEnd.x }), - y1: y({ y: axisStart.y }), - y2: y({ y: axisEnd.y }) - }, style.line), { - className: 'rv-xy-plot__axis__line' - })), - _react2.default.createElement( - 'g', - { className: 'rv-xy-manipulable-axis__ticks' }, - (0, _decorativeAxisTicks2.default)({ - axisDomain: axisDomain, - axisEnd: { x: x(axisEnd), y: y(axisEnd) }, - axisStart: { x: x(axisStart), y: y(axisStart) }, - numberOfTicks: numberOfTicks, - tickValue: tickValue, - tickSize: tickSize, - style: style - }) - ) - ); - } - }]); - - return DecorativeAxis; -}(_abstractSeries2.default); - -var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); - -DecorativeAxis.defaultProps = { - className: '', - numberOfTicks: 10, - tickValue: function tickValue(d) { - return DEFAULT_FORMAT(d); - }, - tickSize: 5, - style: { - line: { - strokeWidth: 1 - }, - ticks: { - strokeWidth: 2 - }, - text: {} - } -}; -DecorativeAxis.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - axisDomain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, - axisEnd: _propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) - }).isRequired, - axisStart: _propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) - }).isRequired, - className: _propTypes2.default.string, - numberOfTicks: _propTypes2.default.number, - tickValue: _propTypes2.default.func, - tickSize: _propTypes2.default.number, - style: _propTypes2.default.shape({ - line: _propTypes2.default.object, - ticks: _propTypes2.default.object, - text: _propTypes2.default.object - }) -}); -DecorativeAxis.displayName = 'DecorativeAxis'; -exports.default = DecorativeAxis; \ No newline at end of file diff --git a/dist/plot/axis/x-axis.js b/dist/plot/axis/x-axis.js deleted file mode 100644 index 7ea59bbeb..000000000 --- a/dist/plot/axis/x-axis.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -var _axis = require('./axis'); - -var _axis2 = _interopRequireDefault(_axis); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = _extends({}, _axis2.default.propTypes, { - orientation: _propTypes2.default.oneOf([TOP, BOTTOM]) -}); - -var defaultProps = { - orientation: BOTTOM, - attr: 'x', - attrAxis: 'y' -}; - -function XAxis(props) { - return _react2.default.createElement(_axis2.default, props); -} - -XAxis.displayName = 'XAxis'; -XAxis.propTypes = propTypes; -XAxis.defaultProps = defaultProps; -XAxis.requiresSVG = true; - -exports.default = XAxis; \ No newline at end of file diff --git a/dist/plot/axis/y-axis.js b/dist/plot/axis/y-axis.js deleted file mode 100644 index a77570258..000000000 --- a/dist/plot/axis/y-axis.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -var _axis = require('./axis'); - -var _axis2 = _interopRequireDefault(_axis); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT; - - -var propTypes = _extends({}, _axis2.default.propTypes, { - orientation: _propTypes2.default.oneOf([LEFT, RIGHT]) -}); - -var defaultProps = { - orientation: LEFT, - attr: 'y', - attrAxis: 'x' -}; - -function YAxis(props) { - return _react2.default.createElement(_axis2.default, props); -} - -YAxis.displayName = 'YAxis'; -YAxis.propTypes = propTypes; -YAxis.defaultProps = defaultProps; -YAxis.requiresSVG = true; - -exports.default = YAxis; \ No newline at end of file diff --git a/dist/plot/borders.js b/dist/plot/borders.js deleted file mode 100644 index fd83342f7..000000000 --- a/dist/plot/borders.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var propTypes = { - style: _propTypes2.default.shape({ - bottom: _propTypes2.default.object, - left: _propTypes2.default.object, - right: _propTypes2.default.object, - top: _propTypes2.default.object - }), - // supplied by xyplot - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; - -var CLASSES = { - bottom: 'rv-xy-plot__borders-bottom', - container: 'rv-xy-plot__borders', - left: 'rv-xy-plot__borders-left', - right: 'rv-xy-plot__borders-right', - top: 'rv-xy-plot__borders-top' -}; - -function Borders(props) { - var marginTop = props.marginTop, - marginBottom = props.marginBottom, - marginLeft = props.marginLeft, - marginRight = props.marginRight, - innerWidth = props.innerWidth, - innerHeight = props.innerHeight, - style = props.style, - className = props.className; - - var height = innerHeight + marginTop + marginBottom; - var width = innerWidth + marginLeft + marginRight; - return _react2.default.createElement( - 'g', - { className: CLASSES.container + ' ' + className }, - _react2.default.createElement('rect', { - className: CLASSES.bottom + ' ' + className + '-bottom', - style: _extends({}, style.all, style.bottom), - x: 0, - y: height - marginBottom, - width: width, - height: marginBottom - }), - _react2.default.createElement('rect', { - className: CLASSES.left + ' ' + className + '-left', - style: _extends({}, style.all, style.left), - x: 0, - y: 0, - width: marginLeft, - height: height - }), - _react2.default.createElement('rect', { - className: CLASSES.right + ' ' + className + '-right', - style: _extends({}, style.all, style.right), - x: width - marginRight, - y: 0, - width: marginRight, - height: height - }), - _react2.default.createElement('rect', { - className: CLASSES.top + ' ' + className + '-top', - style: _extends({}, style.all, style.top), - x: 0, - y: 0, - width: width, - height: marginTop - }) - ); -} - -Borders.displayName = 'Borders'; -Borders.defaultProps = { - className: '', - style: { - all: {}, - bottom: {}, - left: {}, - right: {}, - top: {} - } -}; -Borders.propTypes = propTypes; -Borders.requiresSVG = true; - -exports.default = Borders; \ No newline at end of file diff --git a/dist/plot/circular-grid-lines.js b/dist/plot/circular-grid-lines.js deleted file mode 100644 index a8638ad64..000000000 --- a/dist/plot/circular-grid-lines.js +++ /dev/null @@ -1,165 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _axisUtils = require('../utils/axis-utils'); - -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; } // Copyright (c) 2016 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; - -var CircularGridLines = function (_PureComponent) { - _inherits(CircularGridLines, _PureComponent); - - function CircularGridLines() { - _classCallCheck(this, CircularGridLines); - - return _possibleConstructorReturn(this, (CircularGridLines.__proto__ || Object.getPrototypeOf(CircularGridLines)).apply(this, arguments)); - } - - _createClass(CircularGridLines, [{ - key: '_getDefaultProps', - value: function _getDefaultProps() { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginTop = _props.marginTop, - marginLeft = _props.marginLeft; - - return { - left: marginLeft, - top: marginTop, - width: innerWidth, - height: innerHeight, - style: {}, - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(Math.min(innerWidth, innerHeight)) - }; - } - }, { - key: 'render', - value: function render() { - var _props2 = this.props, - animation = _props2.animation, - centerX = _props2.centerX, - centerY = _props2.centerY; - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(CircularGridLines, _extends({}, this.props, { animation: null })) - ); - } - - var props = _extends({}, this._getDefaultProps(), this.props); - - var tickTotal = props.tickTotal, - tickValues = props.tickValues, - marginLeft = props.marginLeft, - marginTop = props.marginTop, - rRange = props.rRange, - style = props.style; - - - var xScale = (0, _scalesUtils.getAttributeScale)(props, 'x'); - var yScale = (0, _scalesUtils.getAttributeScale)(props, 'y'); - var values = (0, _axisUtils.getTickValues)(xScale, tickTotal, tickValues); - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + (xScale(centerX) + marginLeft) + ',' + (yScale(centerY) + marginTop) + ')', - className: 'rv-xy-plot__circular-grid-lines' - }, - values.reduce(function (res, value, index) { - var radius = xScale(value); - if (rRange && (radius < rRange[0] || radius > rRange[1])) { - return res; - } - return res.concat([_react2.default.createElement('circle', _extends({ cx: 0, cy: 0, r: radius }, { - key: index, - className: 'rv-xy-plot__circular-grid-lines__line', - style: style - }))]); - }, []) - ); - } - }]); - - return CircularGridLines; -}(_react.PureComponent); - -CircularGridLines.displayName = 'CircularGridLines'; -CircularGridLines.propTypes = { - centerX: _propTypes2.default.number, - centerY: _propTypes2.default.number, - width: _propTypes2.default.number, - height: _propTypes2.default.number, - top: _propTypes2.default.number, - left: _propTypes2.default.number, - rRange: _propTypes2.default.arrayOf(_propTypes2.default.number), - - style: _propTypes2.default.object, - - tickValues: _propTypes2.default.arrayOf(_propTypes2.default.number), - tickTotal: _propTypes2.default.number, - - animation: _animation.AnimationPropType, - // generally supplied by xyplot - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; -CircularGridLines.defaultProps = { - centerX: 0, - centerY: 0 -}; -CircularGridLines.requiresSVG = true; - -exports.default = CircularGridLines; \ No newline at end of file diff --git a/dist/plot/crosshair.js b/dist/plot/crosshair.js deleted file mode 100644 index b9c6edeb7..000000000 --- a/dist/plot/crosshair.js +++ /dev/null @@ -1,262 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/** - * Format title by detault. - * @param {Array} values List of values. - * @returns {*} Formatted value or undefined. - */ -function defaultTitleFormat(values) { - var value = getFirstNonEmptyValue(values); - if (value) { - return { - title: 'x', - value: value.x - }; - } -} - -/** - * Format items by default. - * @param {Array} values Array of values. - * @returns {*} Formatted list of items. - */ -function defaultItemsFormat(values) { - return values.map(function (v, i) { - if (v) { - return { value: v.y, title: i }; - } - }); -} - -/** - * Get the first non-empty item from an array. - * @param {Array} values Array of values. - * @returns {*} First non-empty value or undefined. - */ -function getFirstNonEmptyValue(values) { - return (values || []).find(function (v) { - return Boolean(v); - }); -} - -var Crosshair = function (_PureComponent) { - _inherits(Crosshair, _PureComponent); - - function Crosshair() { - _classCallCheck(this, Crosshair); - - return _possibleConstructorReturn(this, (Crosshair.__proto__ || Object.getPrototypeOf(Crosshair)).apply(this, arguments)); - } - - _createClass(Crosshair, [{ - key: '_renderCrosshairItems', - - - /** - * Render crosshair items (title + value for each series). - * @returns {*} Array of React classes with the crosshair values. - * @private - */ - value: function _renderCrosshairItems() { - var _props = this.props, - values = _props.values, - itemsFormat = _props.itemsFormat; - - var items = itemsFormat(values); - if (!items) { - return null; - } - return items.filter(function (i) { - return i; - }).map(function renderValue(item, i) { - return _react2.default.createElement( - 'div', - { className: 'rv-crosshair__item', key: 'item' + i }, - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__item__title' }, - item.title - ), - ': ', - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__item__value' }, - item.value - ) - ); - }); - } - - /** - * Render crosshair title. - * @returns {*} Container with the crosshair title. - * @private - */ - - }, { - key: '_renderCrosshairTitle', - value: function _renderCrosshairTitle() { - var _props2 = this.props, - values = _props2.values, - titleFormat = _props2.titleFormat, - style = _props2.style; - - var titleItem = titleFormat(values); - if (!titleItem) { - return null; - } - return _react2.default.createElement( - 'div', - { className: 'rv-crosshair__title', key: 'title', style: style.title }, - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__title__title' }, - titleItem.title - ), - ': ', - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__title__value' }, - titleItem.value - ) - ); - } - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - children = _props3.children, - className = _props3.className, - values = _props3.values, - marginTop = _props3.marginTop, - marginLeft = _props3.marginLeft, - innerWidth = _props3.innerWidth, - innerHeight = _props3.innerHeight, - style = _props3.style; - - var value = getFirstNonEmptyValue(values); - if (!value) { - return null; - } - var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x'); - var innerLeft = x(value); - - var _props$orientation = this.props.orientation, - orientation = _props$orientation === undefined ? innerLeft > innerWidth / 2 ? 'left' : 'right' : _props$orientation; - - var left = marginLeft + innerLeft; - var top = marginTop; - var innerClassName = 'rv-crosshair__inner rv-crosshair__inner--' + orientation; - - return _react2.default.createElement( - 'div', - { - className: 'rv-crosshair ' + className, - style: { left: left + 'px', top: top + 'px' } - }, - _react2.default.createElement('div', { - className: 'rv-crosshair__line', - style: _extends({ height: innerHeight + 'px' }, style.line) - }), - _react2.default.createElement( - 'div', - { className: innerClassName }, - children ? children : _react2.default.createElement( - 'div', - { className: 'rv-crosshair__inner__content', style: style.box }, - _react2.default.createElement( - 'div', - null, - this._renderCrosshairTitle(), - this._renderCrosshairItems() - ) - ) - ) - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return { - titleFormat: defaultTitleFormat, - itemsFormat: defaultItemsFormat, - style: { - line: {}, - title: {}, - box: {} - } - }; - } - }, { - key: 'propTypes', - get: function get() { - return { - className: _propTypes2.default.string, - values: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.object])), - series: _propTypes2.default.object, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - orientation: _propTypes2.default.oneOf(['left', 'right']), - itemsFormat: _propTypes2.default.func, - titleFormat: _propTypes2.default.func, - style: _propTypes2.default.shape({ - line: _propTypes2.default.object, - title: _propTypes2.default.object, - box: _propTypes2.default.object - }) - }; - } - }]); - - return Crosshair; -}(_react.PureComponent); - -Crosshair.displayName = 'Crosshair'; - -exports.default = Crosshair; \ No newline at end of file diff --git a/dist/plot/gradient-defs.js b/dist/plot/gradient-defs.js deleted file mode 100644 index 2da31b486..000000000 --- a/dist/plot/gradient-defs.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-gradient-defs'; - -function GradientDefs(props) { - var className = props.className; - - return _react2.default.createElement( - 'defs', - { className: predefinedClassName + ' ' + className }, - props.children - ); -} - -GradientDefs.displayName = 'GradientDefs'; -GradientDefs.requiresSVG = true; -GradientDefs.propTypes = { - className: _propTypes2.default.string -}; -GradientDefs.defaultProps = { - className: '' -}; - -exports.default = GradientDefs; \ No newline at end of file diff --git a/dist/plot/grid-lines.js b/dist/plot/grid-lines.js deleted file mode 100644 index 1336d8718..000000000 --- a/dist/plot/grid-lines.js +++ /dev/null @@ -1,178 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _axisUtils = require('../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var VERTICAL = _axisUtils.DIRECTION.VERTICAL, - HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; - - -var propTypes = { - direction: _propTypes2.default.oneOf([VERTICAL, HORIZONTAL]), - attr: _propTypes2.default.string.isRequired, - width: _propTypes2.default.number, - height: _propTypes2.default.number, - top: _propTypes2.default.number, - left: _propTypes2.default.number, - - style: _propTypes2.default.object, - - tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), - tickTotal: _propTypes2.default.number, - - animation: _animation.AnimationPropType, - - // generally supplied by xyplot - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; - -var defaultProps = { - direction: VERTICAL -}; - -var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; - -var GridLines = function (_PureComponent) { - _inherits(GridLines, _PureComponent); - - function GridLines() { - _classCallCheck(this, GridLines); - - return _possibleConstructorReturn(this, (GridLines.__proto__ || Object.getPrototypeOf(GridLines)).apply(this, arguments)); - } - - _createClass(GridLines, [{ - key: '_getDefaultProps', - value: function _getDefaultProps() { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginTop = _props.marginTop, - marginLeft = _props.marginLeft, - direction = _props.direction; - - return { - left: marginLeft, - top: marginTop, - width: innerWidth, - height: innerHeight, - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(direction === VERTICAL ? innerWidth : innerHeight) - }; - } - }, { - key: 'render', - value: function render() { - var animation = this.props.animation; - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(GridLines, _extends({}, this.props, { animation: null })) - ); - } - - var props = _extends({}, this._getDefaultProps(), this.props); - - var attr = props.attr, - direction = props.direction, - width = props.width, - height = props.height, - style = props.style, - tickTotal = props.tickTotal, - tickValues = props.tickValues, - top = props.top, - left = props.left; - - var isVertical = direction === VERTICAL; - var tickXAttr = isVertical ? 'y' : 'x'; - var tickYAttr = isVertical ? 'x' : 'y'; - var length = isVertical ? height : width; - - var scale = (0, _scalesUtils.getAttributeScale)(props, attr); - var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + left + ',' + top + ')', - className: 'rv-xy-plot__grid-lines' - }, - values.map(function (v, i) { - var _pathProps; - - var pos = scale(v); - var pathProps = (_pathProps = {}, _defineProperty(_pathProps, tickYAttr + '1', pos), _defineProperty(_pathProps, tickYAttr + '2', pos), _defineProperty(_pathProps, tickXAttr + '1', 0), _defineProperty(_pathProps, tickXAttr + '2', length), _pathProps); - return _react2.default.createElement('line', _extends({}, pathProps, { - key: i, - className: 'rv-xy-plot__grid-lines__line', - style: style - })); - }) - ); - } - }]); - - return GridLines; -}(_react.PureComponent); - -GridLines.displayName = 'GridLines'; -GridLines.defaultProps = defaultProps; -GridLines.propTypes = propTypes; -GridLines.requiresSVG = true; - -exports.default = GridLines; \ No newline at end of file diff --git a/dist/plot/highlight.js b/dist/plot/highlight.js deleted file mode 100644 index 63458b3e1..000000000 --- a/dist/plot/highlight.js +++ /dev/null @@ -1,426 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _scalesUtils = require('../utils/scales-utils'); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -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; } - -function getLocs(evt) { - var xLoc = evt.type === 'touchstart' ? evt.pageX : evt.offsetX; - var yLoc = evt.type === 'touchstart' ? evt.pageY : evt.offsetY; - return { xLoc: xLoc, yLoc: yLoc }; -} - -var Highlight = function (_AbstractSeries) { - _inherits(Highlight, _AbstractSeries); - - function Highlight() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, Highlight); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Highlight.__proto__ || Object.getPrototypeOf(Highlight)).call.apply(_ref, [this].concat(args))), _this), _this.state = { - dragging: false, - brushArea: { top: 0, right: 0, bottom: 0, left: 0 }, - brushing: false, - startLocX: 0, - startLocY: 0, - dragArea: null - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(Highlight, [{ - key: '_getDrawArea', - value: function _getDrawArea(xLoc, yLoc) { - var _state = this.state, - startLocX = _state.startLocX, - startLocY = _state.startLocY; - var _props = this.props, - enableX = _props.enableX, - enableY = _props.enableY, - highlightWidth = _props.highlightWidth, - highlightHeight = _props.highlightHeight, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - marginBottom = _props.marginBottom, - marginTop = _props.marginTop; - - var plotHeight = innerHeight + marginTop + marginBottom; - var plotWidth = innerWidth + marginLeft + marginRight; - var touchWidth = highlightWidth || plotWidth; - var touchHeight = highlightHeight || plotHeight; - - return { - bottom: enableY ? Math.max(startLocY, yLoc) : touchHeight, - right: enableX ? Math.max(startLocX, xLoc) : touchWidth, - left: enableX ? Math.min(xLoc, startLocX) : 0, - top: enableY ? Math.min(yLoc, startLocY) : 0 - }; - } - }, { - key: '_getDragArea', - value: function _getDragArea(xLoc, yLoc) { - var _props2 = this.props, - enableX = _props2.enableX, - enableY = _props2.enableY; - var _state2 = this.state, - startLocX = _state2.startLocX, - startLocY = _state2.startLocY, - dragArea = _state2.dragArea; - - - return { - bottom: dragArea.bottom + (enableY ? yLoc - startLocY : 0), - left: dragArea.left + (enableX ? xLoc - startLocX : 0), - right: dragArea.right + (enableX ? xLoc - startLocX : 0), - top: dragArea.top + (enableY ? yLoc - startLocY : 0) - }; - } - }, { - key: '_clickedOutsideDrag', - value: function _clickedOutsideDrag(xLoc, yLoc) { - var _props3 = this.props, - enableX = _props3.enableX, - enableY = _props3.enableY; - var _state3 = this.state, - dragArea = _state3.dragArea, - _state3$brushArea = _state3.brushArea, - left = _state3$brushArea.left, - right = _state3$brushArea.right, - top = _state3$brushArea.top, - bottom = _state3$brushArea.bottom; - - var clickedOutsideDragX = dragArea && (xLoc < left || xLoc > right); - var clickedOutsideDragY = dragArea && (yLoc < top || yLoc > bottom); - if (enableX && enableY) { - return clickedOutsideDragX || clickedOutsideDragY; - } - if (enableX) { - return clickedOutsideDragX; - } - if (enableY) { - return clickedOutsideDragY; - } - return true; - } - }, { - key: '_convertAreaToCoordinates', - value: function _convertAreaToCoordinates(brushArea) { - // NOTE only continuous scales are supported for brushing/getting coordinates back - var _props4 = this.props, - enableX = _props4.enableX, - enableY = _props4.enableY, - marginLeft = _props4.marginLeft, - marginTop = _props4.marginTop; - - var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); - var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); - - // Ensure that users wishes are being respected about which scales are evaluated - // this is specifically enabled to ensure brushing on mixed categorical and linear - // charts will run as expected - - if (enableX && enableY) { - return { - bottom: yScale.invert(brushArea.bottom), - left: xScale.invert(brushArea.left - marginLeft), - right: xScale.invert(brushArea.right - marginLeft), - top: yScale.invert(brushArea.top) - }; - } - - if (enableY) { - return { - bottom: yScale.invert(brushArea.bottom - marginTop), - top: yScale.invert(brushArea.top - marginTop) - }; - } - - if (enableX) { - return { - left: xScale.invert(brushArea.left - marginLeft), - right: xScale.invert(brushArea.right - marginLeft) - }; - } - - return {}; - } - }, { - key: 'startBrushing', - value: function startBrushing(e) { - var _this2 = this; - - var _props5 = this.props, - onBrushStart = _props5.onBrushStart, - onDragStart = _props5.onDragStart, - drag = _props5.drag; - var dragArea = this.state.dragArea; - - var _getLocs = getLocs(e.nativeEvent), - xLoc = _getLocs.xLoc, - yLoc = _getLocs.yLoc; - - var startArea = function startArea(dragging, resetDrag) { - var emptyBrush = { - bottom: yLoc, - left: xLoc, - right: xLoc, - top: yLoc - }; - _this2.setState({ - dragging: dragging, - brushArea: dragArea && !resetDrag ? dragArea : emptyBrush, - brushing: !dragging, - startLocX: xLoc, - startLocY: yLoc - }); - }; - - var clickedOutsideDrag = this._clickedOutsideDrag(xLoc, yLoc); - if (drag && !dragArea || !drag || clickedOutsideDrag) { - startArea(false, clickedOutsideDrag); - - if (onBrushStart) { - onBrushStart(e); - } - return; - } - - if (drag && dragArea) { - startArea(true, clickedOutsideDrag); - if (onDragStart) { - onDragStart(e); - } - } - } - }, { - key: 'stopBrushing', - value: function stopBrushing(e) { - var _state4 = this.state, - brushing = _state4.brushing, - dragging = _state4.dragging, - brushArea = _state4.brushArea; - // Quickly short-circuit if the user isn't brushing in our component - - if (!brushing && !dragging) { - return; - } - var _props6 = this.props, - onBrushEnd = _props6.onBrushEnd, - onDragEnd = _props6.onDragEnd, - drag = _props6.drag; - - var noHorizontal = Math.abs(brushArea.right - brushArea.left) < 5; - var noVertical = Math.abs(brushArea.top - brushArea.bottom) < 5; - // Invoke the callback with null if the selected area was < 5px - var isNulled = noVertical || noHorizontal; - // Clear the draw area - this.setState({ - brushing: false, - dragging: false, - brushArea: drag ? brushArea : { top: 0, right: 0, bottom: 0, left: 0 }, - startLocX: 0, - startLocY: 0, - dragArea: drag && !isNulled && brushArea - }); - - if (brushing && onBrushEnd) { - onBrushEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); - } - - if (drag && onDragEnd) { - onDragEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); - } - } - }, { - key: 'onBrush', - value: function onBrush(e) { - var _props7 = this.props, - onBrush = _props7.onBrush, - onDrag = _props7.onDrag, - drag = _props7.drag; - var _state5 = this.state, - brushing = _state5.brushing, - dragging = _state5.dragging; - - var _getLocs2 = getLocs(e.nativeEvent), - xLoc = _getLocs2.xLoc, - yLoc = _getLocs2.yLoc; - - if (brushing) { - var brushArea = this._getDrawArea(xLoc, yLoc); - this.setState({ brushArea: brushArea }); - - if (onBrush) { - onBrush(this._convertAreaToCoordinates(brushArea)); - } - } - - if (drag && dragging) { - var _brushArea = this._getDragArea(xLoc, yLoc); - this.setState({ brushArea: _brushArea }); - if (onDrag) { - onDrag(this._convertAreaToCoordinates(_brushArea)); - } - } - } - }, { - key: 'render', - value: function render() { - var _this3 = this; - - var _props8 = this.props, - color = _props8.color, - className = _props8.className, - highlightHeight = _props8.highlightHeight, - highlightWidth = _props8.highlightWidth, - highlightX = _props8.highlightX, - highlightY = _props8.highlightY, - innerWidth = _props8.innerWidth, - innerHeight = _props8.innerHeight, - marginLeft = _props8.marginLeft, - marginRight = _props8.marginRight, - marginTop = _props8.marginTop, - marginBottom = _props8.marginBottom, - opacity = _props8.opacity; - var _state$brushArea = this.state.brushArea, - left = _state$brushArea.left, - right = _state$brushArea.right, - top = _state$brushArea.top, - bottom = _state$brushArea.bottom; - - - var leftPos = 0; - if (highlightX) { - var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); - leftPos = xScale(highlightX); - } - - var topPos = 0; - if (highlightY) { - var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); - topPos = yScale(highlightY); - } - - var plotWidth = marginLeft + marginRight + innerWidth; - var plotHeight = marginTop + marginBottom + innerHeight; - var touchWidth = highlightWidth || plotWidth; - var touchHeight = highlightHeight || plotHeight; - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + leftPos + ', ' + topPos + ')', - className: className + ' rv-highlight-container' - }, - _react2.default.createElement('rect', { - className: 'rv-mouse-target', - fill: 'black', - opacity: '0', - x: '0', - y: '0', - width: Math.max(touchWidth, 0), - height: Math.max(touchHeight, 0), - onMouseDown: function onMouseDown(e) { - return _this3.startBrushing(e); - }, - onMouseMove: function onMouseMove(e) { - return _this3.onBrush(e); - }, - onMouseUp: function onMouseUp(e) { - return _this3.stopBrushing(e); - }, - onMouseLeave: function onMouseLeave(e) { - return _this3.stopBrushing(e); - } - // preventDefault() so that mouse event emulation does not happen - , onTouchEnd: function onTouchEnd(e) { - e.preventDefault(); - _this3.stopBrushing(e); - }, - onTouchCancel: function onTouchCancel(e) { - e.preventDefault(); - _this3.stopBrushing(e); - }, - onContextMenu: function onContextMenu(e) { - return e.preventDefault(); - }, - onContextMenuCapture: function onContextMenuCapture(e) { - return e.preventDefault(); - } - }), - _react2.default.createElement('rect', { - className: 'rv-highlight', - pointerEvents: 'none', - opacity: opacity, - fill: color, - x: left, - y: top, - width: Math.min(Math.max(0, right - left), touchWidth), - height: Math.min(Math.max(0, bottom - top), touchHeight) - }) - ); - } - }]); - - return Highlight; -}(_abstractSeries2.default); - -Highlight.displayName = 'HighlightOverlay'; -Highlight.defaultProps = { - color: 'rgb(77, 182, 172)', - className: '', - enableX: true, - enableY: true, - opacity: 0.3 -}; - -Highlight.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - enableX: _propTypes2.default.bool, - enableY: _propTypes2.default.bool, - highlightHeight: _propTypes2.default.number, - highlightWidth: _propTypes2.default.number, - highlightX: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), - highlightY: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), - onBrushStart: _propTypes2.default.func, - onDragStart: _propTypes2.default.func, - onBrush: _propTypes2.default.func, - onDrag: _propTypes2.default.func, - onBrushEnd: _propTypes2.default.func, - onDragEnd: _propTypes2.default.func -}); - -exports.default = Highlight; \ No newline at end of file diff --git a/dist/plot/hint.js b/dist/plot/hint.js deleted file mode 100644 index 8e15b3cae..000000000 --- a/dist/plot/hint.js +++ /dev/null @@ -1,454 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/* - * Hint provides two options for placement of hint: - * a) around a data point in one of four quadrants (imagine the point bisected - * by two axes -vertical, horizontal- creating 4 quadrants around a data - * point). - * b) **New** pin to an edge of chart/plot area and position along that edge - * using data point's other dimension value. - * - * To support these two options, deprecate one Hint props (orientation) with two - * new Hint align prop object (horizontal, vertical) with following values: - * - * horizontal: auto, left, right, leftEdge, rightEdge - * vertical: auto, bottom, top, bottomEdge, topEdge - * - * Thus, the following ALIGN constants are the values for horizontal - * and vertical - */ -var ALIGN = { - AUTO: 'auto', - LEFT: 'left', - RIGHT: 'right', - LEFT_EDGE: 'leftEdge', - RIGHT_EDGE: 'rightEdge', - BOTTOM: 'bottom', - TOP: 'top', - BOTTOM_EDGE: 'bottomEdge', - TOP_EDGE: 'topEdge' -}; - -/** - * For backwards support, retain the ORIENTATION prop constants - */ -var ORIENTATION = { - BOTTOM_LEFT: 'bottomleft', - BOTTOM_RIGHT: 'bottomright', - TOP_LEFT: 'topleft', - TOP_RIGHT: 'topright' -}; - -/** - * Default format function for the value. - * @param {Object} value Value. - * @returns {Array} title-value pairs. - */ -function defaultFormat(value) { - return Object.keys(value).map(function getProp(key) { - return { title: key, value: value[key] }; - }); -} - -var Hint = function (_PureComponent) { - _inherits(Hint, _PureComponent); - - function Hint() { - _classCallCheck(this, Hint); - - return _possibleConstructorReturn(this, (Hint.__proto__ || Object.getPrototypeOf(Hint)).apply(this, arguments)); - } - - _createClass(Hint, [{ - key: '_getAlign', - - - /** - * Obtain align object with horizontal and vertical settings - * but convert any AUTO values to the non-auto ALIGN depending on the - * values of x and y. - * @param {number} x X value. - * @param {number} y Y value. - * @returns {Object} Align object w/ horizontal, vertical prop strings. - * @private - */ - value: function _getAlign(x, y) { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - orientation = _props.orientation, - _props$align = _props.align, - horizontal = _props$align.horizontal, - vertical = _props$align.vertical; - - var align = orientation ? this._mapOrientationToAlign(orientation) : { horizontal: horizontal, vertical: vertical }; - if (horizontal === ALIGN.AUTO) { - align.horizontal = x > innerWidth / 2 ? ALIGN.LEFT : ALIGN.RIGHT; - } - if (vertical === ALIGN.AUTO) { - align.vertical = y > innerHeight / 2 ? ALIGN.TOP : ALIGN.BOTTOM; - } - return align; - } - - /** - * Get the class names from align values. - * @param {Object} align object with horizontal and vertical prop strings. - * @returns {string} Class names. - * @private - */ - - }, { - key: '_getAlignClassNames', - value: function _getAlignClassNames(align) { - var orientation = this.props.orientation; - - var orientationClass = orientation ? 'rv-hint--orientation-' + orientation : ''; - return orientationClass + ' rv-hint--horizontalAlign-' + align.horizontal + '\n rv-hint--verticalAlign-' + align.vertical; - } - - /** - * Get a CSS mixin for a proper positioning of the element. - * @param {Object} align object with horizontal and vertical prop strings. - * @param {number} x X position. - * @param {number} y Y position. - * @returns {Object} Object, that may contain `left` or `right, `top` or - * `bottom` properties. - * @private - */ - - }, { - key: '_getAlignStyle', - value: function _getAlignStyle(align, x, y) { - return _extends({}, this._getXCSS(align.horizontal, x), this._getYCSS(align.vertical, y)); - } - - /** - * Get the bottom coordinate of the hint. - * When y undefined or null, edge case, pin bottom. - * @param {number} y Y. - * @returns {{bottom: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSBottom', - value: function _getCSSBottom(y) { - if (y === undefined || y === null) { - return { - bottom: 0 - }; - } - - var _props2 = this.props, - innerHeight = _props2.innerHeight, - marginBottom = _props2.marginBottom; - - return { - bottom: marginBottom + innerHeight - y - }; - } - - /** - * Get the left coordinate of the hint. - * When x undefined or null, edge case, pin left. - * @param {number} x X. - * @returns {{left: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSLeft', - value: function _getCSSLeft(x) { - if (x === undefined || x === null) { - return { - left: 0 - }; - } - - var marginLeft = this.props.marginLeft; - - return { - left: marginLeft + x - }; - } - - /** - * Get the right coordinate of the hint. - * When x undefined or null, edge case, pin right. - * @param {number} x X. - * @returns {{right: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSRight', - value: function _getCSSRight(x) { - if (x === undefined || x === null) { - return { - right: 0 - }; - } - - var _props3 = this.props, - innerWidth = _props3.innerWidth, - marginRight = _props3.marginRight; - - return { - right: marginRight + innerWidth - x - }; - } - - /** - * Get the top coordinate of the hint. - * When y undefined or null, edge case, pin top. - * @param {number} y Y. - * @returns {{top: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSTop', - value: function _getCSSTop(y) { - if (y === undefined || y === null) { - return { - top: 0 - }; - } - - var marginTop = this.props.marginTop; - - return { - top: marginTop + y - }; - } - - /** - * Get the position for the hint and the appropriate class name. - * @returns {{style: Object, className: string}} Style and className for the - * hint. - * @private - */ - - }, { - key: '_getPositionInfo', - value: function _getPositionInfo() { - var _props4 = this.props, - value = _props4.value, - getAlignStyle = _props4.getAlignStyle; - - - var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x')(value); - var y = (0, _scalesUtils.getAttributeFunctor)(this.props, 'y')(value); - - var align = this._getAlign(x, y); - - return { - position: getAlignStyle ? getAlignStyle(align, x, y) : this._getAlignStyle(align, x, y), - className: this._getAlignClassNames(align) - }; - } - }, { - key: '_getXCSS', - value: function _getXCSS(horizontal, x) { - // obtain xCSS - switch (horizontal) { - case ALIGN.LEFT_EDGE: - // this pins x to left edge - return this._getCSSLeft(null); - case ALIGN.RIGHT_EDGE: - // this pins x to left edge - return this._getCSSRight(null); - case ALIGN.LEFT: - // this places hint text to the left of center, so set its right edge - return this._getCSSRight(x); - case ALIGN.RIGHT: - default: - // this places hint text to the right of center, so set its left edge - // default case should not be possible but if it happens set to RIGHT - return this._getCSSLeft(x); - } - } - }, { - key: '_getYCSS', - value: function _getYCSS(verticalAlign, y) { - // obtain yCSS - switch (verticalAlign) { - case ALIGN.TOP_EDGE: - // this pins x to top edge - return this._getCSSTop(null); - case ALIGN.BOTTOM_EDGE: - // this pins x to bottom edge - return this._getCSSBottom(null); - case ALIGN.BOTTOM: - // this places hint text to the bottom of center, so set its top edge - return this._getCSSTop(y); - case ALIGN.TOP: - default: - // this places hint text to the top of center, so set its bottom edge - // default case should not be possible but if it happens set to BOTTOM - return this._getCSSBottom(y); - } - } - }, { - key: '_mapOrientationToAlign', - value: function _mapOrientationToAlign(orientation) { - // TODO: print warning that this feature is deprecated and support will be - // removed in next major release. - switch (orientation) { - case ORIENTATION.BOTTOM_LEFT: - return { - horizontal: ALIGN.LEFT, - vertical: ALIGN.BOTTOM - }; - case ORIENTATION.BOTTOM_RIGHT: - return { - horizontal: ALIGN.RIGHT, - vertical: ALIGN.BOTTOM - }; - case ORIENTATION.TOP_LEFT: - return { - horizontal: ALIGN.LEFT, - vertical: ALIGN.TOP - }; - case ORIENTATION.TOP_RIGHT: - return { - horizontal: ALIGN.RIGHT, - vertical: ALIGN.TOP - }; - default: - // fall back to horizontalAlign, verticalAlign that are either - // provided or defaulted to AUTO. So, don't change things - break; - } - } - }, { - key: 'render', - value: function render() { - var _props5 = this.props, - value = _props5.value, - format = _props5.format, - children = _props5.children, - style = _props5.style; - - var _getPositionInfo2 = this._getPositionInfo(), - position = _getPositionInfo2.position, - className = _getPositionInfo2.className; - - return _react2.default.createElement( - 'div', - { - className: 'rv-hint ' + className, - style: _extends({}, style, position, { - position: 'absolute' - }) - }, - children ? children : _react2.default.createElement( - 'div', - { className: 'rv-hint__content', style: style.content }, - format(value).map(function (formattedProp, i) { - return _react2.default.createElement( - 'div', - { key: 'rv-hint' + i, style: style.row }, - _react2.default.createElement( - 'span', - { className: 'rv-hint__title', style: style.title }, - formattedProp.title - ), - ': ', - _react2.default.createElement( - 'span', - { className: 'rv-hint__value', style: style.value }, - formattedProp.value - ) - ); - }) - ) - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return { - format: defaultFormat, - align: { - horizontal: ALIGN.AUTO, - vertical: ALIGN.AUTO - }, - style: {} - }; - } - }, { - key: 'propTypes', - get: function get() { - return { - marginTop: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number, - scales: _propTypes2.default.object, - value: _propTypes2.default.object, - format: _propTypes2.default.func, - style: _propTypes2.default.object, - align: _propTypes2.default.shape({ - horizontal: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.LEFT, ALIGN.RIGHT, ALIGN.LEFT_EDGE, ALIGN.RIGHT_EDGE]), - vertical: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.BOTTOM, ALIGN.TOP, ALIGN.BOTTOM_EDGE, ALIGN.TOP_EDGE]) - }), - getAlignStyle: _propTypes2.default.func, - orientation: _propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT, ORIENTATION.BOTTOM_RIGHT, ORIENTATION.TOP_LEFT, ORIENTATION.TOP_RIGHT]) - }; - } - }]); - - return Hint; -}(_react.PureComponent); - -Hint.displayName = 'Hint'; -Hint.ORIENTATION = ORIENTATION; -Hint.ALIGN = ALIGN; - -exports.default = Hint; \ No newline at end of file diff --git a/dist/plot/horizontal-grid-lines.js b/dist/plot/horizontal-grid-lines.js deleted file mode 100644 index 549b2d8b5..000000000 --- a/dist/plot/horizontal-grid-lines.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../utils/axis-utils'); - -var _gridLines = require('./grid-lines'); - -var _gridLines2 = _interopRequireDefault(_gridLines); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; - - -var propTypes = _extends({}, _gridLines2.default.propTypes, { - direction: _propTypes2.default.oneOf([HORIZONTAL]) -}); - -var defaultProps = { - direction: HORIZONTAL, - attr: 'y' -}; - -function HorizontalGridLines(props) { - return _react2.default.createElement(_gridLines2.default, props); -} - -HorizontalGridLines.displayName = 'HorizontalGridLines'; -HorizontalGridLines.propTypes = propTypes; -HorizontalGridLines.defaultProps = defaultProps; -HorizontalGridLines.requiresSVG = true; - -exports.default = HorizontalGridLines; \ No newline at end of file diff --git a/dist/plot/series/abstract-series.js b/dist/plot/series/abstract-series.js deleted file mode 100644 index 7f86a482f..000000000 --- a/dist/plot/series/abstract-series.js +++ /dev/null @@ -1,415 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Voronoi = require('d3-voronoi'); - -var _react = require('react'); - -var _animation = require('../../animation'); - -var _scalesUtils = require('../../utils/scales-utils'); - -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; } - -var propTypes = _extends({}, (0, _scalesUtils.getScalePropTypesByAttribute)('x'), (0, _scalesUtils.getScalePropTypesByAttribute)('y'), (0, _scalesUtils.getScalePropTypesByAttribute)('size'), (0, _scalesUtils.getScalePropTypesByAttribute)('opacity'), (0, _scalesUtils.getScalePropTypesByAttribute)('color'), { - width: _propTypes2.default.number, - height: _propTypes2.default.number, - data: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.array])), - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - onValueClick: _propTypes2.default.func, - onValueRightClick: _propTypes2.default.func, - onSeriesMouseOver: _propTypes2.default.func, - onSeriesMouseOut: _propTypes2.default.func, - onSeriesClick: _propTypes2.default.func, - onSeriesRightClick: _propTypes2.default.func, - onNearestX: _propTypes2.default.func, - onNearestXY: _propTypes2.default.func, - style: _propTypes2.default.object, - animation: _animation.AnimationPropType, - stack: _propTypes2.default.bool -}); - -var defaultProps = { - className: '', - stack: false, - style: {} -}; - -var AbstractSeries = function (_PureComponent) { - _inherits(AbstractSeries, _PureComponent); - - function AbstractSeries() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, AbstractSeries); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AbstractSeries.__proto__ || Object.getPrototypeOf(AbstractSeries)).call.apply(_ref, [this].concat(args))), _this), _this._seriesClickHandler = function (event) { - var onSeriesClick = _this.props.onSeriesClick; - - if (onSeriesClick) { - onSeriesClick({ event: event }); - } - }, _this._seriesMouseOutHandler = function (event) { - var onSeriesMouseOut = _this.props.onSeriesMouseOut; - - if (onSeriesMouseOut) { - onSeriesMouseOut({ event: event }); - } - }, _this._seriesMouseOverHandler = function (event) { - var onSeriesMouseOver = _this.props.onSeriesMouseOver; - - if (onSeriesMouseOver) { - onSeriesMouseOver({ event: event }); - } - }, _this._seriesRightClickHandler = function (event) { - var onSeriesRightClick = _this.props.onSeriesRightClick; - - if (onSeriesRightClick) { - onSeriesRightClick({ event: event }); - } - }, _this._valueClickHandler = function (d, event) { - var _this$props = _this.props, - onValueClick = _this$props.onValueClick, - onSeriesClick = _this$props.onSeriesClick; - - if (onValueClick) { - onValueClick(d, { event: event }); - } - if (onSeriesClick) { - onSeriesClick({ event: event }); - } - }, _this._valueMouseOutHandler = function (d, event) { - var _this$props2 = _this.props, - onValueMouseOut = _this$props2.onValueMouseOut, - onSeriesMouseOut = _this$props2.onSeriesMouseOut; - - if (onValueMouseOut) { - onValueMouseOut(d, { event: event }); - } - if (onSeriesMouseOut) { - onSeriesMouseOut({ event: event }); - } - }, _this._valueMouseOverHandler = function (d, event) { - var _this$props3 = _this.props, - onValueMouseOver = _this$props3.onValueMouseOver, - onSeriesMouseOver = _this$props3.onSeriesMouseOver; - - if (onValueMouseOver) { - onValueMouseOver(d, { event: event }); - } - if (onSeriesMouseOver) { - onSeriesMouseOver({ event: event }); - } - }, _this._valueRightClickHandler = function (d, event) { - var _this$props4 = _this.props, - onValueRightClick = _this$props4.onValueRightClick, - onSeriesRightClick = _this$props4.onSeriesRightClick; - - if (onValueRightClick) { - onValueRightClick(d, { event: event }); - } - if (onSeriesRightClick) { - onSeriesRightClick({ event: event }); - } - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(AbstractSeries, [{ - key: 'onParentMouseMove', - value: function onParentMouseMove(event) { - var _props = this.props, - onNearestX = _props.onNearestX, - onNearestXY = _props.onNearestXY, - data = _props.data; - - if (!onNearestX && !onNearestXY || !data) { - return; - } - if (onNearestXY) { - this._handleNearestXY(event); - } else { - this._handleNearestX(event); - } - } - }, { - key: 'onParentTouchMove', - value: function onParentTouchMove(e) { - e.preventDefault(); - this.onParentMouseMove(e); - } - }, { - key: 'onParentTouchStart', - value: function onParentTouchStart(e) { - // prevent mouse event emulation - e.preventDefault(); - } - - /** - * Get the attr0 functor. - * @param {string} attr Attribute name. - * @returns {*} Functor. - * @private - */ - - }, { - key: '_getAttr0Functor', - value: function _getAttr0Functor(attr) { - return (0, _scalesUtils.getAttr0Functor)(this.props, attr); - } - - /** - * Get attribute functor. - * @param {string} attr Attribute name - * @returns {*} Functor. - * @protected - */ - - }, { - key: '_getAttributeFunctor', - value: function _getAttributeFunctor(attr) { - return (0, _scalesUtils.getAttributeFunctor)(this.props, attr); - } - - /** - * Get the attribute value if it is available. - * @param {string} attr Attribute name. - * @returns {*} Attribute value if available, fallback value or undefined - * otherwise. - * @protected - */ - - }, { - key: '_getAttributeValue', - value: function _getAttributeValue(attr) { - return (0, _scalesUtils.getAttributeValue)(this.props, attr); - } - - /** - * Get the scale object distance by the attribute from the list of properties. - * @param {string} attr Attribute name. - * @returns {number} Scale distance. - * @protected - */ - - }, { - key: '_getScaleDistance', - value: function _getScaleDistance(attr) { - var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(this.props, attr); - return scaleObject ? scaleObject.distance : 0; - } - }, { - key: '_getXYCoordinateInContainer', - value: function _getXYCoordinateInContainer(event) { - var _props2 = this.props, - _props2$marginTop = _props2.marginTop, - marginTop = _props2$marginTop === undefined ? 0 : _props2$marginTop, - _props2$marginLeft = _props2.marginLeft, - marginLeft = _props2$marginLeft === undefined ? 0 : _props2$marginLeft; - var evt = event.nativeEvent, - currentTarget = event.currentTarget; - - var rect = currentTarget.getBoundingClientRect(); - var x = evt.clientX; - var y = evt.clientY; - if (evt.type === 'touchmove') { - x = evt.touches[0].pageX; - y = evt.touches[0].pageY; - } - return { - x: x - rect.left - currentTarget.clientLeft - marginLeft, - y: y - rect.top - currentTarget.clientTop - marginTop - }; - } - }, { - key: '_handleNearestX', - value: function _handleNearestX(event) { - var _props3 = this.props, - onNearestX = _props3.onNearestX, - data = _props3.data; - - var minDistance = Number.POSITIVE_INFINITY; - var value = null; - var valueIndex = null; - - var coordinate = this._getXYCoordinateInContainer(event); - var xScaleFn = this._getAttributeFunctor('x'); - - data.forEach(function (item, i) { - var currentCoordinate = xScaleFn(item); - var newDistance = Math.abs(coordinate.x - currentCoordinate); - if (newDistance < minDistance) { - minDistance = newDistance; - value = item; - valueIndex = i; - } - }); - if (!value) { - return; - } - onNearestX(value, { - innerX: xScaleFn(value), - index: valueIndex, - event: event.nativeEvent - }); - } - }, { - key: '_handleNearestXY', - value: function _handleNearestXY(event) { - var _props4 = this.props, - onNearestXY = _props4.onNearestXY, - data = _props4.data; - - - var coordinate = this._getXYCoordinateInContainer(event); - var xScaleFn = this._getAttributeFunctor('x'); - var yScaleFn = this._getAttributeFunctor('y'); - - // Create a voronoi with each node center points - var voronoiInstance = (0, _d3Voronoi.voronoi)().x(xScaleFn).y(yScaleFn); - - var foundPoint = voronoiInstance(data).find(coordinate.x, coordinate.y); - var value = foundPoint.data; - - if (!value) { - return; - } - onNearestXY(value, { - innerX: foundPoint.x, - innerY: foundPoint.y, - index: foundPoint.index, - event: event.nativeEvent - }); - } - - /** - * Click handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse out handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse over handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Right Click handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Click handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse out handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse over handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - - /** - * Right Click handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - }], [{ - key: 'getParentConfig', - - /** - * Get a default config for the parent. - * @returns {Object} Empty config. - */ - value: function getParentConfig() { - return {}; - } - - /** - * Tells the rest of the world that it requires SVG to work. - * @returns {boolean} Result. - */ - - }, { - key: 'requiresSVG', - get: function get() { - return true; - } - }]); - - return AbstractSeries; -}(_react.PureComponent); - -AbstractSeries.displayName = 'AbstractSeries'; -AbstractSeries.propTypes = propTypes; -AbstractSeries.defaultProps = defaultProps; - -exports.default = AbstractSeries; \ No newline at end of file diff --git a/dist/plot/series/arc-series.js b/dist/plot/series/arc-series.js deleted file mode 100644 index 465cf5a91..000000000 --- a/dist/plot/series/arc-series.js +++ /dev/null @@ -1,279 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _d3Shape = require('d3-shape'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _scalesUtils = require('../../utils/scales-utils'); - -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; } - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--arc'; -var ATTRIBUTES = ['radius', 'angle']; - -var defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - center: { x: 0, y: 0 }, - arcClassName: '', - className: '', - style: {}, - padAngle: 0 -}); - -/** - * Prepare the internal representation of row for real use. - * This is necessary because d3 insists on starting at 12 oclock and moving - * clockwise, rather than starting at 3 oclock and moving counter clockwise - * as one might expect from polar - * @param {Object} row - coordinate object to be modifed - * @return {Object} angle corrected object - */ -function modifyRow(row) { - var radius = row.radius, - angle = row.angle, - angle0 = row.angle0; - - var truedAngle = -1 * angle + Math.PI / 2; - var truedAngle0 = -1 * angle0 + Math.PI / 2; - return _extends({}, row, { - x: radius * Math.cos(truedAngle), - y: radius * Math.sin(truedAngle), - angle: truedAngle, - angle0: truedAngle0 - }); -} - -var ArcSeries = function (_AbstractSeries) { - _inherits(ArcSeries, _AbstractSeries); - - function ArcSeries(props) { - _classCallCheck(this, ArcSeries); - - var _this = _possibleConstructorReturn(this, (ArcSeries.__proto__ || Object.getPrototypeOf(ArcSeries)).call(this, props)); - - var scaleProps = _this._getAllScaleProps(props); - _this.state = { scaleProps: scaleProps }; - return _this; - } - - _createClass(ArcSeries, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - this.setState({ scaleProps: this._getAllScaleProps(nextProps) }); - } - - /** - * Get the map of scales from the props. - * @param {Object} props Props. - * @param {Array} data Array of all data. - * @returns {Object} Map of scales. - * @private - */ - - }, { - key: '_getAllScaleProps', - value: function _getAllScaleProps(props) { - var defaultScaleProps = this._getDefaultScaleProps(props); - var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); - var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, userScaleProps), props.data, ATTRIBUTES); - - return _extends({}, defaultScaleProps, userScaleProps, missingScaleProps); - } - - /** - * Get the list of scale-related settings that should be applied by default. - * @param {Object} props Object of props. - * @returns {Object} Defaults. - * @private - */ - - }, { - key: '_getDefaultScaleProps', - value: function _getDefaultScaleProps(props) { - var innerWidth = props.innerWidth, - innerHeight = props.innerHeight; - - var radius = Math.min(innerWidth / 2, innerHeight / 2); - return { - radiusRange: [0, radius], - _radiusValue: radius, - angleType: 'literal' - }; - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - arcClassName = _props.arcClassName, - animation = _props.animation, - className = _props.className, - center = _props.center, - data = _props.data, - disableSeries = _props.disableSeries, - hideSeries = _props.hideSeries, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - padAngle = _props.padAngle, - style = _props.style; - - - if (!data) { - return null; - } - - if (animation) { - var cloneData = data.map(function (d) { - return _extends({}, d); - }); - return _react2.default.createElement( - 'g', - { className: 'rv-xy-plot__series--arc__animation-wrapper' }, - _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { - animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS, - data: cloneData - }), - _react2.default.createElement(ArcSeries, _extends({}, this.props, { - animation: null, - disableSeries: true, - data: cloneData - })) - ), - _react2.default.createElement(ArcSeries, _extends({}, this.props, { - animation: null, - hideSeries: true, - style: { stroke: 'red' } - })) - ); - } - - var scaleProps = this.state.scaleProps; - var radiusDomain = scaleProps.radiusDomain; - // need to generate our own functors as abstract series doesnt have anythign for us - - var radius = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'radius'); - var radius0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'radius'); - var angle = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'angle'); - var angle0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'angle'); - // but it does have good color support! - var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var opacity = this._getAttributeFunctor('opacity'); - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - onMouseOver: this._seriesMouseOverHandler, - onMouseOut: this._seriesMouseOutHandler, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - opacity: hideSeries ? 0 : 1, - pointerEvents: disableSeries ? 'none' : 'all', - transform: 'translate(' + (marginLeft + x(center)) + ',' + (marginTop + y(center)) + ')' - }, - data.map(function (row, i) { - var noRadius = radiusDomain[1] === radiusDomain[0]; - var arcArg = { - innerRadius: noRadius ? 0 : radius0(row), - outerRadius: radius(row), - startAngle: angle0(row) || 0, - endAngle: angle(row) - }; - var arcedData = (0, _d3Shape.arc)().padAngle(padAngle); - var rowStyle = row.style || {}; - var rowClassName = row.className || ''; - return _react2.default.createElement('path', { - style: _extends({ - opacity: opacity && opacity(row), - stroke: stroke && stroke(row), - fill: fill && fill(row) - }, style, rowStyle), - onClick: function onClick(e) { - return _this2._valueClickHandler(modifyRow(row), e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(modifyRow(row), e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(modifyRow(row), e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(modifyRow(row), e); - }, - key: i, - className: predefinedClassName + '-path ' + arcClassName + ' ' + rowClassName, - d: arcedData(arcArg) - }); - }) - ); - } - }]); - - return ArcSeries; -}(_abstractSeries2.default); - -ArcSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, (0, _scalesUtils.getScalePropTypesByAttribute)('radius'), (0, _scalesUtils.getScalePropTypesByAttribute)('angle'), { - center: _propTypes2.default.shape({ - x: _propTypes2.default.number, - y: _propTypes2.default.number - }), - arcClassName: _propTypes2.default.string, - padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) -}); -ArcSeries.defaultProps = defaultProps; -ArcSeries.displayName = 'ArcSeries'; - -exports.default = ArcSeries; \ No newline at end of file diff --git a/dist/plot/series/area-series.js b/dist/plot/series/area-series.js deleted file mode 100644 index 10b6f12b0..000000000 --- a/dist/plot/series/area-series.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Shape = require('d3-shape'); - -var d3Shape = _interopRequireWildcard(_d3Shape); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _theme = require('../../theme'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _reactUtils = require('../../utils/react-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; - -var AreaSeries = function (_AbstractSeries) { - _inherits(AreaSeries, _AbstractSeries); - - function AreaSeries() { - _classCallCheck(this, AreaSeries); - - return _possibleConstructorReturn(this, (AreaSeries.__proto__ || Object.getPrototypeOf(AreaSeries)).apply(this, arguments)); - } - - _createClass(AreaSeries, [{ - key: '_renderArea', - value: function _renderArea(data, x, y0, y, curve, getNull) { - var area = d3Shape.area(); - if (curve !== null) { - if (typeof curve === 'string' && d3Shape[curve]) { - area = area.curve(d3Shape[curve]); - } else if (typeof curve === 'function') { - area = area.curve(curve); - } - } - area = area.defined(getNull); - area = area.x(x).y0(y0).y1(y); - return area(data); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - curve = _props.curve, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - - if (this.props.nullAccessor) { - (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); - } - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(AreaSeries, _extends({}, this.props, { animation: null })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var y0 = this._getAttr0Functor('y'); - var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); - var fill = this._getAttributeValue('fill') || this._getAttributeValue('color'); - var newOpacity = this._getAttributeValue('opacity'); - var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; - var getNull = this.props.nullAccessor || this.props.getNull; - var d = this._renderArea(data, x, y0, y, curve, getNull); - - return _react2.default.createElement('path', { - d: d, - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')', - onMouseOver: this._seriesMouseOverHandler, - onMouseOut: this._seriesMouseOutHandler, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - style: _extends({ - opacity: opacity, - stroke: stroke, - fill: fill - }, style) - }); - } - }]); - - return AreaSeries; -}(_abstractSeries2.default); - -AreaSeries.displayName = 'AreaSeries'; -AreaSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - getNull: _propTypes2.default.func -}); -AreaSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - getNull: function getNull() { - return true; - } -}); - -exports.default = AreaSeries; \ No newline at end of file diff --git a/dist/plot/series/bar-series-canvas.js b/dist/plot/series/bar-series-canvas.js deleted file mode 100644 index 3ede5b8fe..000000000 --- a/dist/plot/series/bar-series-canvas.js +++ /dev/null @@ -1,161 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Color = require('d3-color'); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -function getScaleDistance(props, attr) { - var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(props, attr); - return scaleObject ? scaleObject.distance : 0; -} - -var BarSeriesCanvas = function (_AbstractSeries) { - _inherits(BarSeriesCanvas, _AbstractSeries); - - function BarSeriesCanvas() { - _classCallCheck(this, BarSeriesCanvas); - - return _possibleConstructorReturn(this, (BarSeriesCanvas.__proto__ || Object.getPrototypeOf(BarSeriesCanvas)).apply(this, arguments)); - } - - _createClass(BarSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var data = props.data, - linePosAttr = props.linePosAttr, - lineSizeAttr = props.lineSizeAttr, - valuePosAttr = props.valuePosAttr, - marginTop = props.marginTop, - marginBottom = props.marginBottom; - - if (!data || data.length === 0) { - return; - } - - var distance = getScaleDistance(props, linePosAttr); - var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); - var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); - var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); - var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); - - var halfSpace = distance / 2 * 0.85; - // totalSpaceAvailable is the space we have available to draw all the - // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) - var totalSpaceAvailable = halfSpace * 2; - - var _getStackParams = (0, _seriesUtils.getStackParams)(props), - sameTypeTotal = _getStackParams.sameTypeTotal, - sameTypeIndex = _getStackParams.sameTypeIndex; - - data.forEach(function (row) { - var totalSpaceCenter = line(row); - // totalSpaceStartingPoint is the first pixel were we can start drawing - var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; - - // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal - var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; - // lineSize is the space we have available to draw sameTypeIndex bar - var lineSize = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; - - var fillColor = (0, _d3Color.rgb)(fill(row)); - var strokeColor = (0, _d3Color.rgb)(stroke(row)); - var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; - - // linePos is the first pixel were we can start drawing sameTypeIndex bar - var linePos = totalSpaceStartingPoint + lineSize * sameTypeIndex + sameTypeIndex; - var valuePos = Math.min(value0(row), value(row)); - var x = valuePosAttr === 'x' ? valuePos : linePos; - var y = valuePosAttr === 'y' ? valuePos : linePos; - - var valueSize = Math.abs(-value0(row) + value(row)); - var height = lineSizeAttr === 'height' ? lineSize : valueSize; - var width = lineSizeAttr === 'width' ? lineSize : valueSize; - - ctx.beginPath(); - ctx.rect(x + marginBottom, y + marginTop, width, height); - ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; - ctx.fill(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; - ctx.stroke(); - }); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return BarSeriesCanvas; -}(_abstractSeries2.default); - -BarSeriesCanvas.displayName = 'BarSeriesCanvas'; -BarSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - linePosAttr: _propTypes2.default.string.isRequired, - valuePosAttr: _propTypes2.default.string.isRequired, - lineSizeAttr: _propTypes2.default.string.isRequired, - valueSizeAttr: _propTypes2.default.string.isRequired -}); - -BarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = BarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/bar-series.js b/dist/plot/series/bar-series.js deleted file mode 100644 index 2c38ee25f..000000000 --- a/dist/plot/series/bar-series.js +++ /dev/null @@ -1,180 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--bar'; - -var BarSeries = function (_AbstractSeries) { - _inherits(BarSeries, _AbstractSeries); - - function BarSeries() { - _classCallCheck(this, BarSeries); - - return _possibleConstructorReturn(this, (BarSeries.__proto__ || Object.getPrototypeOf(BarSeries)).apply(this, arguments)); - } - - _createClass(BarSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - linePosAttr = _props.linePosAttr, - lineSizeAttr = _props.lineSizeAttr, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style, - valuePosAttr = _props.valuePosAttr, - valueSizeAttr = _props.valueSizeAttr, - barWidth = _props.barWidth; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(BarSeries, _extends({}, this.props, { animation: null })) - ); - } - - var _getStackParams = (0, _seriesUtils.getStackParams)(this.props), - sameTypeTotal = _getStackParams.sameTypeTotal, - sameTypeIndex = _getStackParams.sameTypeIndex; - - var distance = this._getScaleDistance(linePosAttr); - var lineFunctor = this._getAttributeFunctor(linePosAttr); - var valueFunctor = this._getAttributeFunctor(valuePosAttr); - var value0Functor = this._getAttr0Functor(valuePosAttr); - var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var opacityFunctor = this._getAttributeFunctor('opacity'); - - var halfSpace = distance / 2 * barWidth; - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - var _attrs; - - // totalSpaceAvailable is the space we have available to draw all the - // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) - var totalSpaceAvailable = halfSpace * 2; - var totalSpaceCenter = lineFunctor(d); - // totalSpaceStartingPoint is the first pixel were we can start drawing - var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; - // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal - var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; - // spacePerBar is the space we have available to draw sameTypeIndex bar - var spacePerBar = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; - // barStartingPoint is the first pixel were we can start drawing sameTypeIndex bar - var barStartingPoint = totalSpaceStartingPoint + spacePerBar * sameTypeIndex + sameTypeIndex; - - var attrs = (_attrs = { - style: _extends({ - opacity: opacityFunctor && opacityFunctor(d), - stroke: strokeFunctor && strokeFunctor(d), - fill: fillFunctor && fillFunctor(d) - }, style) - }, _defineProperty(_attrs, linePosAttr, barStartingPoint), _defineProperty(_attrs, lineSizeAttr, spacePerBar), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { - return _this2._valueClickHandler(d, e); - }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - }), _defineProperty(_attrs, 'key', i), _attrs); - return _react2.default.createElement('rect', attrs); - }) - ); - } - }], [{ - key: 'propTypes', - get: function get() { - return _extends({}, _abstractSeries2.default.propTypes, { - linePosAttr: _propTypes2.default.string, - valuePosAttr: _propTypes2.default.string, - lineSizeAttr: _propTypes2.default.string, - valueSizeAttr: _propTypes2.default.string, - cluster: _propTypes2.default.string, - barWidth: _propTypes2.default.number - }); - } - }, { - key: 'defaultProps', - get: function get() { - return { - barWidth: 0.85 - }; - } - }]); - - return BarSeries; -}(_abstractSeries2.default); - -BarSeries.displayName = 'BarSeries'; - -exports.default = BarSeries; \ No newline at end of file diff --git a/dist/plot/series/canvas-wrapper.js b/dist/plot/series/canvas-wrapper.js deleted file mode 100644 index 5211e2bd7..000000000 --- a/dist/plot/series/canvas-wrapper.js +++ /dev/null @@ -1,256 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Interpolate = require('d3-interpolate'); - -var _animation = require('../../animation'); - -var _seriesUtils = require('../../utils/series-utils'); - -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; } - -var MAX_DRAWS = 30; - -/** - * Draw loop draws each of the layers until it should draw more - * @param {CanvasContext} ctx - the context where the drawing will take place - * @param {Number} height - height of the canvas - * @param {Number} width - width of the canvas - * @param {Array} layers - the layer objects to render - */ -function engageDrawLoop(ctx, height, width, layers) { - var drawIteration = 0; - // using setInterval because request animation frame goes too fast - var drawCycle = setInterval(function () { - if (!ctx) { - clearInterval(drawCycle); - return; - } - drawLayers(ctx, height, width, layers, drawIteration); - if (drawIteration > MAX_DRAWS) { - clearInterval(drawCycle); - } - drawIteration += 1; - }, 1); -} - -/** - * Loops across each of the layers to be drawn and draws them - * @param {CanvasContext} ctx - the context where the drawing will take place - * @param {Number} height - height of the canvas - * @param {Number} width - width of the canvas - * @param {Array} layers - the layer objects to render - * @param {Number} drawIteration - width of the canvas - */ -function drawLayers(ctx, height, width, layers, drawIteration) { - ctx.clearRect(0, 0, width, height); - layers.forEach(function (layer) { - var interpolator = layer.interpolator, - newProps = layer.newProps, - animation = layer.animation; - // return an empty object if dont need to be animating - - var interpolatedProps = animation ? interpolator ? interpolator(drawIteration / MAX_DRAWS) : interpolator : function () { - return {}; - }; - layer.renderLayer(_extends({}, newProps, interpolatedProps), ctx); - }); -} - -/** - * Build an array of layer of objects the contain the method for drawing each series - * as well as an interpolar (specifically a d3-interpolate interpolator) - * @param {Object} newChildren the new children to be rendered. - * @param {Object} oldChildren the old children to be rendered. - * @returns {Array} Object for rendering - */ -function buildLayers(newChildren, oldChildren) { - return newChildren.map(function (child, index) { - var oldProps = oldChildren[index] ? oldChildren[index].props : {}; - var newProps = child.props; - - var oldAnimatedProps = (0, _animation.extractAnimatedPropValues)(_extends({}, oldProps, { - animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS - })); - var newAnimatedProps = newProps ? (0, _animation.extractAnimatedPropValues)(_extends({}, newProps, { - animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS - })) : null; - var interpolator = (0, _d3Interpolate.interpolate)(oldAnimatedProps, newAnimatedProps); - - return { - renderLayer: child.type.renderLayer, - newProps: child.props, - animation: child.props.animation, - interpolator: interpolator - }; - }); -} - -var CanvasWrapper = function (_Component) { - _inherits(CanvasWrapper, _Component); - - function CanvasWrapper() { - _classCallCheck(this, CanvasWrapper); - - return _possibleConstructorReturn(this, (CanvasWrapper.__proto__ || Object.getPrototypeOf(CanvasWrapper)).apply(this, arguments)); - } - - _createClass(CanvasWrapper, [{ - key: 'componentDidMount', - value: function componentDidMount() { - var ctx = this.canvas.getContext('2d'); - if (!ctx) { - return; - } - var pixelRatio = this.props.pixelRatio; - - if (!ctx) { - return; - } - ctx.scale(pixelRatio, pixelRatio); - - this.drawChildren(null, this.props, ctx); - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate(oldProps) { - this.drawChildren(oldProps, this.props, this.canvas.getContext('2d')); - } - - /** - * Check that we can and should be animating, then kick off animations as apporpriate - * @param {Object} newProps the new props to be interpolated to - * @param {Object} oldProps the old props to be interpolated against - * @param {DomRef} ctx the canvas context to be drawn on. - * @returns {Array} Object for rendering - */ - - }, { - key: 'drawChildren', - value: function drawChildren(oldProps, newProps, ctx) { - var children = newProps.children, - innerHeight = newProps.innerHeight, - innerWidth = newProps.innerWidth, - marginBottom = newProps.marginBottom, - marginLeft = newProps.marginLeft, - marginRight = newProps.marginRight, - marginTop = newProps.marginTop; - - if (!ctx) { - return; - } - - var childrenShouldAnimate = children.find(function (child) { - return child.props.animation; - }); - - var height = innerHeight + marginTop + marginBottom; - var width = innerWidth + marginLeft + marginRight; - var layers = buildLayers(newProps.children, oldProps ? oldProps.children : []); - // if we don't need to be animating, dont! cut short - if (!childrenShouldAnimate) { - drawLayers(ctx, height, width, layers); - return; - } - - engageDrawLoop(ctx, height, width, layers); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginBottom = _props.marginBottom, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - marginTop = _props.marginTop, - pixelRatio = _props.pixelRatio; - - - var height = innerHeight + marginTop + marginBottom; - var width = innerWidth + marginLeft + marginRight; - - return _react2.default.createElement( - 'div', - { style: { left: 0, top: 0 }, className: 'rv-xy-canvas' }, - _react2.default.createElement('canvas', { - className: 'rv-xy-canvas-element', - height: height * pixelRatio, - width: width * pixelRatio, - style: { - height: height + 'px', - width: width + 'px' - }, - ref: function ref(_ref) { - return _this2.canvas = _ref; - } - }), - this.props.children - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return { - pixelRatio: window && window.devicePixelRatio || 1 - }; - } - }]); - - return CanvasWrapper; -}(_react.Component); - -CanvasWrapper.displayName = 'CanvasWrapper'; -CanvasWrapper.propTypes = { - marginBottom: _propTypes2.default.number.isRequired, - marginLeft: _propTypes2.default.number.isRequired, - marginRight: _propTypes2.default.number.isRequired, - marginTop: _propTypes2.default.number.isRequired, - innerHeight: _propTypes2.default.number.isRequired, - innerWidth: _propTypes2.default.number.isRequired, - pixelRatio: _propTypes2.default.number.isRequired -}; - -exports.default = CanvasWrapper; \ No newline at end of file diff --git a/dist/plot/series/contour-series.js b/dist/plot/series/contour-series.js deleted file mode 100644 index 030567d86..000000000 --- a/dist/plot/series/contour-series.js +++ /dev/null @@ -1,164 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Contour = require('d3-contour'); - -var _d3Geo = require('d3-geo'); - -var _d3Scale = require('d3-scale'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _theme = require('../../theme'); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--contour'; - -function getDomain(data) { - return data.reduce(function (acc, row) { - return { - min: Math.min(acc.min, row.value), - max: Math.max(acc.max, row.value) - }; - }, { min: Infinity, max: -Infinity }); -} - -var ContourSeries = function (_AbstractSeries) { - _inherits(ContourSeries, _AbstractSeries); - - function ContourSeries() { - _classCallCheck(this, ContourSeries); - - return _possibleConstructorReturn(this, (ContourSeries.__proto__ || Object.getPrototypeOf(ContourSeries)).apply(this, arguments)); - } - - _createClass(ContourSeries, [{ - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - bandwidth = _props.bandwidth, - className = _props.className, - colorRange = _props.colorRange, - data = _props.data, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - - if (!data || !innerWidth || !innerHeight) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(ContourSeries, _extends({}, this.props, { animation: null })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - var contouredData = (0, _d3Contour.contourDensity)().x(function (d) { - return x(d); - }).y(function (d) { - return y(d); - }).size([innerWidth, innerHeight]).bandwidth(bandwidth)(data); - - var geo = (0, _d3Geo.geoPath)(); - - var _getDomain = getDomain(contouredData), - min = _getDomain.min, - max = _getDomain.max; - - var colorScale = (0, _d3Scale.scaleLinear)().domain([min, max]).range(colorRange || _theme.CONTINUOUS_COLOR_RANGE); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - contouredData.map(function (polygon, index) { - return _react2.default.createElement('path', { - className: 'rv-xy-plot__series--contour-line', - key: 'rv-xy-plot__series--contour-line-' + index, - d: geo(polygon), - style: _extends({ - fill: colorScale(polygon.value) - }, style) - }); - }) - ); - } - }]); - - return ContourSeries; -}(_abstractSeries2.default); - -ContourSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - animation: _propTypes2.default.bool, - bandwidth: _propTypes2.default.number, - className: _propTypes2.default.string, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - style: _propTypes2.default.object -}); - -ContourSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - bandwidth: 40, - style: {} -}); - -exports.default = ContourSeries; \ No newline at end of file diff --git a/dist/plot/series/custom-svg-series.js b/dist/plot/series/custom-svg-series.js deleted file mode 100644 index 1dfedfcb2..000000000 --- a/dist/plot/series/custom-svg-series.js +++ /dev/null @@ -1,237 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -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; } - -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); } } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--custom-svg-wrapper'; - -var DEFAULT_STYLE = { - stroke: 'blue', - fill: 'blue' -}; - -function predefinedComponents(type) { - var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; - var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_STYLE; - - switch (type) { - case 'diamond': - return _react2.default.createElement('polygon', { - style: style, - points: '0 0 ' + size / 2 + ' ' + size / 2 + ' 0 ' + size + ' ' + -size / 2 + ' ' + size / 2 + ' 0 0' - }); - case 'star': - var starPoints = [].concat(_toConsumableArray(new Array(5))).map(function (c, index) { - var angle = index / 5 * Math.PI * 2; - var innerAngle = angle + Math.PI / 10; - var outerAngle = angle - Math.PI / 10; - // ratio of inner polygon to outer polgyon - var innerRadius = size / 2.61; - return '\n ' + Math.cos(outerAngle) * size + ' ' + Math.sin(outerAngle) * size + '\n ' + Math.cos(innerAngle) * innerRadius + ' ' + Math.sin(innerAngle) * innerRadius + '\n '; - }).join(' '); - return _react2.default.createElement('polygon', { - points: starPoints, - x: '0', - y: '0', - height: size, - width: size, - style: style - }); - case 'square': - return _react2.default.createElement('rect', { - x: '' + -size / 2, - y: '' + -size / 2, - height: size, - width: size, - style: style - }); - default: - case 'circle': - return _react2.default.createElement('circle', { cx: '0', cy: '0', r: size / 2, style: style }); - } -} - -function getInnerComponent(_ref) { - var customComponent = _ref.customComponent, - defaultType = _ref.defaultType, - positionInPixels = _ref.positionInPixels, - positionFunctions = _ref.positionFunctions, - style = _ref.style, - propsSize = _ref.propsSize; - var size = customComponent.size; - - var aggStyle = _extends({}, style, customComponent.style || {}); - var innerComponent = customComponent.customComponent; - if (!innerComponent && typeof defaultType === 'string') { - return predefinedComponents(defaultType, size || propsSize, aggStyle); - } - // if default component is a function - if (!innerComponent) { - return defaultType(customComponent, positionInPixels, aggStyle); - } - if (typeof innerComponent === 'string') { - return predefinedComponents(innerComponent || defaultType, size, aggStyle); - } - // if inner component is a function - return innerComponent(customComponent, positionInPixels, aggStyle); -} - -var CustomSVGSeries = function (_AbstractSeries) { - _inherits(CustomSVGSeries, _AbstractSeries); - - function CustomSVGSeries() { - _classCallCheck(this, CustomSVGSeries); - - return _possibleConstructorReturn(this, (CustomSVGSeries.__proto__ || Object.getPrototypeOf(CustomSVGSeries)).apply(this, arguments)); - } - - _createClass(CustomSVGSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - customComponent = _props.customComponent, - data = _props.data, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style, - size = _props.size; - - - if (!data || !innerWidth || !innerHeight) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(CustomSVGSeries, _extends({}, this.props, { animation: false })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var contents = data.map(function (seriesComponent, index) { - var positionInPixels = { - x: x({ x: seriesComponent.x }), - y: y({ y: seriesComponent.y }) - }; - var innerComponent = getInnerComponent({ - customComponent: seriesComponent, - positionInPixels: positionInPixels, - defaultType: customComponent, - positionFunctions: { x: x, y: y }, - style: style, - propsSize: size - }); - return _react2.default.createElement( - 'g', - { - className: 'rv-xy-plot__series--custom-svg', - key: 'rv-xy-plot__series--custom-svg-' + index, - transform: 'translate(' + positionInPixels.x + ',' + positionInPixels.y + ')', - onMouseEnter: function onMouseEnter(e) { - return _this2._valueMouseOverHandler(seriesComponent, e); - }, - onMouseLeave: function onMouseLeave(e) { - return _this2._valueMouseOutHandler(seriesComponent, e); - } - }, - innerComponent - ); - }); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - contents - ); - } - }]); - - return CustomSVGSeries; -}(_abstractSeries2.default); - -CustomSVGSeries.propTypes = { - animation: _propTypes2.default.bool, - className: _propTypes2.default.string, - customComponent: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), - data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired, - y: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired - })).isRequired, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - style: _propTypes2.default.object, - size: _propTypes2.default.number, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func -}; - -CustomSVGSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - animation: false, - customComponent: 'circle', - style: {}, - size: 2 -}); - -exports.default = CustomSVGSeries; \ No newline at end of file diff --git a/dist/plot/series/heatmap-series.js b/dist/plot/series/heatmap-series.js deleted file mode 100644 index 69c142265..000000000 --- a/dist/plot/series/heatmap-series.js +++ /dev/null @@ -1,147 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--heatmap'; - -var HeatmapSeries = function (_AbstractSeries) { - _inherits(HeatmapSeries, _AbstractSeries); - - function HeatmapSeries() { - _classCallCheck(this, HeatmapSeries); - - return _possibleConstructorReturn(this, (HeatmapSeries.__proto__ || Object.getPrototypeOf(HeatmapSeries)).apply(this, arguments)); - } - - _createClass(HeatmapSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - if (!data) { - return null; - } - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(HeatmapSeries, _extends({}, this.props, { animation: null })) - ); - } - - var _rectStyle$style = _extends({ rectStyle: {} }, style), - rectStyle = _rectStyle$style.rectStyle; - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var opacity = this._getAttributeFunctor('opacity'); - var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var xDistance = this._getScaleDistance('x'); - var yDistance = this._getScaleDistance('y'); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - var attrs = _extends({ - style: _extends({ - stroke: stroke && stroke(d), - fill: fill && fill(d), - opacity: opacity && opacity(d) - }, style) - }, rectStyle, { - x: x(d) - xDistance / 2, - y: y(d) - yDistance / 2, - width: xDistance, - height: yDistance, - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - } - }); - return _react2.default.createElement('rect', attrs); - }) - ); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'x' || attr === 'y'; - return { isDomainAdjustmentNeeded: isDomainAdjustmentNeeded }; - } - }]); - - return HeatmapSeries; -}(_abstractSeries2.default); - -HeatmapSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -HeatmapSeries.displayName = 'HeatmapSeries'; - -exports.default = HeatmapSeries; \ No newline at end of file diff --git a/dist/plot/series/hexbin-series.js b/dist/plot/series/hexbin-series.js deleted file mode 100644 index 2f2cadcf9..000000000 --- a/dist/plot/series/hexbin-series.js +++ /dev/null @@ -1,180 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _d3Hexbin = require('d3-hexbin'); - -var _d3Scale = require('d3-scale'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _theme = require('../../theme'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } - -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); } } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--hexbin'; - -function getColorDomain(_ref, hexes) { - var countDomain = _ref.countDomain; - - if (countDomain) { - return countDomain; - } - return [0, Math.max.apply(Math, _toConsumableArray(hexes.map(function (row) { - return row.length; - })))]; -} - -var HexbinSeries = function (_AbstractSeries) { - _inherits(HexbinSeries, _AbstractSeries); - - function HexbinSeries() { - _classCallCheck(this, HexbinSeries); - - return _possibleConstructorReturn(this, (HexbinSeries.__proto__ || Object.getPrototypeOf(HexbinSeries)).apply(this, arguments)); - } - - _createClass(HexbinSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - colorRange = _props.colorRange, - data = _props.data, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - radius = _props.radius, - sizeHexagonsWithCount = _props.sizeHexagonsWithCount, - style = _props.style, - xOffset = _props.xOffset, - yOffset = _props.yOffset; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(HexbinSeries, _extends({}, this.props, { animation: null })) - ); - } - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - var hex = (0, _d3Hexbin.hexbin)().x(function (d) { - return x(d) + xOffset; - }).y(function (d) { - return y(d) + yOffset; - }).radius(radius).size([innerWidth, innerHeight]); - - var hexagonPath = hex.hexagon(); - var hexes = hex(data); - - var countDomain = getColorDomain(this.props, hexes); - var color = (0, _d3Scale.scaleLinear)().domain(countDomain).range(colorRange); - var size = (0, _d3Scale.scaleLinear)().domain(countDomain).range([0, radius]); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - hexes.map(function (d, i) { - var attrs = { - style: style, - d: sizeHexagonsWithCount ? hex.hexagon(size(d.length)) : hexagonPath, - fill: color(d.length), - transform: 'translate(' + d.x + ', ' + d.y + ')', - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - } - }; - return _react2.default.createElement('path', attrs); - }) - ); - } - }]); - - return HexbinSeries; -}(_abstractSeries2.default); - -HexbinSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - radius: _propTypes2.default.number -}); - -HexbinSeries.defaultProps = { - radius: 20, - colorRange: _theme.CONTINUOUS_COLOR_RANGE, - xOffset: 0, - yOffset: 0 -}; - -HexbinSeries.displayName = 'HexbinSeries'; - -exports.default = HexbinSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series-canvas.js b/dist/plot/series/horizontal-bar-series-canvas.js deleted file mode 100644 index fa817cc24..000000000 --- a/dist/plot/series/horizontal-bar-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeriesCanvas = require('./bar-series-canvas'); - -var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalBarSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); - - function HorizontalBarSeriesCanvas() { - _classCallCheck(this, HorizontalBarSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalBarSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'y'; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _barSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalBarSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; -HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series.js b/dist/plot/series/horizontal-bar-series.js deleted file mode 100644 index ef65b02da..000000000 --- a/dist/plot/series/horizontal-bar-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeries = require('./bar-series'); - -var _barSeries2 = _interopRequireDefault(_barSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalBarSeries = function (_AbstractSeries) { - _inherits(HorizontalBarSeries, _AbstractSeries); - - function HorizontalBarSeries() { - _classCallCheck(this, HorizontalBarSeries); - - return _possibleConstructorReturn(this, (HorizontalBarSeries.__proto__ || Object.getPrototypeOf(HorizontalBarSeries)).apply(this, arguments)); - } - - _createClass(HorizontalBarSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'y'; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return HorizontalBarSeries; -}(_abstractSeries2.default); - -HorizontalBarSeries.displayName = 'HorizontalBarSeries'; - -exports.default = HorizontalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series-canvas.js b/dist/plot/series/horizontal-rect-series-canvas.js deleted file mode 100644 index c275a349d..000000000 --- a/dist/plot/series/horizontal-rect-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeriesCanvas = require('./rect-series-canvas'); - -var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalRectSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); - - function HorizontalRectSeriesCanvas() { - _classCallCheck(this, HorizontalRectSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalRectSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalRectSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; -HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series.js b/dist/plot/series/horizontal-rect-series.js deleted file mode 100644 index 014390674..000000000 --- a/dist/plot/series/horizontal-rect-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeries = require('./rect-series'); - -var _rectSeries2 = _interopRequireDefault(_rectSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalRectSeries = function (_AbstractSeries) { - _inherits(HorizontalRectSeries, _AbstractSeries); - - function HorizontalRectSeries() { - _classCallCheck(this, HorizontalRectSeries); - - return _possibleConstructorReturn(this, (HorizontalRectSeries.__proto__ || Object.getPrototypeOf(HorizontalRectSeries)).apply(this, arguments)); - } - - _createClass(HorizontalRectSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return HorizontalRectSeries; -}(_abstractSeries2.default); - -HorizontalRectSeries.displayName = 'HorizontalRectSeries'; - -exports.default = HorizontalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series-canvas.js b/dist/plot/series/line-mark-series-canvas.js deleted file mode 100644 index 501c2745a..000000000 --- a/dist/plot/series/line-mark-series-canvas.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _markSeriesCanvas = require('./mark-series-canvas'); - -var _markSeriesCanvas2 = _interopRequireDefault(_markSeriesCanvas); - -var _lineSeriesCanvas = require('./line-series-canvas'); - -var _lineSeriesCanvas2 = _interopRequireDefault(_lineSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var LineMarkSeriesCanvas = function (_AbstractSeries) { - _inherits(LineMarkSeriesCanvas, _AbstractSeries); - - function LineMarkSeriesCanvas() { - _classCallCheck(this, LineMarkSeriesCanvas); - - return _possibleConstructorReturn(this, (LineMarkSeriesCanvas.__proto__ || Object.getPrototypeOf(LineMarkSeriesCanvas)).apply(this, arguments)); - } - - _createClass(LineMarkSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _lineSeriesCanvas2.default.renderLayer(props, ctx); - _markSeriesCanvas2.default.renderLayer(props, ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return LineMarkSeriesCanvas; -}(_abstractSeries2.default); - -LineMarkSeriesCanvas.displayName = 'LineMarkSeriesCanvas'; -LineMarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = LineMarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series.js b/dist/plot/series/line-mark-series.js deleted file mode 100644 index 7c3c876cf..000000000 --- a/dist/plot/series/line-mark-series.js +++ /dev/null @@ -1,102 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _lineSeries = require('./line-series'); - -var _lineSeries2 = _interopRequireDefault(_lineSeries); - -var _markSeries = require('./mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -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; } - -var propTypes = _extends({}, _lineSeries2.default.propTypes, { - lineStyle: _propTypes2.default.object, - markStyle: _propTypes2.default.object -}); - -var LineMarkSeries = function (_AbstractSeries) { - _inherits(LineMarkSeries, _AbstractSeries); - - function LineMarkSeries() { - _classCallCheck(this, LineMarkSeries); - - return _possibleConstructorReturn(this, (LineMarkSeries.__proto__ || Object.getPrototypeOf(LineMarkSeries)).apply(this, arguments)); - } - - _createClass(LineMarkSeries, [{ - key: 'render', - value: function render() { - var _props = this.props, - lineStyle = _props.lineStyle, - markStyle = _props.markStyle, - style = _props.style; - - return _react2.default.createElement( - 'g', - { className: 'rv-xy-plot__series rv-xy-plot__series--linemark' }, - _react2.default.createElement(_lineSeries2.default, _extends({}, this.props, { style: _extends({}, style, lineStyle) })), - _react2.default.createElement(_markSeries2.default, _extends({}, this.props, { style: _extends({}, style, markStyle) })) - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return _extends({}, _lineSeries2.default.defaultProps, { - lineStyle: {}, - markStyle: {} - }); - } - }]); - - return LineMarkSeries; -}(_abstractSeries2.default); - -LineMarkSeries.displayName = 'LineMarkSeries'; -LineMarkSeries.propTypes = propTypes; - -exports.default = LineMarkSeries; \ No newline at end of file diff --git a/dist/plot/series/line-series-canvas.js b/dist/plot/series/line-series-canvas.js deleted file mode 100644 index 9694a334d..000000000 --- a/dist/plot/series/line-series-canvas.js +++ /dev/null @@ -1,146 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Color = require('d3-color'); - -var _d3Shape = require('d3-shape'); - -var d3Shape = _interopRequireWildcard(_d3Shape); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -var LineSeriesCanvas = function (_AbstractSeries) { - _inherits(LineSeriesCanvas, _AbstractSeries); - - function LineSeriesCanvas() { - _classCallCheck(this, LineSeriesCanvas); - - return _possibleConstructorReturn(this, (LineSeriesCanvas.__proto__ || Object.getPrototypeOf(LineSeriesCanvas)).apply(this, arguments)); - } - - _createClass(LineSeriesCanvas, [{ - key: 'render', - value: function render() { - return _react2.default.createElement('div', null); - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var curve = props.curve, - data = props.data, - marginLeft = props.marginLeft, - marginTop = props.marginTop, - strokeWidth = props.strokeWidth, - strokeDasharray = props.strokeDasharray; - - if (!data || data.length === 0) { - return; - } - - var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); - var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); - var stroke = (0, _scalesUtils.getAttributeValue)(props, 'stroke') || (0, _scalesUtils.getAttributeValue)(props, 'color'); - var strokeColor = (0, _d3Color.rgb)(stroke); - var newOpacity = (0, _scalesUtils.getAttributeValue)(props, 'opacity'); - var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; - var line = d3Shape.line().x(function (row) { - return x(row) + marginLeft; - }).y(function (row) { - return y(row) + marginTop; - }); - if (typeof curve === 'string' && d3Shape[curve]) { - line = line.curve(d3Shape[curve]); - } else if (typeof curve === 'function') { - line = line.curve(curve); - } - - ctx.beginPath(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + opacity + ')'; - ctx.lineWidth = strokeWidth; - - if (strokeDasharray) { - ctx.setLineDash(strokeDasharray); - } - - line.context(ctx)(data); - ctx.stroke(); - ctx.closePath(); - // set back to default - ctx.lineWidth = 1; - ctx.setLineDash([]); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return LineSeriesCanvas; -}(_abstractSeries2.default); - -LineSeriesCanvas.displayName = 'LineSeriesCanvas'; -LineSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - strokeWidth: 2 -}); - -LineSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - strokeWidth: _propTypes2.default.number -}); - -exports.default = LineSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-series.js b/dist/plot/series/line-series.js deleted file mode 100644 index d643b3b7f..000000000 --- a/dist/plot/series/line-series.js +++ /dev/null @@ -1,177 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Shape = require('d3-shape'); - -var d3Shape = _interopRequireWildcard(_d3Shape); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _theme = require('../../theme'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _reactUtils = require('../../utils/react-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; - -var STROKE_STYLES = { - dashed: '6, 2', - solid: null -}; - -var LineSeries = function (_AbstractSeries) { - _inherits(LineSeries, _AbstractSeries); - - function LineSeries() { - _classCallCheck(this, LineSeries); - - return _possibleConstructorReturn(this, (LineSeries.__proto__ || Object.getPrototypeOf(LineSeries)).apply(this, arguments)); - } - - _createClass(LineSeries, [{ - key: '_renderLine', - value: function _renderLine(data, x, y, curve, getNull) { - var line = d3Shape.line(); - if (curve !== null) { - if (typeof curve === 'string' && d3Shape[curve]) { - line = line.curve(d3Shape[curve]); - } else if (typeof curve === 'function') { - line = line.curve(curve); - } - } - line = line.defined(getNull); - line = line.x(x).y(y); - return line(data); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data; - - - if (this.props.nullAccessor) { - (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); - } - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(LineSeries, _extends({}, this.props, { animation: null })) - ); - } - - var _props2 = this.props, - curve = _props2.curve, - marginLeft = _props2.marginLeft, - marginTop = _props2.marginTop, - strokeDasharray = _props2.strokeDasharray, - strokeStyle = _props2.strokeStyle, - strokeWidth = _props2.strokeWidth, - style = _props2.style; - - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); - var newOpacity = this._getAttributeValue('opacity'); - var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; - var getNull = this.props.nullAccessor || this.props.getNull; - var d = this._renderLine(data, x, y, curve, getNull); - - return _react2.default.createElement('path', { - d: d, - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')', - onMouseOver: this._seriesMouseOverHandler, - onMouseOut: this._seriesMouseOutHandler, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - style: _extends({ - opacity: opacity, - strokeDasharray: STROKE_STYLES[strokeStyle] || strokeDasharray, - strokeWidth: strokeWidth, - stroke: stroke - }, style) - }); - } - }]); - - return LineSeries; -}(_abstractSeries2.default); - -LineSeries.displayName = 'LineSeries'; -LineSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)), - curve: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), - getNull: _propTypes2.default.func -}); -LineSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - strokeStyle: 'solid', - style: {}, - opacity: 1, - curve: null, - className: '', - getNull: function getNull() { - return true; - } -}); - -exports.default = LineSeries; \ No newline at end of file diff --git a/dist/plot/series/mark-series-canvas.js b/dist/plot/series/mark-series-canvas.js deleted file mode 100644 index de7f2e814..000000000 --- a/dist/plot/series/mark-series-canvas.js +++ /dev/null @@ -1,109 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _d3Color = require('d3-color'); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var MarkSeriesCanvas = function (_AbstractSeries) { - _inherits(MarkSeriesCanvas, _AbstractSeries); - - function MarkSeriesCanvas() { - _classCallCheck(this, MarkSeriesCanvas); - - return _possibleConstructorReturn(this, (MarkSeriesCanvas.__proto__ || Object.getPrototypeOf(MarkSeriesCanvas)).apply(this, arguments)); - } - - _createClass(MarkSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var data = props.data, - marginLeft = props.marginLeft, - marginTop = props.marginTop; - - - var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); - var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); - var size = (0, _scalesUtils.getAttributeFunctor)(props, 'size') || function (p) { - return _theme.DEFAULT_SIZE; - }; - var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); - - data.forEach(function (row) { - var fillColor = (0, _d3Color.rgb)(fill(row)); - var strokeColor = (0, _d3Color.rgb)(stroke(row)); - var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; - ctx.beginPath(); - ctx.arc(x(row) + marginLeft, y(row) + marginTop, size(row), 0, 2 * Math.PI); - ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; - ctx.fill(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; - ctx.stroke(); - }); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return MarkSeriesCanvas; -}(_abstractSeries2.default); - -MarkSeriesCanvas.displayName = 'MarkSeriesCanvas'; - -MarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = MarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/mark-series.js b/dist/plot/series/mark-series.js deleted file mode 100644 index 9ba9a0e8a..000000000 --- a/dist/plot/series/mark-series.js +++ /dev/null @@ -1,179 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _reactUtils = require('../../utils/react-utils'); - -var _theme = require('../../theme'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--mark'; -var DEFAULT_STROKE_WIDTH = 1; - -var MarkSeries = function (_AbstractSeries) { - _inherits(MarkSeries, _AbstractSeries); - - function MarkSeries() { - _classCallCheck(this, MarkSeries); - - return _possibleConstructorReturn(this, (MarkSeries.__proto__ || Object.getPrototypeOf(MarkSeries)).apply(this, arguments)); - } - - _createClass(MarkSeries, [{ - key: '_renderCircle', - value: function _renderCircle(d, i, strokeWidth, style, scalingFunctions) { - var _this2 = this; - - var fill = scalingFunctions.fill, - opacity = scalingFunctions.opacity, - size = scalingFunctions.size, - stroke = scalingFunctions.stroke, - x = scalingFunctions.x, - y = scalingFunctions.y; - - - var attrs = { - r: size ? size(d) : _theme.DEFAULT_SIZE, - cx: x(d), - cy: y(d), - style: _extends({ - opacity: opacity ? opacity(d) : _theme.DEFAULT_OPACITY, - stroke: stroke && stroke(d), - fill: fill && fill(d), - strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH - }, style), - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - } - }; - return _react2.default.createElement('circle', attrs); - } - }, { - key: 'render', - value: function render() { - var _this3 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - strokeWidth = _props.strokeWidth, - style = _props.style; - - - if (this.props.nullAccessor) { - (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); - } - - var getNull = this.props.nullAccessor || this.props.getNull; - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(MarkSeries, _extends({}, this.props, { animation: null })) - ); - } - - var scalingFunctions = { - fill: this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'), - opacity: this._getAttributeFunctor('opacity'), - size: this._getAttributeFunctor('size'), - stroke: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), - x: this._getAttributeFunctor('x'), - y: this._getAttributeFunctor('y') - }; - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - return getNull(d) && _this3._renderCircle(d, i, strokeWidth, style, scalingFunctions); - }) - ); - } - }]); - - return MarkSeries; -}(_abstractSeries2.default); - -MarkSeries.displayName = 'MarkSeries'; -MarkSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - getNull: _propTypes2.default.func, - strokeWidth: _propTypes2.default.number -}); -MarkSeries.defaultProps = { - getNull: function getNull() { - return true; - } -}; - -exports.default = MarkSeries; \ No newline at end of file diff --git a/dist/plot/series/polygon-series.js b/dist/plot/series/polygon-series.js deleted file mode 100644 index d922d284b..000000000 --- a/dist/plot/series/polygon-series.js +++ /dev/null @@ -1,126 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--polygon'; -var DEFAULT_COLOR = '#12939A'; - -var generatePath = function generatePath(data, xFunctor, yFunctor) { - return data.reduce(function (res, row, i) { - return res + ' ' + (i ? 'L' : 'M') + xFunctor(row) + ' ' + yFunctor(row); - }, '') + ' Z'; -}; - -var PolygonSeries = function (_AbstractSeries) { - _inherits(PolygonSeries, _AbstractSeries); - - function PolygonSeries() { - _classCallCheck(this, PolygonSeries); - - return _possibleConstructorReturn(this, (PolygonSeries.__proto__ || Object.getPrototypeOf(PolygonSeries)).apply(this, arguments)); - } - - _createClass(PolygonSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - color = _props.color, - className = _props.className, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(PolygonSeries, _extends({}, this.props, { animation: null })) - ); - } - var xFunctor = this._getAttributeFunctor('x'); - var yFunctor = this._getAttributeFunctor('y'); - - return _react2.default.createElement('path', { - className: predefinedClassName + ' ' + className, - onMouseOver: function onMouseOver(e) { - return _this2._seriesMouseOverHandler(data, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._seriesMouseOutHandler(data, e); - }, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - fill: color || DEFAULT_COLOR, - style: style, - d: generatePath(data, xFunctor, yFunctor), - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }); - } - }], [{ - key: 'propTypes', - get: function get() { - return _extends({}, _abstractSeries2.default.propTypes); - } - }]); - - return PolygonSeries; -}(_abstractSeries2.default); - -PolygonSeries.displayName = 'PolygonSeries'; - -exports.default = PolygonSeries; \ No newline at end of file diff --git a/dist/plot/series/rect-series-canvas.js b/dist/plot/series/rect-series-canvas.js deleted file mode 100644 index 727596c9b..000000000 --- a/dist/plot/series/rect-series-canvas.js +++ /dev/null @@ -1,136 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Color = require('d3-color'); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -var RectSeriesCanvas = function (_AbstractSeries) { - _inherits(RectSeriesCanvas, _AbstractSeries); - - function RectSeriesCanvas() { - _classCallCheck(this, RectSeriesCanvas); - - return _possibleConstructorReturn(this, (RectSeriesCanvas.__proto__ || Object.getPrototypeOf(RectSeriesCanvas)).apply(this, arguments)); - } - - _createClass(RectSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var data = props.data, - linePosAttr = props.linePosAttr, - lineSizeAttr = props.lineSizeAttr, - marginLeft = props.marginLeft, - marginTop = props.marginTop, - valuePosAttr = props.valuePosAttr; - - if (!data || data.length === 0) { - return; - } - - var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); - var line0 = (0, _scalesUtils.getAttr0Functor)(props, linePosAttr); - var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); - var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); - var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); - - data.forEach(function (row) { - var fillColor = (0, _d3Color.rgb)(fill(row)); - var strokeColor = (0, _d3Color.rgb)(stroke(row)); - var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; - - var linePos = line0(row); - var valuePos = Math.min(value0(row), value(row)); - var x = valuePosAttr === 'x' ? valuePos : linePos; - var y = valuePosAttr === 'y' ? valuePos : linePos; - - var lineSize = Math.abs(line(row) - line0(row)); - var valueSize = Math.abs(-value0(row) + value(row)); - var height = lineSizeAttr === 'height' ? lineSize : valueSize; - var width = lineSizeAttr === 'width' ? lineSize : valueSize; - - ctx.beginPath(); - ctx.rect(x + marginLeft, y + marginTop, width, height); - ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; - ctx.fill(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; - ctx.stroke(); - }); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return RectSeriesCanvas; -}(_abstractSeries2.default); - -RectSeriesCanvas.displayName = 'RectSeriesCanvas'; -RectSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - linePosAttr: _propTypes2.default.string.isRequired, - valuePosAttr: _propTypes2.default.string.isRequired, - lineSizeAttr: _propTypes2.default.string.isRequired, - valueSizeAttr: _propTypes2.default.string.isRequired -}); - -RectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = RectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/rect-series.js b/dist/plot/series/rect-series.js deleted file mode 100644 index 75bbd5f46..000000000 --- a/dist/plot/series/rect-series.js +++ /dev/null @@ -1,151 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--rect'; - -var RectSeries = function (_AbstractSeries) { - _inherits(RectSeries, _AbstractSeries); - - function RectSeries() { - _classCallCheck(this, RectSeries); - - return _possibleConstructorReturn(this, (RectSeries.__proto__ || Object.getPrototypeOf(RectSeries)).apply(this, arguments)); - } - - _createClass(RectSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - linePosAttr = _props.linePosAttr, - lineSizeAttr = _props.lineSizeAttr, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style, - valuePosAttr = _props.valuePosAttr, - valueSizeAttr = _props.valueSizeAttr; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(RectSeries, _extends({}, this.props, { animation: null })) - ); - } - - var lineFunctor = this._getAttributeFunctor(linePosAttr); - var line0Functor = this._getAttr0Functor(linePosAttr); - var valueFunctor = this._getAttributeFunctor(valuePosAttr); - var value0Functor = this._getAttr0Functor(valuePosAttr); - var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var opacityFunctor = this._getAttributeFunctor('opacity'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - var _attrs; - - var attrs = (_attrs = { - style: _extends({ - opacity: opacityFunctor && opacityFunctor(d), - stroke: strokeFunctor && strokeFunctor(d), - fill: fillFunctor && fillFunctor(d) - }, style) - }, _defineProperty(_attrs, linePosAttr, line0Functor(d)), _defineProperty(_attrs, lineSizeAttr, Math.abs(lineFunctor(d) - line0Functor(d))), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { - return _this2._valueClickHandler(d, e); - }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - }), _defineProperty(_attrs, 'key', i), _attrs); - return _react2.default.createElement('rect', attrs); - }) - ); - } - }], [{ - key: 'propTypes', - get: function get() { - return _extends({}, _abstractSeries2.default.propTypes, { - linePosAttr: _propTypes2.default.string, - valuePosAttr: _propTypes2.default.string, - lineSizeAttr: _propTypes2.default.string, - valueSizeAttr: _propTypes2.default.string - }); - } - }]); - - return RectSeries; -}(_abstractSeries2.default); - -RectSeries.displayName = 'RectSeries'; - -exports.default = RectSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series-canvas.js b/dist/plot/series/vertical-bar-series-canvas.js deleted file mode 100644 index c07d69f63..000000000 --- a/dist/plot/series/vertical-bar-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeriesCanvas = require('./bar-series-canvas'); - -var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalBarSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); - - function HorizontalBarSeriesCanvas() { - _classCallCheck(this, HorizontalBarSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalBarSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'x'; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _barSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalBarSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; -HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series.js b/dist/plot/series/vertical-bar-series.js deleted file mode 100644 index 0a0e1de82..000000000 --- a/dist/plot/series/vertical-bar-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeries = require('./bar-series'); - -var _barSeries2 = _interopRequireDefault(_barSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var VerticalBarSeries = function (_AbstractSeries) { - _inherits(VerticalBarSeries, _AbstractSeries); - - function VerticalBarSeries() { - _classCallCheck(this, VerticalBarSeries); - - return _possibleConstructorReturn(this, (VerticalBarSeries.__proto__ || Object.getPrototypeOf(VerticalBarSeries)).apply(this, arguments)); - } - - _createClass(VerticalBarSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'x'; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return VerticalBarSeries; -}(_abstractSeries2.default); - -VerticalBarSeries.displayName = 'VerticalBarSeries'; - -exports.default = VerticalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series-canvas.js b/dist/plot/series/vertical-rect-series-canvas.js deleted file mode 100644 index a45961e48..000000000 --- a/dist/plot/series/vertical-rect-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeriesCanvas = require('./rect-series-canvas'); - -var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalRectSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); - - function HorizontalRectSeriesCanvas() { - _classCallCheck(this, HorizontalRectSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalRectSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalRectSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; -HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series.js b/dist/plot/series/vertical-rect-series.js deleted file mode 100644 index e4b09a340..000000000 --- a/dist/plot/series/vertical-rect-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeries = require('./rect-series'); - -var _rectSeries2 = _interopRequireDefault(_rectSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var VerticalRectSeries = function (_AbstractSeries) { - _inherits(VerticalRectSeries, _AbstractSeries); - - function VerticalRectSeries() { - _classCallCheck(this, VerticalRectSeries); - - return _possibleConstructorReturn(this, (VerticalRectSeries.__proto__ || Object.getPrototypeOf(VerticalRectSeries)).apply(this, arguments)); - } - - _createClass(VerticalRectSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return VerticalRectSeries; -}(_abstractSeries2.default); - -VerticalRectSeries.displayName = 'VerticalRectSeries'; - -exports.default = VerticalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/whisker-series.js b/dist/plot/series/whisker-series.js deleted file mode 100644 index b2c479d8c..000000000 --- a/dist/plot/series/whisker-series.js +++ /dev/null @@ -1,274 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _theme = require('../../theme'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--whisker'; -var DEFAULT_STROKE_WIDTH = 1; -var DEFAULT_CROSS_BAR_WIDTH = 6; - -/** - * Render whisker lines for a data point. - * @param {Object} whiskerMarkProps All the properties of the whisker mark. - * @private - */ -var renderWhiskerMark = function renderWhiskerMark(whiskerMarkProps) { - return function (d, i) { - var crossBarWidth = whiskerMarkProps.crossBarWidth, - opacityFunctor = whiskerMarkProps.opacityFunctor, - sizeFunctor = whiskerMarkProps.sizeFunctor, - strokeFunctor = whiskerMarkProps.strokeFunctor, - strokeWidth = whiskerMarkProps.strokeWidth, - style = whiskerMarkProps.style, - valueClickHandler = whiskerMarkProps.valueClickHandler, - valueMouseOutHandler = whiskerMarkProps.valueMouseOutHandler, - valueMouseOverHandler = whiskerMarkProps.valueMouseOverHandler, - valueRightClickHandler = whiskerMarkProps.valueRightClickHandler, - xFunctor = whiskerMarkProps.xFunctor, - yFunctor = whiskerMarkProps.yFunctor; - - - var r = sizeFunctor ? sizeFunctor(d) : 0; - var cx = xFunctor(d); - var cy = yFunctor(d); - var positiveXVariance = xFunctor({ x: d.x + d.xVariance / 2 }); - var negativeXVariance = xFunctor({ x: d.x - d.xVariance / 2 }); - var positiveYVariance = yFunctor({ y: d.y + d.yVariance / 2 }); - var negativeYVariance = yFunctor({ y: d.y - d.yVariance / 2 }); - /** - * Determine whether on not we should draw whiskers in each direction. - * We need to see an actual variance value, and also have that value extend past the - * radius "buffer" region in which we won't be drawing (if any). - */ - var hasXWhiskers = positiveXVariance && cx + r < positiveXVariance; - var hasYWhiskers = positiveYVariance && cy - r > positiveYVariance; - if (!hasXWhiskers && !hasYWhiskers) { - return null; - } - - var styleAttr = _extends({ - opacity: opacityFunctor ? opacityFunctor(d) : _theme.DEFAULT_OPACITY, - stroke: strokeFunctor && strokeFunctor(d), - strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH - }, style); - var crossBarExtension = crossBarWidth / 2; - - var rightLineAttrs = { - x1: cx + r, - y1: cy, - x2: positiveXVariance, - y2: cy, - style: styleAttr - }; - var leftLineAttrs = { - x1: cx - r, - y1: cy, - x2: negativeXVariance, - y2: cy, - style: styleAttr - }; - var rightCrossBarAttrs = { - x1: positiveXVariance, - y1: cy - crossBarExtension, - x2: positiveXVariance, - y2: cy + crossBarExtension, - style: styleAttr - }; - var leftCrossBarAttrs = { - x1: negativeXVariance, - y1: cy - crossBarExtension, - x2: negativeXVariance, - y2: cy + crossBarExtension, - style: styleAttr - }; - - var upperLineAttrs = { - x1: cx, - y1: cy - r, - x2: cx, - y2: positiveYVariance, - style: styleAttr - }; - var lowerLineAttrs = { - x1: cx, - y1: cy + r, - x2: cx, - y2: negativeYVariance, - style: styleAttr - }; - var upperCrossBarAttrs = { - x1: cx - crossBarExtension, - y1: positiveYVariance, - x2: cx + crossBarExtension, - y2: positiveYVariance, - style: styleAttr - }; - var lowerCrossBarAttrs = { - x1: cx - crossBarExtension, - y1: negativeYVariance, - x2: cx + crossBarExtension, - y2: negativeYVariance, - style: styleAttr - }; - - return _react2.default.createElement( - 'g', - { - className: 'mark-whiskers', - key: i, - onClick: function onClick(e) { - return valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return valueMouseOutHandler(d, e); - } - }, - hasXWhiskers ? _react2.default.createElement( - 'g', - { className: 'x-whiskers' }, - _react2.default.createElement('line', rightLineAttrs), - _react2.default.createElement('line', leftLineAttrs), - _react2.default.createElement('line', rightCrossBarAttrs), - _react2.default.createElement('line', leftCrossBarAttrs) - ) : null, - hasYWhiskers ? _react2.default.createElement( - 'g', - { className: 'y-whiskers' }, - _react2.default.createElement('line', upperLineAttrs), - _react2.default.createElement('line', lowerLineAttrs), - _react2.default.createElement('line', upperCrossBarAttrs), - _react2.default.createElement('line', lowerCrossBarAttrs) - ) : null - ); - }; -}; - -var WhiskerSeries = function (_AbstractSeries) { - _inherits(WhiskerSeries, _AbstractSeries); - - function WhiskerSeries() { - _classCallCheck(this, WhiskerSeries); - - return _possibleConstructorReturn(this, (WhiskerSeries.__proto__ || Object.getPrototypeOf(WhiskerSeries)).apply(this, arguments)); - } - - _createClass(WhiskerSeries, [{ - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - crossBarWidth = _props.crossBarWidth, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - strokeWidth = _props.strokeWidth, - style = _props.style; - - if (!data) { - return null; - } - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(WhiskerSeries, _extends({}, this.props, { animation: null })) - ); - } - - var whiskerMarkProps = { - crossBarWidth: crossBarWidth, - opacityFunctor: this._getAttributeFunctor('opacity'), - sizeFunctor: this._getAttributeFunctor('size'), - strokeFunctor: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), - strokeWidth: strokeWidth, - style: style, - xFunctor: this._getAttributeFunctor('x'), - yFunctor: this._getAttributeFunctor('y'), - valueClickHandler: this._valueClickHandler, - valueRightClickHandler: this._valueRightClickHandler, - valueMouseOverHandler: this._valueMouseOverHandler, - valueMouseOutHandler: this._valueMouseOutHandler - }; - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(renderWhiskerMark(whiskerMarkProps)) - ); - } - }]); - - return WhiskerSeries; -}(_abstractSeries2.default); - -WhiskerSeries.displayName = 'WhiskerSeries'; -WhiskerSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - strokeWidth: _propTypes2.default.number -}); -WhiskerSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - crossBarWidth: DEFAULT_CROSS_BAR_WIDTH, - size: 0, - strokeWidth: DEFAULT_STROKE_WIDTH -}); -exports.default = WhiskerSeries; \ No newline at end of file diff --git a/dist/plot/vertical-grid-lines.js b/dist/plot/vertical-grid-lines.js deleted file mode 100644 index 220165193..000000000 --- a/dist/plot/vertical-grid-lines.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _gridLines = require('./grid-lines'); - -var _gridLines2 = _interopRequireDefault(_gridLines); - -var _axisUtils = require('../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var VERTICAL = _axisUtils.DIRECTION.VERTICAL; - - -var propTypes = _extends({}, _gridLines2.default.propTypes, { - direction: _propTypes2.default.oneOf([VERTICAL]) -}); - -var defaultProps = { - direction: VERTICAL, - attr: 'x' -}; - -function VerticalGridLines(props) { - return _react2.default.createElement(_gridLines2.default, props); -} - -VerticalGridLines.displayName = 'VerticalGridLines'; -VerticalGridLines.propTypes = propTypes; -VerticalGridLines.defaultProps = defaultProps; -VerticalGridLines.requiresSVG = true; - -exports.default = VerticalGridLines; \ No newline at end of file diff --git a/dist/plot/voronoi.js b/dist/plot/voronoi.js deleted file mode 100644 index 45517bb4f..000000000 --- a/dist/plot/voronoi.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Voronoi = require('d3-voronoi'); - -var _scalesUtils = require('../utils/scales-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var NOOP = function NOOP(f) { - return f; -}; - -// Find the index of the node at coordinates of a touch point -function getNodeIndex(evt) { - var _evt$nativeEvent = evt.nativeEvent, - pageX = _evt$nativeEvent.pageX, - pageY = _evt$nativeEvent.pageY; - - var target = document.elementFromPoint(pageX, pageY); - if (!target) { - return -1; - } - var parentNode = target.parentNode; - - return Array.prototype.indexOf.call(parentNode.childNodes, target); -} - -function getExtent(_ref) { - var innerWidth = _ref.innerWidth, - innerHeight = _ref.innerHeight, - marginLeft = _ref.marginLeft, - marginTop = _ref.marginTop; - - return [[marginLeft, marginTop], [innerWidth + marginLeft, innerHeight + marginTop]]; -} - -function Voronoi(props) { - var className = props.className, - extent = props.extent, - nodes = props.nodes, - onBlur = props.onBlur, - _onClick = props.onClick, - _onMouseUp = props.onMouseUp, - _onMouseDown = props.onMouseDown, - onHover = props.onHover, - polygonStyle = props.polygonStyle, - style = props.style, - x = props.x, - y = props.y; - // Create a voronoi with each node center points - - var voronoiInstance = (0, _d3Voronoi.voronoi)().x(x || (0, _scalesUtils.getAttributeFunctor)(props, 'x')).y(y || (0, _scalesUtils.getAttributeFunctor)(props, 'y')).extent(extent || getExtent(props)); - - // Create an array of polygons corresponding to the cells in voronoi - var polygons = voronoiInstance.polygons(nodes); - - // Create helper function to handle special logic for touch events - var handleTouchEvent = function handleTouchEvent(handler) { - return function (evt) { - evt.preventDefault(); - var index = getNodeIndex(evt); - if (index > -1 && index < polygons.length) { - var d = polygons[index]; - handler(d.data); - } - }; - }; - - return _react2.default.createElement( - 'g', - { - className: className + ' rv-voronoi', - style: style - // Because of the nature of how touch events, and more specifically touchmove - // and how it differs from mouseover, we must manage touch events on the parent - , onTouchEnd: handleTouchEvent(_onMouseUp), - onTouchStart: handleTouchEvent(_onMouseDown), - onTouchMove: handleTouchEvent(onHover), - onTouchCancel: handleTouchEvent(onBlur) - }, - polygons.map(function (d, i) { - return _react2.default.createElement('path', { - className: 'rv-voronoi__cell ' + (d.data && d.data.className || ''), - d: 'M' + d.join('L') + 'Z', - onClick: function onClick() { - return _onClick(d.data); - }, - onMouseUp: function onMouseUp() { - return _onMouseUp(d.data); - }, - onMouseDown: function onMouseDown() { - return _onMouseDown(d.data); - }, - onMouseOver: function onMouseOver() { - return onHover(d.data); - }, - onMouseOut: function onMouseOut() { - return onBlur(d.data); - }, - fill: 'none', - style: _extends({ - pointerEvents: 'all' - }, polygonStyle, d.data && d.data.style), - key: i - }); - }) - ); -} - -Voronoi.requiresSVG = true; -Voronoi.displayName = 'Voronoi'; -Voronoi.defaultProps = { - className: '', - onBlur: NOOP, - onClick: NOOP, - onHover: NOOP, - onMouseDown: NOOP, - onMouseUp: NOOP -}; - -Voronoi.propTypes = { - className: _propTypes2.default.string, - extent: _propTypes2.default.arrayOf(_propTypes2.default.arrayOf(_propTypes2.default.number)), - nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - onBlur: _propTypes2.default.func, - onClick: _propTypes2.default.func, - onHover: _propTypes2.default.func, - onMouseDown: _propTypes2.default.func, - onMouseUp: _propTypes2.default.func, - x: _propTypes2.default.func, - y: _propTypes2.default.func -}; - -exports.default = Voronoi; \ No newline at end of file diff --git a/dist/plot/xy-plot.js b/dist/plot/xy-plot.js deleted file mode 100644 index 5d5eec470..000000000 --- a/dist/plot/xy-plot.js +++ /dev/null @@ -1,660 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _deepEqual = require('deep-equal'); - -var _deepEqual2 = _interopRequireDefault(_deepEqual); - -var _scalesUtils = require('../utils/scales-utils'); - -var _seriesUtils = require('../utils/series-utils'); - -var _chartUtils = require('../utils/chart-utils'); - -var _animation = require('../animation'); - -var _theme = require('../theme'); - -var _canvasWrapper = require('./series/canvas-wrapper'); - -var _canvasWrapper2 = _interopRequireDefault(_canvasWrapper); - -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 _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; } - -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; } - -var ATTRIBUTES = ['x', 'y', 'radius', 'angle', 'color', 'fill', 'stroke', 'opacity', 'size']; - -/** - * Remove parents from tree formatted data. deep-equal doesnt play nice with data - * that has circular structures, so we make every node single directional by pruning the parents. - * @param {Array} data - the data object to have circular deps resolved in - * @returns {Array} the sanitized data - */ -function cleanseData(data) { - return data.map(function (series) { - if (!Array.isArray(series)) { - return series; - } - return series.map(function (row) { - return _extends({}, row, { parent: null }); - }); - }); -} - -/** - * Wrapper on the deep-equal method for checking equality of next props vs current props - * @param {Object} scaleMixins - Scale object. - * @param {Object} nextScaleMixins - Scale object. - * @param {Boolean} hasTreeStructure - Whether or not to cleanse the data of possible cyclic structures - * @returns {Boolean} whether or not the two mixins objects are equal - */ -function checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, hasTreeStructure) { - var newMixins = _extends({}, nextScaleMixins, { - _allData: hasTreeStructure ? cleanseData(nextScaleMixins._allData) : nextScaleMixins._allData - }); - var oldMixins = _extends({}, scaleMixins, { - _allData: hasTreeStructure ? cleanseData(scaleMixins._allData) : scaleMixins._allData - }); - // it's hard to say if this function is reasonable? - return (0, _deepEqual2.default)(newMixins, oldMixins); -} - -var XYPlot = function (_React$Component) { - _inherits(XYPlot, _React$Component); - - _createClass(XYPlot, null, [{ - key: 'defaultProps', - get: function get() { - return { - className: '' - }; - } - }, { - key: 'propTypes', - get: function get() { - return { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - dontCheckIfEmpty: _propTypes2.default.bool, - height: _propTypes2.default.number.isRequired, - margin: _chartUtils.MarginPropType, - onClick: _propTypes2.default.func, - onDoubleClick: _propTypes2.default.func, - onMouseDown: _propTypes2.default.func, - onMouseUp: _propTypes2.default.func, - onMouseEnter: _propTypes2.default.func, - onMouseLeave: _propTypes2.default.func, - onMouseMove: _propTypes2.default.func, - onTouchStart: _propTypes2.default.func, - onTouchMove: _propTypes2.default.func, - onTouchEnd: _propTypes2.default.func, - onTouchCancel: _propTypes2.default.func, - onWheel: _propTypes2.default.func, - stackBy: _propTypes2.default.oneOf(ATTRIBUTES), - style: _propTypes2.default.object, - width: _propTypes2.default.number.isRequired - }; - } - }]); - - function XYPlot(props) { - _classCallCheck(this, XYPlot); - - var _this = _possibleConstructorReturn(this, (XYPlot.__proto__ || Object.getPrototypeOf(XYPlot)).call(this, props)); - - _initialiseProps.call(_this); - - var stackBy = props.stackBy; - - var children = (0, _seriesUtils.getSeriesChildren)(props.children); - var data = (0, _seriesUtils.getStackedData)(children, stackBy); - _this.state = { - scaleMixins: _this._getScaleMixins(data, props), - data: data - }; - return _this; - } - - _createClass(XYPlot, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - var children = (0, _seriesUtils.getSeriesChildren)(nextProps.children); - var nextData = (0, _seriesUtils.getStackedData)(children, nextProps.stackBy); - var scaleMixins = this.state.scaleMixins; - - var nextScaleMixins = this._getScaleMixins(nextData, nextProps); - if (!checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, nextProps.hasTreeStructure)) { - this.setState({ - scaleMixins: nextScaleMixins, - data: nextData - }); - } - } - - /** - * Trigger click related callbacks if they are available. - * @param {React.SyntheticEvent} event Click event. - * @private - */ - - - /** - * Trigger doule-click related callbacks if they are available. - * @param {React.SyntheticEvent} event Double-click event. - * @private - */ - - }, { - key: '_getClonedChildComponents', - - - /** - * Prepare the child components (including series) for rendering. - * @returns {Array} Array of child components. - * @private - */ - value: function _getClonedChildComponents() { - var _this2 = this; - - var props = this.props; - var animation = this.props.animation; - var _state = this.state, - scaleMixins = _state.scaleMixins, - data = _state.data; - - var dimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS); - var children = _react2.default.Children.toArray(this.props.children); - var seriesProps = (0, _seriesUtils.getSeriesPropsFromChildren)(children); - var XYPlotValues = (0, _scalesUtils.getXYPlotValues)(props, children); - return children.map(function (child, index) { - var dataProps = null; - if (seriesProps[index]) { - // Get the index of the series in the list of props and retrieve - // the data property from it. - var seriesIndex = seriesProps[index].seriesIndex; - - dataProps = { data: data[seriesIndex] }; - } - return _react2.default.cloneElement(child, _extends({}, dimensions, { - animation: animation - }, dataProps && child.type.prototype && child.type.prototype.render ? { - ref: function ref(_ref) { - return _this2['series' + seriesProps[index].seriesIndex] = _ref; - } - } : {}, seriesProps[index], scaleMixins, child.props, XYPlotValues[index], dataProps)); - }); - } - /** - * Get the list of scale-related settings that should be applied by default. - * @param {Object} props Object of props. - * @returns {Object} Defaults. - * @private - */ - - }, { - key: '_getDefaultScaleProps', - value: function _getDefaultScaleProps(props) { - var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(props, _chartUtils.DEFAULT_MARGINS), - innerWidth = _getInnerDimensions.innerWidth, - innerHeight = _getInnerDimensions.innerHeight; - - var colorRanges = ['color', 'fill', 'stroke'].reduce(function (acc, attr) { - var range = props[attr + 'Type'] === 'category' ? _theme.EXTENDED_DISCRETE_COLOR_RANGE : _theme.CONTINUOUS_COLOR_RANGE; - return _extends({}, acc, _defineProperty({}, attr + 'Range', range)); - }, {}); - - return _extends({ - xRange: [0, innerWidth], - yRange: [innerHeight, 0] - }, colorRanges, { - opacityType: _theme.OPACITY_TYPE, - sizeRange: _theme.SIZE_RANGE - }); - } - - /** - * Get the map of scales from the props, apply defaults to them and then pass - * them further. - * @param {Object} data Array of all data. - * @param {Object} props Props of the component. - * @returns {Object} Map of scale-related props. - * @private - */ - - }, { - key: '_getScaleMixins', - value: function _getScaleMixins(data, props) { - var _ref2; - - var filteredData = data.filter(function (d) { - return d; - }); - var allData = (_ref2 = []).concat.apply(_ref2, _toConsumableArray(filteredData)); - - var defaultScaleProps = this._getDefaultScaleProps(props); - var optionalScaleProps = (0, _scalesUtils.getOptionalScaleProps)(props); - var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); - var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, optionalScaleProps, userScaleProps), allData, ATTRIBUTES); - var children = (0, _seriesUtils.getSeriesChildren)(props.children); - var zeroBaseProps = {}; - var adjustBy = new Set(); - var adjustWhat = new Set(); - children.forEach(function (child, index) { - if (!child || !data[index]) { - return; - } - ATTRIBUTES.forEach(function (attr) { - var _child$type$getParent = child.type.getParentConfig(attr, child.props), - isDomainAdjustmentNeeded = _child$type$getParent.isDomainAdjustmentNeeded, - zeroBaseValue = _child$type$getParent.zeroBaseValue; - - if (isDomainAdjustmentNeeded) { - adjustBy.add(attr); - adjustWhat.add(index); - } - if (zeroBaseValue) { - var specifiedDomain = props[attr + 'Domain']; - zeroBaseProps[attr + 'BaseValue'] = specifiedDomain ? specifiedDomain[0] : 0; - } - }); - }); - return _extends({}, defaultScaleProps, zeroBaseProps, userScaleProps, missingScaleProps, { - _allData: data, - _adjustBy: Array.from(adjustBy), - _adjustWhat: Array.from(adjustWhat), - _stackBy: props.stackBy - }); - } - - /** - * Checks if the plot is empty or not. - * Currently checks the data only. - * @returns {boolean} True for empty. - * @private - */ - - }, { - key: '_isPlotEmpty', - value: function _isPlotEmpty() { - var data = this.state.data; - - return !data || !data.length || !data.some(function (series) { - return series && series.some(function (d) { - return d; - }); - }); - } - - /** - * Trigger mouse-down related callbacks if they are available. - * @param {React.SyntheticEvent} event Mouse down event. - * @private - */ - - - /** - * Trigger onMouseEnter handler if it was passed in props. - * @param {React.SyntheticEvent} event Mouse enter event. - * @private - */ - - - /** - * Trigger onMouseLeave handler if it was passed in props. - * @param {React.SyntheticEvent} event Mouse leave event. - * @private - */ - - - /** - * Trigger movement-related callbacks if they are available. - * @param {React.SyntheticEvent} event Mouse move event. - * @private - */ - - - /** - * Trigger mouse-up related callbacks if they are available. - * @param {React.SyntheticEvent} event Mouse up event. - * @private - */ - - - /** - * Trigger onTouchCancel handler if it was passed in props. - * @param {React.SyntheticEvent} event Touch Cancel event. - * @private - */ - - - /** - * Trigger onTouchEnd handler if it was passed in props. - * @param {React.SyntheticEvent} event Touch End event. - * @private - */ - - - /** - * Trigger touch movement-related callbacks if they are available. - * @param {React.SyntheticEvent} event Touch move event. - * @private - */ - - - /** - * Trigger touch-start related callbacks if they are available. - * @param {React.SyntheticEvent} event Touch start event. - * @private - */ - - - /** - * Trigger doule-click related callbacks if they are available. - * @param {React.SyntheticEvent} event Double-click event. - * @private - */ - - }, { - key: 'renderCanvasComponents', - value: function renderCanvasComponents(components, props) { - var componentsToRender = components.filter(function (c) { - return c && !c.type.requiresSVG && c.type.isCanvas; - }); - - if (componentsToRender.length === 0) { - return null; - } - var _componentsToRender$ = componentsToRender[0].props, - marginLeft = _componentsToRender$.marginLeft, - marginTop = _componentsToRender$.marginTop, - marginBottom = _componentsToRender$.marginBottom, - marginRight = _componentsToRender$.marginRight, - innerHeight = _componentsToRender$.innerHeight, - innerWidth = _componentsToRender$.innerWidth; - - return _react2.default.createElement( - _canvasWrapper2.default, - { - innerHeight: innerHeight, - innerWidth: innerWidth, - marginLeft: marginLeft, - marginTop: marginTop, - marginBottom: marginBottom, - marginRight: marginRight - }, - componentsToRender - ); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - className = _props.className, - dontCheckIfEmpty = _props.dontCheckIfEmpty, - style = _props.style, - width = _props.width, - height = _props.height; - - - if (!dontCheckIfEmpty && this._isPlotEmpty()) { - return _react2.default.createElement('div', { - className: 'rv-xy-plot ' + className, - style: _extends({ - width: width + 'px', - height: height + 'px' - }, this.props.style) - }); - } - var components = this._getClonedChildComponents(); - return _react2.default.createElement( - 'div', - { - style: { - width: width + 'px', - height: height + 'px' - }, - className: 'rv-xy-plot ' + className - }, - _react2.default.createElement( - 'svg', - { - className: 'rv-xy-plot__inner', - width: width, - height: height, - style: style, - onClick: this._clickHandler, - onDoubleClick: this._doubleClickHandler, - onMouseDown: this._mouseDownHandler, - onMouseUp: this._mouseUpHandler, - onMouseMove: this._mouseMoveHandler, - onMouseLeave: this._mouseLeaveHandler, - onMouseEnter: this._mouseEnterHandler, - onTouchStart: this._mouseDownHandler, - onTouchMove: this._touchMoveHandler, - onTouchEnd: this._touchEndHandler, - onTouchCancel: this._touchCancelHandler, - onWheel: this._wheelHandler - }, - components.filter(function (c) { - return c && c.type.requiresSVG; - }) - ), - this.renderCanvasComponents(components, this.props), - components.filter(function (c) { - return c && !c.type.requiresSVG && !c.type.isCanvas; - }) - ); - } - }]); - - return XYPlot; -}(_react2.default.Component); - -var _initialiseProps = function _initialiseProps() { - var _this3 = this; - - this._clickHandler = function (event) { - var onClick = _this3.props.onClick; - - if (onClick) { - onClick(event); - } - }; - - this._doubleClickHandler = function (event) { - var onDoubleClick = _this3.props.onDoubleClick; - - if (onDoubleClick) { - onDoubleClick(event); - } - }; - - this._mouseDownHandler = function (event) { - var _props2 = _this3.props, - onMouseDown = _props2.onMouseDown, - children = _props2.children; - - if (onMouseDown) { - onMouseDown(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseDown) { - component.onParentMouseDown(event); - } - }); - }; - - this._mouseEnterHandler = function (event) { - var _props3 = _this3.props, - onMouseEnter = _props3.onMouseEnter, - children = _props3.children; - - if (onMouseEnter) { - onMouseEnter(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseEnter) { - component.onParentMouseEnter(event); - } - }); - }; - - this._mouseLeaveHandler = function (event) { - var _props4 = _this3.props, - onMouseLeave = _props4.onMouseLeave, - children = _props4.children; - - if (onMouseLeave) { - onMouseLeave(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseLeave) { - component.onParentMouseLeave(event); - } - }); - }; - - this._mouseMoveHandler = function (event) { - var _props5 = _this3.props, - onMouseMove = _props5.onMouseMove, - children = _props5.children; - - if (onMouseMove) { - onMouseMove(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseMove) { - component.onParentMouseMove(event); - } - }); - }; - - this._mouseUpHandler = function (event) { - var _props6 = _this3.props, - onMouseUp = _props6.onMouseUp, - children = _props6.children; - - if (onMouseUp) { - onMouseUp(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseUp) { - component.onParentMouseUp(event); - } - }); - }; - - this._touchCancelHandler = function (event) { - var onTouchCancel = _this3.props.onTouchCancel; - - if (onTouchCancel) { - onTouchCancel(event); - } - }; - - this._touchEndHandler = function (event) { - var onTouchEnd = _this3.props.onTouchEnd; - - if (onTouchEnd) { - onTouchEnd(event); - } - }; - - this._touchMoveHandler = function (event) { - var _props7 = _this3.props, - onTouchMove = _props7.onTouchMove, - children = _props7.children; - - if (onTouchMove) { - onTouchMove(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentTouchMove) { - component.onParentTouchMove(event); - } - }); - }; - - this._touchStartHandler = function (event) { - var _props8 = _this3.props, - onTouchStart = _props8.onTouchStart, - children = _props8.children; - - if (onTouchStart) { - onTouchStart(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentTouchStart) { - component.onParentTouchStart(event); - } - }); - }; - - this._wheelHandler = function (event) { - var onWheel = _this3.props.onWheel; - - if (onWheel) { - onWheel(event); - } - }; -}; - -XYPlot.displayName = 'XYPlot'; - -exports.default = XYPlot; \ No newline at end of file diff --git a/dist/radar-chart/index.js b/dist/radar-chart/index.js deleted file mode 100644 index b1f659dfd..000000000 --- a/dist/radar-chart/index.js +++ /dev/null @@ -1,418 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Scale = require('d3-scale'); - -var _d3Format = require('d3-format'); - -var _animation = require('../animation'); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _theme = require('../theme'); - -var _chartUtils = require('../utils/chart-utils'); - -var _markSeries = require('../plot/series/mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -var _polygonSeries = require('../plot/series/polygon-series'); - -var _polygonSeries2 = _interopRequireDefault(_polygonSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _decorativeAxis = require('../plot/axis/decorative-axis'); - -var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var predefinedClassName = 'rv-radar-chart'; -var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); -/** - * Generate axes for each of the domains - * @param {Object} props - - props.animation {Boolean} - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for the whole chart - - props.tickFormat {Function} formatting function for axes - - props.startingAngle {number} the initial angle offset - * @return {Array} the plotted axis components - */ -function getAxes(props) { - var animation = props.animation, - domains = props.domains, - startingAngle = props.startingAngle, - style = props.style, - tickFormat = props.tickFormat, - hideInnerMostValues = props.hideInnerMostValues; - - return domains.map(function (domain, index) { - var angle = index / domains.length * Math.PI * 2 + startingAngle; - var sortedDomain = domain.domain; - - var domainTickFormat = function domainTickFormat(t) { - if (hideInnerMostValues && t === sortedDomain[0]) { - return ''; - } - return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); - }; - - return _react2.default.createElement(_decorativeAxis2.default, { - animation: animation, - key: index + '-axis', - axisStart: { x: 0, y: 0 }, - axisEnd: { - x: getCoordinate(Math.cos(angle)), - y: getCoordinate(Math.sin(angle)) - }, - axisDomain: sortedDomain, - numberOfTicks: 5, - tickValue: domainTickFormat, - style: style.axes - }); - }); -} - -/** - * Generate x or y coordinate for axisEnd - * @param {Number} axisEndPoint - - epsilon is an arbitrarily chosen small number to approximate axisEndPoints - - to true values resulting from trigonometry functions (sin, cos) on angles - * @return {Number} the x or y coordinate accounting for exact trig values - */ -function getCoordinate(axisEndPoint) { - var epsilon = 10e-13; - if (Math.abs(axisEndPoint) <= epsilon) { - axisEndPoint = 0; - } else if (axisEndPoint > 0) { - if (Math.abs(axisEndPoint - 0.5) <= epsilon) { - axisEndPoint = 0.5; - } - } else if (axisEndPoint < 0) { - if (Math.abs(axisEndPoint + 0.5) <= epsilon) { - axisEndPoint = -0.5; - } - } - return axisEndPoint; -} - -/** - * Generate labels for the ends of the axes - * @param {Object} props - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.startingAngle {number} the initial angle offset - - props.style {object} style object for just the labels - * @return {Array} the prepped data for the labelSeries - */ -function getLabels(props) { - var domains = props.domains, - startingAngle = props.startingAngle, - style = props.style; - - return domains.map(function (_ref, index) { - var name = _ref.name; - - var angle = index / domains.length * Math.PI * 2 + startingAngle; - var radius = 1.2; - return { - x: radius * Math.cos(angle), - y: radius * Math.sin(angle), - label: name, - style: style - }; - }); -} - -/** - * Generate the actual polygons to be plotted - * @param {Object} props - - props.animation {Boolean} - - props.data {Array} array of object specifying what values are to be plotted - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.startingAngle {number} the initial angle offset - - props.style {object} style object for the whole chart - * @return {Array} the plotted axis components - */ -function getPolygons(props) { - var animation = props.animation, - colorRange = props.colorRange, - domains = props.domains, - data = props.data, - style = props.style, - startingAngle = props.startingAngle, - onSeriesMouseOver = props.onSeriesMouseOver, - onSeriesMouseOut = props.onSeriesMouseOut; - - var scales = domains.reduce(function (acc, _ref2) { - var domain = _ref2.domain, - name = _ref2.name; - - acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); - return acc; - }, {}); - - return data.map(function (row, rowIndex) { - var mappedData = domains.map(function (_ref3, index) { - var name = _ref3.name, - getValue = _ref3.getValue; - - var dataPoint = getValue ? getValue(row) : row[name]; - // error handling if point doesn't exist - var angle = index / domains.length * Math.PI * 2 + startingAngle; - // dont let the radius become negative - var radius = Math.max(scales[name](dataPoint), 0); - return { x: radius * Math.cos(angle), y: radius * Math.sin(angle), name: row.name }; - }); - - return _react2.default.createElement(_polygonSeries2.default, { - animation: animation, - className: predefinedClassName + '-polygon', - key: rowIndex + '-polygon', - data: mappedData, - style: _extends({ - stroke: row.color || row.stroke || colorRange[rowIndex % colorRange.length], - fill: row.color || row.fill || colorRange[rowIndex % colorRange.length] - }, style.polygons), - onSeriesMouseOver: onSeriesMouseOver, - onSeriesMouseOut: onSeriesMouseOut - }); - }); -} - -/** - * Generate circles at the polygon points for Hover functionality - * @param {Object} props - - props.animation {Boolean} - - props.data {Array} array of object specifying what values are to be plotted - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.startingAngle {number} the initial angle offset - - props.style {object} style object for the whole chart - - props.onValueMouseOver {function} function to call on mouse over a polygon point - - props.onValueMouseOver {function} function to call when mouse leaves a polygon point - * @return {Array} the plotted axis components - */ -function getPolygonPoints(props) { - var animation = props.animation, - domains = props.domains, - data = props.data, - startingAngle = props.startingAngle, - style = props.style, - onValueMouseOver = props.onValueMouseOver, - onValueMouseOut = props.onValueMouseOut; - - if (!onValueMouseOver) { - return; - } - var scales = domains.reduce(function (acc, _ref4) { - var domain = _ref4.domain, - name = _ref4.name; - - acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); - return acc; - }, {}); - return data.map(function (row, rowIndex) { - var mappedData = domains.map(function (_ref5, index) { - var name = _ref5.name, - getValue = _ref5.getValue; - - var dataPoint = getValue ? getValue(row) : row[name]; - // error handling if point doesn't exist - var angle = index / domains.length * Math.PI * 2 + startingAngle; - // dont let the radius become negative - var radius = Math.max(scales[name](dataPoint), 0); - return { - x: radius * Math.cos(angle), - y: radius * Math.sin(angle), - domain: name, - value: dataPoint, - dataName: row.name - }; - }); - - return _react2.default.createElement(_markSeries2.default, { - animation: animation, - className: predefinedClassName + '-polygonPoint', - key: rowIndex + '-polygonPoint', - data: mappedData, - size: 10, - style: _extends({}, style.polygons, { - fill: 'transparent', - stroke: 'transparent' - }), - onValueMouseOver: onValueMouseOver, - onValueMouseOut: onValueMouseOut - }); - }); -} - -function RadarChart(props) { - var animation = props.animation, - className = props.className, - children = props.children, - colorRange = props.colorRange, - data = props.data, - domains = props.domains, - height = props.height, - hideInnerMostValues = props.hideInnerMostValues, - margin = props.margin, - onMouseLeave = props.onMouseLeave, - onMouseEnter = props.onMouseEnter, - startingAngle = props.startingAngle, - style = props.style, - tickFormat = props.tickFormat, - width = props.width, - renderAxesOverPolygons = props.renderAxesOverPolygons, - onValueMouseOver = props.onValueMouseOver, - onValueMouseOut = props.onValueMouseOut, - onSeriesMouseOver = props.onSeriesMouseOver, - onSeriesMouseOut = props.onSeriesMouseOut; - - - var axes = getAxes({ - domains: domains, - animation: animation, - hideInnerMostValues: hideInnerMostValues, - startingAngle: startingAngle, - style: style, - tickFormat: tickFormat - }); - - var polygons = getPolygons({ - animation: animation, - colorRange: colorRange, - domains: domains, - data: data, - startingAngle: startingAngle, - style: style, - onSeriesMouseOver: onSeriesMouseOver, - onSeriesMouseOut: onSeriesMouseOut - }); - - var polygonPoints = getPolygonPoints({ - animation: animation, - colorRange: colorRange, - domains: domains, - data: data, - startingAngle: startingAngle, - style: style, - onValueMouseOver: onValueMouseOver, - onValueMouseOut: onValueMouseOut - }); - - var labelSeries = _react2.default.createElement(_labelSeries2.default, { - animation: animation, - key: className, - className: predefinedClassName + '-label', - data: getLabels({ domains: domains, style: style.labels, startingAngle: startingAngle }) }); - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - width: width, - margin: margin, - dontCheckIfEmpty: true, - className: className + ' ' + predefinedClassName, - onMouseLeave: onMouseLeave, - onMouseEnter: onMouseEnter, - xDomain: [-1, 1], - yDomain: [-1, 1] }, - children, - !renderAxesOverPolygons && axes.concat(polygons).concat(labelSeries).concat(polygonPoints), - renderAxesOverPolygons && polygons.concat(labelSeries).concat(axes).concat(polygonPoints) - ); -} - -RadarChart.displayName = 'RadarChart'; -RadarChart.propTypes = { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), - data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - name: _propTypes2.default.string.isRequired, - domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, - tickFormat: _propTypes2.default.func - })).isRequired, - height: _propTypes2.default.number.isRequired, - hideInnerMostValues: _propTypes2.default.bool, - margin: _chartUtils.MarginPropType, - startingAngle: _propTypes2.default.number, - style: _propTypes2.default.shape({ - axes: _propTypes2.default.object, - labels: _propTypes2.default.object, - polygons: _propTypes2.default.object - }), - tickFormat: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired, - renderAxesOverPolygons: _propTypes2.default.bool, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - onSeriesMouseOver: _propTypes2.default.func, - onSeriesMouseOut: _propTypes2.default.func -}; -RadarChart.defaultProps = { - className: '', - colorType: 'category', - colorRange: _theme.DISCRETE_COLOR_RANGE, - hideInnerMostValues: true, - startingAngle: Math.PI / 2, - style: { - axes: { - line: {}, - ticks: {}, - text: {} - }, - labels: { - fontSize: 10, - textAnchor: 'middle' - }, - polygons: { - strokeWidth: 0.5, - strokeOpacity: 1, - fillOpacity: 0.1 - } - }, - tickFormat: DEFAULT_FORMAT, - renderAxesOverPolygons: false -}; - -exports.default = RadarChart; \ No newline at end of file diff --git a/dist/radial-chart/index.js b/dist/radial-chart/index.js deleted file mode 100644 index a43e58552..000000000 --- a/dist/radial-chart/index.js +++ /dev/null @@ -1,263 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Shape = require('d3-shape'); - -var _animation = require('../animation'); - -var _arcSeries = require('../plot/series/arc-series'); - -var _arcSeries2 = _interopRequireDefault(_arcSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _theme = require('../theme'); - -var _chartUtils = require('../utils/chart-utils'); - -var _seriesUtils = require('../utils/series-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var predefinedClassName = 'rv-radial-chart'; - -var DEFAULT_RADIUS_MARGIN = 15; - -/** - * Create the list of wedges to render. - * @param {Object} props - props.data {Object} - tree structured data (each node has a name anc an array of children) - * @returns {Array} Array of nodes. - */ -function getWedgesToRender(_ref) { - var data = _ref.data, - getAngle = _ref.getAngle; - - var pie = (0, _d3Shape.pie)().sort(null).value(getAngle); - var pieData = pie(data).reverse(); - return pieData.map(function (row, index) { - return _extends({}, row.data, { - angle0: row.startAngle, - angle: row.endAngle, - radius0: row.data.innerRadius || 0, - radius: row.data.radius || 1, - color: row.data.color || index - }); - }); -} - -function generateLabels(mappedData, accessors) { - var labelsRadiusMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.1; - var getLabel = accessors.getLabel, - getSubLabel = accessors.getSubLabel; - - return mappedData.reduce(function (res, row) { - var angle = row.angle, - angle0 = row.angle0, - radius = row.radius; - - var centeredAngle = (angle + angle0) / 2; - - // unfortunate, but true fact: d3 starts its radians at 12 oclock rather than 3 - // and move clockwise rather than counter clockwise. why why why! - var updatedAngle = -1 * centeredAngle + Math.PI / 2; - var newLabels = []; - if (getLabel(row)) { - newLabels.push({ - angle: updatedAngle, - radius: radius * labelsRadiusMultiplier, - label: getLabel(row) - }); - } - - if (getSubLabel(row)) { - newLabels.push({ - angle: updatedAngle, - radius: radius * labelsRadiusMultiplier, - label: getSubLabel(row), - style: { fontSize: 10 }, - yOffset: 12 - }); - } - return res.concat(newLabels); - }, []); - // could add force direction here to make sure the labels dont overlap -} - -/** - * Get the max radius so the chart can extend to the margin. - * @param {Number} width - container width - * @param {Number} height - container height - * @return {Number} radius - */ -function getMaxRadius(width, height) { - return Math.min(width, height) / 2 - DEFAULT_RADIUS_MARGIN; -} - -function RadialChart(props) { - var animation = props.animation, - className = props.className, - children = props.children, - colorType = props.colorType, - data = props.data, - getAngle = props.getAngle, - getLabel = props.getLabel, - getSubLabel = props.getSubLabel, - height = props.height, - hideRootNode = props.hideRootNode, - innerRadius = props.innerRadius, - labelsAboveChildren = props.labelsAboveChildren, - labelsRadiusMultiplier = props.labelsRadiusMultiplier, - labelsStyle = props.labelsStyle, - margin = props.margin, - onMouseLeave = props.onMouseLeave, - onMouseEnter = props.onMouseEnter, - radius = props.radius, - showLabels = props.showLabels, - style = props.style, - width = props.width; - - var mappedData = getWedgesToRender({ - data: data, - height: height, - hideRootNode: hideRootNode, - width: width, - getAngle: getAngle - }); - var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); - var arcProps = _extends({ - colorType: colorType - }, props, { - animation: animation, - radiusDomain: [0, radialDomain], - data: mappedData, - radiusNoFallBack: true, - style: style, - arcClassName: 'rv-radial-chart__series--pie__slice' - }); - if (radius) { - arcProps.radiusDomain = [0, 1]; - arcProps.radiusRange = [innerRadius || 0, radius]; - arcProps.radiusType = 'linear'; - } - var maxRadius = radius ? radius : getMaxRadius(width, height); - var defaultMargin = (0, _chartUtils.getRadialLayoutMargin)(width, height, maxRadius); - - var labels = generateLabels(mappedData, { - getLabel: getLabel, - getSubLabel: getSubLabel - }, labelsRadiusMultiplier); - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - width: width, - margin: _extends({}, margin, defaultMargin), - className: className + ' ' + predefinedClassName, - onMouseLeave: onMouseLeave, - onMouseEnter: onMouseEnter, - xDomain: [-radialDomain, radialDomain], - yDomain: [-radialDomain, radialDomain] - }, - _react2.default.createElement(_arcSeries2.default, _extends({}, arcProps, { getAngle: function getAngle(d) { - return d.angle; - } })), - showLabels && !labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }), - children, - showLabels && labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }) - ); -} - -RadialChart.displayName = 'RadialChart'; -RadialChart.propTypes = { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - angle: _propTypes2.default.number, - className: _propTypes2.default.string, - label: _propTypes2.default.string, - radius: _propTypes2.default.number, - style: _propTypes2.default.object - })).isRequired, - getAngle: _propTypes2.default.func, - getAngle0: _propTypes2.default.func, - padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]), - getRadius: _propTypes2.default.func, - getRadius0: _propTypes2.default.func, - getLabel: _propTypes2.default.func, - height: _propTypes2.default.number.isRequired, - labelsAboveChildren: _propTypes2.default.bool, - labelsStyle: _propTypes2.default.object, - margin: _chartUtils.MarginPropType, - onValueClick: _propTypes2.default.func, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - showLabels: _propTypes2.default.bool, - style: _propTypes2.default.object, - subLabel: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired -}; -RadialChart.defaultProps = { - className: '', - colorType: 'category', - colorRange: _theme.DISCRETE_COLOR_RANGE, - padAngle: 0, - getAngle: function getAngle(d) { - return d.angle; - }, - getAngle0: function getAngle0(d) { - return d.angle0; - }, - getRadius: function getRadius(d) { - return d.radius; - }, - getRadius0: function getRadius0(d) { - return d.radius0; - }, - getLabel: function getLabel(d) { - return d.label; - }, - getSubLabel: function getSubLabel(d) { - return d.subLabel; - } -}; - -exports.default = RadialChart; \ No newline at end of file diff --git a/dist/sankey/index.js b/dist/sankey/index.js deleted file mode 100644 index 55b694d88..000000000 --- a/dist/sankey/index.js +++ /dev/null @@ -1,238 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Sankey = require('d3-sankey'); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _chartUtils = require('../utils/chart-utils'); - -var _verticalRectSeries = require('../plot/series/vertical-rect-series'); - -var _verticalRectSeries2 = _interopRequireDefault(_verticalRectSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _voronoi = require('../plot/voronoi'); - -var _voronoi2 = _interopRequireDefault(_voronoi); - -var _theme = require('../theme'); - -var _sankeyLink = require('./sankey-link'); - -var _sankeyLink2 = _interopRequireDefault(_sankeyLink); - -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); } } - -var NOOP = function NOOP(f) { - return f; -}; - -var ALIGNMENTS = { - justify: _d3Sankey.sankeyJustify, - center: _d3Sankey.sankeyCenter, - left: _d3Sankey.sankeyLeft, - right: _d3Sankey.sankeyRight -}; - -var DEFAULT_MARGINS = { - top: 20, - left: 20, - right: 20, - bottom: 20 -}; - -function Sankey(props) { - var align = props.align, - animation = props.animation, - children = props.children, - className = props.className, - hasVoronoi = props.hasVoronoi, - height = props.height, - hideLabels = props.hideLabels, - labelRotation = props.labelRotation, - layout = props.layout, - links = props.links, - linkOpacity = props.linkOpacity, - margin = props.margin, - nodePadding = props.nodePadding, - nodes = props.nodes, - nodeWidth = props.nodeWidth, - onValueClick = props.onValueClick, - onValueMouseOver = props.onValueMouseOver, - onValueMouseOut = props.onValueMouseOut, - onLinkClick = props.onLinkClick, - onLinkMouseOver = props.onLinkMouseOver, - onLinkMouseOut = props.onLinkMouseOut, - style = props.style, - width = props.width; - - var nodesCopy = [].concat(_toConsumableArray(new Array(nodes.length))).map(function (e, i) { - return _extends({}, nodes[i]); - }); - var linksCopy = [].concat(_toConsumableArray(new Array(links.length))).map(function (e, i) { - return _extends({}, links[i]); - }); - - var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)({ - margin: margin, - height: height, - width: width - }, DEFAULT_MARGINS), - marginLeft = _getInnerDimensions.marginLeft, - marginTop = _getInnerDimensions.marginTop, - marginRight = _getInnerDimensions.marginRight, - marginBottom = _getInnerDimensions.marginBottom; - - var sankeyInstance = (0, _d3Sankey.sankey)().extent([[marginLeft, marginTop], [width - marginRight, height - marginBottom - marginTop]]).nodeWidth(nodeWidth).nodePadding(nodePadding).nodes(nodesCopy).links(linksCopy).nodeAlign(ALIGNMENTS[align]).iterations(layout); - sankeyInstance(nodesCopy); - - var nWidth = sankeyInstance.nodeWidth(); - var path = (0, _d3Sankey.sankeyLinkHorizontal)(); - - return _react2.default.createElement( - _xyPlot2.default, - _extends({}, props, { yType: 'literal', className: 'rv-sankey ' + className }), - linksCopy.map(function (link, i) { - return _react2.default.createElement(_sankeyLink2.default, { - style: style.links, - data: path(link), - opacity: link.opacity || linkOpacity, - color: link.color, - onLinkClick: onLinkClick, - onLinkMouseOver: onLinkMouseOver, - onLinkMouseOut: onLinkMouseOut, - strokeWidth: Math.max(link.width, 1), - node: link, - nWidth: nWidth, - key: 'link-' + i - }); - }), - _react2.default.createElement(_verticalRectSeries2.default, { - animation: animation, - className: className + ' rv-sankey__node', - data: nodesCopy.map(function (node) { - return _extends({}, node, { - y: node.y1 - marginTop, - y0: node.y0 - marginTop, - x: node.x1, - x0: node.x0, - color: node.color || _theme.DISCRETE_COLOR_RANGE[0], - sourceLinks: null, - targetLinks: null - }); - }), - style: style.rects, - onValueClick: onValueClick, - onValueMouseOver: onValueMouseOver, - onValueMouseOut: onValueMouseOut, - colorType: 'literal' - }), - !hideLabels && _react2.default.createElement(_labelSeries2.default, { - animation: animation, - className: className, - rotation: labelRotation, - labelAnchorY: 'text-before-edge', - data: nodesCopy.map(function (node, i) { - return _extends({ - x: node.x0 + (node.x0 < width / 2 ? nWidth + 10 : -10), - y: (node.y0 + node.y1) / 2 - marginTop, - label: node.name, - style: _extends({ - textAnchor: node.x0 < width / 2 ? 'start' : 'end', - dy: '-.5em' - }, style.labels) - }, nodes[i]); - }) - }), - hasVoronoi && _react2.default.createElement(_voronoi2.default, { - className: 'rv-sankey__voronoi', - extent: [[-marginLeft, -marginTop], [width + marginRight, height + marginBottom]], - nodes: nodesCopy, - onClick: onValueClick, - onHover: onValueMouseOver, - onBlur: onValueMouseOut, - x: function x(d) { - return d.x0 + (d.x1 - d.x0) / 2; - }, - y: function y(d) { - return d.y0 + (d.y1 - d.y0) / 2; - } - }), - children - ); -} - -Sankey.defaultProps = { - align: 'justify', - className: '', - hasVoronoi: false, - hideLabels: false, - labelRotation: 0, - layout: 50, - margin: DEFAULT_MARGINS, - nodePadding: 10, - nodeWidth: 10, - onValueMouseOver: NOOP, - onValueClick: NOOP, - onValueMouseOut: NOOP, - onLinkClick: NOOP, - onLinkMouseOver: NOOP, - onLinkMouseOut: NOOP, - style: { - links: {}, - rects: {}, - labels: {} - } -}; - -Sankey.propTypes = { - align: _propTypes2.default.oneOf(['justify', 'left', 'right', 'center']), - className: _propTypes2.default.string, - hasVoronoi: _propTypes2.default.bool, - height: _propTypes2.default.number.isRequired, - hideLabels: _propTypes2.default.bool, - labelRotation: _propTypes2.default.number, - layout: _propTypes2.default.number, - links: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - source: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired, - target: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired - })).isRequired, - margin: _chartUtils.MarginPropType, - nodePadding: _propTypes2.default.number, - nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - nodeWidth: _propTypes2.default.number, - onValueMouseOver: _propTypes2.default.func, - onValueClick: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - onLinkClick: _propTypes2.default.func, - onLinkMouseOver: _propTypes2.default.func, - onLinkMouseOut: _propTypes2.default.func, - style: _propTypes2.default.shape({ - links: _propTypes2.default.object, - rects: _propTypes2.default.object, - labels: _propTypes2.default.object - }), - width: _propTypes2.default.number.isRequired -}; -exports.default = Sankey; \ No newline at end of file diff --git a/dist/sankey/sankey-link.js b/dist/sankey/sankey-link.js deleted file mode 100644 index d664e22d6..000000000 --- a/dist/sankey/sankey-link.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _theme = require('../theme'); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../utils/series-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var DEFAULT_LINK_COLOR = _theme.DISCRETE_COLOR_RANGE[1]; -var DEFAULT_LINK_OPACITY = 0.7; - -function SankeyLink(props) { - var animation = props.animation, - data = props.data, - node = props.node, - opacity = props.opacity, - color = props.color, - strokeWidth = props.strokeWidth, - style = props.style, - onLinkClick = props.onLinkClick, - onLinkMouseOver = props.onLinkMouseOver, - onLinkMouseOut = props.onLinkMouseOut; - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(SankeyLink, _extends({}, props, { animation: null })) - ); - } - return _react2.default.createElement('path', _extends({ - d: data - }, style, { - className: 'rv-sankey__link', - opacity: Number.isFinite(opacity) ? opacity : DEFAULT_LINK_OPACITY, - stroke: color || DEFAULT_LINK_COLOR, - onClick: function onClick(e) { - return onLinkClick(node, e); - }, - onMouseOver: function onMouseOver(e) { - return onLinkMouseOver(node, e); - }, - onMouseOut: function onMouseOut(e) { - return onLinkMouseOut(node, e); - }, - strokeWidth: strokeWidth, - fill: 'none' - })); -} - -SankeyLink.displayName = 'SankeyLink'; -SankeyLink.requiresSVG = true; -exports.default = SankeyLink; \ No newline at end of file diff --git a/dist/style.css b/dist/style.css deleted file mode 100644 index 42d247c14..000000000 --- a/dist/style.css +++ /dev/null @@ -1 +0,0 @@ -.react-vis-magic-css-import-rule{display:inherit}.rv-treemap{font-size:12px;position:relative}.rv-treemap__leaf{overflow:hidden;position:absolute}.rv-treemap__leaf--circle{align-items:center;border-radius:100%;display:flex;justify-content:center}.rv-treemap__leaf__content{overflow:hidden;padding:10px;text-overflow:ellipsis}.rv-xy-plot{color:#c3c3c3;position:relative}.rv-xy-plot canvas{pointer-events:none}.rv-xy-plot .rv-xy-canvas{pointer-events:none;position:absolute}.rv-xy-plot__inner{display:block}.rv-xy-plot__axis__line{fill:none;stroke-width:2px;stroke:#e6e6e9}.rv-xy-plot__axis__tick__line{stroke:#e6e6e9}.rv-xy-plot__axis__tick__text{fill:#6b6b76;font-size:11px}.rv-xy-plot__axis__title text{fill:#6b6b76;font-size:11px}.rv-xy-plot__grid-lines__line{stroke:#e6e6e9}.rv-xy-plot__circular-grid-lines__line{fill-opacity:0;stroke:#e6e6e9}.rv-xy-plot__series,.rv-xy-plot__series path{pointer-events:all}.rv-xy-plot__series--line{fill:none;stroke:#000;stroke-width:2px}.rv-crosshair{position:absolute;font-size:11px;pointer-events:none}.rv-crosshair__line{background:#47d3d9;width:1px}.rv-crosshair__inner{position:absolute;text-align:left;top:0}.rv-crosshair__inner__content{border-radius:4px;background:#3a3a48;color:#fff;font-size:12px;padding:7px 10px;box-shadow:0 2px 4px rgba(0,0,0,0.5)}.rv-crosshair__inner--left{right:4px}.rv-crosshair__inner--right{left:4px}.rv-crosshair__title{font-weight:bold;white-space:nowrap}.rv-crosshair__item{white-space:nowrap}.rv-hint{position:absolute;pointer-events:none}.rv-hint__content{border-radius:4px;padding:7px 10px;font-size:12px;background:#3a3a48;box-shadow:0 2px 4px rgba(0,0,0,0.5);color:#fff;text-align:left;white-space:nowrap}.rv-discrete-color-legend{box-sizing:border-box;overflow-y:auto;font-size:12px}.rv-discrete-color-legend.horizontal{white-space:nowrap}.rv-discrete-color-legend-item{color:#3a3a48;border-radius:1px;padding:9px 10px}.rv-discrete-color-legend-item.horizontal{display:inline-block}.rv-discrete-color-legend-item.horizontal .rv-discrete-color-legend-item__title{margin-left:0;display:block}.rv-discrete-color-legend-item__color{display:inline-block;vertical-align:middle;overflow:visible}.rv-discrete-color-legend-item__color__path{stroke:#dcdcdc;stroke-width:2px}.rv-discrete-color-legend-item__title{margin-left:10px}.rv-discrete-color-legend-item.disabled{color:#b8b8b8}.rv-discrete-color-legend-item.clickable{cursor:pointer}.rv-discrete-color-legend-item.clickable:hover{background:#f9f9f9}.rv-search-wrapper{display:flex;flex-direction:column}.rv-search-wrapper__form{flex:0}.rv-search-wrapper__form__input{width:100%;color:#a6a6a5;border:1px solid #e5e5e4;padding:7px 10px;font-size:12px;box-sizing:border-box;border-radius:2px;margin:0 0 9px;outline:0}.rv-search-wrapper__contents{flex:1;overflow:auto}.rv-continuous-color-legend{font-size:12px}.rv-continuous-color-legend .rv-gradient{height:4px;border-radius:2px;margin-bottom:5px}.rv-continuous-size-legend{font-size:12px}.rv-continuous-size-legend .rv-bubbles{text-align:justify;overflow:hidden;margin-bottom:5px;width:100%}.rv-continuous-size-legend .rv-bubble{background:#d8d9dc;display:inline-block;vertical-align:bottom}.rv-continuous-size-legend .rv-spacer{display:inline-block;font-size:0;line-height:0;width:100%}.rv-legend-titles{height:16px;position:relative}.rv-legend-titles__left,.rv-legend-titles__right,.rv-legend-titles__center{position:absolute;white-space:nowrap;overflow:hidden}.rv-legend-titles__center{display:block;text-align:center;width:100%}.rv-legend-titles__right{right:0}.rv-radial-chart .rv-xy-plot__series--label{pointer-events:none} diff --git a/dist/styles/examples.scss b/dist/styles/examples.scss deleted file mode 100644 index 420cb2eb1..000000000 --- a/dist/styles/examples.scss +++ /dev/null @@ -1,461 +0,0 @@ -@import '../main.scss'; - -$black: #000; -$white: #fff; - -body { - font-family: Sintony, Helvetica, sans-serif; - font-size: 14px; - margin: 0; - padding: 0; -} - -h1, -h2, -h3, -h4, -h5 { - font-weight: normal; -} - -h1 { - font-size: 36px; - margin: 20px 0; -} - -h2 { - font-size: 24px; - margin: 15px 0; -} - -main { - padding: 40px 0; -} - -header { - background: #f0f0f0; - line-height: 40px; - position: fixed; - top: 0; - width: 100%; - z-index: 1000; -} - -.flex { - display: flex; -} - -.docs-link { - font-weight: 500; - font-size: 11px; - margin-right: 5px; - text-transform: uppercase; - border-left: 1px solid #c0c0c0; - padding-left: 5px; - line-height: 1; -} - -.docs-link:first-child { - border-left: 0px; - padding-left: 0px; -} - -.docs-comment { - display: flex; - max-width: 300px; -} - -.header-contents { - align-items: center; - display: flex; - justify-content: space-between; - padding: 0 20px; -} - -.header-logo { - color: $black; - float: left; - font-size: 20px; - text-decoration: none; -} - -.background-overlay { - bottom: 0; - left: 0; - position: fixed; - right: 0; - top: 0; - z-index: 1; -} - -.dropdown-button { - cursor: pointer; - z-index: 10; -} - -.dropdown-wrapper { - display: flex; - position: relative; - - .dropdown-inner-wrapper { - background: $white; - border: 2px solid $black; - display: flex; - flex-direction: column; - font-size: 11px; - height: auto; - list-style: none; - padding: 10px; - position: absolute; - right: -5px; - top: 25px; - width: 150px; - z-index: 10; - } - - a { - display: flex; - height: auto; - line-height: 15px; - text-decoration: none; - } - - li { - display: flex; - height: 100%; - } - - .subsection-label { - font-weight: 600; - line-height: 15px; - } -} - - -article { - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: flex-start; - margin: 0 auto; - max-width: 1200px; - min-width: 650px; - padding: 30px 20px 0; - - h1, - h2 { - flex: 1 100%; - - small { - color: #6b6b76; - font-size: 50%; - } - } - - section { - flex-basis: 400px; - flex-grow: 1; - margin: 0 0 40px; - } - - .section-title { - margin-bottom: 5px; - } - - .section-header { - margin-bottom: 1em; - } -} - -.click-me { - border: 0; - background: #ef5d28; - color: $white; - cursor: pointer; - font-family: Sintony, Helvetica, sans-serif; - font-size: 14px; - outline: none; - padding: 11px 20px; - text-transform: uppercase; - - &:hover { - background: #ff9833; - } - - animation: shake 5s 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite; - transform: translate3d(0, 0, 0); -} - -@keyframes shake { - 1%, - 9% { - transform: translate3d(-1px, 0, 0); - } - - 2%, - 8% { - transform: translate3d(2px, 0, 0); - } - - 3%, - 5%, - 7% { - transform: translate3d(-4px, 0, 0); - } - - 4%, - 6% { - transform: translate3d(4px, 0, 0); - } -} - -.example-with-click-me { - position: relative; - text-align: center; - width: 100%; - - &:hover { - .click-me { - animation: none; - } - } - - .chart { - margin-right: 200px; - .rv-xy-plot__axis__tick__line { - stroke: $rv-xy-plot-axis-font-color; - } - } - - .legend { - position: absolute; - text-align: left; - right: 0; - } -} - -.custom-hint { - background: #f9e7bb; - border-radius: 3px; - border: 1px solid #edaf00; - padding: 10px; - color: #333; - font-size: 10px; - position: relative; - margin: 12px 0 0 -10px; - - &::after { - border-radius: 5px; - border: 2px solid #edaf00; - background: $white; - display: block; - content: ' '; - height: 6px; - width: 6px; - top: -17px; - left: 5px; - position: absolute; - } -} - -.complex-hint { - margin-top: 40px; - - .rv-hint { - /* must be positioned in a parent with relative positioning */ - position: absolute; - width: 0; - height: 100%; - $hint-color: black; - $margin-left: 30px; - $margin-right: 10px; - $margin-top: 10px; - $margin-bottom: 25px; - - & .hint--text-container { - position: absolute; - - /* - * set to 0,0 so that its content (including children) - * can overflow out in vertical and horizontal - */ - width: 0; - height: 0; - - /* - * use flex to place its children (centered) and aligned (bottom). - * As its height is 0, align-items flex-end paints its items from cross-axis - * up. flex-start, its items would paint from cross-axis down. - */ - display: flex; - justify-content: center; - - &.rightEdge-top { - flex-direction: column-reverse; - align-items: flex-start; - } - - &.left-topEdge { - flex-direction: row; - align-items: flex-end; - } - - &.left-bottomEdge { - flex-direction: row; - align-items: flex-start; - } - - &.leftEdge-top { - flex-direction: column; - align-items: flex-end; - } - - & .hint--text { - /* text content uses -micro padding */ - padding: 4px; - border: 2px solid $hint-color; - color: $hint-color; - white-space: nowrap; - } - } - - & .hint--pole { - position: absolute; - - &.rightEdge-top { - top: -1px; - left: -$margin-right; - border-top: 2px solid $hint-color; - width: $margin-right; - height: 0; - } - - &.left-topEdge { - border-left: 2px solid $hint-color; - left: -1px; - height: $margin-top; - width: 0; - top: 0; - } - - &.left-bottomEdge { - border-left: 2px solid $hint-color; - left: -1px; - height: $margin-bottom; - width: 0; - top: -$margin-bottom; - } - - &.leftEdge-top { - top: -1px; - border-top: 2px solid $hint-color; - width: $margin-left; - height: 0; - } - } - } - - .rv-hint--horizontalAlign-rightEdge.rv-hint--verticalAlign-top { - width: 0; - height: 0; - } - - .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-topEdge { - width: 0; - height: 100%; - } - - .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-bottomEdge { - width: 0; - height: 0; - } - - .rv-hint--horizontalAlign-leftEdge.rv-hint--verticalAlign-top { - width: 100%; - height: 0; - } -} - -.centered-and-flexed { - align-items: center; - display: flex; - flex-direction: column; - justify-content: center; - padding: 0 10px; - - .centered-and-flexed-controls { - align-items: center; - display: flex; - justify-content: space-between; - padding: 10px 0; - width: 75%; - } -} - -.dynamic-treemap-example { - .rv-treemap__leaf--circle { - border: thin solid white; - } -} - -.clustered-stacked-bar-chart-example { - .rv-discrete-color-legend { - left: 40px; - position: absolute; - top: 0; - } -} - -.basic-sunburst-example-path-name { - height: 20px; -} - -.showcase-button { - background: $white; - border: thin solid #333; - border-radius: 5px; - cursor: pointer; - font-size: 10px; - font-weight: 600; - padding: 5px 10px; -} - -.donut-chart-example { - .rv-radial-chart__series--pie__slice:hover { - stroke: $black !important; - stroke-width: 2px !important; - } -} - -.parallel-coordinates-example { - .rv-xy-plot__series--line { - stroke: #12939A !important; - - &:hover { - stroke: #F15C17 !important; - } - } -} - - -.canvas-example-controls { - display: flex; -} - -.canvas-wrapper { - align-items: center; - display: flex; - flex-direction: column; - width: 100%; -} - -.highlight-container { - cursor: crosshair; -} - -.no-select { - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} diff --git a/dist/styles/legends.scss b/dist/styles/legends.scss deleted file mode 100644 index f79e9c850..000000000 --- a/dist/styles/legends.scss +++ /dev/null @@ -1,137 +0,0 @@ -$rv-legend-enabled-color: #3a3a48; -$rv-legend-disabled-color: #b8b8b8; - -.rv-discrete-color-legend { - box-sizing: border-box; - overflow-y: auto; - font-size: 12px; - - &.horizontal { - white-space: nowrap; - } -} - -.rv-discrete-color-legend-item { - color: $rv-legend-enabled-color; - border-radius: 1px; - padding: 9px 10px; - - &.horizontal { - display: inline-block; - - .rv-discrete-color-legend-item__title { - margin-left: 0; - display: block; - } - } -} - -.rv-discrete-color-legend-item__color { - display: inline-block; - vertical-align: middle; - overflow: visible; -} - -.rv-discrete-color-legend-item__color__path { - stroke: #dcdcdc; - stroke-width: 2px; -} - -.rv-discrete-color-legend-item__title { - margin-left: 10px; -} - -.rv-discrete-color-legend-item.disabled { - color: $rv-legend-disabled-color; -} - -.rv-discrete-color-legend-item.clickable { - cursor: pointer; - - &:hover { - background: #f9f9f9; - } -} - -.rv-search-wrapper { - display: flex; - flex-direction: column; -} - -.rv-search-wrapper__form { - flex: 0; -} - -.rv-search-wrapper__form__input { - width: 100%; - color: #a6a6a5; - border: 1px solid #e5e5e4; - padding: 7px 10px; - font-size: 12px; - box-sizing: border-box; - border-radius: 2px; - margin: 0 0 9px; - outline: 0; -} - -.rv-search-wrapper__contents { - flex: 1; - overflow: auto; -} - -.rv-continuous-color-legend { - font-size: 12px; - - .rv-gradient { - height: 4px; - border-radius: 2px; - margin-bottom: 5px; - } -} - -.rv-continuous-size-legend { - font-size: 12px; - - .rv-bubbles { - text-align: justify; - overflow: hidden; - margin-bottom: 5px; - width: 100%; - } - - .rv-bubble { - background: #d8d9dc; - display: inline-block; - vertical-align: bottom; - } - - .rv-spacer { - display: inline-block; - font-size: 0; - line-height: 0; - width: 100%; - } -} - -.rv-legend-titles { - height: 16px; - position: relative; -} - -.rv-legend-titles__left, -.rv-legend-titles__right, -.rv-legend-titles__center { - position: absolute; - white-space: nowrap; - overflow: hidden; -} - -.rv-legend-titles__center { - display: block; - text-align: center; - width: 100%; -} - -.rv-legend-titles__right { - right: 0; -} diff --git a/dist/styles/plot.scss b/dist/styles/plot.scss deleted file mode 100644 index 8d1f75ca2..000000000 --- a/dist/styles/plot.scss +++ /dev/null @@ -1,128 +0,0 @@ -$rv-xy-plot-axis-font-color: #6b6b76; -$rv-xy-plot-axis-line-color: #e6e6e9; -$rv-xy-plot-axis-font-size: 11px; -$rv-xy-plot-tooltip-background: #3a3a48; -$rv-xy-plot-tooltip-color: #fff; -$rv-xy-plot-tooltip-font-size: 12px; -$rv-xy-plot-tooltip-border-radius: 4px; -$rv-xy-plot-tooltip-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); -$rv-xy-plot-tooltip-padding: 7px 10px; - -.rv-xy-plot { - color: #c3c3c3; - position: relative; - - canvas { - pointer-events: none; - } - - .rv-xy-canvas { - pointer-events: none; - position: absolute; - } -} - -.rv-xy-plot__inner { - display: block; -} - -.rv-xy-plot__axis__line { - fill: none; - stroke-width: 2px; - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__axis__tick__line { - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__axis__tick__text { - fill: $rv-xy-plot-axis-font-color; - font-size: $rv-xy-plot-axis-font-size; -} - -.rv-xy-plot__axis__title { - text { - fill: $rv-xy-plot-axis-font-color; - font-size: $rv-xy-plot-axis-font-size; - } -} - -.rv-xy-plot__grid-lines__line { - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__circular-grid-lines__line { - fill-opacity: 0; - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__series, -.rv-xy-plot__series path { - pointer-events: all; -} - -.rv-xy-plot__series--line { - fill: none; - stroke: #000; - stroke-width: 2px; -} - -.rv-crosshair { - position: absolute; - font-size: 11px; - pointer-events: none; -} - -.rv-crosshair__line { - background: #47d3d9; - width: 1px; -} - -.rv-crosshair__inner { - position: absolute; - text-align: left; - top: 0; -} - -.rv-crosshair__inner__content { - border-radius: $rv-xy-plot-tooltip-border-radius; - background: $rv-xy-plot-tooltip-background; - color: $rv-xy-plot-tooltip-color; - font-size: $rv-xy-plot-tooltip-font-size; - padding: $rv-xy-plot-tooltip-padding; - box-shadow: $rv-xy-plot-tooltip-shadow; -} - -.rv-crosshair__inner--left { - right: 4px; -} - -.rv-crosshair__inner--right { - left: 4px; -} - -.rv-crosshair__title { - font-weight: bold; - white-space: nowrap; -} - -.rv-crosshair__item { - white-space: nowrap; -} - -.rv-hint { - position: absolute; - pointer-events: none; -} - -.rv-hint__content { - border-radius: $rv-xy-plot-tooltip-border-radius; - padding: $rv-xy-plot-tooltip-padding; - font-size: $rv-xy-plot-tooltip-font-size; - background: $rv-xy-plot-tooltip-background; - box-shadow: $rv-xy-plot-tooltip-shadow; - color: $rv-xy-plot-tooltip-color; - text-align: left; - white-space: nowrap; -} diff --git a/dist/styles/radial-chart.scss b/dist/styles/radial-chart.scss deleted file mode 100644 index 854a57d4b..000000000 --- a/dist/styles/radial-chart.scss +++ /dev/null @@ -1,6 +0,0 @@ -.rv-radial-chart { - - .rv-xy-plot__series--label { - pointer-events: none; - } -} diff --git a/dist/styles/treemap.scss b/dist/styles/treemap.scss deleted file mode 100644 index 4626d66ea..000000000 --- a/dist/styles/treemap.scss +++ /dev/null @@ -1,22 +0,0 @@ -.rv-treemap { - font-size: 12px; - position: relative; -} - -.rv-treemap__leaf { - overflow: hidden; - position: absolute; -} - -.rv-treemap__leaf--circle { - align-items: center; - border-radius: 100%; - display: flex; - justify-content: center; -} - -.rv-treemap__leaf__content { - overflow: hidden; - padding: 10px; - text-overflow: ellipsis; -} diff --git a/dist/sunburst/index.js b/dist/sunburst/index.js deleted file mode 100644 index a9c12d6c2..000000000 --- a/dist/sunburst/index.js +++ /dev/null @@ -1,253 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Hierarchy = require('d3-hierarchy'); - -var _d3Scale = require('d3-scale'); - -var _animation = require('../animation'); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _arcSeries = require('../plot/series/arc-series'); - -var _arcSeries2 = _interopRequireDefault(_arcSeries); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _seriesUtils = require('../utils/series-utils'); - -var _chartUtils = require('../utils/chart-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var predefinedClassName = 'rv-sunburst'; - -var LISTENERS_TO_OVERWRITE = ['onValueMouseOver', 'onValueMouseOut', 'onValueClick', 'onValueRightClick', 'onSeriesMouseOver', 'onSeriesMouseOut', 'onSeriesClick', 'onSeriesRightClick']; - -/** - * Create the list of nodes to render. - * @param {Object} props - props.data {Object} - tree structured data (each node has a name anc an array of children) - props.height {number} - the height of the graphic to be rendered - props.hideRootNode {boolean} - whether or not to hide the root node - props.width {number} - the width of the graphic to be rendered - props.getSize {function} - accessor for the size - * @returns {Array} Array of nodes. - */ -function getNodesToRender(_ref) { - var data = _ref.data, - height = _ref.height, - hideRootNode = _ref.hideRootNode, - width = _ref.width, - getSize = _ref.getSize; - - var partitionFunction = (0, _d3Hierarchy.partition)(); - var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize); - var radius = Math.min(width, height) / 2 - 10; - var x = (0, _d3Scale.scaleLinear)().range([0, 2 * Math.PI]); - var y = (0, _d3Scale.scaleSqrt)().range([0, radius]); - - return partitionFunction(structuredInput).descendants().reduce(function (res, cell, index) { - if (hideRootNode && index === 0) { - return res; - } - - return res.concat([_extends({ - angle0: Math.max(0, Math.min(2 * Math.PI, x(cell.x0))), - angle: Math.max(0, Math.min(2 * Math.PI, x(cell.x1))), - radius0: Math.max(0, y(cell.y0)), - radius: Math.max(0, y(cell.y1)), - depth: cell.depth, - parent: cell.parent - }, cell.data)]); - }, []); -} - -/** - * Convert arc nodes into label rows. - * Important to use mappedData rather than regular data, bc it is already unrolled - * @param {Array} mappedData - Array of nodes. - * @param {Object} accessors - object of accessors - * @returns {Array} array of node for rendering as labels - */ -function buildLabels(mappedData, accessors) { - var getAngle = accessors.getAngle, - getAngle0 = accessors.getAngle0, - getLabel = accessors.getLabel, - getRadius0 = accessors.getRadius0; - - - return mappedData.filter(getLabel).map(function (row) { - var truedAngle = -1 * getAngle(row) + Math.PI / 2; - var truedAngle0 = -1 * getAngle0(row) + Math.PI / 2; - var angle = (truedAngle0 + truedAngle) / 2; - var rotateLabels = !row.dontRotateLabel; - var rotAngle = -angle / (2 * Math.PI) * 360; - - return _extends({}, row, { - children: null, - angle: null, - radius: null, - x: getRadius0(row) * Math.cos(angle), - y: getRadius0(row) * Math.sin(angle), - style: _extends({ - textAnchor: rotAngle > 90 ? 'end' : 'start' - }, row.labelStyle), - rotation: rotateLabels ? rotAngle > 90 ? rotAngle + 180 : rotAngle === 90 ? 90 : rotAngle : null - }); - }); -} - -var NOOP = function NOOP() {}; - -function Sunburst(props) { - var getAngle = props.getAngle, - getAngle0 = props.getAngle0, - animation = props.animation, - className = props.className, - children = props.children, - data = props.data, - height = props.height, - hideRootNode = props.hideRootNode, - getLabel = props.getLabel, - width = props.width, - getSize = props.getSize, - colorType = props.colorType; - - var mappedData = getNodesToRender({ - data: data, - height: height, - hideRootNode: hideRootNode, - width: width, - getSize: getSize - }); - var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); - var margin = (0, _chartUtils.getRadialLayoutMargin)(width, height, radialDomain); - - var labelData = buildLabels(mappedData, { - getAngle: getAngle, - getAngle0: getAngle0, - getLabel: getLabel, - getRadius0: function getRadius0(d) { - return d.radius0; - } - }); - - var hofBuilder = function hofBuilder(f) { - return function (e, i) { - return f ? f(mappedData[e.index], i) : NOOP; - }; - }; - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - hasTreeStructure: true, - width: width, - className: predefinedClassName + ' ' + className, - margin: margin, - xDomain: [-radialDomain, radialDomain], - yDomain: [-radialDomain, radialDomain] - }, - _react2.default.createElement(_arcSeries2.default, _extends({ - colorType: colorType - }, props, { - animation: animation, - radiusDomain: [0, radialDomain], - // need to present a stripped down version for interpolation - data: animation ? mappedData.map(function (row, index) { - return _extends({}, row, { - parent: null, - children: null, - index: index - }); - }) : mappedData, - _data: animation ? mappedData : null, - arcClassName: predefinedClassName + '__series--radial__arc' - }, LISTENERS_TO_OVERWRITE.reduce(function (acc, propName) { - var prop = props[propName]; - acc[propName] = animation ? hofBuilder(prop) : prop; - return acc; - }, {}))), - labelData.length > 0 && _react2.default.createElement(_labelSeries2.default, { data: labelData, getLabel: getLabel }), - children - ); -} - -Sunburst.displayName = 'Sunburst'; -Sunburst.propTypes = { - animation: _animation.AnimationPropType, - getAngle: _propTypes2.default.func, - getAngle0: _propTypes2.default.func, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - data: _propTypes2.default.object.isRequired, - height: _propTypes2.default.number.isRequired, - hideRootNode: _propTypes2.default.bool, - getLabel: _propTypes2.default.func, - onValueClick: _propTypes2.default.func, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - getSize: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired, - padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) -}; -Sunburst.defaultProps = { - getAngle: function getAngle(d) { - return d.angle; - }, - getAngle0: function getAngle0(d) { - return d.angle0; - }, - className: '', - colorType: 'literal', - getColor: function getColor(d) { - return d.color; - }, - hideRootNode: false, - getLabel: function getLabel(d) { - return d.label; - }, - getSize: function getSize(d) { - return d.size; - }, - padAngle: 0 -}; - -exports.default = Sunburst; \ No newline at end of file diff --git a/dist/theme.js b/dist/theme.js deleted file mode 100644 index 3807452c3..000000000 --- a/dist/theme.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var DISCRETE_COLOR_RANGE = exports.DISCRETE_COLOR_RANGE = ['#12939A', '#79C7E3', '#1A3177', '#FF9833', '#EF5D28']; - -var EXTENDED_DISCRETE_COLOR_RANGE = exports.EXTENDED_DISCRETE_COLOR_RANGE = ['#19CDD7', '#DDB27C', '#88572C', '#FF991F', '#F15C17', '#223F9A', '#DA70BF', '#125C77', '#4DC19C', '#776E57', '#12939A', '#17B8BE', '#F6D18A', '#B7885E', '#FFCB99', '#F89570', '#829AE3', '#E79FD5', '#1E96BE', '#89DAC1', '#B3AD9E']; - -var CONTINUOUS_COLOR_RANGE = exports.CONTINUOUS_COLOR_RANGE = ['#EF5D28', '#FF9833']; - -var SIZE_RANGE = exports.SIZE_RANGE = [1, 10]; - -var OPACITY_RANGE = exports.OPACITY_RANGE = [0.1, 1]; -var OPACITY_TYPE = exports.OPACITY_TYPE = 'literal'; -var DEFAULT_OPACITY = exports.DEFAULT_OPACITY = 1; - -var DEFAULT_SIZE = exports.DEFAULT_SIZE = 5; - -var DEFAULT_COLOR = exports.DEFAULT_COLOR = DISCRETE_COLOR_RANGE[0]; - -var DEFAULT_TICK_SIZE = exports.DEFAULT_TICK_SIZE = 7; \ No newline at end of file diff --git a/dist/treemap/index.js b/dist/treemap/index.js deleted file mode 100644 index 27244fe2d..000000000 --- a/dist/treemap/index.js +++ /dev/null @@ -1,254 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Hierarchy = require('d3-hierarchy'); - -var _theme = require('../theme'); - -var _animation = require('../animation'); - -var _scalesUtils = require('../utils/scales-utils'); - -var _chartUtils = require('../utils/chart-utils'); - -var _treemapDom = require('./treemap-dom'); - -var _treemapDom2 = _interopRequireDefault(_treemapDom); - -var _treemapSvg = require('./treemap-svg'); - -var _treemapSvg2 = _interopRequireDefault(_treemapSvg); - -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; } - -var TREEMAP_TILE_MODES = { - squarify: _d3Hierarchy.treemapSquarify, - resquarify: _d3Hierarchy.treemapResquarify, - slice: _d3Hierarchy.treemapSlice, - dice: _d3Hierarchy.treemapDice, - slicedice: _d3Hierarchy.treemapSliceDice, - binary: _d3Hierarchy.treemapBinary -}; - -var TREEMAP_LAYOUT_MODES = ['circlePack', 'partition', 'partition-pivot']; - -var NOOP = function NOOP(d) { - return d; -}; - -var ATTRIBUTES = ['opacity', 'color']; - -var DEFAULT_MARGINS = { - left: 40, - right: 10, - top: 10, - bottom: 40 -}; - -/** - * Get the map of scale functions from the given props. - * @param {Object} props Props for the component. - * @returns {Object} Map of scale functions. - * @private - */ -function _getScaleFns(props) { - var data = props.data; - - var allData = data.children || []; - - // Adding _allData property to the object to reuse the existing - // getAttributeFunctor function. - var compatibleProps = _extends({}, props, (0, _scalesUtils.getMissingScaleProps)(props, allData, ATTRIBUTES), { - _allData: allData - }); - return { - opacity: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'opacity'), - color: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'color') - }; -} - -var Treemap = function (_React$Component) { - _inherits(Treemap, _React$Component); - - function Treemap(props) { - _classCallCheck(this, Treemap); - - var _this = _possibleConstructorReturn(this, (Treemap.__proto__ || Object.getPrototypeOf(Treemap)).call(this, props)); - - _this.state = _extends({ - scales: _getScaleFns(props) - }, (0, _chartUtils.getInnerDimensions)(props, props.margin)); - return _this; - } - - _createClass(Treemap, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { - this.setState(_extends({ - scales: _getScaleFns(props) - }, (0, _chartUtils.getInnerDimensions)(props, props.margin))); - } - - /** - * Create the list of nodes to render. - * @returns {Array} Array of nodes. - * @private - */ - - }, { - key: '_getNodesToRender', - value: function _getNodesToRender() { - var _state = this.state, - innerWidth = _state.innerWidth, - innerHeight = _state.innerHeight; - var _props = this.props, - data = _props.data, - mode = _props.mode, - padding = _props.padding, - sortFunction = _props.sortFunction, - getSize = _props.getSize; - - if (!data) { - return []; - } - - if (mode === 'partition' || mode === 'partition-pivot') { - var partitionFunction = (0, _d3Hierarchy.partition)().size(mode === 'partition-pivot' ? [innerHeight, innerWidth] : [innerWidth, innerHeight]).padding(padding); - var _structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { - return sortFunction(a, b, getSize); - }); - var mappedNodes = partitionFunction(_structuredInput).descendants(); - if (mode === 'partition-pivot') { - return mappedNodes.map(function (node) { - return _extends({}, node, { - x0: node.y0, - x1: node.y1, - y0: node.x0, - y1: node.x1 - }); - }); - } - return mappedNodes; - } - if (mode === 'circlePack') { - var packingFunction = (0, _d3Hierarchy.pack)().size([innerWidth, innerHeight]).padding(padding); - var _structuredInput2 = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { - return sortFunction(a, b, getSize); - }); - return packingFunction(_structuredInput2).descendants(); - } - - var tileFn = TREEMAP_TILE_MODES[mode]; - var treemapingFunction = (0, _d3Hierarchy.treemap)(tileFn).tile(tileFn).size([innerWidth, innerHeight]).padding(padding); - var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { - return sortFunction(a, b, getSize); - }); - return treemapingFunction(structuredInput).descendants(); - } - }, { - key: 'render', - value: function render() { - var renderMode = this.props.renderMode; - var scales = this.state.scales; - - var nodes = this._getNodesToRender(); - var TreemapElement = renderMode === 'SVG' ? _treemapSvg2.default : _treemapDom2.default; - return _react2.default.createElement(TreemapElement, _extends({}, this.props, { nodes: nodes, scales: scales })); - } - }]); - - return Treemap; -}(_react2.default.Component); - -Treemap.displayName = 'Treemap'; -Treemap.propTypes = { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - data: _propTypes2.default.object.isRequired, - height: _propTypes2.default.number.isRequired, - hideRootNode: _propTypes2.default.bool, - margin: _chartUtils.MarginPropType, - mode: _propTypes2.default.oneOf(Object.keys(TREEMAP_TILE_MODES).concat(TREEMAP_LAYOUT_MODES)), - onLeafClick: _propTypes2.default.func, - onLeafMouseOver: _propTypes2.default.func, - onLeafMouseOut: _propTypes2.default.func, - useCirclePacking: _propTypes2.default.bool, - padding: _propTypes2.default.number.isRequired, - sortFunction: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired, - getSize: _propTypes2.default.func, - getColor: _propTypes2.default.func -}; - -Treemap.defaultProps = { - className: '', - colorRange: _theme.CONTINUOUS_COLOR_RANGE, - _colorValue: _theme.DEFAULT_COLOR, - data: { - children: [] - }, - hideRootNode: false, - margin: DEFAULT_MARGINS, - mode: 'squarify', - onLeafClick: NOOP, - onLeafMouseOver: NOOP, - onLeafMouseOut: NOOP, - opacityType: _theme.OPACITY_TYPE, - _opacityValue: _theme.DEFAULT_OPACITY, - padding: 1, - sortFunction: function sortFunction(a, b, accessor) { - if (!accessor) { - return 0; - } - return accessor(a) - accessor(b); - }, - getSize: function getSize(d) { - return d.size; - }, - getColor: function getColor(d) { - return d.color; - }, - getLabel: function getLabel(d) { - return d.title; - } -}; -exports.default = Treemap; \ No newline at end of file diff --git a/dist/treemap/treemap-dom.js b/dist/treemap/treemap-dom.js deleted file mode 100644 index b8112f0a9..000000000 --- a/dist/treemap/treemap-dom.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _treemapLeaf = require('./treemap-leaf'); - -var _treemapLeaf2 = _interopRequireDefault(_treemapLeaf); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function TreemapDOM(props) { - var animation = props.animation, - className = props.className, - height = props.height, - hideRootNode = props.hideRootNode, - getLabel = props.getLabel, - mode = props.mode, - nodes = props.nodes, - width = props.width, - scales = props.scales, - style = props.style; - - var useCirclePacking = mode === 'circlePack'; - return _react2.default.createElement( - 'div', - { - className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, - style: { height: height, width: width } - }, - nodes.map(function (node, index) { - // throw out the rootest node - if (hideRootNode && !index) { - return null; - } - - var nodeProps = _extends({ - animation: animation, - node: node, - getLabel: getLabel - }, props, { - x0: useCirclePacking ? node.x : node.x0, - x1: useCirclePacking ? node.x : node.x1, - y0: useCirclePacking ? node.y : node.y0, - y1: useCirclePacking ? node.y : node.y1, - r: useCirclePacking ? node.r : 1, - scales: scales, - style: style - }); - return _react2.default.createElement(_treemapLeaf2.default, _extends({}, nodeProps, { key: 'leaf-' + index })); - }) - ); -} - -TreemapDOM.displayName = 'TreemapDOM'; -exports.default = TreemapDOM; \ No newline at end of file diff --git a/dist/treemap/treemap-leaf.js b/dist/treemap/treemap-leaf.js deleted file mode 100644 index d0a67615f..000000000 --- a/dist/treemap/treemap-leaf.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _scalesUtils = require('../utils/scales-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var ANIMATED_PROPS = ['colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'x0', 'x1', 'y0', 'y1', 'r']; - -function TreemapLeaf(props) { - var animation = props.animation, - getLabel = props.getLabel, - mode = props.mode, - node = props.node, - onLeafClick = props.onLeafClick, - onLeafMouseOver = props.onLeafMouseOver, - onLeafMouseOut = props.onLeafMouseOut, - r = props.r, - scales = props.scales, - x0 = props.x0, - x1 = props.x1, - y0 = props.y0, - y1 = props.y1, - style = props.style; - - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, props, { animatedProps: ANIMATED_PROPS }), - _react2.default.createElement(TreemapLeaf, _extends({}, props, { animation: null })) - ); - } - var useCirclePacking = mode === 'circlePack'; - var background = scales.color(node); - var opacity = scales.opacity(node); - var color = (0, _scalesUtils.getFontColorFromBackground)(background); - var data = node.data; - - var title = getLabel(data); - var leafStyle = _extends({ - top: useCirclePacking ? y0 - r : y0, - left: useCirclePacking ? x0 - r : x0, - width: useCirclePacking ? r * 2 : x1 - x0, - height: useCirclePacking ? r * 2 : y1 - y0, - background: background, - opacity: opacity, - color: color - }, style, node.data.style); - - return _react2.default.createElement( - 'div', - { - className: 'rv-treemap__leaf ' + (useCirclePacking ? 'rv-treemap__leaf--circle' : ''), - onMouseEnter: function onMouseEnter(event) { - return onLeafMouseOver(node, event); - }, - onMouseLeave: function onMouseLeave(event) { - return onLeafMouseOut(node, event); - }, - onClick: function onClick(event) { - return onLeafClick(node, event); - }, - style: leafStyle - }, - _react2.default.createElement( - 'div', - { className: 'rv-treemap__leaf__content' }, - title - ) - ); -} - -TreemapLeaf.propTypes = { - animation: _animation.AnimationPropType, - height: _propTypes2.default.number.isRequired, - mode: _propTypes2.default.string, - node: _propTypes2.default.object.isRequired, - onLeafClick: _propTypes2.default.func, - onLeafMouseOver: _propTypes2.default.func, - onLeafMouseOut: _propTypes2.default.func, - scales: _propTypes2.default.object.isRequired, - width: _propTypes2.default.number.isRequired, - r: _propTypes2.default.number.isRequired, - x0: _propTypes2.default.number.isRequired, - x1: _propTypes2.default.number.isRequired, - y0: _propTypes2.default.number.isRequired, - y1: _propTypes2.default.number.isRequired -}; -exports.default = TreemapLeaf; \ No newline at end of file diff --git a/dist/treemap/treemap-svg.js b/dist/treemap/treemap-svg.js deleted file mode 100644 index 6255dafbc..000000000 --- a/dist/treemap/treemap-svg.js +++ /dev/null @@ -1,246 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _polygonSeries = require('../plot/series/polygon-series'); - -var _polygonSeries2 = _interopRequireDefault(_polygonSeries); - -var _markSeries = require('../plot/series/mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var MARGIN_ADJUST = 1.2; - -var TreemapSVG = function (_React$Component) { - _inherits(TreemapSVG, _React$Component); - - function TreemapSVG() { - _classCallCheck(this, TreemapSVG); - - return _possibleConstructorReturn(this, (TreemapSVG.__proto__ || Object.getPrototypeOf(TreemapSVG)).apply(this, arguments)); - } - - _createClass(TreemapSVG, [{ - key: 'getCircularNodes', - value: function getCircularNodes() { - var _props = this.props, - animation = _props.animation, - hideRootNode = _props.hideRootNode, - nodes = _props.nodes, - onLeafMouseOver = _props.onLeafMouseOver, - onLeafMouseOut = _props.onLeafMouseOut, - onLeafClick = _props.onLeafClick, - scales = _props.scales, - style = _props.style; - - var _nodes$reduce = nodes.reduce(function (acc, node, index) { - if (!index && hideRootNode) { - return acc; - } - var x = node.x, - y = node.y, - r = node.r; - - return { - maxY: Math.max(y + r, acc.maxY), - minY: Math.min(y - r, acc.minY), - maxX: Math.max(x + MARGIN_ADJUST * r, acc.maxX), - minX: Math.min(x - MARGIN_ADJUST * r, acc.minX), - rows: acc.rows.concat([{ - x: x, - y: y, - size: r, - color: scales.color(node) - }]) - }; - }, { - rows: [], - maxY: -Infinity, - minY: Infinity, - maxX: -Infinity, - minX: Infinity - }), - rows = _nodes$reduce.rows, - minY = _nodes$reduce.minY, - maxY = _nodes$reduce.maxY, - minX = _nodes$reduce.minX, - maxX = _nodes$reduce.maxX; - - return { - updatedNodes: _react2.default.createElement(_markSeries2.default, { - animation: animation, - className: 'rv-treemap__leaf rv-treemap__leaf--circle', - onSeriesMouseEnter: onLeafMouseOver, - onSeriesMouseLeave: onLeafMouseOut, - onSeriesClick: onLeafClick, - data: rows, - colorType: 'literal', - getColor: function getColor(d) { - return d.color; - }, - sizeType: 'literal', - getSize: function getSize(d) { - return d.size; - }, - style: style - }), - minY: minY, - maxY: maxY, - minX: minX, - maxX: maxX - }; - } - }, { - key: 'getNonCircularNodes', - value: function getNonCircularNodes() { - var _props2 = this.props, - animation = _props2.animation, - hideRootNode = _props2.hideRootNode, - nodes = _props2.nodes, - onLeafMouseOver = _props2.onLeafMouseOver, - onLeafMouseOut = _props2.onLeafMouseOut, - onLeafClick = _props2.onLeafClick, - scales = _props2.scales, - style = _props2.style; - var color = scales.color; - - return nodes.reduce(function (acc, node, index) { - if (!index && hideRootNode) { - return acc; - } - var x0 = node.x0, - x1 = node.x1, - y1 = node.y1, - y0 = node.y0; - - var x = x0; - var y = y0; - var nodeHeight = y1 - y0; - var nodeWidth = x1 - x0; - - acc.maxY = Math.max(y + nodeHeight, acc.maxY); - acc.minY = Math.min(y, acc.minY); - acc.maxX = Math.max(x + nodeWidth, acc.maxX); - acc.minX = Math.min(x, acc.minX); - - var data = [{ x: x, y: y }, { x: x, y: y + nodeHeight }, { x: x + nodeWidth, y: y + nodeHeight }, { x: x + nodeWidth, y: y }]; - - acc.updatedNodes = acc.updatedNodes.concat([_react2.default.createElement(_polygonSeries2.default, { - animation: animation, - className: 'rv-treemap__leaf', - key: index, - color: color(node), - type: 'literal', - onSeriesMouseEnter: onLeafMouseOver, - onSeriesMouseLeave: onLeafMouseOut, - onSeriesClick: onLeafClick, - data: data, - style: _extends({}, style, node.style) - })]); - return acc; - }, { - updatedNodes: [], - maxY: -Infinity, - minY: Infinity, - maxX: -Infinity, - minX: Infinity - }); - } - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - className = _props3.className, - height = _props3.height, - mode = _props3.mode, - nodes = _props3.nodes, - width = _props3.width; - - var useCirclePacking = mode === 'circlePack'; - - var _ref = useCirclePacking ? this.getCircularNodes() : this.getNonCircularNodes(), - minY = _ref.minY, - maxY = _ref.maxY, - minX = _ref.minX, - maxX = _ref.maxX, - updatedNodes = _ref.updatedNodes; - - var labels = nodes.reduce(function (acc, node) { - if (!node.data.title) { - return acc; - } - return acc.concat(_extends({}, node.data, { - x: node.x0 || node.x, - y: node.y0 || node.y, - label: '' + node.data.title - })); - }, []); - - return _react2.default.createElement( - _xyPlot2.default, - _extends({ - className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, - width: width, - height: height, - yDomain: [maxY, minY], - xDomain: [minX, maxX], - colorType: 'literal', - hasTreeStructure: true - }, this.props), - updatedNodes, - _react2.default.createElement(_labelSeries2.default, { data: labels }) - ); - } - }]); - - return TreemapSVG; -}(_react2.default.Component); - -TreemapSVG.displayName = 'TreemapSVG'; - -exports.default = TreemapSVG; \ No newline at end of file diff --git a/dist/utils/axis-utils.js b/dist/utils/axis-utils.js deleted file mode 100644 index db9f09fa9..000000000 --- a/dist/utils/axis-utils.js +++ /dev/null @@ -1,167 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DIRECTION = exports.ORIENTATION = undefined; -exports.getTicksTotalFromSize = getTicksTotalFromSize; -exports.getTickValues = getTickValues; -exports.generateFit = generateFit; -exports.generatePoints = generatePoints; -exports.getAxisAngle = getAxisAngle; - -var _d3Array = require('d3-array'); - -var _d3Scale = require('d3-scale'); - -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var ORIENTATION = exports.ORIENTATION = { - TOP: 'top', - LEFT: 'left', - RIGHT: 'right', - BOTTOM: 'bottom', - VERTICAL: 'vertical', - HORIZONTAL: 'horizontal' -}; - -var DIRECTION = exports.DIRECTION = { - VERTICAL: 'vertical', - HORIZONTAL: 'horizontal' -}; - -/** - * Get total amount of ticks from a given size in pixels. - * @param {number} size Size of the axis in pixels. - * @returns {number} Total amount of ticks. - */ -function getTicksTotalFromSize(size) { - if (size < 700) { - if (size > 300) { - return 10; - } - return 5; - } - return 20; -} - -/** - * Get the tick values from a given d3 scale. - * @param {d3.scale} scale Scale function. - * @param {number} tickTotal Total number of ticks - * @param {Array} tickValues Array of tick values if they exist. - * @returns {Array} Array of tick values. - */ -function getTickValues(scale, tickTotal, tickValues) { - return !tickValues ? scale.ticks ? scale.ticks(tickTotal) : scale.domain() : tickValues; -} - -/** - * Generate a description of a decorative axis in terms of a linear equation - * y = slope * x + offset in coordinates - * @param {Object} axisStart Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @param {Object} axisEnd Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @returns {Number} Object describing each the line in coordinates - */ -function generateFit(axisStart, axisEnd) { - // address the special case when the slope is infinite - if (axisStart.x === axisEnd.x) { - return { - left: axisStart.y, - right: axisEnd.y, - slope: 0, - offset: axisStart.x - }; - } - var slope = (axisStart.y - axisEnd.y) / (axisStart.x - axisEnd.x); - return { - left: axisStart.x, - right: axisEnd.x, - // generate the linear projection of the axis direction - slope: slope, - offset: axisStart.y - slope * axisStart.x - }; -} - -/** - * Generate a description of a decorative axis in terms of a linear equation - * y = slope * x + offset in coordinates - * @param props - * props.@param {Object} axisStart Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * props.@param {Object} axisEnd Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * props.@param {Number} numberOfTicks The number of ticks on the axis - * props.@param {Array.Numbers} axisDomain The values to be interpolated across for the axis - * @returns {Number} Object describing the slope and the specific coordinates of the points - */ -function generatePoints(_ref) { - var axisStart = _ref.axisStart, - axisEnd = _ref.axisEnd, - numberOfTicks = _ref.numberOfTicks, - axisDomain = _ref.axisDomain; - - var _generateFit = generateFit(axisStart, axisEnd), - left = _generateFit.left, - right = _generateFit.right, - slope = _generateFit.slope, - offset = _generateFit.offset; - // construct a linear band of points, then map them - - - var pointSlope = (right - left) / numberOfTicks; - var axisScale = (0, _d3Scale.scaleLinear)().domain([left, right]).range(axisDomain); - - var slopeVertical = axisStart.x === axisEnd.x; - return { - slope: slopeVertical ? Infinity : slope, - points: (0, _d3Array.range)(left, right + pointSlope, pointSlope).map(function (val) { - if (slopeVertical) { - return { y: val, x: slope * val + offset, text: axisScale(val) }; - } - return { x: val, y: slope * val + offset, text: axisScale(val) }; - }).slice(0, numberOfTicks + 1) - }; -} - -/** - * Compute the angle (in radians) of a decorative axis - * @param {Object} axisStart Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @param {Object} axisEnd Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @returns {Number} Angle in radials - */ -function getAxisAngle(axisStart, axisEnd) { - if (axisStart.x === axisEnd.x) { - return axisEnd.y > axisStart.y ? Math.PI / 2 : 3 * Math.PI / 2; - } - return Math.atan((axisEnd.y - axisStart.y) / (axisEnd.x - axisStart.x)); -} - -exports.default = { - DIRECTION: DIRECTION, - ORIENTATION: ORIENTATION, - getTicksTotalFromSize: getTicksTotalFromSize, - getTickValues: getTickValues -}; \ No newline at end of file diff --git a/dist/utils/chart-utils.js b/dist/utils/chart-utils.js deleted file mode 100644 index 296899ae8..000000000 --- a/dist/utils/chart-utils.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DEFAULT_MARGINS = exports.MarginPropType = undefined; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.getInnerDimensions = getInnerDimensions; -exports.getRadialLayoutMargin = getRadialLayoutMargin; - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Get the dimensions of the component for the future use. - * @param {Object} props Props. - * @param {Object} defaultMargins Object with default margins. - * @returns {Object} Dimensions of the component. - */ -function getInnerDimensions(props, defaultMargins) { - var margin = props.margin, - width = props.width, - height = props.height; - - var marginProps = _extends({}, defaultMargins, typeof margin === 'number' ? { - left: margin, - right: margin, - top: margin, - bottom: margin - } : margin); - var _marginProps$left = marginProps.left, - marginLeft = _marginProps$left === undefined ? 0 : _marginProps$left, - _marginProps$top = marginProps.top, - marginTop = _marginProps$top === undefined ? 0 : _marginProps$top, - _marginProps$right = marginProps.right, - marginRight = _marginProps$right === undefined ? 0 : _marginProps$right, - _marginProps$bottom = marginProps.bottom, - marginBottom = _marginProps$bottom === undefined ? 0 : _marginProps$bottom; - - return { - marginLeft: marginLeft, - marginTop: marginTop, - marginRight: marginRight, - marginBottom: marginBottom, - innerHeight: height - marginBottom - marginTop, - innerWidth: width - marginLeft - marginRight - }; -} - -/** - * Calculate the margin of the sunburst, - * so it can be at the center of the container - * @param {Number} width - the width of the container - * @param {Number} height - the height of the container - * @param {Number} radius - the max radius of the sunburst - * @return {Object} an object includes {bottom, left, right, top} - */ -function getRadialLayoutMargin(width, height, radius) { - var marginX = width / 2 - radius; - var marginY = height / 2 - radius; - return { - bottom: marginY, - left: marginX, - right: marginX, - top: marginY - }; -} - -var MarginPropType = exports.MarginPropType = _propTypes2.default.oneOfType([_propTypes2.default.shape({ - left: _propTypes2.default.number, - top: _propTypes2.default.number, - right: _propTypes2.default.number, - bottom: _propTypes2.default.number -}), _propTypes2.default.number]); - -var DEFAULT_MARGINS = exports.DEFAULT_MARGINS = { - left: 40, - right: 10, - top: 10, - bottom: 40 -}; \ No newline at end of file diff --git a/dist/utils/data-utils.js b/dist/utils/data-utils.js deleted file mode 100644 index af24379d4..000000000 --- a/dist/utils/data-utils.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getUniquePropertyValues = getUniquePropertyValues; -exports.addValueToArray = addValueToArray; -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/** - * Get unique property values from an array. - * @param {Array} arr Array of data. - * @param {string} propertyName Prop name. - * @returns {Array} Array of unique values. - */ -function getUniquePropertyValues(arr, accessor) { - var setOfValues = new Set(arr.map(accessor)); - return Array.from(setOfValues); -} - -/** - * Add zero to the domain. - * @param {Array} arr Add zero to the domain. - * @param {Number} value Add zero to domain. - * @returns {Array} Adjusted domain. - */ -function addValueToArray(arr, value) { - var result = [].concat(arr); - if (result[0] > value) { - result[0] = value; - } - if (result[result.length - 1] < value) { - result[result.length - 1] = value; - } - return result; -} \ No newline at end of file diff --git a/dist/utils/react-utils.js b/dist/utils/react-utils.js deleted file mode 100644 index 7bc856814..000000000 --- a/dist/utils/react-utils.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getDOMNode = exports.isReactDOMSupported = undefined; - -var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.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 (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.warning = warning; -exports.warnOnce = warnOnce; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _React$version$split = _react2.default.version.split('.'), - _React$version$split2 = _slicedToArray(_React$version$split, 2), - major = _React$version$split2[0], - minor = _React$version$split2[1]; - -var versionHigherThanThirteen = Number(minor) > 13 || Number(major) > 13; - -var isReactDOMSupported = exports.isReactDOMSupported = function isReactDOMSupported() { - return versionHigherThanThirteen; -}; - -/** - * Support React 0.13 and greater where refs are React components, not DOM - * nodes. - * @param {*} ref React's ref. - * @returns {Element} DOM element. - */ -var getDOMNode = exports.getDOMNode = function getDOMNode(ref) { - if (!isReactDOMSupported()) { - return ref && ref.getDOMNode(); - } - return ref; -}; - -var USED_MESSAGES = {}; -var HIDDEN_PROCESSES = { - test: true, - production: true -}; - -/** - * Warn the user about something - * @param {String} message - the message to be shown - * @param {Boolean} onlyShowMessageOnce - whether or not we allow the - - message to be show multiple times - */ -function warning(message) { - var onlyShowMessageOnce = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - /* eslint-disable no-undef, no-process-env */ - if (global.process && HIDDEN_PROCESSES[process.env.NODE_ENV]) { - return; - } - /* eslint-enable no-undef, no-process-env */ - if (!onlyShowMessageOnce || !USED_MESSAGES[message]) { - /* eslint-disable no-console */ - console.warn(message); - /* eslint-enable no-console */ - USED_MESSAGES[message] = true; - } -} - -/** - * Convience wrapper for warning - * @param {String} message - the message to be shown - */ -function warnOnce(message) { - warning(message, true); -} \ No newline at end of file diff --git a/dist/utils/series-utils.js b/dist/utils/series-utils.js deleted file mode 100644 index 7e1796dbe..000000000 --- a/dist/utils/series-utils.js +++ /dev/null @@ -1,268 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ANIMATED_SERIES_PROPS = undefined; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.isSeriesChild = isSeriesChild; -exports.getSeriesChildren = getSeriesChildren; -exports.getStackedData = getStackedData; -exports.getSeriesPropsFromChildren = getSeriesPropsFromChildren; -exports.getRadialDomain = getRadialDomain; -exports.getStackParams = getStackParams; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _abstractSeries = require('../plot/series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _theme = require('../theme'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -/** - * Check if the component is series or not. - * @param {React.Component} child Component. - * @returns {boolean} True if the child is series, false otherwise. - */ -function isSeriesChild(child) { - var prototype = child.type.prototype; - - return prototype instanceof _abstractSeries2.default; -} - -/** - * Get all series from the 'children' object of the component. - * @param {Object} children Children. - * @returns {Array} Array of children. - */ -function getSeriesChildren(children) { - return _react2.default.Children.toArray(children).filter(function (child) { - return child && isSeriesChild(child); - }); -} - -/** - * Collect the map of repetitions of the series type for all children. - * @param {Array} children Array of children. - * @returns {{}} Map of repetitions where sameTypeTotal is the total amount and - * sameTypeIndex is always 0. - */ -function collectSeriesTypesInfo(children) { - var result = {}; - children.filter(isSeriesChild).forEach(function (child) { - var displayName = child.type.displayName; - var cluster = child.props.cluster; - - if (!result[displayName]) { - result[displayName] = { - sameTypeTotal: 0, - sameTypeIndex: 0, - clusters: new Set() - }; - } - result[displayName].clusters.add(cluster); - result[displayName].sameTypeTotal++; - }); - return result; -} - -/** - * Check series to see if it has angular data that needs to be converted - * @param {Array} data - an array of objects to check - * @returns {Boolean} whether or not this series contains polar configuration - */ -function seriesHasAngleRadius() { - var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - if (!data) { - return false; - } - return data.some(function (row) { - return row.radius && row.angle; - }); -} - -/** - * Possibly convert polar coordinates to x/y for computing domain - * @param {Array} data - an array of objects to check - * @param {String} attr - the property being checked - * @returns {Boolean} whether or not this series contains polar configuration - */ -function prepareData(data) { - if (!seriesHasAngleRadius(data)) { - return data; - } - - return data.map(function (row) { - return _extends({}, row, { - x: row.radius * Math.cos(row.angle), - y: row.radius * Math.sin(row.angle) - }); - }); -} - -/** - * Collect the stacked data for all children in use. If the children don't have - * the data (e.g. the child is invalid series or something else), then the child - * is skipped. - * Each next value of attr is equal to the previous value plus the difference - * between attr0 and attr. - * @param {Array} children Array of children. - * @param {string} attr Attribute to stack by. - * @returns {Array} New array of children for the series. - */ -function getStackedData(children, attr) { - var areSomeSeriesStacked = children.some(function (series) { - return series && series.props.stack; - }); - // It stores the last segment position added to each bar, separated by cluster. - var latestAttrPositions = {}; - - return children.reduce(function (accumulator, series, seriesIndex) { - // Skip the children that are not series (e.g. don't have any data). - if (!series) { - accumulator.push(null); - return accumulator; - } - - var _series$props = series.props, - data = _series$props.data, - _series$props$cluster = _series$props.cluster, - cluster = _series$props$cluster === undefined ? 'default' : _series$props$cluster, - stack = _series$props.stack; - - var preppedData = prepareData(data, attr); - - if (!attr || !preppedData || !preppedData.length || areSomeSeriesStacked && !stack) { - accumulator.push(preppedData); - return accumulator; - } - - var attr0 = attr + '0'; - var baseAttr = attr === 'y' ? 'x' : 'y'; - - accumulator.push(preppedData.map(function (d, dIndex) { - var _extends2, _latestAttrPositions$2; - - if (!latestAttrPositions[cluster]) { - latestAttrPositions[cluster] = {}; - } - - var prevD = latestAttrPositions[cluster][d[baseAttr]]; - // It is the first segment of a bar. - if (!prevD) { - var _latestAttrPositions$; - - latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$ = {}, _defineProperty(_latestAttrPositions$, attr0, d[attr0]), _defineProperty(_latestAttrPositions$, attr, d[attr]), _latestAttrPositions$); - - return _extends({}, d); - } - - // Calculate the position of the next segment in a bar. - var nextD = _extends({}, d, (_extends2 = {}, _defineProperty(_extends2, attr0, prevD[attr]), _defineProperty(_extends2, attr, prevD[attr] + d[attr] - (d[attr0] || 0)), _extends2)); - - latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$2 = {}, _defineProperty(_latestAttrPositions$2, attr0, nextD[attr0]), _defineProperty(_latestAttrPositions$2, attr, nextD[attr]), _latestAttrPositions$2); - - return nextD; - })); - - return accumulator; - }, []); -} - -/** - * Get the list of series props for a child. - * @param {Array} children Array of all children. - * @returns {Array} Array of series props for each child. If a child is not a - * series, than it's undefined. - */ -function getSeriesPropsFromChildren(children) { - var result = []; - var seriesTypesInfo = collectSeriesTypesInfo(children); - var seriesIndex = 0; - var _opacityValue = _theme.DEFAULT_OPACITY; - children.forEach(function (child) { - var props = void 0; - if (isSeriesChild(child)) { - var seriesTypeInfo = seriesTypesInfo[child.type.displayName]; - var _colorValue = _theme.DISCRETE_COLOR_RANGE[seriesIndex % _theme.DISCRETE_COLOR_RANGE.length]; - props = _extends({}, seriesTypeInfo, { - seriesIndex: seriesIndex, - _colorValue: _colorValue, - _opacityValue: _opacityValue - }); - seriesTypeInfo.sameTypeIndex++; - seriesIndex++; - if (child.props.cluster) { - props.cluster = child.props.cluster; - // Using Array.from() so we can use .indexOf - props.clusters = Array.from(seriesTypeInfo.clusters); - props.sameTypeTotal = props.clusters.length; - props.sameTypeIndex = props.clusters.indexOf(child.props.cluster); - } - } - result.push(props); - }); - return result; -} - -/** - * Find the max radius value from the nodes to be rendered after they have been - * transformed into an array - * @param {Array} data - the tree data after it has been broken into a iterable - * it is an array of objects! - * @returns {number} the maximum value in coordinates for the radial variable - */ -function getRadialDomain(data) { - return data.reduce(function (res, row) { - return Math.max(row.radius, res); - }, 0); -} - -var ANIMATED_SERIES_PROPS = exports.ANIMATED_SERIES_PROPS = ['xRange', 'xDomain', 'x', 'yRange', 'yDomain', 'y', 'colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'strokeRange', 'strokeDomain', 'stroke', 'fillRange', 'fillDomain', 'fill', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'data', 'angleDomain', 'angleRange', 'angle', 'radiusDomain', 'radiusRange', 'radius', 'innerRadiusDomain', 'innerRadiusRange', 'innerRadius']; - -function getStackParams(props) { - var _stackBy = props._stackBy, - valuePosAttr = props.valuePosAttr, - cluster = props.cluster; - var _props$sameTypeTotal = props.sameTypeTotal, - sameTypeTotal = _props$sameTypeTotal === undefined ? 1 : _props$sameTypeTotal, - _props$sameTypeIndex = props.sameTypeIndex, - sameTypeIndex = _props$sameTypeIndex === undefined ? 0 : _props$sameTypeIndex; - - // If bars are stacked, but not clustering, override `sameTypeTotal` and - // `sameTypeIndex` such that bars are stacked and not staggered. - - if (_stackBy === valuePosAttr && !cluster) { - sameTypeTotal = 1; - sameTypeIndex = 0; - } - return { sameTypeTotal: sameTypeTotal, sameTypeIndex: sameTypeIndex }; -} \ No newline at end of file From f34a9c1eb8cc7d1537e8078f24c7c2ec07e202e7 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Wed, 21 Nov 2018 11:44:18 +0100 Subject: [PATCH 07/10] Revert "Revert "Adding temp dist for my fork."" This reverts commit aa5c7401462b4a6350fb8976cb13341ba3af7f55. --- dist/animation.js | 188 +++++ dist/legends/continuous-color-legend.js | 107 +++ dist/legends/continuous-size-legend.js | 116 +++ dist/legends/discrete-color-legend-item.js | 103 +++ dist/legends/discrete-color-legend.js | 107 +++ .../searchable-discrete-color-legend.js | 107 +++ dist/main.scss | 9 + dist/make-vis-flexible.js | 250 +++++++ dist/parallel-coordinates/index.js | 360 ++++++++++ dist/plot/axis/axis-line.js | 99 +++ dist/plot/axis/axis-ticks.js | 271 +++++++ dist/plot/axis/axis-title.js | 186 +++++ dist/plot/axis/axis.js | 264 +++++++ dist/plot/axis/decorative-axis-ticks.js | 99 +++ dist/plot/axis/decorative-axis.js | 174 +++++ dist/plot/axis/x-axis.js | 66 ++ dist/plot/axis/y-axis.js | 66 ++ dist/plot/borders.js | 125 ++++ dist/plot/circular-grid-lines.js | 165 +++++ dist/plot/crosshair.js | 262 +++++++ dist/plot/gradient-defs.js | 58 ++ dist/plot/grid-lines.js | 178 +++++ dist/plot/highlight.js | 426 +++++++++++ dist/plot/hint.js | 454 ++++++++++++ dist/plot/horizontal-grid-lines.js | 64 ++ dist/plot/series/abstract-series.js | 415 +++++++++++ dist/plot/series/arc-series.js | 279 ++++++++ dist/plot/series/area-series.js | 160 +++++ dist/plot/series/bar-series-canvas.js | 161 +++++ dist/plot/series/bar-series.js | 180 +++++ dist/plot/series/canvas-wrapper.js | 256 +++++++ dist/plot/series/contour-series.js | 164 +++++ dist/plot/series/custom-svg-series.js | 237 +++++++ dist/plot/series/heatmap-series.js | 147 ++++ dist/plot/series/hexbin-series.js | 180 +++++ .../series/horizontal-bar-series-canvas.js | 97 +++ dist/plot/series/horizontal-bar-series.js | 85 +++ .../series/horizontal-rect-series-canvas.js | 97 +++ dist/plot/series/horizontal-rect-series.js | 85 +++ dist/plot/series/line-mark-series-canvas.js | 87 +++ dist/plot/series/line-mark-series.js | 102 +++ dist/plot/series/line-series-canvas.js | 146 ++++ dist/plot/series/line-series.js | 177 +++++ dist/plot/series/mark-series-canvas.js | 109 +++ dist/plot/series/mark-series.js | 179 +++++ dist/plot/series/polygon-series.js | 126 ++++ dist/plot/series/rect-series-canvas.js | 136 ++++ dist/plot/series/rect-series.js | 151 ++++ .../plot/series/vertical-bar-series-canvas.js | 97 +++ dist/plot/series/vertical-bar-series.js | 85 +++ .../series/vertical-rect-series-canvas.js | 97 +++ dist/plot/series/vertical-rect-series.js | 85 +++ dist/plot/series/whisker-series.js | 274 ++++++++ dist/plot/vertical-grid-lines.js | 64 ++ dist/plot/voronoi.js | 148 ++++ dist/plot/xy-plot.js | 660 ++++++++++++++++++ dist/radar-chart/index.js | 418 +++++++++++ dist/radial-chart/index.js | 263 +++++++ dist/sankey/index.js | 238 +++++++ dist/sankey/sankey-link.js | 85 +++ dist/style.css | 1 + dist/styles/examples.scss | 461 ++++++++++++ dist/styles/legends.scss | 137 ++++ dist/styles/plot.scss | 128 ++++ dist/styles/radial-chart.scss | 6 + dist/styles/treemap.scss | 22 + dist/sunburst/index.js | 253 +++++++ dist/theme.js | 42 ++ dist/treemap/index.js | 254 +++++++ dist/treemap/treemap-dom.js | 82 +++ dist/treemap/treemap-leaf.js | 125 ++++ dist/treemap/treemap-svg.js | 246 +++++++ dist/utils/axis-utils.js | 167 +++++ dist/utils/chart-utils.js | 104 +++ dist/utils/data-utils.js | 54 ++ dist/utils/react-utils.js | 95 +++ dist/utils/series-utils.js | 268 +++++++ 77 files changed, 13019 insertions(+) create mode 100644 dist/animation.js create mode 100644 dist/legends/continuous-color-legend.js create mode 100644 dist/legends/continuous-size-legend.js create mode 100644 dist/legends/discrete-color-legend-item.js create mode 100644 dist/legends/discrete-color-legend.js create mode 100644 dist/legends/searchable-discrete-color-legend.js create mode 100644 dist/main.scss create mode 100644 dist/make-vis-flexible.js create mode 100644 dist/parallel-coordinates/index.js create mode 100644 dist/plot/axis/axis-line.js create mode 100644 dist/plot/axis/axis-ticks.js create mode 100644 dist/plot/axis/axis-title.js create mode 100644 dist/plot/axis/axis.js create mode 100644 dist/plot/axis/decorative-axis-ticks.js create mode 100644 dist/plot/axis/decorative-axis.js create mode 100644 dist/plot/axis/x-axis.js create mode 100644 dist/plot/axis/y-axis.js create mode 100644 dist/plot/borders.js create mode 100644 dist/plot/circular-grid-lines.js create mode 100644 dist/plot/crosshair.js create mode 100644 dist/plot/gradient-defs.js create mode 100644 dist/plot/grid-lines.js create mode 100644 dist/plot/highlight.js create mode 100644 dist/plot/hint.js create mode 100644 dist/plot/horizontal-grid-lines.js create mode 100644 dist/plot/series/abstract-series.js create mode 100644 dist/plot/series/arc-series.js create mode 100644 dist/plot/series/area-series.js create mode 100644 dist/plot/series/bar-series-canvas.js create mode 100644 dist/plot/series/bar-series.js create mode 100644 dist/plot/series/canvas-wrapper.js create mode 100644 dist/plot/series/contour-series.js create mode 100644 dist/plot/series/custom-svg-series.js create mode 100644 dist/plot/series/heatmap-series.js create mode 100644 dist/plot/series/hexbin-series.js create mode 100644 dist/plot/series/horizontal-bar-series-canvas.js create mode 100644 dist/plot/series/horizontal-bar-series.js create mode 100644 dist/plot/series/horizontal-rect-series-canvas.js create mode 100644 dist/plot/series/horizontal-rect-series.js create mode 100644 dist/plot/series/line-mark-series-canvas.js create mode 100644 dist/plot/series/line-mark-series.js create mode 100644 dist/plot/series/line-series-canvas.js create mode 100644 dist/plot/series/line-series.js create mode 100644 dist/plot/series/mark-series-canvas.js create mode 100644 dist/plot/series/mark-series.js create mode 100644 dist/plot/series/polygon-series.js create mode 100644 dist/plot/series/rect-series-canvas.js create mode 100644 dist/plot/series/rect-series.js create mode 100644 dist/plot/series/vertical-bar-series-canvas.js create mode 100644 dist/plot/series/vertical-bar-series.js create mode 100644 dist/plot/series/vertical-rect-series-canvas.js create mode 100644 dist/plot/series/vertical-rect-series.js create mode 100644 dist/plot/series/whisker-series.js create mode 100644 dist/plot/vertical-grid-lines.js create mode 100644 dist/plot/voronoi.js create mode 100644 dist/plot/xy-plot.js create mode 100644 dist/radar-chart/index.js create mode 100644 dist/radial-chart/index.js create mode 100644 dist/sankey/index.js create mode 100644 dist/sankey/sankey-link.js create mode 100644 dist/style.css create mode 100644 dist/styles/examples.scss create mode 100644 dist/styles/legends.scss create mode 100644 dist/styles/plot.scss create mode 100644 dist/styles/radial-chart.scss create mode 100644 dist/styles/treemap.scss create mode 100644 dist/sunburst/index.js create mode 100644 dist/theme.js create mode 100644 dist/treemap/index.js create mode 100644 dist/treemap/treemap-dom.js create mode 100644 dist/treemap/treemap-leaf.js create mode 100644 dist/treemap/treemap-svg.js create mode 100644 dist/utils/axis-utils.js create mode 100644 dist/utils/chart-utils.js create mode 100644 dist/utils/data-utils.js create mode 100644 dist/utils/react-utils.js create mode 100644 dist/utils/series-utils.js diff --git a/dist/animation.js b/dist/animation.js new file mode 100644 index 000000000..9638ef2d6 --- /dev/null +++ b/dist/animation.js @@ -0,0 +1,188 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.AnimationPropType = undefined; + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.extractAnimatedPropValues = extractAnimatedPropValues; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Interpolate = require('d3-interpolate'); + +var _reactMotion = require('react-motion'); + +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; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +var ANIMATION_PROPTYPES = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({ + stiffness: _propTypes2.default.number, + nonAnimatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string), + damping: _propTypes2.default.number +}), _propTypes2.default.bool]); + +var propTypes = { + animatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string).isRequired, + animation: ANIMATION_PROPTYPES, + onStart: _propTypes2.default.func, + onEnd: _propTypes2.default.func +}; + +/** + * Format the animation style object + * @param {Object|String} animationStyle - The animation style property, either the name of a + * presets are one of noWobble, gentle, wobbly, stiff + */ +function getAnimationStyle() { + var animationStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _reactMotion.presets.noWobble; + + if (typeof animationStyle === 'string') { + return _reactMotion.presets[animationStyle] || _reactMotion.presets.noWobble; + } + var damping = animationStyle.damping, + stiffness = animationStyle.stiffness; + + return _extends({ + damping: damping || _reactMotion.presets.noWobble.damping, + stiffness: stiffness || _reactMotion.presets.noWobble.stiffness + }, animationStyle); +} + +/** + * Extract the animated props from the entire props object. + * @param {Object} props Props. + * @returns {Object} Object of animated props. + */ +function extractAnimatedPropValues(props) { + var animatedProps = props.animatedProps, + otherProps = _objectWithoutProperties(props, ['animatedProps']); + + return animatedProps.reduce(function (result, animatedPropName) { + if (otherProps.hasOwnProperty(animatedPropName)) { + result[animatedPropName] = otherProps[animatedPropName]; + } + return result; + }, {}); +} + +var Animation = function (_PureComponent) { + _inherits(Animation, _PureComponent); + + function Animation(props) { + _classCallCheck(this, Animation); + + var _this = _possibleConstructorReturn(this, (Animation.__proto__ || Object.getPrototypeOf(Animation)).call(this, props)); + + _this._motionEndHandler = function () { + if (_this.props.onEnd) { + _this.props.onEnd(); + } + }; + + _this._renderChildren = function (_ref) { + var i = _ref.i; + var children = _this.props.children; + + var interpolator = _this._interpolator; + var child = _react2.default.Children.only(children); + var interpolatedProps = interpolator ? interpolator(i) : interpolator; + + // interpolator doesnt play nice with deeply nested objected + // so we expose an additional prop for situations like these, soit _data, + // which stores the full tree and can be recombined with the sanitized version + // after interpolation + var data = interpolatedProps && interpolatedProps.data || null; + if (data && child.props._data) { + data = data.map(function (row, index) { + var correspondingCell = child.props._data[index]; + return _extends({}, row, { + parent: correspondingCell.parent, + children: correspondingCell.children + }); + }); + } + + return _react2.default.cloneElement(child, _extends({}, child.props, interpolatedProps, { + data: data || child.props.data || null, + // enforce re-rendering + _animation: Math.random() + })); + }; + + _this._updateInterpolator(props); + return _this; + } + + _createClass(Animation, [{ + key: 'componentWillUpdate', + value: function componentWillUpdate(props) { + this._updateInterpolator(this.props, props); + if (props.onStart) { + props.onStart(); + } + } + + /** + * Render the child into the parent. + * @param {Number} i Number generated by the spring. + * @returns {React.Component} Rendered react element. + * @private + */ + + }, { + key: '_updateInterpolator', + + + /** + * Update the interpolator function and assign it to this._interpolator. + * @param {Object} oldProps Old props. + * @param {Object} newProps New props. + * @private + */ + value: function _updateInterpolator(oldProps, newProps) { + this._interpolator = (0, _d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps), newProps ? extractAnimatedPropValues(newProps) : null); + } + }, { + key: 'render', + value: function render() { + var animationStyle = getAnimationStyle(this.props.animation); + var defaultStyle = { i: 0 }; + var style = { i: (0, _reactMotion.spring)(1, animationStyle) }; + // In order to make Motion re-run animations each time, the random key is + // always passed. + // TODO: find a better solution for the spring. + var key = Math.random(); + return _react2.default.createElement( + _reactMotion.Motion, + _extends({ defaultStyle: defaultStyle, style: style, key: key }, { onRest: this._motionEndHandler }), + this._renderChildren + ); + } + }]); + + return Animation; +}(_react.PureComponent); + +Animation.propTypes = propTypes; +Animation.displayName = 'Animation'; + +exports.default = Animation; +var AnimationPropType = exports.AnimationPropType = ANIMATION_PROPTYPES; \ No newline at end of file diff --git a/dist/legends/continuous-color-legend.js b/dist/legends/continuous-color-legend.js new file mode 100644 index 000000000..8784a3dcc --- /dev/null +++ b/dist/legends/continuous-color-legend.js @@ -0,0 +1,107 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _theme = require('../theme'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var propTypes = { + className: _propTypes2.default.string, + height: _propTypes2.default.number, + endColor: _propTypes2.default.string, + endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + midColor: _propTypes2.default.string, + midTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + startColor: _propTypes2.default.string, + startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + width: _propTypes2.default.number +}; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var defaultProps = { + className: '', + startColor: _theme.CONTINUOUS_COLOR_RANGE[0], + endColor: _theme.CONTINUOUS_COLOR_RANGE[1] +}; + +function ContinuousColorLegend(_ref) { + var startColor = _ref.startColor, + midColor = _ref.midColor, + endColor = _ref.endColor, + startTitle = _ref.startTitle, + midTitle = _ref.midTitle, + endTitle = _ref.endTitle, + height = _ref.height, + width = _ref.width, + className = _ref.className; + + var colors = [startColor]; + if (midColor) { + colors.push(midColor); + } + colors.push(endColor); + return _react2.default.createElement( + 'div', + { + className: 'rv-continuous-color-legend ' + className, + style: { width: width, height: height } + }, + _react2.default.createElement('div', { + className: 'rv-gradient', + style: { background: 'linear-gradient(to right, ' + colors.join(',') + ')' } + }), + _react2.default.createElement( + 'div', + { className: 'rv-legend-titles' }, + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__left' }, + startTitle + ), + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__right' }, + endTitle + ), + midTitle ? _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__center' }, + midTitle + ) : null + ) + ); +} + +ContinuousColorLegend.displayName = 'ContinuousColorLegend'; +ContinuousColorLegend.propTypes = propTypes; +ContinuousColorLegend.defaultProps = defaultProps; + +exports.default = ContinuousColorLegend; \ No newline at end of file diff --git a/dist/legends/continuous-size-legend.js b/dist/legends/continuous-size-legend.js new file mode 100644 index 000000000..91f072d5e --- /dev/null +++ b/dist/legends/continuous-size-legend.js @@ -0,0 +1,116 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var propTypes = { + className: _propTypes2.default.string, + circlesTotal: _propTypes2.default.number, + endSize: _propTypes2.default.number, + endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + height: _propTypes2.default.number, + startSize: _propTypes2.default.number, + startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, + width: _propTypes2.default.number +}; + +var defaultProps = { + circlesTotal: 10, + className: '', + endSize: 20, + startSize: 2 +}; + +function ContinuousSizeLegend(_ref) { + var startTitle = _ref.startTitle, + endTitle = _ref.endTitle, + startSize = _ref.startSize, + endSize = _ref.endSize, + circlesTotal = _ref.circlesTotal, + height = _ref.height, + width = _ref.width, + className = _ref.className; + + var circles = []; + var step = (endSize - startSize) / (circlesTotal - 1); + + for (var i = 0; i < circlesTotal; i++) { + var size = step * i + startSize; + circles.push(_react2.default.createElement('div', { + key: i, + className: 'rv-bubble', + style: { + width: size, + height: size, + borderRadius: size / 2 + } + })); + // Add the separator in order to justify the content (otherwise the tags + // will be stacked together without any margins around). + circles.push(' '); + } + return _react2.default.createElement( + 'div', + { + className: 'rv-continuous-size-legend ' + className, + style: { width: width, height: height } + }, + _react2.default.createElement( + 'div', + { className: 'rv-bubbles', style: { height: endSize } }, + circles, + _react2.default.createElement('div', { className: 'rv-spacer' }) + ), + _react2.default.createElement( + 'div', + { className: 'rv-legend-titles' }, + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__left' }, + startTitle + ), + _react2.default.createElement( + 'span', + { className: 'rv-legend-titles__right' }, + endTitle + ) + ) + ); +} + +ContinuousSizeLegend.displayName = 'ContinuousSizeLegend'; +ContinuousSizeLegend.propTypes = propTypes; +ContinuousSizeLegend.defaultProps = defaultProps; + +exports.default = ContinuousSizeLegend; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend-item.js b/dist/legends/discrete-color-legend-item.js new file mode 100644 index 000000000..4b12b4428 --- /dev/null +++ b/dist/legends/discrete-color-legend-item.js @@ -0,0 +1,103 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var STROKE_STYLES = { + dashed: '6, 2', + solid: null +}; + +function DiscreteColorLegendItem(_ref) { + var color = _ref.color, + strokeDasharray = _ref.strokeDasharray, + strokeStyle = _ref.strokeStyle, + strokeWidth = _ref.strokeWidth, + disabled = _ref.disabled, + onClick = _ref.onClick, + orientation = _ref.orientation, + onMouseEnter = _ref.onMouseEnter, + onMouseLeave = _ref.onMouseLeave, + title = _ref.title; + + var className = 'rv-discrete-color-legend-item ' + orientation; + if (disabled) { + className += ' disabled'; + } + if (onClick) { + className += ' clickable'; + } + var strokeDasharrayStyle = STROKE_STYLES[strokeStyle] || strokeDasharray; + return _react2.default.createElement( + 'div', + { className: className, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, + _react2.default.createElement( + 'svg', + { className: 'rv-discrete-color-legend-item__color', height: 2, width: 14 }, + _react2.default.createElement('path', { + className: 'rv-discrete-color-legend-item__color__path', + d: 'M 0, 1 L 14, 1', + style: _extends({}, strokeWidth ? { strokeWidth: strokeWidth } : {}, strokeDasharrayStyle ? { strokeDasharray: strokeDasharrayStyle } : {}, { + stroke: disabled ? null : color + }) + + }) + ), + _react2.default.createElement( + 'span', + { className: 'rv-discrete-color-legend-item__title' }, + title + ) + ); +} + +DiscreteColorLegendItem.propTypes = { + color: _propTypes2.default.string.isRequired, + disabled: _propTypes2.default.bool, + title: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]).isRequired, + onClick: _propTypes2.default.func, + onMouseEnter: _propTypes2.default.func, + onMouseLeave: _propTypes2.default.func, + orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']).isRequired, + strokeDasharray: _propTypes2.default.string, + strokeWidth: _propTypes2.default.number, + strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)) +}; +DiscreteColorLegendItem.defaultProps = { + disabled: false, + strokeStyle: 'solid' +}; +DiscreteColorLegendItem.displayName = 'DiscreteColorLegendItem'; + +exports.default = DiscreteColorLegendItem; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend.js b/dist/legends/discrete-color-legend.js new file mode 100644 index 000000000..76424e745 --- /dev/null +++ b/dist/legends/discrete-color-legend.js @@ -0,0 +1,107 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _discreteColorLegendItem = require('./discrete-color-legend-item'); + +var _discreteColorLegendItem2 = _interopRequireDefault(_discreteColorLegendItem); + +var _theme = require('../theme'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function DiscreteColorLegend(_ref) { + var className = _ref.className, + colors = _ref.colors, + height = _ref.height, + items = _ref.items, + onItemClick = _ref.onItemClick, + onItemMouseEnter = _ref.onItemMouseEnter, + onItemMouseLeave = _ref.onItemMouseLeave, + orientation = _ref.orientation, + style = _ref.style, + width = _ref.width; + + return _react2.default.createElement( + 'div', + { + className: 'rv-discrete-color-legend ' + orientation + ' ' + className, + style: _extends({ width: width, height: height }, style) + }, + items.map(function (item, i) { + return _react2.default.createElement(_discreteColorLegendItem2.default, { + title: item.title ? item.title : item, + color: item.color ? item.color : colors[i % colors.length], + strokeDasharray: item.strokeDasharray, + strokeStyle: item.strokeStyle, + strokeWidth: item.strokeWidth, + disabled: Boolean(item.disabled), + orientation: orientation, + key: i, + onClick: onItemClick ? function (e) { + return onItemClick(item, i, e); + } : null, + onMouseEnter: onItemMouseEnter ? function (e) { + return onItemMouseEnter(item, i, e); + } : null, + onMouseLeave: onItemMouseEnter ? function (e) { + return onItemMouseLeave(item, i, e); + } : null + }); + }) + ); +} + +DiscreteColorLegend.displayName = 'DiscreteColorLegendItem'; +DiscreteColorLegend.propTypes = { + className: _propTypes2.default.string, + items: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.shape({ + title: _propTypes2.default.string.isRequired, + color: _propTypes2.default.string, + disabled: _propTypes2.default.bool + }), _propTypes2.default.string.isRequired, _propTypes2.default.element])).isRequired, + onItemClick: _propTypes2.default.func, + onItemMouseEnter: _propTypes2.default.func, + onItemMouseLeave: _propTypes2.default.func, + height: _propTypes2.default.number, + width: _propTypes2.default.number, + orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']) +}; + +DiscreteColorLegend.defaultProps = { + className: '', + colors: _theme.DISCRETE_COLOR_RANGE, + orientation: 'vertical' +}; + +exports.default = DiscreteColorLegend; \ No newline at end of file diff --git a/dist/legends/searchable-discrete-color-legend.js b/dist/legends/searchable-discrete-color-legend.js new file mode 100644 index 000000000..49e081ef0 --- /dev/null +++ b/dist/legends/searchable-discrete-color-legend.js @@ -0,0 +1,107 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _discreteColorLegend = require('./discrete-color-legend'); + +var _discreteColorLegend2 = _interopRequireDefault(_discreteColorLegend); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var propTypes = _extends({}, _discreteColorLegend2.default.propTypes, { + searchText: _propTypes2.default.string, + onSearchChange: _propTypes2.default.func, + searchPlaceholder: _propTypes2.default.string, + searchFn: _propTypes2.default.func +}); + +var defaultProps = { + className: '', + searchText: '', + searchFn: function searchFn(items, s) { + return items.filter(function (item) { + return String(item.title || item).toLowerCase().indexOf(s) !== -1; + }); + } +}; + +function SearchableDiscreteColorLegend(props) { + var className = props.className, + colors = props.colors, + height = props.height, + items = props.items, + onItemClick = props.onItemClick, + onSearchChange = props.onSearchChange, + orientation = props.orientation, + searchFn = props.searchFn, + searchPlaceholder = props.searchPlaceholder, + searchText = props.searchText, + width = props.width; + + var onChange = onSearchChange ? function (_ref) { + var value = _ref.target.value; + return onSearchChange(value); + } : null; + var filteredItems = searchFn(items, searchText); + return _react2.default.createElement( + 'div', + { className: 'rv-search-wrapper ' + className, style: { width: width, height: height } }, + _react2.default.createElement( + 'form', + { className: 'rv-search-wrapper__form' }, + _react2.default.createElement('input', { + type: 'search', + placeholder: searchPlaceholder, + className: 'rv-search-wrapper__form__input', + value: searchText, + onChange: onChange + }) + ), + _react2.default.createElement( + 'div', + { className: 'rv-search-wrapper__contents' }, + _react2.default.createElement(_discreteColorLegend2.default, { + colors: colors, + items: filteredItems, + onItemClick: onItemClick, + orientation: orientation + }) + ) + ); +} + +SearchableDiscreteColorLegend.propTypes = propTypes; +SearchableDiscreteColorLegend.defaultProps = defaultProps; +SearchableDiscreteColorLegend.displayName = 'SearchableDiscreteColorLegend'; + +exports.default = SearchableDiscreteColorLegend; \ No newline at end of file diff --git a/dist/main.scss b/dist/main.scss new file mode 100644 index 000000000..30bac3dc2 --- /dev/null +++ b/dist/main.scss @@ -0,0 +1,9 @@ +// special tag for using to check if the style file has been imported +.react-vis-magic-css-import-rule { + display: inherit; +} + +@import 'styles/treemap'; +@import 'styles/plot'; +@import 'styles/legends'; +@import 'styles/radial-chart'; diff --git a/dist/make-vis-flexible.js b/dist/make-vis-flexible.js new file mode 100644 index 000000000..c99808b61 --- /dev/null +++ b/dist/make-vis-flexible.js @@ -0,0 +1,250 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.FlexibleXYPlot = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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; }; }(); + +exports.makeHeightFlexible = makeHeightFlexible; +exports.makeVisFlexible = makeVisFlexible; +exports.makeWidthFlexible = makeWidthFlexible; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _window = require('global/window'); + +var _window2 = _interopRequireDefault(_window); + +var _xyPlot = require('./plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _reactUtils = require('./utils/react-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var CONTAINER_REF = 'container'; + +// As a performance enhancement, we want to only listen once +var resizeSubscribers = []; +var DEBOUNCE_DURATION = 100; +var timeoutId = null; + +/** + * Calls each subscriber, debounced to the + */ +function debounceEmitResize() { + _window2.default.clearTimeout(timeoutId); + timeoutId = _window2.default.setTimeout(emitResize, DEBOUNCE_DURATION); +} + +/** + * Calls each subscriber once syncronously. + */ +function emitResize() { + resizeSubscribers.forEach(function (cb) { + return cb(); + }); +} + +/** + * Add the given callback to the list of subscribers to be caled when the + * window resizes. Returns a function that, when called, removes the given + * callback from the list of subscribers. This function is also resposible for + * adding and removing the resize listener on `window`. + * + * @param {Function} cb - Subscriber callback function + * @returns {Function} Unsubscribe function + */ +function subscribeToDebouncedResize(cb) { + resizeSubscribers.push(cb); + + // if we go from zero to one Flexible components instances, add the listener + if (resizeSubscribers.length === 1) { + _window2.default.addEventListener('resize', debounceEmitResize); + } + return function unsubscribe() { + removeSubscriber(cb); + + // if we have no Flexible components, remove the listener + if (resizeSubscribers.length === 0) { + _window2.default.clearTimeout(timeoutId); + _window2.default.removeEventListener('resize', debounceEmitResize); + } + }; +} + +/** + * Helper for removing the given callback from the list of subscribers. + * + * @param {Function} cb - Subscriber callback function + */ +function removeSubscriber(cb) { + var index = resizeSubscribers.indexOf(cb); + if (index > -1) { + resizeSubscribers.splice(index, 1); + } +} + +/** + * Helper for getting a display name for the child component + * @param {*} Component React class for the child component. + * @returns {String} The child components name + */ +function getDisplayName(Component) { + return Component.displayName || Component.name || 'Component'; +} + +/** + * Add the ability to stretch the visualization on window resize. + * @param {*} Component React class for the child component. + * @returns {*} Flexible component. + */ + +function makeFlexible(Component, isWidthFlexible, isHeightFlexible) { + var ResultClass = function (_React$Component) { + _inherits(ResultClass, _React$Component); + + _createClass(ResultClass, null, [{ + key: 'propTypes', + get: function get() { + var _Component$propTypes = Component.propTypes, + height = _Component$propTypes.height, + width = _Component$propTypes.width, + otherPropTypes = _objectWithoutProperties(_Component$propTypes, ['height', 'width']); // eslint-disable-line no-unused-vars + + + return otherPropTypes; + } + }]); + + function ResultClass(props) { + _classCallCheck(this, ResultClass); + + var _this = _possibleConstructorReturn(this, (ResultClass.__proto__ || Object.getPrototypeOf(ResultClass)).call(this, props)); + + _this._onResize = function () { + var containerElement = (0, _reactUtils.getDOMNode)(_this[CONTAINER_REF]); + var offsetHeight = containerElement.offsetHeight, + offsetWidth = containerElement.offsetWidth; + + + var newHeight = _this.state.height === offsetHeight ? {} : { height: offsetHeight }; + + var newWidth = _this.state.width === offsetWidth ? {} : { width: offsetWidth }; + + _this.setState(_extends({}, newHeight, newWidth)); + }; + + _this.state = { + height: 0, + width: 0 + }; + return _this; + } + + /** + * Get the width of the container and assign the width. + * @private + */ + + + _createClass(ResultClass, [{ + key: 'componentDidMount', + value: function componentDidMount() { + this._onResize(); + this.cancelSubscription = subscribeToDebouncedResize(this._onResize); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps() { + this._onResize(); + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + this.cancelSubscription(); + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _state = this.state, + height = _state.height, + width = _state.width; + + var props = _extends({}, this.props, { + animation: height === 0 && width === 0 ? null : this.props.animation + }); + + var updatedDimensions = _extends({}, isHeightFlexible ? { height: height } : {}, isWidthFlexible ? { width: width } : {}); + + return _react2.default.createElement( + 'div', + { + ref: function ref(_ref) { + return _this2[CONTAINER_REF] = _ref; + }, + style: { width: '100%', height: '100%' } + }, + _react2.default.createElement(Component, _extends({}, updatedDimensions, props)) + ); + } + }]); + + return ResultClass; + }(_react2.default.Component); + + ResultClass.displayName = 'Flexible' + getDisplayName(Component); + + return ResultClass; +} + +function makeHeightFlexible(component) { + return makeFlexible(component, false, true); +} + +function makeVisFlexible(component) { + return makeFlexible(component, true, true); +} + +function makeWidthFlexible(component) { + return makeFlexible(component, true, false); +} + +var FlexibleWidthXYPlot = exports.FlexibleWidthXYPlot = makeWidthFlexible(_xyPlot2.default); +var FlexibleHeightXYPlot = exports.FlexibleHeightXYPlot = makeHeightFlexible(_xyPlot2.default); +var FlexibleXYPlot = exports.FlexibleXYPlot = makeVisFlexible(_xyPlot2.default); \ No newline at end of file diff --git a/dist/parallel-coordinates/index.js b/dist/parallel-coordinates/index.js new file mode 100644 index 000000000..6b39942e9 --- /dev/null +++ b/dist/parallel-coordinates/index.js @@ -0,0 +1,360 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Scale = require('d3-scale'); + +var _d3Format = require('d3-format'); + +var _animation = require('../animation'); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _theme = require('../theme'); + +var _chartUtils = require('../utils/chart-utils'); + +var _lineSeries = require('../plot/series/line-series'); + +var _lineSeries2 = _interopRequireDefault(_lineSeries); + +var _lineMarkSeries = require('../plot/series/line-mark-series'); + +var _lineMarkSeries2 = _interopRequireDefault(_lineMarkSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _decorativeAxis = require('../plot/axis/decorative-axis'); + +var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); + +var _highlight = require('../plot/highlight'); + +var _highlight2 = _interopRequireDefault(_highlight); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +var predefinedClassName = 'rv-parallel-coordinates-chart'; +var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); +/** + * Generate axes for each of the domains + * @param {Object} props + - props.animation {Boolean} + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for the whole chart + - props.tickFormat {Function} formatting function for axes + * @return {Array} the plotted axis components + */ +function getAxes(props) { + var animation = props.animation, + domains = props.domains, + style = props.style, + tickFormat = props.tickFormat; + + return domains.map(function (domain, index) { + var sortedDomain = domain.domain; + + var domainTickFormat = function domainTickFormat(t) { + return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); + }; + + return _react2.default.createElement(_decorativeAxis2.default, { + animation: animation, + key: index + '-axis', + axisStart: { x: domain.name, y: 0 }, + axisEnd: { x: domain.name, y: 1 }, + axisDomain: sortedDomain, + numberOfTicks: 5, + tickValue: domainTickFormat, + style: style.axes + }); + }); +} + +/** + * Generate labels for the ends of the axes + * @param {Object} props + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for just the labels + * @return {Array} the prepped data for the labelSeries + */ +function getLabels(props) { + var domains = props.domains, + style = props.style; + + return domains.map(function (domain, index) { + return { + x: domain.name, + y: 1.1, + label: domain.name, + style: style + }; + }); +} + +/** + * Generate the actual lines to be plotted + * @param {Object} props + - props.animation {Boolean} + - props.data {Array} array of object specifying what values are to be plotted + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for the whole chart + - props.showMarks {Bool} whether or not to use the line mark series + * @return {Array} the plotted axis components + */ +function getLines(props) { + var animation = props.animation, + brushFilters = props.brushFilters, + colorRange = props.colorRange, + domains = props.domains, + data = props.data, + style = props.style, + showMarks = props.showMarks; + + var scales = domains.reduce(function (acc, _ref) { + var domain = _ref.domain, + name = _ref.name; + + acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); + return acc; + }, {}); + // const + + return data.map(function (row, rowIndex) { + var withinFilteredRange = true; + var mappedData = domains.map(function (domain, index) { + var getValue = domain.getValue, + name = domain.name; + + // watch out! Gotcha afoot + // yVal after being scale is in [0, 1] range + + var yVal = scales[name](getValue ? getValue(row) : row[name]); + var filter = brushFilters[name]; + // filter value after being scale back from pixel space is also in [0, 1] + if (filter && (yVal < filter.min || yVal > filter.max)) { + withinFilteredRange = false; + } + return { x: name, y: yVal }; + }); + var selectedName = predefinedClassName + '-line'; + var unselectedName = selectedName + ' ' + predefinedClassName + '-line-unselected'; + var lineProps = { + animation: animation, + className: withinFilteredRange ? selectedName : unselectedName, + key: rowIndex + '-polygon', + data: mappedData, + color: row.color || colorRange[rowIndex % colorRange.length], + style: _extends({}, style.lines, row.style || {}) + }; + if (!withinFilteredRange) { + lineProps.style = _extends({}, lineProps.style, style.deselectedLineStyle); + } + return showMarks ? _react2.default.createElement(_lineMarkSeries2.default, lineProps) : _react2.default.createElement(_lineSeries2.default, lineProps); + }); +} + +var ParallelCoordinates = function (_Component) { + _inherits(ParallelCoordinates, _Component); + + function ParallelCoordinates() { + var _ref2; + + var _temp, _this, _ret; + + _classCallCheck(this, ParallelCoordinates); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = ParallelCoordinates.__proto__ || Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2, [this].concat(args))), _this), _this.state = { + brushFilters: {} + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(ParallelCoordinates, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var brushFilters = this.state.brushFilters; + var _props = this.props, + animation = _props.animation, + brushing = _props.brushing, + className = _props.className, + children = _props.children, + colorRange = _props.colorRange, + data = _props.data, + domains = _props.domains, + height = _props.height, + hideInnerMostValues = _props.hideInnerMostValues, + margin = _props.margin, + onMouseLeave = _props.onMouseLeave, + onMouseEnter = _props.onMouseEnter, + showMarks = _props.showMarks, + style = _props.style, + tickFormat = _props.tickFormat, + width = _props.width; + + + var axes = getAxes({ + domains: domains, + animation: animation, + hideInnerMostValues: hideInnerMostValues, + style: style, + tickFormat: tickFormat + }); + + var lines = getLines({ + animation: animation, + brushFilters: brushFilters, + colorRange: colorRange, + domains: domains, + data: data, + showMarks: showMarks, + style: style + }); + var labelSeries = _react2.default.createElement(_labelSeries2.default, { + animation: true, + key: className, + className: predefinedClassName + '-label', + data: getLabels({ domains: domains, style: style.labels }) + }); + + var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS), + marginLeft = _getInnerDimensions.marginLeft, + marginRight = _getInnerDimensions.marginRight; + + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + width: width, + margin: margin, + dontCheckIfEmpty: true, + className: className + ' ' + predefinedClassName, + onMouseLeave: onMouseLeave, + onMouseEnter: onMouseEnter, + xType: 'ordinal', + yDomain: [0, 1] + }, + children, + axes.concat(lines).concat(labelSeries), + brushing && domains.map(function (d) { + var trigger = function trigger(row) { + _this2.setState({ + brushFilters: _extends({}, brushFilters, _defineProperty({}, d.name, row ? { min: row.bottom, max: row.top } : null)) + }); + }; + return _react2.default.createElement(_highlight2.default, { + key: d.name, + drag: true, + highlightX: d.name, + onBrushEnd: trigger, + onDragEnd: trigger, + highlightWidth: (width - marginLeft - marginRight) / domains.length, + enableX: false + }); + }) + ); + } + }]); + + return ParallelCoordinates; +}(_react.Component); + +ParallelCoordinates.displayName = 'ParallelCoordinates'; +ParallelCoordinates.propTypes = { + animation: _animation.AnimationPropType, + brushing: _propTypes2.default.bool, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), + data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + name: _propTypes2.default.string.isRequired, + domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, + tickFormat: _propTypes2.default.func + })).isRequired, + height: _propTypes2.default.number.isRequired, + margin: _chartUtils.MarginPropType, + style: _propTypes2.default.shape({ + axes: _propTypes2.default.object, + labels: _propTypes2.default.object, + lines: _propTypes2.default.object + }), + showMarks: _propTypes2.default.bool, + tickFormat: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired +}; +ParallelCoordinates.defaultProps = { + className: '', + colorType: 'category', + colorRange: _theme.DISCRETE_COLOR_RANGE, + style: { + axes: { + line: {}, + ticks: {}, + text: {} + }, + labels: { + fontSize: 10, + textAnchor: 'middle' + }, + lines: { + strokeWidth: 1, + strokeOpacity: 1 + }, + deselectedLineStyle: { + strokeOpacity: 0.1 + } + }, + tickFormat: DEFAULT_FORMAT +}; + +exports.default = ParallelCoordinates; \ No newline at end of file diff --git a/dist/plot/axis/axis-line.js b/dist/plot/axis/axis-line.js new file mode 100644 index 000000000..23b8f0d9c --- /dev/null +++ b/dist/plot/axis/axis-line.js @@ -0,0 +1,99 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = { + height: _propTypes2.default.number.isRequired, + style: _propTypes2.default.object, + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, + width: _propTypes2.default.number.isRequired +}; + +var defaultProps = { + style: {} +}; + +function AxisLine(_ref) { + var orientation = _ref.orientation, + width = _ref.width, + height = _ref.height, + style = _ref.style; + + var lineProps = void 0; + if (orientation === LEFT) { + lineProps = { + x1: width, + x2: width, + y1: 0, + y2: height + }; + } else if (orientation === RIGHT) { + lineProps = { + x1: 0, + x2: 0, + y1: 0, + y2: height + }; + } else if (orientation === TOP) { + lineProps = { + x1: 0, + x2: width, + y1: height, + y2: height + }; + } else { + lineProps = { + x1: 0, + x2: width, + y1: 0, + y2: 0 + }; + } + return _react2.default.createElement('line', _extends({}, lineProps, { className: 'rv-xy-plot__axis__line', style: style })); +} + +AxisLine.defaultProps = defaultProps; +AxisLine.displayName = 'AxisLine'; +AxisLine.propTypes = propTypes; + +exports.default = AxisLine; \ No newline at end of file diff --git a/dist/plot/axis/axis-ticks.js b/dist/plot/axis/axis-ticks.js new file mode 100644 index 000000000..f0d0b8e91 --- /dev/null +++ b/dist/plot/axis/axis-ticks.js @@ -0,0 +1,271 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +var _scalesUtils = require('../../utils/scales-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = { + height: _propTypes2.default.number.isRequired, + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, + style: _propTypes2.default.object, + width: _propTypes2.default.number.isRequired +}; + +var defaultProps = { + style: {} +}; + +function _getTickFormatFn(scale, tickTotal, tickFormat) { + return !tickFormat ? scale.tickFormat ? scale.tickFormat(tickTotal) : function (v) { + return v; + } : tickFormat; +} + +var AxisTicks = function (_React$Component) { + _inherits(AxisTicks, _React$Component); + + function AxisTicks() { + _classCallCheck(this, AxisTicks); + + return _possibleConstructorReturn(this, (AxisTicks.__proto__ || Object.getPrototypeOf(AxisTicks)).apply(this, arguments)); + } + + _createClass(AxisTicks, [{ + key: '_areTicksWrapped', + + /** + * Check if axis ticks should be mirrored (for the right and top positions. + * @returns {boolean} True if mirrored. + * @private + */ + value: function _areTicksWrapped() { + var orientation = this.props.orientation; + + return orientation === LEFT || orientation === TOP; + } + }, { + key: '_getTickContainerPropsGetterFn', + value: function _getTickContainerPropsGetterFn() { + if (this._isAxisVertical()) { + return function (pos) { + return { transform: 'translate(0, ' + pos + ')' }; + }; + } + return function (pos) { + return { transform: 'translate(' + pos + ', 0)' }; + }; + } + + /** + * Get attributes for the label of the tick. + * @returns {Object} Object with properties. + * @private + */ + + }, { + key: '_getTickLabelProps', + value: function _getTickLabelProps() { + var _props = this.props, + orientation = _props.orientation, + tickLabelAngle = _props.tickLabelAngle, + tickSize = _props.tickSize, + _props$tickSizeOuter = _props.tickSizeOuter, + tickSizeOuter = _props$tickSizeOuter === undefined ? tickSize : _props$tickSizeOuter, + _props$tickPadding = _props.tickPadding, + tickPadding = _props$tickPadding === undefined ? tickSize : _props$tickPadding; + + // Assign the text orientation inside the label of the tick mark. + + var textAnchor = void 0; + if (orientation === LEFT || orientation === BOTTOM && tickLabelAngle) { + textAnchor = 'end'; + } else if (orientation === RIGHT || orientation === TOP && tickLabelAngle) { + textAnchor = 'start'; + } else { + textAnchor = 'middle'; + } + + // The label's position is translated to the given padding and then the + // label is rotated to the given angle. + var isVertical = this._isAxisVertical(); + var wrap = this._areTicksWrapped() ? -1 : 1; + + var labelOffset = wrap * (tickSizeOuter + tickPadding); + var transform = (isVertical ? 'translate(' + labelOffset + ', 0)' : 'translate(0, ' + labelOffset + ')') + (tickLabelAngle ? ' rotate(' + tickLabelAngle + ')' : ''); + + // Set the vertical offset of the label according to the position of + // the axis. + var dy = orientation === TOP || tickLabelAngle ? '0' : orientation === BOTTOM ? '0.72em' : '0.32em'; + + return { + textAnchor: textAnchor, + dy: dy, + transform: transform + }; + } + + /** + * Get the props of the tick line. + * @returns {Object} Props. + * @private + */ + + }, { + key: '_getTickLineProps', + value: function _getTickLineProps() { + var _ref; + + var _props2 = this.props, + tickSize = _props2.tickSize, + _props2$tickSizeOuter = _props2.tickSizeOuter, + tickSizeOuter = _props2$tickSizeOuter === undefined ? tickSize : _props2$tickSizeOuter, + _props2$tickSizeInner = _props2.tickSizeInner, + tickSizeInner = _props2$tickSizeInner === undefined ? tickSize : _props2$tickSizeInner; + + var isVertical = this._isAxisVertical(); + var tickXAttr = isVertical ? 'y' : 'x'; + var tickYAttr = isVertical ? 'x' : 'y'; + var wrap = this._areTicksWrapped() ? -1 : 1; + return _ref = {}, _defineProperty(_ref, tickXAttr + '1', 0), _defineProperty(_ref, tickXAttr + '2', 0), _defineProperty(_ref, tickYAttr + '1', -wrap * tickSizeInner), _defineProperty(_ref, tickYAttr + '2', wrap * tickSizeOuter), _ref; + } + + /** + * Gets if the axis is vertical. + * @returns {boolean} True if vertical. + * @private + */ + + }, { + key: '_isAxisVertical', + value: function _isAxisVertical() { + var orientation = this.props.orientation; + + return orientation === LEFT || orientation === RIGHT; + } + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + attr = _props3.attr, + orientation = _props3.orientation, + width = _props3.width, + height = _props3.height, + style = _props3.style, + tickFormat = _props3.tickFormat, + tickTotal = _props3.tickTotal, + tickValues = _props3.tickValues; + + + var x = orientation === LEFT ? width : 0; + var y = orientation === TOP ? height : 0; + + var scale = (0, _scalesUtils.getAttributeScale)(this.props, attr); + + var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); + var tickFormatFn = _getTickFormatFn(scale, tickTotal, tickFormat); + + var translateFn = this._getTickContainerPropsGetterFn(); + var pathProps = this._getTickLineProps(); + var textProps = this._getTickLabelProps(); + + var ticks = values.map(function (v, i) { + var pos = scale(v); + var labelNode = tickFormatFn(v, i, scale, tickTotal); + var shouldRenderAsOwnNode = _react2.default.isValidElement(labelNode) && !['tspan', 'textPath'].includes(labelNode.type); + var shouldAddProps = labelNode && typeof labelNode.type !== 'string'; + return _react2.default.createElement( + 'g', + _extends({ + key: i + }, translateFn(pos, 0), { + className: 'rv-xy-plot__axis__tick', + style: style + }), + _react2.default.createElement('line', _extends({}, pathProps, { + className: 'rv-xy-plot__axis__tick__line', + style: _extends({}, style, style.line) + })), + shouldRenderAsOwnNode ? _react2.default.cloneElement(labelNode, shouldAddProps ? _extends({}, textProps, { + containerWidth: width, + tickCount: values.length + }) : undefined) : _react2.default.createElement( + 'text', + _extends({}, textProps, { + className: 'rv-xy-plot__axis__tick__text', + style: _extends({}, style, style.text) + }), + labelNode + ) + ); + }); + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + x + ', ' + y + ')', + className: 'rv-xy-plot__axis__ticks' + }, + ticks + ); + } + }]); + + return AxisTicks; +}(_react2.default.Component); + +AxisTicks.defaultProps = defaultProps; +AxisTicks.displayName = 'AxisTicks'; +AxisTicks.propTypes = propTypes; +AxisTicks.requiresSVG = true; + +exports.default = AxisTicks; \ No newline at end of file diff --git a/dist/plot/axis/axis-title.js b/dist/plot/axis/axis-title.js new file mode 100644 index 000000000..619a31ec1 --- /dev/null +++ b/dist/plot/axis/axis-title.js @@ -0,0 +1,186 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// Assuming that 16px = 1em +var ADJUSTMENT_FOR_TEXT_SIZE = 16; +var MARGIN = 6; +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + +var defaultProps = { + position: 'end' +}; + +/** + * Compute transformations, keyed by orientation + * @param {number} width - width of axis + * @param {number} height - height of axis + * @returns {Object} Object of transformations, keyed by orientation + */ +var transformation = function transformation(width, height) { + var _ref; + + return _ref = {}, _defineProperty(_ref, LEFT, { + end: { + x: ADJUSTMENT_FOR_TEXT_SIZE, + y: MARGIN, + rotation: -90, + textAnchor: 'end' + }, + middle: { + x: ADJUSTMENT_FOR_TEXT_SIZE, + y: height / 2 - MARGIN, + rotation: -90, + textAnchor: 'middle' + }, + start: { + x: ADJUSTMENT_FOR_TEXT_SIZE, + y: height - MARGIN, + rotation: -90, + textAnchor: 'start' + } + }), _defineProperty(_ref, RIGHT, { + end: { + x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, + y: MARGIN, + rotation: -90, + textAnchor: 'end' + }, + middle: { + x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, + y: height / 2 - MARGIN, + rotation: -90, + textAnchor: 'middle' + }, + start: { + x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, + y: height - MARGIN, + rotation: -90, + textAnchor: 'start' + } + }), _defineProperty(_ref, TOP, { + start: { + x: MARGIN, + y: ADJUSTMENT_FOR_TEXT_SIZE, + rotation: 0, + textAnchor: 'start' + }, + middle: { + x: width / 2 - MARGIN, + y: ADJUSTMENT_FOR_TEXT_SIZE, + rotation: 0, + textAnchor: 'middle' + }, + end: { + x: width - MARGIN, + y: ADJUSTMENT_FOR_TEXT_SIZE, + rotation: 0, + textAnchor: 'end' + } + }), _defineProperty(_ref, BOTTOM, { + start: { + x: MARGIN, + y: -MARGIN, + rotation: 0, + textAnchor: 'start' + }, + middle: { + x: width / 2 - MARGIN, + y: -MARGIN, + rotation: 0, + textAnchor: 'middle' + }, + end: { + x: width - MARGIN, + y: -MARGIN, + rotation: 0, + textAnchor: 'end' + } + }), _ref; +}; + +var propTypes = { + width: _propTypes2.default.number.isRequired, + height: _propTypes2.default.number.isRequired, + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, + style: _propTypes2.default.object, + title: _propTypes2.default.string.isRequired +}; + +function AxisTitle(_ref2) { + var orientation = _ref2.orientation, + position = _ref2.position, + width = _ref2.width, + height = _ref2.height, + style = _ref2.style, + title = _ref2.title; + + var outerGroupTranslateX = orientation === LEFT ? width : 0; + var outerGroupTranslateY = orientation === TOP ? height : 0; + var outerGroupTransform = 'translate(' + outerGroupTranslateX + ', ' + outerGroupTranslateY + ')'; + var _transformation$orien = transformation(width, height)[orientation][position], + x = _transformation$orien.x, + y = _transformation$orien.y, + rotation = _transformation$orien.rotation, + textAnchor = _transformation$orien.textAnchor; + + var innerGroupTransform = 'translate(' + x + ', ' + y + ') rotate(' + rotation + ')'; + + return _react2.default.createElement( + 'g', + { transform: outerGroupTransform, className: 'rv-xy-plot__axis__title' }, + _react2.default.createElement( + 'g', + { style: _extends({ textAnchor: textAnchor }, style), transform: innerGroupTransform }, + _react2.default.createElement( + 'text', + { style: style }, + title + ) + ) + ); +} + +AxisTitle.displayName = 'AxisTitle'; +AxisTitle.propTypes = propTypes; +AxisTitle.defaultProps = defaultProps; +exports.default = AxisTitle; \ No newline at end of file diff --git a/dist/plot/axis/axis.js b/dist/plot/axis/axis.js new file mode 100644 index 000000000..e41a8d82b --- /dev/null +++ b/dist/plot/axis/axis.js @@ -0,0 +1,264 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _axisUtils = require('../../utils/axis-utils'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _axisLine = require('./axis-line'); + +var _axisLine2 = _interopRequireDefault(_axisLine); + +var _axisTicks = require('./axis-ticks'); + +var _axisTicks2 = _interopRequireDefault(_axisTicks); + +var _axisTitle = require('./axis-title'); + +var _axisTitle2 = _interopRequireDefault(_axisTitle); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var defaultAnimatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT, + TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = { + orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]), + attr: _propTypes2.default.string.isRequired, + attrAxis: _propTypes2.default.string, + width: _propTypes2.default.number, + height: _propTypes2.default.number, + top: _propTypes2.default.number, + left: _propTypes2.default.number, + title: _propTypes2.default.string, + + style: _propTypes2.default.object, + + className: _propTypes2.default.string, + hideTicks: _propTypes2.default.bool, + hideLine: _propTypes2.default.bool, + on0: _propTypes2.default.bool, + tickLabelAngle: _propTypes2.default.number, + tickSize: _propTypes2.default.number, + tickSizeInner: _propTypes2.default.number, + tickSizeOuter: _propTypes2.default.number, + tickPadding: _propTypes2.default.number, + tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), + tickFormat: _propTypes2.default.func, + tickTotal: _propTypes2.default.number, + + // Not expected to be used by the users. + // TODO: Add underscore to these properties later. + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; + +var defaultProps = { + className: '', + on0: false, + style: {}, + tickSize: 6, + tickPadding: 8, + orientation: BOTTOM +}; + +var predefinedClassName = 'rv-xy-plot__axis'; +var VERTICAL_CLASS_NAME = 'rv-xy-plot__axis--vertical'; +var HORIZONTAL_CLASS_NAME = 'rv-xy-plot__axis--horizontal'; + +var Axis = function (_PureComponent) { + _inherits(Axis, _PureComponent); + + function Axis() { + _classCallCheck(this, Axis); + + return _possibleConstructorReturn(this, (Axis.__proto__ || Object.getPrototypeOf(Axis)).apply(this, arguments)); + } + + _createClass(Axis, [{ + key: '_getDefaultAxisProps', + + /** + * Define the default values depending on the data passed from the outside. + * @returns {*} Object of default properties. + * @private + */ + value: function _getDefaultAxisProps() { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginTop = _props.marginTop, + marginBottom = _props.marginBottom, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + orientation = _props.orientation; + + if (orientation === BOTTOM) { + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), + top: innerHeight + marginTop, + left: marginLeft, + width: innerWidth, + height: marginBottom + }; + } else if (orientation === TOP) { + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), + top: 0, + left: marginLeft, + width: innerWidth, + height: marginTop + }; + } else if (orientation === LEFT) { + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), + top: marginTop, + left: 0, + width: marginLeft, + height: innerHeight + }; + } + return { + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), + top: marginTop, + left: marginLeft + innerWidth, + width: marginRight, + height: innerHeight + }; + } + }, { + key: 'render', + value: function render() { + var animation = this.props.animation; + + + if (animation) { + var animatedProps = animation.nonAnimatedProps ? defaultAnimatedProps.filter(function (prop) { + return animation.nonAnimatedProps.indexOf(prop) < 0; + }) : defaultAnimatedProps; + + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(Axis, _extends({}, this.props, { animation: null })) + ); + } + + var props = _extends({}, this._getDefaultAxisProps(), this.props); + + var attrAxis = props.attrAxis, + className = props.className, + height = props.height, + hideLine = props.hideLine, + hideTicks = props.hideTicks, + left = props.left, + marginTop = props.marginTop, + on0 = props.on0, + orientation = props.orientation, + position = props.position, + style = props.style, + title = props.title, + top = props.top, + width = props.width; + + var isVertical = [LEFT, RIGHT].indexOf(orientation) > -1; + var axisClassName = isVertical ? VERTICAL_CLASS_NAME : HORIZONTAL_CLASS_NAME; + + var leftPos = left; + var topPos = top; + if (on0) { + var scale = (0, _scalesUtils.getAttributeScale)(props, attrAxis); + if (isVertical) { + leftPos = scale(0); + } else { + topPos = marginTop + scale(0); + } + } + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + leftPos + ',' + topPos + ')', + className: predefinedClassName + ' ' + axisClassName + ' ' + className, + style: style + }, + !hideLine && _react2.default.createElement(_axisLine2.default, { + height: height, + width: width, + orientation: orientation, + style: _extends({}, style, style.line) + }), + !hideTicks && _react2.default.createElement(_axisTicks2.default, _extends({}, props, { style: _extends({}, style, style.ticks) })), + title ? _react2.default.createElement(_axisTitle2.default, { + position: position, + title: title, + height: height, + width: width, + style: _extends({}, style, style.title), + orientation: orientation + }) : null + ); + } + }]); + + return Axis; +}(_react.PureComponent); + +Axis.displayName = 'Axis'; +Axis.propTypes = propTypes; +Axis.defaultProps = defaultProps; +Axis.requiresSVG = true; + +exports.default = Axis; \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis-ticks.js b/dist/plot/axis/decorative-axis-ticks.js new file mode 100644 index 000000000..f070bea88 --- /dev/null +++ b/dist/plot/axis/decorative-axis-ticks.js @@ -0,0 +1,99 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.default = decorativeAxisTick; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _axisUtils = require('../../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Generate the actual polygons to be plotted + * @param {Object} props + - props.animation {Boolean} + - props.axisDomain {Array} a pair of values specifying the domain of the axis + - props.numberOfTicks{Number} the number of ticks on the axis + - props.axisStart {Object} a object specify in cartesian space the start of the axis + example: {x: 0, y: 0} + - props.axisEnd {Object} a object specify in cartesian space the start of the axis + - props.tickValue {Func} a formatting function for the tick values + - props.tickSize {Number} a pixel size of the axis + - props.style {Object} The style object for the axis + * @return {Component} the plotted axis + */ +function decorativeAxisTick(props) { + var axisDomain = props.axisDomain, + numberOfTicks = props.numberOfTicks, + axisStart = props.axisStart, + axisEnd = props.axisEnd, + tickValue = props.tickValue, + tickSize = props.tickSize, + style = props.style; + + var _generatePoints = (0, _axisUtils.generatePoints)({ + axisStart: axisStart, + axisEnd: axisEnd, + numberOfTicks: numberOfTicks, + axisDomain: axisDomain + }), + points = _generatePoints.points; + // add a quarter rotation to make ticks orthogonal to axis + + + var tickAngle = (0, _axisUtils.getAxisAngle)(axisStart, axisEnd) + Math.PI / 2; + return points.map(function (point, index) { + var tickProps = _extends({ + x1: 0, + y1: 0, + x2: tickSize * Math.cos(tickAngle), + y2: tickSize * Math.sin(tickAngle) + }, style.ticks); + + var textProps = _extends({ + x: tickSize * Math.cos(tickAngle), + y: tickSize * Math.sin(tickAngle), + textAnchor: 'start' + }, style.text); + return _react2.default.createElement( + 'g', + { + key: index, + transform: 'translate(' + point.x + ', ' + point.y + ')', + className: 'rv-xy-plot__axis__tick' + }, + _react2.default.createElement('line', _extends({}, tickProps, { className: 'rv-xy-plot__axis__tick__line' })), + _react2.default.createElement( + 'text', + _extends({}, textProps, { className: 'rv-xy-plot__axis__tick__text' }), + tickValue(point.text) + ) + ); + }); +} \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis.js b/dist/plot/axis/decorative-axis.js new file mode 100644 index 000000000..809b9dfec --- /dev/null +++ b/dist/plot/axis/decorative-axis.js @@ -0,0 +1,174 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _d3Format = require('d3-format'); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('../series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _decorativeAxisTicks = require('./decorative-axis-ticks'); + +var _decorativeAxisTicks2 = _interopRequireDefault(_decorativeAxisTicks); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-manipulable-axis rv-xy-plot__axis'; + +var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; + +var DecorativeAxis = function (_AbstractSeries) { + _inherits(DecorativeAxis, _AbstractSeries); + + function DecorativeAxis() { + _classCallCheck(this, DecorativeAxis); + + return _possibleConstructorReturn(this, (DecorativeAxis.__proto__ || Object.getPrototypeOf(DecorativeAxis)).apply(this, arguments)); + } + + _createClass(DecorativeAxis, [{ + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + axisStart = _props.axisStart, + axisEnd = _props.axisEnd, + axisDomain = _props.axisDomain, + numberOfTicks = _props.numberOfTicks, + tickValue = _props.tickValue, + tickSize = _props.tickSize, + style = _props.style; + + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(DecorativeAxis, _extends({}, this.props, { animation: null })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + _react2.default.createElement('line', _extends({}, _extends({ + x1: x({ x: axisStart.x }), + x2: x({ x: axisEnd.x }), + y1: y({ y: axisStart.y }), + y2: y({ y: axisEnd.y }) + }, style.line), { + className: 'rv-xy-plot__axis__line' + })), + _react2.default.createElement( + 'g', + { className: 'rv-xy-manipulable-axis__ticks' }, + (0, _decorativeAxisTicks2.default)({ + axisDomain: axisDomain, + axisEnd: { x: x(axisEnd), y: y(axisEnd) }, + axisStart: { x: x(axisStart), y: y(axisStart) }, + numberOfTicks: numberOfTicks, + tickValue: tickValue, + tickSize: tickSize, + style: style + }) + ) + ); + } + }]); + + return DecorativeAxis; +}(_abstractSeries2.default); + +var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); + +DecorativeAxis.defaultProps = { + className: '', + numberOfTicks: 10, + tickValue: function tickValue(d) { + return DEFAULT_FORMAT(d); + }, + tickSize: 5, + style: { + line: { + strokeWidth: 1 + }, + ticks: { + strokeWidth: 2 + }, + text: {} + } +}; +DecorativeAxis.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + axisDomain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, + axisEnd: _propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) + }).isRequired, + axisStart: _propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), + y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) + }).isRequired, + className: _propTypes2.default.string, + numberOfTicks: _propTypes2.default.number, + tickValue: _propTypes2.default.func, + tickSize: _propTypes2.default.number, + style: _propTypes2.default.shape({ + line: _propTypes2.default.object, + ticks: _propTypes2.default.object, + text: _propTypes2.default.object + }) +}); +DecorativeAxis.displayName = 'DecorativeAxis'; +exports.default = DecorativeAxis; \ No newline at end of file diff --git a/dist/plot/axis/x-axis.js b/dist/plot/axis/x-axis.js new file mode 100644 index 000000000..7ea59bbeb --- /dev/null +++ b/dist/plot/axis/x-axis.js @@ -0,0 +1,66 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +var _axis = require('./axis'); + +var _axis2 = _interopRequireDefault(_axis); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var TOP = _axisUtils.ORIENTATION.TOP, + BOTTOM = _axisUtils.ORIENTATION.BOTTOM; + + +var propTypes = _extends({}, _axis2.default.propTypes, { + orientation: _propTypes2.default.oneOf([TOP, BOTTOM]) +}); + +var defaultProps = { + orientation: BOTTOM, + attr: 'x', + attrAxis: 'y' +}; + +function XAxis(props) { + return _react2.default.createElement(_axis2.default, props); +} + +XAxis.displayName = 'XAxis'; +XAxis.propTypes = propTypes; +XAxis.defaultProps = defaultProps; +XAxis.requiresSVG = true; + +exports.default = XAxis; \ No newline at end of file diff --git a/dist/plot/axis/y-axis.js b/dist/plot/axis/y-axis.js new file mode 100644 index 000000000..a77570258 --- /dev/null +++ b/dist/plot/axis/y-axis.js @@ -0,0 +1,66 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../../utils/axis-utils'); + +var _axis = require('./axis'); + +var _axis2 = _interopRequireDefault(_axis); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var LEFT = _axisUtils.ORIENTATION.LEFT, + RIGHT = _axisUtils.ORIENTATION.RIGHT; + + +var propTypes = _extends({}, _axis2.default.propTypes, { + orientation: _propTypes2.default.oneOf([LEFT, RIGHT]) +}); + +var defaultProps = { + orientation: LEFT, + attr: 'y', + attrAxis: 'x' +}; + +function YAxis(props) { + return _react2.default.createElement(_axis2.default, props); +} + +YAxis.displayName = 'YAxis'; +YAxis.propTypes = propTypes; +YAxis.defaultProps = defaultProps; +YAxis.requiresSVG = true; + +exports.default = YAxis; \ No newline at end of file diff --git a/dist/plot/borders.js b/dist/plot/borders.js new file mode 100644 index 000000000..fd83342f7 --- /dev/null +++ b/dist/plot/borders.js @@ -0,0 +1,125 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var propTypes = { + style: _propTypes2.default.shape({ + bottom: _propTypes2.default.object, + left: _propTypes2.default.object, + right: _propTypes2.default.object, + top: _propTypes2.default.object + }), + // supplied by xyplot + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; + +var CLASSES = { + bottom: 'rv-xy-plot__borders-bottom', + container: 'rv-xy-plot__borders', + left: 'rv-xy-plot__borders-left', + right: 'rv-xy-plot__borders-right', + top: 'rv-xy-plot__borders-top' +}; + +function Borders(props) { + var marginTop = props.marginTop, + marginBottom = props.marginBottom, + marginLeft = props.marginLeft, + marginRight = props.marginRight, + innerWidth = props.innerWidth, + innerHeight = props.innerHeight, + style = props.style, + className = props.className; + + var height = innerHeight + marginTop + marginBottom; + var width = innerWidth + marginLeft + marginRight; + return _react2.default.createElement( + 'g', + { className: CLASSES.container + ' ' + className }, + _react2.default.createElement('rect', { + className: CLASSES.bottom + ' ' + className + '-bottom', + style: _extends({}, style.all, style.bottom), + x: 0, + y: height - marginBottom, + width: width, + height: marginBottom + }), + _react2.default.createElement('rect', { + className: CLASSES.left + ' ' + className + '-left', + style: _extends({}, style.all, style.left), + x: 0, + y: 0, + width: marginLeft, + height: height + }), + _react2.default.createElement('rect', { + className: CLASSES.right + ' ' + className + '-right', + style: _extends({}, style.all, style.right), + x: width - marginRight, + y: 0, + width: marginRight, + height: height + }), + _react2.default.createElement('rect', { + className: CLASSES.top + ' ' + className + '-top', + style: _extends({}, style.all, style.top), + x: 0, + y: 0, + width: width, + height: marginTop + }) + ); +} + +Borders.displayName = 'Borders'; +Borders.defaultProps = { + className: '', + style: { + all: {}, + bottom: {}, + left: {}, + right: {}, + top: {} + } +}; +Borders.propTypes = propTypes; +Borders.requiresSVG = true; + +exports.default = Borders; \ No newline at end of file diff --git a/dist/plot/circular-grid-lines.js b/dist/plot/circular-grid-lines.js new file mode 100644 index 000000000..a8638ad64 --- /dev/null +++ b/dist/plot/circular-grid-lines.js @@ -0,0 +1,165 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _axisUtils = require('../utils/axis-utils'); + +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; } // Copyright (c) 2016 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; + +var CircularGridLines = function (_PureComponent) { + _inherits(CircularGridLines, _PureComponent); + + function CircularGridLines() { + _classCallCheck(this, CircularGridLines); + + return _possibleConstructorReturn(this, (CircularGridLines.__proto__ || Object.getPrototypeOf(CircularGridLines)).apply(this, arguments)); + } + + _createClass(CircularGridLines, [{ + key: '_getDefaultProps', + value: function _getDefaultProps() { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginTop = _props.marginTop, + marginLeft = _props.marginLeft; + + return { + left: marginLeft, + top: marginTop, + width: innerWidth, + height: innerHeight, + style: {}, + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(Math.min(innerWidth, innerHeight)) + }; + } + }, { + key: 'render', + value: function render() { + var _props2 = this.props, + animation = _props2.animation, + centerX = _props2.centerX, + centerY = _props2.centerY; + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(CircularGridLines, _extends({}, this.props, { animation: null })) + ); + } + + var props = _extends({}, this._getDefaultProps(), this.props); + + var tickTotal = props.tickTotal, + tickValues = props.tickValues, + marginLeft = props.marginLeft, + marginTop = props.marginTop, + rRange = props.rRange, + style = props.style; + + + var xScale = (0, _scalesUtils.getAttributeScale)(props, 'x'); + var yScale = (0, _scalesUtils.getAttributeScale)(props, 'y'); + var values = (0, _axisUtils.getTickValues)(xScale, tickTotal, tickValues); + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + (xScale(centerX) + marginLeft) + ',' + (yScale(centerY) + marginTop) + ')', + className: 'rv-xy-plot__circular-grid-lines' + }, + values.reduce(function (res, value, index) { + var radius = xScale(value); + if (rRange && (radius < rRange[0] || radius > rRange[1])) { + return res; + } + return res.concat([_react2.default.createElement('circle', _extends({ cx: 0, cy: 0, r: radius }, { + key: index, + className: 'rv-xy-plot__circular-grid-lines__line', + style: style + }))]); + }, []) + ); + } + }]); + + return CircularGridLines; +}(_react.PureComponent); + +CircularGridLines.displayName = 'CircularGridLines'; +CircularGridLines.propTypes = { + centerX: _propTypes2.default.number, + centerY: _propTypes2.default.number, + width: _propTypes2.default.number, + height: _propTypes2.default.number, + top: _propTypes2.default.number, + left: _propTypes2.default.number, + rRange: _propTypes2.default.arrayOf(_propTypes2.default.number), + + style: _propTypes2.default.object, + + tickValues: _propTypes2.default.arrayOf(_propTypes2.default.number), + tickTotal: _propTypes2.default.number, + + animation: _animation.AnimationPropType, + // generally supplied by xyplot + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; +CircularGridLines.defaultProps = { + centerX: 0, + centerY: 0 +}; +CircularGridLines.requiresSVG = true; + +exports.default = CircularGridLines; \ No newline at end of file diff --git a/dist/plot/crosshair.js b/dist/plot/crosshair.js new file mode 100644 index 000000000..b9c6edeb7 --- /dev/null +++ b/dist/plot/crosshair.js @@ -0,0 +1,262 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/** + * Format title by detault. + * @param {Array} values List of values. + * @returns {*} Formatted value or undefined. + */ +function defaultTitleFormat(values) { + var value = getFirstNonEmptyValue(values); + if (value) { + return { + title: 'x', + value: value.x + }; + } +} + +/** + * Format items by default. + * @param {Array} values Array of values. + * @returns {*} Formatted list of items. + */ +function defaultItemsFormat(values) { + return values.map(function (v, i) { + if (v) { + return { value: v.y, title: i }; + } + }); +} + +/** + * Get the first non-empty item from an array. + * @param {Array} values Array of values. + * @returns {*} First non-empty value or undefined. + */ +function getFirstNonEmptyValue(values) { + return (values || []).find(function (v) { + return Boolean(v); + }); +} + +var Crosshair = function (_PureComponent) { + _inherits(Crosshair, _PureComponent); + + function Crosshair() { + _classCallCheck(this, Crosshair); + + return _possibleConstructorReturn(this, (Crosshair.__proto__ || Object.getPrototypeOf(Crosshair)).apply(this, arguments)); + } + + _createClass(Crosshair, [{ + key: '_renderCrosshairItems', + + + /** + * Render crosshair items (title + value for each series). + * @returns {*} Array of React classes with the crosshair values. + * @private + */ + value: function _renderCrosshairItems() { + var _props = this.props, + values = _props.values, + itemsFormat = _props.itemsFormat; + + var items = itemsFormat(values); + if (!items) { + return null; + } + return items.filter(function (i) { + return i; + }).map(function renderValue(item, i) { + return _react2.default.createElement( + 'div', + { className: 'rv-crosshair__item', key: 'item' + i }, + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__item__title' }, + item.title + ), + ': ', + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__item__value' }, + item.value + ) + ); + }); + } + + /** + * Render crosshair title. + * @returns {*} Container with the crosshair title. + * @private + */ + + }, { + key: '_renderCrosshairTitle', + value: function _renderCrosshairTitle() { + var _props2 = this.props, + values = _props2.values, + titleFormat = _props2.titleFormat, + style = _props2.style; + + var titleItem = titleFormat(values); + if (!titleItem) { + return null; + } + return _react2.default.createElement( + 'div', + { className: 'rv-crosshair__title', key: 'title', style: style.title }, + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__title__title' }, + titleItem.title + ), + ': ', + _react2.default.createElement( + 'span', + { className: 'rv-crosshair__title__value' }, + titleItem.value + ) + ); + } + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + children = _props3.children, + className = _props3.className, + values = _props3.values, + marginTop = _props3.marginTop, + marginLeft = _props3.marginLeft, + innerWidth = _props3.innerWidth, + innerHeight = _props3.innerHeight, + style = _props3.style; + + var value = getFirstNonEmptyValue(values); + if (!value) { + return null; + } + var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x'); + var innerLeft = x(value); + + var _props$orientation = this.props.orientation, + orientation = _props$orientation === undefined ? innerLeft > innerWidth / 2 ? 'left' : 'right' : _props$orientation; + + var left = marginLeft + innerLeft; + var top = marginTop; + var innerClassName = 'rv-crosshair__inner rv-crosshair__inner--' + orientation; + + return _react2.default.createElement( + 'div', + { + className: 'rv-crosshair ' + className, + style: { left: left + 'px', top: top + 'px' } + }, + _react2.default.createElement('div', { + className: 'rv-crosshair__line', + style: _extends({ height: innerHeight + 'px' }, style.line) + }), + _react2.default.createElement( + 'div', + { className: innerClassName }, + children ? children : _react2.default.createElement( + 'div', + { className: 'rv-crosshair__inner__content', style: style.box }, + _react2.default.createElement( + 'div', + null, + this._renderCrosshairTitle(), + this._renderCrosshairItems() + ) + ) + ) + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return { + titleFormat: defaultTitleFormat, + itemsFormat: defaultItemsFormat, + style: { + line: {}, + title: {}, + box: {} + } + }; + } + }, { + key: 'propTypes', + get: function get() { + return { + className: _propTypes2.default.string, + values: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.object])), + series: _propTypes2.default.object, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + orientation: _propTypes2.default.oneOf(['left', 'right']), + itemsFormat: _propTypes2.default.func, + titleFormat: _propTypes2.default.func, + style: _propTypes2.default.shape({ + line: _propTypes2.default.object, + title: _propTypes2.default.object, + box: _propTypes2.default.object + }) + }; + } + }]); + + return Crosshair; +}(_react.PureComponent); + +Crosshair.displayName = 'Crosshair'; + +exports.default = Crosshair; \ No newline at end of file diff --git a/dist/plot/gradient-defs.js b/dist/plot/gradient-defs.js new file mode 100644 index 000000000..2da31b486 --- /dev/null +++ b/dist/plot/gradient-defs.js @@ -0,0 +1,58 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-gradient-defs'; + +function GradientDefs(props) { + var className = props.className; + + return _react2.default.createElement( + 'defs', + { className: predefinedClassName + ' ' + className }, + props.children + ); +} + +GradientDefs.displayName = 'GradientDefs'; +GradientDefs.requiresSVG = true; +GradientDefs.propTypes = { + className: _propTypes2.default.string +}; +GradientDefs.defaultProps = { + className: '' +}; + +exports.default = GradientDefs; \ No newline at end of file diff --git a/dist/plot/grid-lines.js b/dist/plot/grid-lines.js new file mode 100644 index 000000000..1336d8718 --- /dev/null +++ b/dist/plot/grid-lines.js @@ -0,0 +1,178 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _axisUtils = require('../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var VERTICAL = _axisUtils.DIRECTION.VERTICAL, + HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; + + +var propTypes = { + direction: _propTypes2.default.oneOf([VERTICAL, HORIZONTAL]), + attr: _propTypes2.default.string.isRequired, + width: _propTypes2.default.number, + height: _propTypes2.default.number, + top: _propTypes2.default.number, + left: _propTypes2.default.number, + + style: _propTypes2.default.object, + + tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), + tickTotal: _propTypes2.default.number, + + animation: _animation.AnimationPropType, + + // generally supplied by xyplot + marginTop: _propTypes2.default.number, + marginBottom: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + marginRight: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number +}; + +var defaultProps = { + direction: VERTICAL +}; + +var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; + +var GridLines = function (_PureComponent) { + _inherits(GridLines, _PureComponent); + + function GridLines() { + _classCallCheck(this, GridLines); + + return _possibleConstructorReturn(this, (GridLines.__proto__ || Object.getPrototypeOf(GridLines)).apply(this, arguments)); + } + + _createClass(GridLines, [{ + key: '_getDefaultProps', + value: function _getDefaultProps() { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginTop = _props.marginTop, + marginLeft = _props.marginLeft, + direction = _props.direction; + + return { + left: marginLeft, + top: marginTop, + width: innerWidth, + height: innerHeight, + tickTotal: (0, _axisUtils.getTicksTotalFromSize)(direction === VERTICAL ? innerWidth : innerHeight) + }; + } + }, { + key: 'render', + value: function render() { + var animation = this.props.animation; + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: animatedProps }), + _react2.default.createElement(GridLines, _extends({}, this.props, { animation: null })) + ); + } + + var props = _extends({}, this._getDefaultProps(), this.props); + + var attr = props.attr, + direction = props.direction, + width = props.width, + height = props.height, + style = props.style, + tickTotal = props.tickTotal, + tickValues = props.tickValues, + top = props.top, + left = props.left; + + var isVertical = direction === VERTICAL; + var tickXAttr = isVertical ? 'y' : 'x'; + var tickYAttr = isVertical ? 'x' : 'y'; + var length = isVertical ? height : width; + + var scale = (0, _scalesUtils.getAttributeScale)(props, attr); + var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + left + ',' + top + ')', + className: 'rv-xy-plot__grid-lines' + }, + values.map(function (v, i) { + var _pathProps; + + var pos = scale(v); + var pathProps = (_pathProps = {}, _defineProperty(_pathProps, tickYAttr + '1', pos), _defineProperty(_pathProps, tickYAttr + '2', pos), _defineProperty(_pathProps, tickXAttr + '1', 0), _defineProperty(_pathProps, tickXAttr + '2', length), _pathProps); + return _react2.default.createElement('line', _extends({}, pathProps, { + key: i, + className: 'rv-xy-plot__grid-lines__line', + style: style + })); + }) + ); + } + }]); + + return GridLines; +}(_react.PureComponent); + +GridLines.displayName = 'GridLines'; +GridLines.defaultProps = defaultProps; +GridLines.propTypes = propTypes; +GridLines.requiresSVG = true; + +exports.default = GridLines; \ No newline at end of file diff --git a/dist/plot/highlight.js b/dist/plot/highlight.js new file mode 100644 index 000000000..63458b3e1 --- /dev/null +++ b/dist/plot/highlight.js @@ -0,0 +1,426 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _scalesUtils = require('../utils/scales-utils'); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +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; } + +function getLocs(evt) { + var xLoc = evt.type === 'touchstart' ? evt.pageX : evt.offsetX; + var yLoc = evt.type === 'touchstart' ? evt.pageY : evt.offsetY; + return { xLoc: xLoc, yLoc: yLoc }; +} + +var Highlight = function (_AbstractSeries) { + _inherits(Highlight, _AbstractSeries); + + function Highlight() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, Highlight); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Highlight.__proto__ || Object.getPrototypeOf(Highlight)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + dragging: false, + brushArea: { top: 0, right: 0, bottom: 0, left: 0 }, + brushing: false, + startLocX: 0, + startLocY: 0, + dragArea: null + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(Highlight, [{ + key: '_getDrawArea', + value: function _getDrawArea(xLoc, yLoc) { + var _state = this.state, + startLocX = _state.startLocX, + startLocY = _state.startLocY; + var _props = this.props, + enableX = _props.enableX, + enableY = _props.enableY, + highlightWidth = _props.highlightWidth, + highlightHeight = _props.highlightHeight, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + marginBottom = _props.marginBottom, + marginTop = _props.marginTop; + + var plotHeight = innerHeight + marginTop + marginBottom; + var plotWidth = innerWidth + marginLeft + marginRight; + var touchWidth = highlightWidth || plotWidth; + var touchHeight = highlightHeight || plotHeight; + + return { + bottom: enableY ? Math.max(startLocY, yLoc) : touchHeight, + right: enableX ? Math.max(startLocX, xLoc) : touchWidth, + left: enableX ? Math.min(xLoc, startLocX) : 0, + top: enableY ? Math.min(yLoc, startLocY) : 0 + }; + } + }, { + key: '_getDragArea', + value: function _getDragArea(xLoc, yLoc) { + var _props2 = this.props, + enableX = _props2.enableX, + enableY = _props2.enableY; + var _state2 = this.state, + startLocX = _state2.startLocX, + startLocY = _state2.startLocY, + dragArea = _state2.dragArea; + + + return { + bottom: dragArea.bottom + (enableY ? yLoc - startLocY : 0), + left: dragArea.left + (enableX ? xLoc - startLocX : 0), + right: dragArea.right + (enableX ? xLoc - startLocX : 0), + top: dragArea.top + (enableY ? yLoc - startLocY : 0) + }; + } + }, { + key: '_clickedOutsideDrag', + value: function _clickedOutsideDrag(xLoc, yLoc) { + var _props3 = this.props, + enableX = _props3.enableX, + enableY = _props3.enableY; + var _state3 = this.state, + dragArea = _state3.dragArea, + _state3$brushArea = _state3.brushArea, + left = _state3$brushArea.left, + right = _state3$brushArea.right, + top = _state3$brushArea.top, + bottom = _state3$brushArea.bottom; + + var clickedOutsideDragX = dragArea && (xLoc < left || xLoc > right); + var clickedOutsideDragY = dragArea && (yLoc < top || yLoc > bottom); + if (enableX && enableY) { + return clickedOutsideDragX || clickedOutsideDragY; + } + if (enableX) { + return clickedOutsideDragX; + } + if (enableY) { + return clickedOutsideDragY; + } + return true; + } + }, { + key: '_convertAreaToCoordinates', + value: function _convertAreaToCoordinates(brushArea) { + // NOTE only continuous scales are supported for brushing/getting coordinates back + var _props4 = this.props, + enableX = _props4.enableX, + enableY = _props4.enableY, + marginLeft = _props4.marginLeft, + marginTop = _props4.marginTop; + + var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); + var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); + + // Ensure that users wishes are being respected about which scales are evaluated + // this is specifically enabled to ensure brushing on mixed categorical and linear + // charts will run as expected + + if (enableX && enableY) { + return { + bottom: yScale.invert(brushArea.bottom), + left: xScale.invert(brushArea.left - marginLeft), + right: xScale.invert(brushArea.right - marginLeft), + top: yScale.invert(brushArea.top) + }; + } + + if (enableY) { + return { + bottom: yScale.invert(brushArea.bottom - marginTop), + top: yScale.invert(brushArea.top - marginTop) + }; + } + + if (enableX) { + return { + left: xScale.invert(brushArea.left - marginLeft), + right: xScale.invert(brushArea.right - marginLeft) + }; + } + + return {}; + } + }, { + key: 'startBrushing', + value: function startBrushing(e) { + var _this2 = this; + + var _props5 = this.props, + onBrushStart = _props5.onBrushStart, + onDragStart = _props5.onDragStart, + drag = _props5.drag; + var dragArea = this.state.dragArea; + + var _getLocs = getLocs(e.nativeEvent), + xLoc = _getLocs.xLoc, + yLoc = _getLocs.yLoc; + + var startArea = function startArea(dragging, resetDrag) { + var emptyBrush = { + bottom: yLoc, + left: xLoc, + right: xLoc, + top: yLoc + }; + _this2.setState({ + dragging: dragging, + brushArea: dragArea && !resetDrag ? dragArea : emptyBrush, + brushing: !dragging, + startLocX: xLoc, + startLocY: yLoc + }); + }; + + var clickedOutsideDrag = this._clickedOutsideDrag(xLoc, yLoc); + if (drag && !dragArea || !drag || clickedOutsideDrag) { + startArea(false, clickedOutsideDrag); + + if (onBrushStart) { + onBrushStart(e); + } + return; + } + + if (drag && dragArea) { + startArea(true, clickedOutsideDrag); + if (onDragStart) { + onDragStart(e); + } + } + } + }, { + key: 'stopBrushing', + value: function stopBrushing(e) { + var _state4 = this.state, + brushing = _state4.brushing, + dragging = _state4.dragging, + brushArea = _state4.brushArea; + // Quickly short-circuit if the user isn't brushing in our component + + if (!brushing && !dragging) { + return; + } + var _props6 = this.props, + onBrushEnd = _props6.onBrushEnd, + onDragEnd = _props6.onDragEnd, + drag = _props6.drag; + + var noHorizontal = Math.abs(brushArea.right - brushArea.left) < 5; + var noVertical = Math.abs(brushArea.top - brushArea.bottom) < 5; + // Invoke the callback with null if the selected area was < 5px + var isNulled = noVertical || noHorizontal; + // Clear the draw area + this.setState({ + brushing: false, + dragging: false, + brushArea: drag ? brushArea : { top: 0, right: 0, bottom: 0, left: 0 }, + startLocX: 0, + startLocY: 0, + dragArea: drag && !isNulled && brushArea + }); + + if (brushing && onBrushEnd) { + onBrushEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); + } + + if (drag && onDragEnd) { + onDragEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); + } + } + }, { + key: 'onBrush', + value: function onBrush(e) { + var _props7 = this.props, + onBrush = _props7.onBrush, + onDrag = _props7.onDrag, + drag = _props7.drag; + var _state5 = this.state, + brushing = _state5.brushing, + dragging = _state5.dragging; + + var _getLocs2 = getLocs(e.nativeEvent), + xLoc = _getLocs2.xLoc, + yLoc = _getLocs2.yLoc; + + if (brushing) { + var brushArea = this._getDrawArea(xLoc, yLoc); + this.setState({ brushArea: brushArea }); + + if (onBrush) { + onBrush(this._convertAreaToCoordinates(brushArea)); + } + } + + if (drag && dragging) { + var _brushArea = this._getDragArea(xLoc, yLoc); + this.setState({ brushArea: _brushArea }); + if (onDrag) { + onDrag(this._convertAreaToCoordinates(_brushArea)); + } + } + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var _props8 = this.props, + color = _props8.color, + className = _props8.className, + highlightHeight = _props8.highlightHeight, + highlightWidth = _props8.highlightWidth, + highlightX = _props8.highlightX, + highlightY = _props8.highlightY, + innerWidth = _props8.innerWidth, + innerHeight = _props8.innerHeight, + marginLeft = _props8.marginLeft, + marginRight = _props8.marginRight, + marginTop = _props8.marginTop, + marginBottom = _props8.marginBottom, + opacity = _props8.opacity; + var _state$brushArea = this.state.brushArea, + left = _state$brushArea.left, + right = _state$brushArea.right, + top = _state$brushArea.top, + bottom = _state$brushArea.bottom; + + + var leftPos = 0; + if (highlightX) { + var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); + leftPos = xScale(highlightX); + } + + var topPos = 0; + if (highlightY) { + var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); + topPos = yScale(highlightY); + } + + var plotWidth = marginLeft + marginRight + innerWidth; + var plotHeight = marginTop + marginBottom + innerHeight; + var touchWidth = highlightWidth || plotWidth; + var touchHeight = highlightHeight || plotHeight; + + return _react2.default.createElement( + 'g', + { + transform: 'translate(' + leftPos + ', ' + topPos + ')', + className: className + ' rv-highlight-container' + }, + _react2.default.createElement('rect', { + className: 'rv-mouse-target', + fill: 'black', + opacity: '0', + x: '0', + y: '0', + width: Math.max(touchWidth, 0), + height: Math.max(touchHeight, 0), + onMouseDown: function onMouseDown(e) { + return _this3.startBrushing(e); + }, + onMouseMove: function onMouseMove(e) { + return _this3.onBrush(e); + }, + onMouseUp: function onMouseUp(e) { + return _this3.stopBrushing(e); + }, + onMouseLeave: function onMouseLeave(e) { + return _this3.stopBrushing(e); + } + // preventDefault() so that mouse event emulation does not happen + , onTouchEnd: function onTouchEnd(e) { + e.preventDefault(); + _this3.stopBrushing(e); + }, + onTouchCancel: function onTouchCancel(e) { + e.preventDefault(); + _this3.stopBrushing(e); + }, + onContextMenu: function onContextMenu(e) { + return e.preventDefault(); + }, + onContextMenuCapture: function onContextMenuCapture(e) { + return e.preventDefault(); + } + }), + _react2.default.createElement('rect', { + className: 'rv-highlight', + pointerEvents: 'none', + opacity: opacity, + fill: color, + x: left, + y: top, + width: Math.min(Math.max(0, right - left), touchWidth), + height: Math.min(Math.max(0, bottom - top), touchHeight) + }) + ); + } + }]); + + return Highlight; +}(_abstractSeries2.default); + +Highlight.displayName = 'HighlightOverlay'; +Highlight.defaultProps = { + color: 'rgb(77, 182, 172)', + className: '', + enableX: true, + enableY: true, + opacity: 0.3 +}; + +Highlight.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + enableX: _propTypes2.default.bool, + enableY: _propTypes2.default.bool, + highlightHeight: _propTypes2.default.number, + highlightWidth: _propTypes2.default.number, + highlightX: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), + highlightY: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), + onBrushStart: _propTypes2.default.func, + onDragStart: _propTypes2.default.func, + onBrush: _propTypes2.default.func, + onDrag: _propTypes2.default.func, + onBrushEnd: _propTypes2.default.func, + onDragEnd: _propTypes2.default.func +}); + +exports.default = Highlight; \ No newline at end of file diff --git a/dist/plot/hint.js b/dist/plot/hint.js new file mode 100644 index 000000000..8e15b3cae --- /dev/null +++ b/dist/plot/hint.js @@ -0,0 +1,454 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _scalesUtils = require('../utils/scales-utils'); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/* + * Hint provides two options for placement of hint: + * a) around a data point in one of four quadrants (imagine the point bisected + * by two axes -vertical, horizontal- creating 4 quadrants around a data + * point). + * b) **New** pin to an edge of chart/plot area and position along that edge + * using data point's other dimension value. + * + * To support these two options, deprecate one Hint props (orientation) with two + * new Hint align prop object (horizontal, vertical) with following values: + * + * horizontal: auto, left, right, leftEdge, rightEdge + * vertical: auto, bottom, top, bottomEdge, topEdge + * + * Thus, the following ALIGN constants are the values for horizontal + * and vertical + */ +var ALIGN = { + AUTO: 'auto', + LEFT: 'left', + RIGHT: 'right', + LEFT_EDGE: 'leftEdge', + RIGHT_EDGE: 'rightEdge', + BOTTOM: 'bottom', + TOP: 'top', + BOTTOM_EDGE: 'bottomEdge', + TOP_EDGE: 'topEdge' +}; + +/** + * For backwards support, retain the ORIENTATION prop constants + */ +var ORIENTATION = { + BOTTOM_LEFT: 'bottomleft', + BOTTOM_RIGHT: 'bottomright', + TOP_LEFT: 'topleft', + TOP_RIGHT: 'topright' +}; + +/** + * Default format function for the value. + * @param {Object} value Value. + * @returns {Array} title-value pairs. + */ +function defaultFormat(value) { + return Object.keys(value).map(function getProp(key) { + return { title: key, value: value[key] }; + }); +} + +var Hint = function (_PureComponent) { + _inherits(Hint, _PureComponent); + + function Hint() { + _classCallCheck(this, Hint); + + return _possibleConstructorReturn(this, (Hint.__proto__ || Object.getPrototypeOf(Hint)).apply(this, arguments)); + } + + _createClass(Hint, [{ + key: '_getAlign', + + + /** + * Obtain align object with horizontal and vertical settings + * but convert any AUTO values to the non-auto ALIGN depending on the + * values of x and y. + * @param {number} x X value. + * @param {number} y Y value. + * @returns {Object} Align object w/ horizontal, vertical prop strings. + * @private + */ + value: function _getAlign(x, y) { + var _props = this.props, + innerWidth = _props.innerWidth, + innerHeight = _props.innerHeight, + orientation = _props.orientation, + _props$align = _props.align, + horizontal = _props$align.horizontal, + vertical = _props$align.vertical; + + var align = orientation ? this._mapOrientationToAlign(orientation) : { horizontal: horizontal, vertical: vertical }; + if (horizontal === ALIGN.AUTO) { + align.horizontal = x > innerWidth / 2 ? ALIGN.LEFT : ALIGN.RIGHT; + } + if (vertical === ALIGN.AUTO) { + align.vertical = y > innerHeight / 2 ? ALIGN.TOP : ALIGN.BOTTOM; + } + return align; + } + + /** + * Get the class names from align values. + * @param {Object} align object with horizontal and vertical prop strings. + * @returns {string} Class names. + * @private + */ + + }, { + key: '_getAlignClassNames', + value: function _getAlignClassNames(align) { + var orientation = this.props.orientation; + + var orientationClass = orientation ? 'rv-hint--orientation-' + orientation : ''; + return orientationClass + ' rv-hint--horizontalAlign-' + align.horizontal + '\n rv-hint--verticalAlign-' + align.vertical; + } + + /** + * Get a CSS mixin for a proper positioning of the element. + * @param {Object} align object with horizontal and vertical prop strings. + * @param {number} x X position. + * @param {number} y Y position. + * @returns {Object} Object, that may contain `left` or `right, `top` or + * `bottom` properties. + * @private + */ + + }, { + key: '_getAlignStyle', + value: function _getAlignStyle(align, x, y) { + return _extends({}, this._getXCSS(align.horizontal, x), this._getYCSS(align.vertical, y)); + } + + /** + * Get the bottom coordinate of the hint. + * When y undefined or null, edge case, pin bottom. + * @param {number} y Y. + * @returns {{bottom: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSBottom', + value: function _getCSSBottom(y) { + if (y === undefined || y === null) { + return { + bottom: 0 + }; + } + + var _props2 = this.props, + innerHeight = _props2.innerHeight, + marginBottom = _props2.marginBottom; + + return { + bottom: marginBottom + innerHeight - y + }; + } + + /** + * Get the left coordinate of the hint. + * When x undefined or null, edge case, pin left. + * @param {number} x X. + * @returns {{left: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSLeft', + value: function _getCSSLeft(x) { + if (x === undefined || x === null) { + return { + left: 0 + }; + } + + var marginLeft = this.props.marginLeft; + + return { + left: marginLeft + x + }; + } + + /** + * Get the right coordinate of the hint. + * When x undefined or null, edge case, pin right. + * @param {number} x X. + * @returns {{right: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSRight', + value: function _getCSSRight(x) { + if (x === undefined || x === null) { + return { + right: 0 + }; + } + + var _props3 = this.props, + innerWidth = _props3.innerWidth, + marginRight = _props3.marginRight; + + return { + right: marginRight + innerWidth - x + }; + } + + /** + * Get the top coordinate of the hint. + * When y undefined or null, edge case, pin top. + * @param {number} y Y. + * @returns {{top: *}} Mixin. + * @private + */ + + }, { + key: '_getCSSTop', + value: function _getCSSTop(y) { + if (y === undefined || y === null) { + return { + top: 0 + }; + } + + var marginTop = this.props.marginTop; + + return { + top: marginTop + y + }; + } + + /** + * Get the position for the hint and the appropriate class name. + * @returns {{style: Object, className: string}} Style and className for the + * hint. + * @private + */ + + }, { + key: '_getPositionInfo', + value: function _getPositionInfo() { + var _props4 = this.props, + value = _props4.value, + getAlignStyle = _props4.getAlignStyle; + + + var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x')(value); + var y = (0, _scalesUtils.getAttributeFunctor)(this.props, 'y')(value); + + var align = this._getAlign(x, y); + + return { + position: getAlignStyle ? getAlignStyle(align, x, y) : this._getAlignStyle(align, x, y), + className: this._getAlignClassNames(align) + }; + } + }, { + key: '_getXCSS', + value: function _getXCSS(horizontal, x) { + // obtain xCSS + switch (horizontal) { + case ALIGN.LEFT_EDGE: + // this pins x to left edge + return this._getCSSLeft(null); + case ALIGN.RIGHT_EDGE: + // this pins x to left edge + return this._getCSSRight(null); + case ALIGN.LEFT: + // this places hint text to the left of center, so set its right edge + return this._getCSSRight(x); + case ALIGN.RIGHT: + default: + // this places hint text to the right of center, so set its left edge + // default case should not be possible but if it happens set to RIGHT + return this._getCSSLeft(x); + } + } + }, { + key: '_getYCSS', + value: function _getYCSS(verticalAlign, y) { + // obtain yCSS + switch (verticalAlign) { + case ALIGN.TOP_EDGE: + // this pins x to top edge + return this._getCSSTop(null); + case ALIGN.BOTTOM_EDGE: + // this pins x to bottom edge + return this._getCSSBottom(null); + case ALIGN.BOTTOM: + // this places hint text to the bottom of center, so set its top edge + return this._getCSSTop(y); + case ALIGN.TOP: + default: + // this places hint text to the top of center, so set its bottom edge + // default case should not be possible but if it happens set to BOTTOM + return this._getCSSBottom(y); + } + } + }, { + key: '_mapOrientationToAlign', + value: function _mapOrientationToAlign(orientation) { + // TODO: print warning that this feature is deprecated and support will be + // removed in next major release. + switch (orientation) { + case ORIENTATION.BOTTOM_LEFT: + return { + horizontal: ALIGN.LEFT, + vertical: ALIGN.BOTTOM + }; + case ORIENTATION.BOTTOM_RIGHT: + return { + horizontal: ALIGN.RIGHT, + vertical: ALIGN.BOTTOM + }; + case ORIENTATION.TOP_LEFT: + return { + horizontal: ALIGN.LEFT, + vertical: ALIGN.TOP + }; + case ORIENTATION.TOP_RIGHT: + return { + horizontal: ALIGN.RIGHT, + vertical: ALIGN.TOP + }; + default: + // fall back to horizontalAlign, verticalAlign that are either + // provided or defaulted to AUTO. So, don't change things + break; + } + } + }, { + key: 'render', + value: function render() { + var _props5 = this.props, + value = _props5.value, + format = _props5.format, + children = _props5.children, + style = _props5.style; + + var _getPositionInfo2 = this._getPositionInfo(), + position = _getPositionInfo2.position, + className = _getPositionInfo2.className; + + return _react2.default.createElement( + 'div', + { + className: 'rv-hint ' + className, + style: _extends({}, style, position, { + position: 'absolute' + }) + }, + children ? children : _react2.default.createElement( + 'div', + { className: 'rv-hint__content', style: style.content }, + format(value).map(function (formattedProp, i) { + return _react2.default.createElement( + 'div', + { key: 'rv-hint' + i, style: style.row }, + _react2.default.createElement( + 'span', + { className: 'rv-hint__title', style: style.title }, + formattedProp.title + ), + ': ', + _react2.default.createElement( + 'span', + { className: 'rv-hint__value', style: style.value }, + formattedProp.value + ) + ); + }) + ) + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return { + format: defaultFormat, + align: { + horizontal: ALIGN.AUTO, + vertical: ALIGN.AUTO + }, + style: {} + }; + } + }, { + key: 'propTypes', + get: function get() { + return { + marginTop: _propTypes2.default.number, + marginLeft: _propTypes2.default.number, + innerWidth: _propTypes2.default.number, + innerHeight: _propTypes2.default.number, + scales: _propTypes2.default.object, + value: _propTypes2.default.object, + format: _propTypes2.default.func, + style: _propTypes2.default.object, + align: _propTypes2.default.shape({ + horizontal: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.LEFT, ALIGN.RIGHT, ALIGN.LEFT_EDGE, ALIGN.RIGHT_EDGE]), + vertical: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.BOTTOM, ALIGN.TOP, ALIGN.BOTTOM_EDGE, ALIGN.TOP_EDGE]) + }), + getAlignStyle: _propTypes2.default.func, + orientation: _propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT, ORIENTATION.BOTTOM_RIGHT, ORIENTATION.TOP_LEFT, ORIENTATION.TOP_RIGHT]) + }; + } + }]); + + return Hint; +}(_react.PureComponent); + +Hint.displayName = 'Hint'; +Hint.ORIENTATION = ORIENTATION; +Hint.ALIGN = ALIGN; + +exports.default = Hint; \ No newline at end of file diff --git a/dist/plot/horizontal-grid-lines.js b/dist/plot/horizontal-grid-lines.js new file mode 100644 index 000000000..549b2d8b5 --- /dev/null +++ b/dist/plot/horizontal-grid-lines.js @@ -0,0 +1,64 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _axisUtils = require('../utils/axis-utils'); + +var _gridLines = require('./grid-lines'); + +var _gridLines2 = _interopRequireDefault(_gridLines); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; + + +var propTypes = _extends({}, _gridLines2.default.propTypes, { + direction: _propTypes2.default.oneOf([HORIZONTAL]) +}); + +var defaultProps = { + direction: HORIZONTAL, + attr: 'y' +}; + +function HorizontalGridLines(props) { + return _react2.default.createElement(_gridLines2.default, props); +} + +HorizontalGridLines.displayName = 'HorizontalGridLines'; +HorizontalGridLines.propTypes = propTypes; +HorizontalGridLines.defaultProps = defaultProps; +HorizontalGridLines.requiresSVG = true; + +exports.default = HorizontalGridLines; \ No newline at end of file diff --git a/dist/plot/series/abstract-series.js b/dist/plot/series/abstract-series.js new file mode 100644 index 000000000..7f86a482f --- /dev/null +++ b/dist/plot/series/abstract-series.js @@ -0,0 +1,415 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Voronoi = require('d3-voronoi'); + +var _react = require('react'); + +var _animation = require('../../animation'); + +var _scalesUtils = require('../../utils/scales-utils'); + +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; } + +var propTypes = _extends({}, (0, _scalesUtils.getScalePropTypesByAttribute)('x'), (0, _scalesUtils.getScalePropTypesByAttribute)('y'), (0, _scalesUtils.getScalePropTypesByAttribute)('size'), (0, _scalesUtils.getScalePropTypesByAttribute)('opacity'), (0, _scalesUtils.getScalePropTypesByAttribute)('color'), { + width: _propTypes2.default.number, + height: _propTypes2.default.number, + data: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.array])), + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + onValueClick: _propTypes2.default.func, + onValueRightClick: _propTypes2.default.func, + onSeriesMouseOver: _propTypes2.default.func, + onSeriesMouseOut: _propTypes2.default.func, + onSeriesClick: _propTypes2.default.func, + onSeriesRightClick: _propTypes2.default.func, + onNearestX: _propTypes2.default.func, + onNearestXY: _propTypes2.default.func, + style: _propTypes2.default.object, + animation: _animation.AnimationPropType, + stack: _propTypes2.default.bool +}); + +var defaultProps = { + className: '', + stack: false, + style: {} +}; + +var AbstractSeries = function (_PureComponent) { + _inherits(AbstractSeries, _PureComponent); + + function AbstractSeries() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, AbstractSeries); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AbstractSeries.__proto__ || Object.getPrototypeOf(AbstractSeries)).call.apply(_ref, [this].concat(args))), _this), _this._seriesClickHandler = function (event) { + var onSeriesClick = _this.props.onSeriesClick; + + if (onSeriesClick) { + onSeriesClick({ event: event }); + } + }, _this._seriesMouseOutHandler = function (event) { + var onSeriesMouseOut = _this.props.onSeriesMouseOut; + + if (onSeriesMouseOut) { + onSeriesMouseOut({ event: event }); + } + }, _this._seriesMouseOverHandler = function (event) { + var onSeriesMouseOver = _this.props.onSeriesMouseOver; + + if (onSeriesMouseOver) { + onSeriesMouseOver({ event: event }); + } + }, _this._seriesRightClickHandler = function (event) { + var onSeriesRightClick = _this.props.onSeriesRightClick; + + if (onSeriesRightClick) { + onSeriesRightClick({ event: event }); + } + }, _this._valueClickHandler = function (d, event) { + var _this$props = _this.props, + onValueClick = _this$props.onValueClick, + onSeriesClick = _this$props.onSeriesClick; + + if (onValueClick) { + onValueClick(d, { event: event }); + } + if (onSeriesClick) { + onSeriesClick({ event: event }); + } + }, _this._valueMouseOutHandler = function (d, event) { + var _this$props2 = _this.props, + onValueMouseOut = _this$props2.onValueMouseOut, + onSeriesMouseOut = _this$props2.onSeriesMouseOut; + + if (onValueMouseOut) { + onValueMouseOut(d, { event: event }); + } + if (onSeriesMouseOut) { + onSeriesMouseOut({ event: event }); + } + }, _this._valueMouseOverHandler = function (d, event) { + var _this$props3 = _this.props, + onValueMouseOver = _this$props3.onValueMouseOver, + onSeriesMouseOver = _this$props3.onSeriesMouseOver; + + if (onValueMouseOver) { + onValueMouseOver(d, { event: event }); + } + if (onSeriesMouseOver) { + onSeriesMouseOver({ event: event }); + } + }, _this._valueRightClickHandler = function (d, event) { + var _this$props4 = _this.props, + onValueRightClick = _this$props4.onValueRightClick, + onSeriesRightClick = _this$props4.onSeriesRightClick; + + if (onValueRightClick) { + onValueRightClick(d, { event: event }); + } + if (onSeriesRightClick) { + onSeriesRightClick({ event: event }); + } + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(AbstractSeries, [{ + key: 'onParentMouseMove', + value: function onParentMouseMove(event) { + var _props = this.props, + onNearestX = _props.onNearestX, + onNearestXY = _props.onNearestXY, + data = _props.data; + + if (!onNearestX && !onNearestXY || !data) { + return; + } + if (onNearestXY) { + this._handleNearestXY(event); + } else { + this._handleNearestX(event); + } + } + }, { + key: 'onParentTouchMove', + value: function onParentTouchMove(e) { + e.preventDefault(); + this.onParentMouseMove(e); + } + }, { + key: 'onParentTouchStart', + value: function onParentTouchStart(e) { + // prevent mouse event emulation + e.preventDefault(); + } + + /** + * Get the attr0 functor. + * @param {string} attr Attribute name. + * @returns {*} Functor. + * @private + */ + + }, { + key: '_getAttr0Functor', + value: function _getAttr0Functor(attr) { + return (0, _scalesUtils.getAttr0Functor)(this.props, attr); + } + + /** + * Get attribute functor. + * @param {string} attr Attribute name + * @returns {*} Functor. + * @protected + */ + + }, { + key: '_getAttributeFunctor', + value: function _getAttributeFunctor(attr) { + return (0, _scalesUtils.getAttributeFunctor)(this.props, attr); + } + + /** + * Get the attribute value if it is available. + * @param {string} attr Attribute name. + * @returns {*} Attribute value if available, fallback value or undefined + * otherwise. + * @protected + */ + + }, { + key: '_getAttributeValue', + value: function _getAttributeValue(attr) { + return (0, _scalesUtils.getAttributeValue)(this.props, attr); + } + + /** + * Get the scale object distance by the attribute from the list of properties. + * @param {string} attr Attribute name. + * @returns {number} Scale distance. + * @protected + */ + + }, { + key: '_getScaleDistance', + value: function _getScaleDistance(attr) { + var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(this.props, attr); + return scaleObject ? scaleObject.distance : 0; + } + }, { + key: '_getXYCoordinateInContainer', + value: function _getXYCoordinateInContainer(event) { + var _props2 = this.props, + _props2$marginTop = _props2.marginTop, + marginTop = _props2$marginTop === undefined ? 0 : _props2$marginTop, + _props2$marginLeft = _props2.marginLeft, + marginLeft = _props2$marginLeft === undefined ? 0 : _props2$marginLeft; + var evt = event.nativeEvent, + currentTarget = event.currentTarget; + + var rect = currentTarget.getBoundingClientRect(); + var x = evt.clientX; + var y = evt.clientY; + if (evt.type === 'touchmove') { + x = evt.touches[0].pageX; + y = evt.touches[0].pageY; + } + return { + x: x - rect.left - currentTarget.clientLeft - marginLeft, + y: y - rect.top - currentTarget.clientTop - marginTop + }; + } + }, { + key: '_handleNearestX', + value: function _handleNearestX(event) { + var _props3 = this.props, + onNearestX = _props3.onNearestX, + data = _props3.data; + + var minDistance = Number.POSITIVE_INFINITY; + var value = null; + var valueIndex = null; + + var coordinate = this._getXYCoordinateInContainer(event); + var xScaleFn = this._getAttributeFunctor('x'); + + data.forEach(function (item, i) { + var currentCoordinate = xScaleFn(item); + var newDistance = Math.abs(coordinate.x - currentCoordinate); + if (newDistance < minDistance) { + minDistance = newDistance; + value = item; + valueIndex = i; + } + }); + if (!value) { + return; + } + onNearestX(value, { + innerX: xScaleFn(value), + index: valueIndex, + event: event.nativeEvent + }); + } + }, { + key: '_handleNearestXY', + value: function _handleNearestXY(event) { + var _props4 = this.props, + onNearestXY = _props4.onNearestXY, + data = _props4.data; + + + var coordinate = this._getXYCoordinateInContainer(event); + var xScaleFn = this._getAttributeFunctor('x'); + var yScaleFn = this._getAttributeFunctor('y'); + + // Create a voronoi with each node center points + var voronoiInstance = (0, _d3Voronoi.voronoi)().x(xScaleFn).y(yScaleFn); + + var foundPoint = voronoiInstance(data).find(coordinate.x, coordinate.y); + var value = foundPoint.data; + + if (!value) { + return; + } + onNearestXY(value, { + innerX: foundPoint.x, + innerY: foundPoint.y, + index: foundPoint.index, + event: event.nativeEvent + }); + } + + /** + * Click handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse out handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse over handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Right Click handler for the entire series. + * @param {Object} event Event. + * @protected + */ + + + /** + * Click handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse out handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + + /** + * Mouse over handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + + /** + * Right Click handler for the specific series' value. + * @param {Object} d Value object + * @param {Object} event Event. + * @protected + */ + + }], [{ + key: 'getParentConfig', + + /** + * Get a default config for the parent. + * @returns {Object} Empty config. + */ + value: function getParentConfig() { + return {}; + } + + /** + * Tells the rest of the world that it requires SVG to work. + * @returns {boolean} Result. + */ + + }, { + key: 'requiresSVG', + get: function get() { + return true; + } + }]); + + return AbstractSeries; +}(_react.PureComponent); + +AbstractSeries.displayName = 'AbstractSeries'; +AbstractSeries.propTypes = propTypes; +AbstractSeries.defaultProps = defaultProps; + +exports.default = AbstractSeries; \ No newline at end of file diff --git a/dist/plot/series/arc-series.js b/dist/plot/series/arc-series.js new file mode 100644 index 000000000..465cf5a91 --- /dev/null +++ b/dist/plot/series/arc-series.js @@ -0,0 +1,279 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _d3Shape = require('d3-shape'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _scalesUtils = require('../../utils/scales-utils'); + +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; } + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--arc'; +var ATTRIBUTES = ['radius', 'angle']; + +var defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + center: { x: 0, y: 0 }, + arcClassName: '', + className: '', + style: {}, + padAngle: 0 +}); + +/** + * Prepare the internal representation of row for real use. + * This is necessary because d3 insists on starting at 12 oclock and moving + * clockwise, rather than starting at 3 oclock and moving counter clockwise + * as one might expect from polar + * @param {Object} row - coordinate object to be modifed + * @return {Object} angle corrected object + */ +function modifyRow(row) { + var radius = row.radius, + angle = row.angle, + angle0 = row.angle0; + + var truedAngle = -1 * angle + Math.PI / 2; + var truedAngle0 = -1 * angle0 + Math.PI / 2; + return _extends({}, row, { + x: radius * Math.cos(truedAngle), + y: radius * Math.sin(truedAngle), + angle: truedAngle, + angle0: truedAngle0 + }); +} + +var ArcSeries = function (_AbstractSeries) { + _inherits(ArcSeries, _AbstractSeries); + + function ArcSeries(props) { + _classCallCheck(this, ArcSeries); + + var _this = _possibleConstructorReturn(this, (ArcSeries.__proto__ || Object.getPrototypeOf(ArcSeries)).call(this, props)); + + var scaleProps = _this._getAllScaleProps(props); + _this.state = { scaleProps: scaleProps }; + return _this; + } + + _createClass(ArcSeries, [{ + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + this.setState({ scaleProps: this._getAllScaleProps(nextProps) }); + } + + /** + * Get the map of scales from the props. + * @param {Object} props Props. + * @param {Array} data Array of all data. + * @returns {Object} Map of scales. + * @private + */ + + }, { + key: '_getAllScaleProps', + value: function _getAllScaleProps(props) { + var defaultScaleProps = this._getDefaultScaleProps(props); + var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); + var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, userScaleProps), props.data, ATTRIBUTES); + + return _extends({}, defaultScaleProps, userScaleProps, missingScaleProps); + } + + /** + * Get the list of scale-related settings that should be applied by default. + * @param {Object} props Object of props. + * @returns {Object} Defaults. + * @private + */ + + }, { + key: '_getDefaultScaleProps', + value: function _getDefaultScaleProps(props) { + var innerWidth = props.innerWidth, + innerHeight = props.innerHeight; + + var radius = Math.min(innerWidth / 2, innerHeight / 2); + return { + radiusRange: [0, radius], + _radiusValue: radius, + angleType: 'literal' + }; + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + arcClassName = _props.arcClassName, + animation = _props.animation, + className = _props.className, + center = _props.center, + data = _props.data, + disableSeries = _props.disableSeries, + hideSeries = _props.hideSeries, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + padAngle = _props.padAngle, + style = _props.style; + + + if (!data) { + return null; + } + + if (animation) { + var cloneData = data.map(function (d) { + return _extends({}, d); + }); + return _react2.default.createElement( + 'g', + { className: 'rv-xy-plot__series--arc__animation-wrapper' }, + _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { + animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS, + data: cloneData + }), + _react2.default.createElement(ArcSeries, _extends({}, this.props, { + animation: null, + disableSeries: true, + data: cloneData + })) + ), + _react2.default.createElement(ArcSeries, _extends({}, this.props, { + animation: null, + hideSeries: true, + style: { stroke: 'red' } + })) + ); + } + + var scaleProps = this.state.scaleProps; + var radiusDomain = scaleProps.radiusDomain; + // need to generate our own functors as abstract series doesnt have anythign for us + + var radius = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'radius'); + var radius0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'radius'); + var angle = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'angle'); + var angle0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'angle'); + // but it does have good color support! + var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var opacity = this._getAttributeFunctor('opacity'); + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + onMouseOver: this._seriesMouseOverHandler, + onMouseOut: this._seriesMouseOutHandler, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + opacity: hideSeries ? 0 : 1, + pointerEvents: disableSeries ? 'none' : 'all', + transform: 'translate(' + (marginLeft + x(center)) + ',' + (marginTop + y(center)) + ')' + }, + data.map(function (row, i) { + var noRadius = radiusDomain[1] === radiusDomain[0]; + var arcArg = { + innerRadius: noRadius ? 0 : radius0(row), + outerRadius: radius(row), + startAngle: angle0(row) || 0, + endAngle: angle(row) + }; + var arcedData = (0, _d3Shape.arc)().padAngle(padAngle); + var rowStyle = row.style || {}; + var rowClassName = row.className || ''; + return _react2.default.createElement('path', { + style: _extends({ + opacity: opacity && opacity(row), + stroke: stroke && stroke(row), + fill: fill && fill(row) + }, style, rowStyle), + onClick: function onClick(e) { + return _this2._valueClickHandler(modifyRow(row), e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(modifyRow(row), e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(modifyRow(row), e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(modifyRow(row), e); + }, + key: i, + className: predefinedClassName + '-path ' + arcClassName + ' ' + rowClassName, + d: arcedData(arcArg) + }); + }) + ); + } + }]); + + return ArcSeries; +}(_abstractSeries2.default); + +ArcSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, (0, _scalesUtils.getScalePropTypesByAttribute)('radius'), (0, _scalesUtils.getScalePropTypesByAttribute)('angle'), { + center: _propTypes2.default.shape({ + x: _propTypes2.default.number, + y: _propTypes2.default.number + }), + arcClassName: _propTypes2.default.string, + padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) +}); +ArcSeries.defaultProps = defaultProps; +ArcSeries.displayName = 'ArcSeries'; + +exports.default = ArcSeries; \ No newline at end of file diff --git a/dist/plot/series/area-series.js b/dist/plot/series/area-series.js new file mode 100644 index 000000000..10b6f12b0 --- /dev/null +++ b/dist/plot/series/area-series.js @@ -0,0 +1,160 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Shape = require('d3-shape'); + +var d3Shape = _interopRequireWildcard(_d3Shape); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _theme = require('../../theme'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _reactUtils = require('../../utils/react-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; + +var AreaSeries = function (_AbstractSeries) { + _inherits(AreaSeries, _AbstractSeries); + + function AreaSeries() { + _classCallCheck(this, AreaSeries); + + return _possibleConstructorReturn(this, (AreaSeries.__proto__ || Object.getPrototypeOf(AreaSeries)).apply(this, arguments)); + } + + _createClass(AreaSeries, [{ + key: '_renderArea', + value: function _renderArea(data, x, y0, y, curve, getNull) { + var area = d3Shape.area(); + if (curve !== null) { + if (typeof curve === 'string' && d3Shape[curve]) { + area = area.curve(d3Shape[curve]); + } else if (typeof curve === 'function') { + area = area.curve(curve); + } + } + area = area.defined(getNull); + area = area.x(x).y0(y0).y1(y); + return area(data); + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + curve = _props.curve, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + + if (this.props.nullAccessor) { + (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); + } + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(AreaSeries, _extends({}, this.props, { animation: null })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var y0 = this._getAttr0Functor('y'); + var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); + var fill = this._getAttributeValue('fill') || this._getAttributeValue('color'); + var newOpacity = this._getAttributeValue('opacity'); + var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; + var getNull = this.props.nullAccessor || this.props.getNull; + var d = this._renderArea(data, x, y0, y, curve, getNull); + + return _react2.default.createElement('path', { + d: d, + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')', + onMouseOver: this._seriesMouseOverHandler, + onMouseOut: this._seriesMouseOutHandler, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + style: _extends({ + opacity: opacity, + stroke: stroke, + fill: fill + }, style) + }); + } + }]); + + return AreaSeries; +}(_abstractSeries2.default); + +AreaSeries.displayName = 'AreaSeries'; +AreaSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + getNull: _propTypes2.default.func +}); +AreaSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + getNull: function getNull() { + return true; + } +}); + +exports.default = AreaSeries; \ No newline at end of file diff --git a/dist/plot/series/bar-series-canvas.js b/dist/plot/series/bar-series-canvas.js new file mode 100644 index 000000000..3ede5b8fe --- /dev/null +++ b/dist/plot/series/bar-series-canvas.js @@ -0,0 +1,161 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Color = require('d3-color'); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +function getScaleDistance(props, attr) { + var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(props, attr); + return scaleObject ? scaleObject.distance : 0; +} + +var BarSeriesCanvas = function (_AbstractSeries) { + _inherits(BarSeriesCanvas, _AbstractSeries); + + function BarSeriesCanvas() { + _classCallCheck(this, BarSeriesCanvas); + + return _possibleConstructorReturn(this, (BarSeriesCanvas.__proto__ || Object.getPrototypeOf(BarSeriesCanvas)).apply(this, arguments)); + } + + _createClass(BarSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var data = props.data, + linePosAttr = props.linePosAttr, + lineSizeAttr = props.lineSizeAttr, + valuePosAttr = props.valuePosAttr, + marginTop = props.marginTop, + marginBottom = props.marginBottom; + + if (!data || data.length === 0) { + return; + } + + var distance = getScaleDistance(props, linePosAttr); + var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); + var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); + var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); + var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); + + var halfSpace = distance / 2 * 0.85; + // totalSpaceAvailable is the space we have available to draw all the + // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) + var totalSpaceAvailable = halfSpace * 2; + + var _getStackParams = (0, _seriesUtils.getStackParams)(props), + sameTypeTotal = _getStackParams.sameTypeTotal, + sameTypeIndex = _getStackParams.sameTypeIndex; + + data.forEach(function (row) { + var totalSpaceCenter = line(row); + // totalSpaceStartingPoint is the first pixel were we can start drawing + var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; + + // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal + var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; + // lineSize is the space we have available to draw sameTypeIndex bar + var lineSize = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; + + var fillColor = (0, _d3Color.rgb)(fill(row)); + var strokeColor = (0, _d3Color.rgb)(stroke(row)); + var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; + + // linePos is the first pixel were we can start drawing sameTypeIndex bar + var linePos = totalSpaceStartingPoint + lineSize * sameTypeIndex + sameTypeIndex; + var valuePos = Math.min(value0(row), value(row)); + var x = valuePosAttr === 'x' ? valuePos : linePos; + var y = valuePosAttr === 'y' ? valuePos : linePos; + + var valueSize = Math.abs(-value0(row) + value(row)); + var height = lineSizeAttr === 'height' ? lineSize : valueSize; + var width = lineSizeAttr === 'width' ? lineSize : valueSize; + + ctx.beginPath(); + ctx.rect(x + marginBottom, y + marginTop, width, height); + ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; + ctx.fill(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; + ctx.stroke(); + }); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return BarSeriesCanvas; +}(_abstractSeries2.default); + +BarSeriesCanvas.displayName = 'BarSeriesCanvas'; +BarSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + linePosAttr: _propTypes2.default.string.isRequired, + valuePosAttr: _propTypes2.default.string.isRequired, + lineSizeAttr: _propTypes2.default.string.isRequired, + valueSizeAttr: _propTypes2.default.string.isRequired +}); + +BarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = BarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/bar-series.js b/dist/plot/series/bar-series.js new file mode 100644 index 000000000..2c38ee25f --- /dev/null +++ b/dist/plot/series/bar-series.js @@ -0,0 +1,180 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--bar'; + +var BarSeries = function (_AbstractSeries) { + _inherits(BarSeries, _AbstractSeries); + + function BarSeries() { + _classCallCheck(this, BarSeries); + + return _possibleConstructorReturn(this, (BarSeries.__proto__ || Object.getPrototypeOf(BarSeries)).apply(this, arguments)); + } + + _createClass(BarSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + linePosAttr = _props.linePosAttr, + lineSizeAttr = _props.lineSizeAttr, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style, + valuePosAttr = _props.valuePosAttr, + valueSizeAttr = _props.valueSizeAttr, + barWidth = _props.barWidth; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(BarSeries, _extends({}, this.props, { animation: null })) + ); + } + + var _getStackParams = (0, _seriesUtils.getStackParams)(this.props), + sameTypeTotal = _getStackParams.sameTypeTotal, + sameTypeIndex = _getStackParams.sameTypeIndex; + + var distance = this._getScaleDistance(linePosAttr); + var lineFunctor = this._getAttributeFunctor(linePosAttr); + var valueFunctor = this._getAttributeFunctor(valuePosAttr); + var value0Functor = this._getAttr0Functor(valuePosAttr); + var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var opacityFunctor = this._getAttributeFunctor('opacity'); + + var halfSpace = distance / 2 * barWidth; + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + var _attrs; + + // totalSpaceAvailable is the space we have available to draw all the + // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) + var totalSpaceAvailable = halfSpace * 2; + var totalSpaceCenter = lineFunctor(d); + // totalSpaceStartingPoint is the first pixel were we can start drawing + var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; + // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal + var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; + // spacePerBar is the space we have available to draw sameTypeIndex bar + var spacePerBar = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; + // barStartingPoint is the first pixel were we can start drawing sameTypeIndex bar + var barStartingPoint = totalSpaceStartingPoint + spacePerBar * sameTypeIndex + sameTypeIndex; + + var attrs = (_attrs = { + style: _extends({ + opacity: opacityFunctor && opacityFunctor(d), + stroke: strokeFunctor && strokeFunctor(d), + fill: fillFunctor && fillFunctor(d) + }, style) + }, _defineProperty(_attrs, linePosAttr, barStartingPoint), _defineProperty(_attrs, lineSizeAttr, spacePerBar), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { + return _this2._valueClickHandler(d, e); + }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + }), _defineProperty(_attrs, 'key', i), _attrs); + return _react2.default.createElement('rect', attrs); + }) + ); + } + }], [{ + key: 'propTypes', + get: function get() { + return _extends({}, _abstractSeries2.default.propTypes, { + linePosAttr: _propTypes2.default.string, + valuePosAttr: _propTypes2.default.string, + lineSizeAttr: _propTypes2.default.string, + valueSizeAttr: _propTypes2.default.string, + cluster: _propTypes2.default.string, + barWidth: _propTypes2.default.number + }); + } + }, { + key: 'defaultProps', + get: function get() { + return { + barWidth: 0.85 + }; + } + }]); + + return BarSeries; +}(_abstractSeries2.default); + +BarSeries.displayName = 'BarSeries'; + +exports.default = BarSeries; \ No newline at end of file diff --git a/dist/plot/series/canvas-wrapper.js b/dist/plot/series/canvas-wrapper.js new file mode 100644 index 000000000..5211e2bd7 --- /dev/null +++ b/dist/plot/series/canvas-wrapper.js @@ -0,0 +1,256 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Interpolate = require('d3-interpolate'); + +var _animation = require('../../animation'); + +var _seriesUtils = require('../../utils/series-utils'); + +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; } + +var MAX_DRAWS = 30; + +/** + * Draw loop draws each of the layers until it should draw more + * @param {CanvasContext} ctx - the context where the drawing will take place + * @param {Number} height - height of the canvas + * @param {Number} width - width of the canvas + * @param {Array} layers - the layer objects to render + */ +function engageDrawLoop(ctx, height, width, layers) { + var drawIteration = 0; + // using setInterval because request animation frame goes too fast + var drawCycle = setInterval(function () { + if (!ctx) { + clearInterval(drawCycle); + return; + } + drawLayers(ctx, height, width, layers, drawIteration); + if (drawIteration > MAX_DRAWS) { + clearInterval(drawCycle); + } + drawIteration += 1; + }, 1); +} + +/** + * Loops across each of the layers to be drawn and draws them + * @param {CanvasContext} ctx - the context where the drawing will take place + * @param {Number} height - height of the canvas + * @param {Number} width - width of the canvas + * @param {Array} layers - the layer objects to render + * @param {Number} drawIteration - width of the canvas + */ +function drawLayers(ctx, height, width, layers, drawIteration) { + ctx.clearRect(0, 0, width, height); + layers.forEach(function (layer) { + var interpolator = layer.interpolator, + newProps = layer.newProps, + animation = layer.animation; + // return an empty object if dont need to be animating + + var interpolatedProps = animation ? interpolator ? interpolator(drawIteration / MAX_DRAWS) : interpolator : function () { + return {}; + }; + layer.renderLayer(_extends({}, newProps, interpolatedProps), ctx); + }); +} + +/** + * Build an array of layer of objects the contain the method for drawing each series + * as well as an interpolar (specifically a d3-interpolate interpolator) + * @param {Object} newChildren the new children to be rendered. + * @param {Object} oldChildren the old children to be rendered. + * @returns {Array} Object for rendering + */ +function buildLayers(newChildren, oldChildren) { + return newChildren.map(function (child, index) { + var oldProps = oldChildren[index] ? oldChildren[index].props : {}; + var newProps = child.props; + + var oldAnimatedProps = (0, _animation.extractAnimatedPropValues)(_extends({}, oldProps, { + animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS + })); + var newAnimatedProps = newProps ? (0, _animation.extractAnimatedPropValues)(_extends({}, newProps, { + animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS + })) : null; + var interpolator = (0, _d3Interpolate.interpolate)(oldAnimatedProps, newAnimatedProps); + + return { + renderLayer: child.type.renderLayer, + newProps: child.props, + animation: child.props.animation, + interpolator: interpolator + }; + }); +} + +var CanvasWrapper = function (_Component) { + _inherits(CanvasWrapper, _Component); + + function CanvasWrapper() { + _classCallCheck(this, CanvasWrapper); + + return _possibleConstructorReturn(this, (CanvasWrapper.__proto__ || Object.getPrototypeOf(CanvasWrapper)).apply(this, arguments)); + } + + _createClass(CanvasWrapper, [{ + key: 'componentDidMount', + value: function componentDidMount() { + var ctx = this.canvas.getContext('2d'); + if (!ctx) { + return; + } + var pixelRatio = this.props.pixelRatio; + + if (!ctx) { + return; + } + ctx.scale(pixelRatio, pixelRatio); + + this.drawChildren(null, this.props, ctx); + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate(oldProps) { + this.drawChildren(oldProps, this.props, this.canvas.getContext('2d')); + } + + /** + * Check that we can and should be animating, then kick off animations as apporpriate + * @param {Object} newProps the new props to be interpolated to + * @param {Object} oldProps the old props to be interpolated against + * @param {DomRef} ctx the canvas context to be drawn on. + * @returns {Array} Object for rendering + */ + + }, { + key: 'drawChildren', + value: function drawChildren(oldProps, newProps, ctx) { + var children = newProps.children, + innerHeight = newProps.innerHeight, + innerWidth = newProps.innerWidth, + marginBottom = newProps.marginBottom, + marginLeft = newProps.marginLeft, + marginRight = newProps.marginRight, + marginTop = newProps.marginTop; + + if (!ctx) { + return; + } + + var childrenShouldAnimate = children.find(function (child) { + return child.props.animation; + }); + + var height = innerHeight + marginTop + marginBottom; + var width = innerWidth + marginLeft + marginRight; + var layers = buildLayers(newProps.children, oldProps ? oldProps.children : []); + // if we don't need to be animating, dont! cut short + if (!childrenShouldAnimate) { + drawLayers(ctx, height, width, layers); + return; + } + + engageDrawLoop(ctx, height, width, layers); + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginBottom = _props.marginBottom, + marginLeft = _props.marginLeft, + marginRight = _props.marginRight, + marginTop = _props.marginTop, + pixelRatio = _props.pixelRatio; + + + var height = innerHeight + marginTop + marginBottom; + var width = innerWidth + marginLeft + marginRight; + + return _react2.default.createElement( + 'div', + { style: { left: 0, top: 0 }, className: 'rv-xy-canvas' }, + _react2.default.createElement('canvas', { + className: 'rv-xy-canvas-element', + height: height * pixelRatio, + width: width * pixelRatio, + style: { + height: height + 'px', + width: width + 'px' + }, + ref: function ref(_ref) { + return _this2.canvas = _ref; + } + }), + this.props.children + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return { + pixelRatio: window && window.devicePixelRatio || 1 + }; + } + }]); + + return CanvasWrapper; +}(_react.Component); + +CanvasWrapper.displayName = 'CanvasWrapper'; +CanvasWrapper.propTypes = { + marginBottom: _propTypes2.default.number.isRequired, + marginLeft: _propTypes2.default.number.isRequired, + marginRight: _propTypes2.default.number.isRequired, + marginTop: _propTypes2.default.number.isRequired, + innerHeight: _propTypes2.default.number.isRequired, + innerWidth: _propTypes2.default.number.isRequired, + pixelRatio: _propTypes2.default.number.isRequired +}; + +exports.default = CanvasWrapper; \ No newline at end of file diff --git a/dist/plot/series/contour-series.js b/dist/plot/series/contour-series.js new file mode 100644 index 000000000..030567d86 --- /dev/null +++ b/dist/plot/series/contour-series.js @@ -0,0 +1,164 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Contour = require('d3-contour'); + +var _d3Geo = require('d3-geo'); + +var _d3Scale = require('d3-scale'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _theme = require('../../theme'); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--contour'; + +function getDomain(data) { + return data.reduce(function (acc, row) { + return { + min: Math.min(acc.min, row.value), + max: Math.max(acc.max, row.value) + }; + }, { min: Infinity, max: -Infinity }); +} + +var ContourSeries = function (_AbstractSeries) { + _inherits(ContourSeries, _AbstractSeries); + + function ContourSeries() { + _classCallCheck(this, ContourSeries); + + return _possibleConstructorReturn(this, (ContourSeries.__proto__ || Object.getPrototypeOf(ContourSeries)).apply(this, arguments)); + } + + _createClass(ContourSeries, [{ + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + bandwidth = _props.bandwidth, + className = _props.className, + colorRange = _props.colorRange, + data = _props.data, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + + if (!data || !innerWidth || !innerHeight) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(ContourSeries, _extends({}, this.props, { animation: null })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + var contouredData = (0, _d3Contour.contourDensity)().x(function (d) { + return x(d); + }).y(function (d) { + return y(d); + }).size([innerWidth, innerHeight]).bandwidth(bandwidth)(data); + + var geo = (0, _d3Geo.geoPath)(); + + var _getDomain = getDomain(contouredData), + min = _getDomain.min, + max = _getDomain.max; + + var colorScale = (0, _d3Scale.scaleLinear)().domain([min, max]).range(colorRange || _theme.CONTINUOUS_COLOR_RANGE); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + contouredData.map(function (polygon, index) { + return _react2.default.createElement('path', { + className: 'rv-xy-plot__series--contour-line', + key: 'rv-xy-plot__series--contour-line-' + index, + d: geo(polygon), + style: _extends({ + fill: colorScale(polygon.value) + }, style) + }); + }) + ); + } + }]); + + return ContourSeries; +}(_abstractSeries2.default); + +ContourSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + animation: _propTypes2.default.bool, + bandwidth: _propTypes2.default.number, + className: _propTypes2.default.string, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + style: _propTypes2.default.object +}); + +ContourSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + bandwidth: 40, + style: {} +}); + +exports.default = ContourSeries; \ No newline at end of file diff --git a/dist/plot/series/custom-svg-series.js b/dist/plot/series/custom-svg-series.js new file mode 100644 index 000000000..1dfedfcb2 --- /dev/null +++ b/dist/plot/series/custom-svg-series.js @@ -0,0 +1,237 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +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; } + +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); } } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--custom-svg-wrapper'; + +var DEFAULT_STYLE = { + stroke: 'blue', + fill: 'blue' +}; + +function predefinedComponents(type) { + var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_STYLE; + + switch (type) { + case 'diamond': + return _react2.default.createElement('polygon', { + style: style, + points: '0 0 ' + size / 2 + ' ' + size / 2 + ' 0 ' + size + ' ' + -size / 2 + ' ' + size / 2 + ' 0 0' + }); + case 'star': + var starPoints = [].concat(_toConsumableArray(new Array(5))).map(function (c, index) { + var angle = index / 5 * Math.PI * 2; + var innerAngle = angle + Math.PI / 10; + var outerAngle = angle - Math.PI / 10; + // ratio of inner polygon to outer polgyon + var innerRadius = size / 2.61; + return '\n ' + Math.cos(outerAngle) * size + ' ' + Math.sin(outerAngle) * size + '\n ' + Math.cos(innerAngle) * innerRadius + ' ' + Math.sin(innerAngle) * innerRadius + '\n '; + }).join(' '); + return _react2.default.createElement('polygon', { + points: starPoints, + x: '0', + y: '0', + height: size, + width: size, + style: style + }); + case 'square': + return _react2.default.createElement('rect', { + x: '' + -size / 2, + y: '' + -size / 2, + height: size, + width: size, + style: style + }); + default: + case 'circle': + return _react2.default.createElement('circle', { cx: '0', cy: '0', r: size / 2, style: style }); + } +} + +function getInnerComponent(_ref) { + var customComponent = _ref.customComponent, + defaultType = _ref.defaultType, + positionInPixels = _ref.positionInPixels, + positionFunctions = _ref.positionFunctions, + style = _ref.style, + propsSize = _ref.propsSize; + var size = customComponent.size; + + var aggStyle = _extends({}, style, customComponent.style || {}); + var innerComponent = customComponent.customComponent; + if (!innerComponent && typeof defaultType === 'string') { + return predefinedComponents(defaultType, size || propsSize, aggStyle); + } + // if default component is a function + if (!innerComponent) { + return defaultType(customComponent, positionInPixels, aggStyle); + } + if (typeof innerComponent === 'string') { + return predefinedComponents(innerComponent || defaultType, size, aggStyle); + } + // if inner component is a function + return innerComponent(customComponent, positionInPixels, aggStyle); +} + +var CustomSVGSeries = function (_AbstractSeries) { + _inherits(CustomSVGSeries, _AbstractSeries); + + function CustomSVGSeries() { + _classCallCheck(this, CustomSVGSeries); + + return _possibleConstructorReturn(this, (CustomSVGSeries.__proto__ || Object.getPrototypeOf(CustomSVGSeries)).apply(this, arguments)); + } + + _createClass(CustomSVGSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + customComponent = _props.customComponent, + data = _props.data, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style, + size = _props.size; + + + if (!data || !innerWidth || !innerHeight) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(CustomSVGSeries, _extends({}, this.props, { animation: false })) + ); + } + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var contents = data.map(function (seriesComponent, index) { + var positionInPixels = { + x: x({ x: seriesComponent.x }), + y: y({ y: seriesComponent.y }) + }; + var innerComponent = getInnerComponent({ + customComponent: seriesComponent, + positionInPixels: positionInPixels, + defaultType: customComponent, + positionFunctions: { x: x, y: y }, + style: style, + propsSize: size + }); + return _react2.default.createElement( + 'g', + { + className: 'rv-xy-plot__series--custom-svg', + key: 'rv-xy-plot__series--custom-svg-' + index, + transform: 'translate(' + positionInPixels.x + ',' + positionInPixels.y + ')', + onMouseEnter: function onMouseEnter(e) { + return _this2._valueMouseOverHandler(seriesComponent, e); + }, + onMouseLeave: function onMouseLeave(e) { + return _this2._valueMouseOutHandler(seriesComponent, e); + } + }, + innerComponent + ); + }); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + contents + ); + } + }]); + + return CustomSVGSeries; +}(_abstractSeries2.default); + +CustomSVGSeries.propTypes = { + animation: _propTypes2.default.bool, + className: _propTypes2.default.string, + customComponent: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), + data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + x: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired, + y: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired + })).isRequired, + marginLeft: _propTypes2.default.number, + marginTop: _propTypes2.default.number, + style: _propTypes2.default.object, + size: _propTypes2.default.number, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func +}; + +CustomSVGSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + animation: false, + customComponent: 'circle', + style: {}, + size: 2 +}); + +exports.default = CustomSVGSeries; \ No newline at end of file diff --git a/dist/plot/series/heatmap-series.js b/dist/plot/series/heatmap-series.js new file mode 100644 index 000000000..69c142265 --- /dev/null +++ b/dist/plot/series/heatmap-series.js @@ -0,0 +1,147 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--heatmap'; + +var HeatmapSeries = function (_AbstractSeries) { + _inherits(HeatmapSeries, _AbstractSeries); + + function HeatmapSeries() { + _classCallCheck(this, HeatmapSeries); + + return _possibleConstructorReturn(this, (HeatmapSeries.__proto__ || Object.getPrototypeOf(HeatmapSeries)).apply(this, arguments)); + } + + _createClass(HeatmapSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + if (!data) { + return null; + } + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(HeatmapSeries, _extends({}, this.props, { animation: null })) + ); + } + + var _rectStyle$style = _extends({ rectStyle: {} }, style), + rectStyle = _rectStyle$style.rectStyle; + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var opacity = this._getAttributeFunctor('opacity'); + var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var xDistance = this._getScaleDistance('x'); + var yDistance = this._getScaleDistance('y'); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + var attrs = _extends({ + style: _extends({ + stroke: stroke && stroke(d), + fill: fill && fill(d), + opacity: opacity && opacity(d) + }, style) + }, rectStyle, { + x: x(d) - xDistance / 2, + y: y(d) - yDistance / 2, + width: xDistance, + height: yDistance, + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + } + }); + return _react2.default.createElement('rect', attrs); + }) + ); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'x' || attr === 'y'; + return { isDomainAdjustmentNeeded: isDomainAdjustmentNeeded }; + } + }]); + + return HeatmapSeries; +}(_abstractSeries2.default); + +HeatmapSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +HeatmapSeries.displayName = 'HeatmapSeries'; + +exports.default = HeatmapSeries; \ No newline at end of file diff --git a/dist/plot/series/hexbin-series.js b/dist/plot/series/hexbin-series.js new file mode 100644 index 000000000..2f2cadcf9 --- /dev/null +++ b/dist/plot/series/hexbin-series.js @@ -0,0 +1,180 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _d3Hexbin = require('d3-hexbin'); + +var _d3Scale = require('d3-scale'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _theme = require('../../theme'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } + +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); } } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--hexbin'; + +function getColorDomain(_ref, hexes) { + var countDomain = _ref.countDomain; + + if (countDomain) { + return countDomain; + } + return [0, Math.max.apply(Math, _toConsumableArray(hexes.map(function (row) { + return row.length; + })))]; +} + +var HexbinSeries = function (_AbstractSeries) { + _inherits(HexbinSeries, _AbstractSeries); + + function HexbinSeries() { + _classCallCheck(this, HexbinSeries); + + return _possibleConstructorReturn(this, (HexbinSeries.__proto__ || Object.getPrototypeOf(HexbinSeries)).apply(this, arguments)); + } + + _createClass(HexbinSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + colorRange = _props.colorRange, + data = _props.data, + innerHeight = _props.innerHeight, + innerWidth = _props.innerWidth, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + radius = _props.radius, + sizeHexagonsWithCount = _props.sizeHexagonsWithCount, + style = _props.style, + xOffset = _props.xOffset, + yOffset = _props.yOffset; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(HexbinSeries, _extends({}, this.props, { animation: null })) + ); + } + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + + var hex = (0, _d3Hexbin.hexbin)().x(function (d) { + return x(d) + xOffset; + }).y(function (d) { + return y(d) + yOffset; + }).radius(radius).size([innerWidth, innerHeight]); + + var hexagonPath = hex.hexagon(); + var hexes = hex(data); + + var countDomain = getColorDomain(this.props, hexes); + var color = (0, _d3Scale.scaleLinear)().domain(countDomain).range(colorRange); + var size = (0, _d3Scale.scaleLinear)().domain(countDomain).range([0, radius]); + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + hexes.map(function (d, i) { + var attrs = { + style: style, + d: sizeHexagonsWithCount ? hex.hexagon(size(d.length)) : hexagonPath, + fill: color(d.length), + transform: 'translate(' + d.x + ', ' + d.y + ')', + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + } + }; + return _react2.default.createElement('path', attrs); + }) + ); + } + }]); + + return HexbinSeries; +}(_abstractSeries2.default); + +HexbinSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + radius: _propTypes2.default.number +}); + +HexbinSeries.defaultProps = { + radius: 20, + colorRange: _theme.CONTINUOUS_COLOR_RANGE, + xOffset: 0, + yOffset: 0 +}; + +HexbinSeries.displayName = 'HexbinSeries'; + +exports.default = HexbinSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series-canvas.js b/dist/plot/series/horizontal-bar-series-canvas.js new file mode 100644 index 000000000..fa817cc24 --- /dev/null +++ b/dist/plot/series/horizontal-bar-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeriesCanvas = require('./bar-series-canvas'); + +var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalBarSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); + + function HorizontalBarSeriesCanvas() { + _classCallCheck(this, HorizontalBarSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalBarSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'y'; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _barSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalBarSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; +HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series.js b/dist/plot/series/horizontal-bar-series.js new file mode 100644 index 000000000..ef65b02da --- /dev/null +++ b/dist/plot/series/horizontal-bar-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeries = require('./bar-series'); + +var _barSeries2 = _interopRequireDefault(_barSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalBarSeries = function (_AbstractSeries) { + _inherits(HorizontalBarSeries, _AbstractSeries); + + function HorizontalBarSeries() { + _classCallCheck(this, HorizontalBarSeries); + + return _possibleConstructorReturn(this, (HorizontalBarSeries.__proto__ || Object.getPrototypeOf(HorizontalBarSeries)).apply(this, arguments)); + } + + _createClass(HorizontalBarSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'y'; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return HorizontalBarSeries; +}(_abstractSeries2.default); + +HorizontalBarSeries.displayName = 'HorizontalBarSeries'; + +exports.default = HorizontalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series-canvas.js b/dist/plot/series/horizontal-rect-series-canvas.js new file mode 100644 index 000000000..c275a349d --- /dev/null +++ b/dist/plot/series/horizontal-rect-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeriesCanvas = require('./rect-series-canvas'); + +var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalRectSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); + + function HorizontalRectSeriesCanvas() { + _classCallCheck(this, HorizontalRectSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalRectSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalRectSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; +HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series.js b/dist/plot/series/horizontal-rect-series.js new file mode 100644 index 000000000..014390674 --- /dev/null +++ b/dist/plot/series/horizontal-rect-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeries = require('./rect-series'); + +var _rectSeries2 = _interopRequireDefault(_rectSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalRectSeries = function (_AbstractSeries) { + _inherits(HorizontalRectSeries, _AbstractSeries); + + function HorizontalRectSeries() { + _classCallCheck(this, HorizontalRectSeries); + + return _possibleConstructorReturn(this, (HorizontalRectSeries.__proto__ || Object.getPrototypeOf(HorizontalRectSeries)).apply(this, arguments)); + } + + _createClass(HorizontalRectSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { + linePosAttr: 'y', + valuePosAttr: 'x', + lineSizeAttr: 'height', + valueSizeAttr: 'width' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'x'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return HorizontalRectSeries; +}(_abstractSeries2.default); + +HorizontalRectSeries.displayName = 'HorizontalRectSeries'; + +exports.default = HorizontalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series-canvas.js b/dist/plot/series/line-mark-series-canvas.js new file mode 100644 index 000000000..501c2745a --- /dev/null +++ b/dist/plot/series/line-mark-series-canvas.js @@ -0,0 +1,87 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _markSeriesCanvas = require('./mark-series-canvas'); + +var _markSeriesCanvas2 = _interopRequireDefault(_markSeriesCanvas); + +var _lineSeriesCanvas = require('./line-series-canvas'); + +var _lineSeriesCanvas2 = _interopRequireDefault(_lineSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var LineMarkSeriesCanvas = function (_AbstractSeries) { + _inherits(LineMarkSeriesCanvas, _AbstractSeries); + + function LineMarkSeriesCanvas() { + _classCallCheck(this, LineMarkSeriesCanvas); + + return _possibleConstructorReturn(this, (LineMarkSeriesCanvas.__proto__ || Object.getPrototypeOf(LineMarkSeriesCanvas)).apply(this, arguments)); + } + + _createClass(LineMarkSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _lineSeriesCanvas2.default.renderLayer(props, ctx); + _markSeriesCanvas2.default.renderLayer(props, ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return LineMarkSeriesCanvas; +}(_abstractSeries2.default); + +LineMarkSeriesCanvas.displayName = 'LineMarkSeriesCanvas'; +LineMarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = LineMarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series.js b/dist/plot/series/line-mark-series.js new file mode 100644 index 000000000..7c3c876cf --- /dev/null +++ b/dist/plot/series/line-mark-series.js @@ -0,0 +1,102 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _lineSeries = require('./line-series'); + +var _lineSeries2 = _interopRequireDefault(_lineSeries); + +var _markSeries = require('./mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +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; } + +var propTypes = _extends({}, _lineSeries2.default.propTypes, { + lineStyle: _propTypes2.default.object, + markStyle: _propTypes2.default.object +}); + +var LineMarkSeries = function (_AbstractSeries) { + _inherits(LineMarkSeries, _AbstractSeries); + + function LineMarkSeries() { + _classCallCheck(this, LineMarkSeries); + + return _possibleConstructorReturn(this, (LineMarkSeries.__proto__ || Object.getPrototypeOf(LineMarkSeries)).apply(this, arguments)); + } + + _createClass(LineMarkSeries, [{ + key: 'render', + value: function render() { + var _props = this.props, + lineStyle = _props.lineStyle, + markStyle = _props.markStyle, + style = _props.style; + + return _react2.default.createElement( + 'g', + { className: 'rv-xy-plot__series rv-xy-plot__series--linemark' }, + _react2.default.createElement(_lineSeries2.default, _extends({}, this.props, { style: _extends({}, style, lineStyle) })), + _react2.default.createElement(_markSeries2.default, _extends({}, this.props, { style: _extends({}, style, markStyle) })) + ); + } + }], [{ + key: 'defaultProps', + get: function get() { + return _extends({}, _lineSeries2.default.defaultProps, { + lineStyle: {}, + markStyle: {} + }); + } + }]); + + return LineMarkSeries; +}(_abstractSeries2.default); + +LineMarkSeries.displayName = 'LineMarkSeries'; +LineMarkSeries.propTypes = propTypes; + +exports.default = LineMarkSeries; \ No newline at end of file diff --git a/dist/plot/series/line-series-canvas.js b/dist/plot/series/line-series-canvas.js new file mode 100644 index 000000000..9694a334d --- /dev/null +++ b/dist/plot/series/line-series-canvas.js @@ -0,0 +1,146 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Color = require('d3-color'); + +var _d3Shape = require('d3-shape'); + +var d3Shape = _interopRequireWildcard(_d3Shape); + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +var LineSeriesCanvas = function (_AbstractSeries) { + _inherits(LineSeriesCanvas, _AbstractSeries); + + function LineSeriesCanvas() { + _classCallCheck(this, LineSeriesCanvas); + + return _possibleConstructorReturn(this, (LineSeriesCanvas.__proto__ || Object.getPrototypeOf(LineSeriesCanvas)).apply(this, arguments)); + } + + _createClass(LineSeriesCanvas, [{ + key: 'render', + value: function render() { + return _react2.default.createElement('div', null); + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var curve = props.curve, + data = props.data, + marginLeft = props.marginLeft, + marginTop = props.marginTop, + strokeWidth = props.strokeWidth, + strokeDasharray = props.strokeDasharray; + + if (!data || data.length === 0) { + return; + } + + var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); + var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); + var stroke = (0, _scalesUtils.getAttributeValue)(props, 'stroke') || (0, _scalesUtils.getAttributeValue)(props, 'color'); + var strokeColor = (0, _d3Color.rgb)(stroke); + var newOpacity = (0, _scalesUtils.getAttributeValue)(props, 'opacity'); + var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; + var line = d3Shape.line().x(function (row) { + return x(row) + marginLeft; + }).y(function (row) { + return y(row) + marginTop; + }); + if (typeof curve === 'string' && d3Shape[curve]) { + line = line.curve(d3Shape[curve]); + } else if (typeof curve === 'function') { + line = line.curve(curve); + } + + ctx.beginPath(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + opacity + ')'; + ctx.lineWidth = strokeWidth; + + if (strokeDasharray) { + ctx.setLineDash(strokeDasharray); + } + + line.context(ctx)(data); + ctx.stroke(); + ctx.closePath(); + // set back to default + ctx.lineWidth = 1; + ctx.setLineDash([]); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return LineSeriesCanvas; +}(_abstractSeries2.default); + +LineSeriesCanvas.displayName = 'LineSeriesCanvas'; +LineSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + strokeWidth: 2 +}); + +LineSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + strokeWidth: _propTypes2.default.number +}); + +exports.default = LineSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-series.js b/dist/plot/series/line-series.js new file mode 100644 index 000000000..d643b3b7f --- /dev/null +++ b/dist/plot/series/line-series.js @@ -0,0 +1,177 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Shape = require('d3-shape'); + +var d3Shape = _interopRequireWildcard(_d3Shape); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _theme = require('../../theme'); + +var _seriesUtils = require('../../utils/series-utils'); + +var _reactUtils = require('../../utils/react-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; + +var STROKE_STYLES = { + dashed: '6, 2', + solid: null +}; + +var LineSeries = function (_AbstractSeries) { + _inherits(LineSeries, _AbstractSeries); + + function LineSeries() { + _classCallCheck(this, LineSeries); + + return _possibleConstructorReturn(this, (LineSeries.__proto__ || Object.getPrototypeOf(LineSeries)).apply(this, arguments)); + } + + _createClass(LineSeries, [{ + key: '_renderLine', + value: function _renderLine(data, x, y, curve, getNull) { + var line = d3Shape.line(); + if (curve !== null) { + if (typeof curve === 'string' && d3Shape[curve]) { + line = line.curve(d3Shape[curve]); + } else if (typeof curve === 'function') { + line = line.curve(curve); + } + } + line = line.defined(getNull); + line = line.x(x).y(y); + return line(data); + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data; + + + if (this.props.nullAccessor) { + (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); + } + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(LineSeries, _extends({}, this.props, { animation: null })) + ); + } + + var _props2 = this.props, + curve = _props2.curve, + marginLeft = _props2.marginLeft, + marginTop = _props2.marginTop, + strokeDasharray = _props2.strokeDasharray, + strokeStyle = _props2.strokeStyle, + strokeWidth = _props2.strokeWidth, + style = _props2.style; + + + var x = this._getAttributeFunctor('x'); + var y = this._getAttributeFunctor('y'); + var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); + var newOpacity = this._getAttributeValue('opacity'); + var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; + var getNull = this.props.nullAccessor || this.props.getNull; + var d = this._renderLine(data, x, y, curve, getNull); + + return _react2.default.createElement('path', { + d: d, + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')', + onMouseOver: this._seriesMouseOverHandler, + onMouseOut: this._seriesMouseOutHandler, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + style: _extends({ + opacity: opacity, + strokeDasharray: STROKE_STYLES[strokeStyle] || strokeDasharray, + strokeWidth: strokeWidth, + stroke: stroke + }, style) + }); + } + }]); + + return LineSeries; +}(_abstractSeries2.default); + +LineSeries.displayName = 'LineSeries'; +LineSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)), + curve: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), + getNull: _propTypes2.default.func +}); +LineSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + strokeStyle: 'solid', + style: {}, + opacity: 1, + curve: null, + className: '', + getNull: function getNull() { + return true; + } +}); + +exports.default = LineSeries; \ No newline at end of file diff --git a/dist/plot/series/mark-series-canvas.js b/dist/plot/series/mark-series-canvas.js new file mode 100644 index 000000000..de7f2e814 --- /dev/null +++ b/dist/plot/series/mark-series-canvas.js @@ -0,0 +1,109 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _d3Color = require('d3-color'); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var MarkSeriesCanvas = function (_AbstractSeries) { + _inherits(MarkSeriesCanvas, _AbstractSeries); + + function MarkSeriesCanvas() { + _classCallCheck(this, MarkSeriesCanvas); + + return _possibleConstructorReturn(this, (MarkSeriesCanvas.__proto__ || Object.getPrototypeOf(MarkSeriesCanvas)).apply(this, arguments)); + } + + _createClass(MarkSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var data = props.data, + marginLeft = props.marginLeft, + marginTop = props.marginTop; + + + var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); + var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); + var size = (0, _scalesUtils.getAttributeFunctor)(props, 'size') || function (p) { + return _theme.DEFAULT_SIZE; + }; + var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); + + data.forEach(function (row) { + var fillColor = (0, _d3Color.rgb)(fill(row)); + var strokeColor = (0, _d3Color.rgb)(stroke(row)); + var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; + ctx.beginPath(); + ctx.arc(x(row) + marginLeft, y(row) + marginTop, size(row), 0, 2 * Math.PI); + ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; + ctx.fill(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; + ctx.stroke(); + }); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return MarkSeriesCanvas; +}(_abstractSeries2.default); + +MarkSeriesCanvas.displayName = 'MarkSeriesCanvas'; + +MarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = MarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/mark-series.js b/dist/plot/series/mark-series.js new file mode 100644 index 000000000..9ba9a0e8a --- /dev/null +++ b/dist/plot/series/mark-series.js @@ -0,0 +1,179 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _reactUtils = require('../../utils/react-utils'); + +var _theme = require('../../theme'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--mark'; +var DEFAULT_STROKE_WIDTH = 1; + +var MarkSeries = function (_AbstractSeries) { + _inherits(MarkSeries, _AbstractSeries); + + function MarkSeries() { + _classCallCheck(this, MarkSeries); + + return _possibleConstructorReturn(this, (MarkSeries.__proto__ || Object.getPrototypeOf(MarkSeries)).apply(this, arguments)); + } + + _createClass(MarkSeries, [{ + key: '_renderCircle', + value: function _renderCircle(d, i, strokeWidth, style, scalingFunctions) { + var _this2 = this; + + var fill = scalingFunctions.fill, + opacity = scalingFunctions.opacity, + size = scalingFunctions.size, + stroke = scalingFunctions.stroke, + x = scalingFunctions.x, + y = scalingFunctions.y; + + + var attrs = { + r: size ? size(d) : _theme.DEFAULT_SIZE, + cx: x(d), + cy: y(d), + style: _extends({ + opacity: opacity ? opacity(d) : _theme.DEFAULT_OPACITY, + stroke: stroke && stroke(d), + fill: fill && fill(d), + strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH + }, style), + key: i, + onClick: function onClick(e) { + return _this2._valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + } + }; + return _react2.default.createElement('circle', attrs); + } + }, { + key: 'render', + value: function render() { + var _this3 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + strokeWidth = _props.strokeWidth, + style = _props.style; + + + if (this.props.nullAccessor) { + (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); + } + + var getNull = this.props.nullAccessor || this.props.getNull; + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(MarkSeries, _extends({}, this.props, { animation: null })) + ); + } + + var scalingFunctions = { + fill: this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'), + opacity: this._getAttributeFunctor('opacity'), + size: this._getAttributeFunctor('size'), + stroke: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), + x: this._getAttributeFunctor('x'), + y: this._getAttributeFunctor('y') + }; + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + return getNull(d) && _this3._renderCircle(d, i, strokeWidth, style, scalingFunctions); + }) + ); + } + }]); + + return MarkSeries; +}(_abstractSeries2.default); + +MarkSeries.displayName = 'MarkSeries'; +MarkSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + getNull: _propTypes2.default.func, + strokeWidth: _propTypes2.default.number +}); +MarkSeries.defaultProps = { + getNull: function getNull() { + return true; + } +}; + +exports.default = MarkSeries; \ No newline at end of file diff --git a/dist/plot/series/polygon-series.js b/dist/plot/series/polygon-series.js new file mode 100644 index 000000000..d922d284b --- /dev/null +++ b/dist/plot/series/polygon-series.js @@ -0,0 +1,126 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--polygon'; +var DEFAULT_COLOR = '#12939A'; + +var generatePath = function generatePath(data, xFunctor, yFunctor) { + return data.reduce(function (res, row, i) { + return res + ' ' + (i ? 'L' : 'M') + xFunctor(row) + ' ' + yFunctor(row); + }, '') + ' Z'; +}; + +var PolygonSeries = function (_AbstractSeries) { + _inherits(PolygonSeries, _AbstractSeries); + + function PolygonSeries() { + _classCallCheck(this, PolygonSeries); + + return _possibleConstructorReturn(this, (PolygonSeries.__proto__ || Object.getPrototypeOf(PolygonSeries)).apply(this, arguments)); + } + + _createClass(PolygonSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + color = _props.color, + className = _props.className, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(PolygonSeries, _extends({}, this.props, { animation: null })) + ); + } + var xFunctor = this._getAttributeFunctor('x'); + var yFunctor = this._getAttributeFunctor('y'); + + return _react2.default.createElement('path', { + className: predefinedClassName + ' ' + className, + onMouseOver: function onMouseOver(e) { + return _this2._seriesMouseOverHandler(data, e); + }, + onMouseOut: function onMouseOut(e) { + return _this2._seriesMouseOutHandler(data, e); + }, + onClick: this._seriesClickHandler, + onContextMenu: this._seriesRightClickHandler, + fill: color || DEFAULT_COLOR, + style: style, + d: generatePath(data, xFunctor, yFunctor), + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }); + } + }], [{ + key: 'propTypes', + get: function get() { + return _extends({}, _abstractSeries2.default.propTypes); + } + }]); + + return PolygonSeries; +}(_abstractSeries2.default); + +PolygonSeries.displayName = 'PolygonSeries'; + +exports.default = PolygonSeries; \ No newline at end of file diff --git a/dist/plot/series/rect-series-canvas.js b/dist/plot/series/rect-series-canvas.js new file mode 100644 index 000000000..727596c9b --- /dev/null +++ b/dist/plot/series/rect-series-canvas.js @@ -0,0 +1,136 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Color = require('d3-color'); + +var _theme = require('../../theme'); + +var _scalesUtils = require('../../utils/scales-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +var RectSeriesCanvas = function (_AbstractSeries) { + _inherits(RectSeriesCanvas, _AbstractSeries); + + function RectSeriesCanvas() { + _classCallCheck(this, RectSeriesCanvas); + + return _possibleConstructorReturn(this, (RectSeriesCanvas.__proto__ || Object.getPrototypeOf(RectSeriesCanvas)).apply(this, arguments)); + } + + _createClass(RectSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'renderLayer', + value: function renderLayer(props, ctx) { + var data = props.data, + linePosAttr = props.linePosAttr, + lineSizeAttr = props.lineSizeAttr, + marginLeft = props.marginLeft, + marginTop = props.marginTop, + valuePosAttr = props.valuePosAttr; + + if (!data || data.length === 0) { + return; + } + + var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); + var line0 = (0, _scalesUtils.getAttr0Functor)(props, linePosAttr); + var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); + var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); + var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); + var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); + + data.forEach(function (row) { + var fillColor = (0, _d3Color.rgb)(fill(row)); + var strokeColor = (0, _d3Color.rgb)(stroke(row)); + var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; + + var linePos = line0(row); + var valuePos = Math.min(value0(row), value(row)); + var x = valuePosAttr === 'x' ? valuePos : linePos; + var y = valuePosAttr === 'y' ? valuePos : linePos; + + var lineSize = Math.abs(line(row) - line0(row)); + var valueSize = Math.abs(-value0(row) + value(row)); + var height = lineSizeAttr === 'height' ? lineSize : valueSize; + var width = lineSizeAttr === 'width' ? lineSize : valueSize; + + ctx.beginPath(); + ctx.rect(x + marginLeft, y + marginTop, width, height); + ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; + ctx.fill(); + ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; + ctx.stroke(); + }); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return RectSeriesCanvas; +}(_abstractSeries2.default); + +RectSeriesCanvas.displayName = 'RectSeriesCanvas'; +RectSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + linePosAttr: _propTypes2.default.string.isRequired, + valuePosAttr: _propTypes2.default.string.isRequired, + lineSizeAttr: _propTypes2.default.string.isRequired, + valueSizeAttr: _propTypes2.default.string.isRequired +}); + +RectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = RectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/rect-series.js b/dist/plot/series/rect-series.js new file mode 100644 index 000000000..75bbd5f46 --- /dev/null +++ b/dist/plot/series/rect-series.js @@ -0,0 +1,151 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--rect'; + +var RectSeries = function (_AbstractSeries) { + _inherits(RectSeries, _AbstractSeries); + + function RectSeries() { + _classCallCheck(this, RectSeries); + + return _possibleConstructorReturn(this, (RectSeries.__proto__ || Object.getPrototypeOf(RectSeries)).apply(this, arguments)); + } + + _createClass(RectSeries, [{ + key: 'render', + value: function render() { + var _this2 = this; + + var _props = this.props, + animation = _props.animation, + className = _props.className, + data = _props.data, + linePosAttr = _props.linePosAttr, + lineSizeAttr = _props.lineSizeAttr, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + style = _props.style, + valuePosAttr = _props.valuePosAttr, + valueSizeAttr = _props.valueSizeAttr; + + + if (!data) { + return null; + } + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(RectSeries, _extends({}, this.props, { animation: null })) + ); + } + + var lineFunctor = this._getAttributeFunctor(linePosAttr); + var line0Functor = this._getAttr0Functor(linePosAttr); + var valueFunctor = this._getAttributeFunctor(valuePosAttr); + var value0Functor = this._getAttr0Functor(valuePosAttr); + var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); + var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); + var opacityFunctor = this._getAttributeFunctor('opacity'); + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(function (d, i) { + var _attrs; + + var attrs = (_attrs = { + style: _extends({ + opacity: opacityFunctor && opacityFunctor(d), + stroke: strokeFunctor && strokeFunctor(d), + fill: fillFunctor && fillFunctor(d) + }, style) + }, _defineProperty(_attrs, linePosAttr, line0Functor(d)), _defineProperty(_attrs, lineSizeAttr, Math.abs(lineFunctor(d) - line0Functor(d))), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { + return _this2._valueClickHandler(d, e); + }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { + return _this2._valueRightClickHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { + return _this2._valueMouseOverHandler(d, e); + }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { + return _this2._valueMouseOutHandler(d, e); + }), _defineProperty(_attrs, 'key', i), _attrs); + return _react2.default.createElement('rect', attrs); + }) + ); + } + }], [{ + key: 'propTypes', + get: function get() { + return _extends({}, _abstractSeries2.default.propTypes, { + linePosAttr: _propTypes2.default.string, + valuePosAttr: _propTypes2.default.string, + lineSizeAttr: _propTypes2.default.string, + valueSizeAttr: _propTypes2.default.string + }); + } + }]); + + return RectSeries; +}(_abstractSeries2.default); + +RectSeries.displayName = 'RectSeries'; + +exports.default = RectSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series-canvas.js b/dist/plot/series/vertical-bar-series-canvas.js new file mode 100644 index 000000000..c07d69f63 --- /dev/null +++ b/dist/plot/series/vertical-bar-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeriesCanvas = require('./bar-series-canvas'); + +var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalBarSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); + + function HorizontalBarSeriesCanvas() { + _classCallCheck(this, HorizontalBarSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalBarSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'x'; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _barSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalBarSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; +HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series.js b/dist/plot/series/vertical-bar-series.js new file mode 100644 index 000000000..0a0e1de82 --- /dev/null +++ b/dist/plot/series/vertical-bar-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _barSeries = require('./bar-series'); + +var _barSeries2 = _interopRequireDefault(_barSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var VerticalBarSeries = function (_AbstractSeries) { + _inherits(VerticalBarSeries, _AbstractSeries); + + function VerticalBarSeries() { + _classCallCheck(this, VerticalBarSeries); + + return _possibleConstructorReturn(this, (VerticalBarSeries.__proto__ || Object.getPrototypeOf(VerticalBarSeries)).apply(this, arguments)); + } + + _createClass(VerticalBarSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = attr === 'x'; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return VerticalBarSeries; +}(_abstractSeries2.default); + +VerticalBarSeries.displayName = 'VerticalBarSeries'; + +exports.default = VerticalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series-canvas.js b/dist/plot/series/vertical-rect-series-canvas.js new file mode 100644 index 000000000..a45961e48 --- /dev/null +++ b/dist/plot/series/vertical-rect-series-canvas.js @@ -0,0 +1,97 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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 _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeriesCanvas = require('./rect-series-canvas'); + +var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); + +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; } // Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var HorizontalRectSeriesCanvas = function (_AbstractSeries) { + _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); + + function HorizontalRectSeriesCanvas() { + _classCallCheck(this, HorizontalRectSeriesCanvas); + + return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); + } + + _createClass(HorizontalRectSeriesCanvas, [{ + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }, { + key: 'renderLayer', + value: function renderLayer(props, ctx) { + _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + }), ctx); + } + }, { + key: 'requiresSVG', + get: function get() { + return false; + } + }, { + key: 'isCanvas', + get: function get() { + return true; + } + }]); + + return HorizontalRectSeriesCanvas; +}(_abstractSeries2.default); + +HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; +HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); + +exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series.js b/dist/plot/series/vertical-rect-series.js new file mode 100644 index 000000000..e4b09a340 --- /dev/null +++ b/dist/plot/series/vertical-rect-series.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _rectSeries = require('./rect-series'); + +var _rectSeries2 = _interopRequireDefault(_rectSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var VerticalRectSeries = function (_AbstractSeries) { + _inherits(VerticalRectSeries, _AbstractSeries); + + function VerticalRectSeries() { + _classCallCheck(this, VerticalRectSeries); + + return _possibleConstructorReturn(this, (VerticalRectSeries.__proto__ || Object.getPrototypeOf(VerticalRectSeries)).apply(this, arguments)); + } + + _createClass(VerticalRectSeries, [{ + key: 'render', + value: function render() { + return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { + linePosAttr: 'x', + valuePosAttr: 'y', + lineSizeAttr: 'width', + valueSizeAttr: 'height' + })); + } + }], [{ + key: 'getParentConfig', + value: function getParentConfig(attr) { + var isDomainAdjustmentNeeded = false; + var zeroBaseValue = attr === 'y'; + return { + isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, + zeroBaseValue: zeroBaseValue + }; + } + }]); + + return VerticalRectSeries; +}(_abstractSeries2.default); + +VerticalRectSeries.displayName = 'VerticalRectSeries'; + +exports.default = VerticalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/whisker-series.js b/dist/plot/series/whisker-series.js new file mode 100644 index 000000000..b2c479d8c --- /dev/null +++ b/dist/plot/series/whisker-series.js @@ -0,0 +1,274 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../../utils/series-utils'); + +var _theme = require('../../theme'); + +var _abstractSeries = require('./abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +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; } + +var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--whisker'; +var DEFAULT_STROKE_WIDTH = 1; +var DEFAULT_CROSS_BAR_WIDTH = 6; + +/** + * Render whisker lines for a data point. + * @param {Object} whiskerMarkProps All the properties of the whisker mark. + * @private + */ +var renderWhiskerMark = function renderWhiskerMark(whiskerMarkProps) { + return function (d, i) { + var crossBarWidth = whiskerMarkProps.crossBarWidth, + opacityFunctor = whiskerMarkProps.opacityFunctor, + sizeFunctor = whiskerMarkProps.sizeFunctor, + strokeFunctor = whiskerMarkProps.strokeFunctor, + strokeWidth = whiskerMarkProps.strokeWidth, + style = whiskerMarkProps.style, + valueClickHandler = whiskerMarkProps.valueClickHandler, + valueMouseOutHandler = whiskerMarkProps.valueMouseOutHandler, + valueMouseOverHandler = whiskerMarkProps.valueMouseOverHandler, + valueRightClickHandler = whiskerMarkProps.valueRightClickHandler, + xFunctor = whiskerMarkProps.xFunctor, + yFunctor = whiskerMarkProps.yFunctor; + + + var r = sizeFunctor ? sizeFunctor(d) : 0; + var cx = xFunctor(d); + var cy = yFunctor(d); + var positiveXVariance = xFunctor({ x: d.x + d.xVariance / 2 }); + var negativeXVariance = xFunctor({ x: d.x - d.xVariance / 2 }); + var positiveYVariance = yFunctor({ y: d.y + d.yVariance / 2 }); + var negativeYVariance = yFunctor({ y: d.y - d.yVariance / 2 }); + /** + * Determine whether on not we should draw whiskers in each direction. + * We need to see an actual variance value, and also have that value extend past the + * radius "buffer" region in which we won't be drawing (if any). + */ + var hasXWhiskers = positiveXVariance && cx + r < positiveXVariance; + var hasYWhiskers = positiveYVariance && cy - r > positiveYVariance; + if (!hasXWhiskers && !hasYWhiskers) { + return null; + } + + var styleAttr = _extends({ + opacity: opacityFunctor ? opacityFunctor(d) : _theme.DEFAULT_OPACITY, + stroke: strokeFunctor && strokeFunctor(d), + strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH + }, style); + var crossBarExtension = crossBarWidth / 2; + + var rightLineAttrs = { + x1: cx + r, + y1: cy, + x2: positiveXVariance, + y2: cy, + style: styleAttr + }; + var leftLineAttrs = { + x1: cx - r, + y1: cy, + x2: negativeXVariance, + y2: cy, + style: styleAttr + }; + var rightCrossBarAttrs = { + x1: positiveXVariance, + y1: cy - crossBarExtension, + x2: positiveXVariance, + y2: cy + crossBarExtension, + style: styleAttr + }; + var leftCrossBarAttrs = { + x1: negativeXVariance, + y1: cy - crossBarExtension, + x2: negativeXVariance, + y2: cy + crossBarExtension, + style: styleAttr + }; + + var upperLineAttrs = { + x1: cx, + y1: cy - r, + x2: cx, + y2: positiveYVariance, + style: styleAttr + }; + var lowerLineAttrs = { + x1: cx, + y1: cy + r, + x2: cx, + y2: negativeYVariance, + style: styleAttr + }; + var upperCrossBarAttrs = { + x1: cx - crossBarExtension, + y1: positiveYVariance, + x2: cx + crossBarExtension, + y2: positiveYVariance, + style: styleAttr + }; + var lowerCrossBarAttrs = { + x1: cx - crossBarExtension, + y1: negativeYVariance, + x2: cx + crossBarExtension, + y2: negativeYVariance, + style: styleAttr + }; + + return _react2.default.createElement( + 'g', + { + className: 'mark-whiskers', + key: i, + onClick: function onClick(e) { + return valueClickHandler(d, e); + }, + onContextMenu: function onContextMenu(e) { + return valueRightClickHandler(d, e); + }, + onMouseOver: function onMouseOver(e) { + return valueMouseOverHandler(d, e); + }, + onMouseOut: function onMouseOut(e) { + return valueMouseOutHandler(d, e); + } + }, + hasXWhiskers ? _react2.default.createElement( + 'g', + { className: 'x-whiskers' }, + _react2.default.createElement('line', rightLineAttrs), + _react2.default.createElement('line', leftLineAttrs), + _react2.default.createElement('line', rightCrossBarAttrs), + _react2.default.createElement('line', leftCrossBarAttrs) + ) : null, + hasYWhiskers ? _react2.default.createElement( + 'g', + { className: 'y-whiskers' }, + _react2.default.createElement('line', upperLineAttrs), + _react2.default.createElement('line', lowerLineAttrs), + _react2.default.createElement('line', upperCrossBarAttrs), + _react2.default.createElement('line', lowerCrossBarAttrs) + ) : null + ); + }; +}; + +var WhiskerSeries = function (_AbstractSeries) { + _inherits(WhiskerSeries, _AbstractSeries); + + function WhiskerSeries() { + _classCallCheck(this, WhiskerSeries); + + return _possibleConstructorReturn(this, (WhiskerSeries.__proto__ || Object.getPrototypeOf(WhiskerSeries)).apply(this, arguments)); + } + + _createClass(WhiskerSeries, [{ + key: 'render', + value: function render() { + var _props = this.props, + animation = _props.animation, + className = _props.className, + crossBarWidth = _props.crossBarWidth, + data = _props.data, + marginLeft = _props.marginLeft, + marginTop = _props.marginTop, + strokeWidth = _props.strokeWidth, + style = _props.style; + + if (!data) { + return null; + } + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(WhiskerSeries, _extends({}, this.props, { animation: null })) + ); + } + + var whiskerMarkProps = { + crossBarWidth: crossBarWidth, + opacityFunctor: this._getAttributeFunctor('opacity'), + sizeFunctor: this._getAttributeFunctor('size'), + strokeFunctor: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), + strokeWidth: strokeWidth, + style: style, + xFunctor: this._getAttributeFunctor('x'), + yFunctor: this._getAttributeFunctor('y'), + valueClickHandler: this._valueClickHandler, + valueRightClickHandler: this._valueRightClickHandler, + valueMouseOverHandler: this._valueMouseOverHandler, + valueMouseOutHandler: this._valueMouseOutHandler + }; + + return _react2.default.createElement( + 'g', + { + className: predefinedClassName + ' ' + className, + transform: 'translate(' + marginLeft + ',' + marginTop + ')' + }, + data.map(renderWhiskerMark(whiskerMarkProps)) + ); + } + }]); + + return WhiskerSeries; +}(_abstractSeries2.default); + +WhiskerSeries.displayName = 'WhiskerSeries'; +WhiskerSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { + strokeWidth: _propTypes2.default.number +}); +WhiskerSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { + crossBarWidth: DEFAULT_CROSS_BAR_WIDTH, + size: 0, + strokeWidth: DEFAULT_STROKE_WIDTH +}); +exports.default = WhiskerSeries; \ No newline at end of file diff --git a/dist/plot/vertical-grid-lines.js b/dist/plot/vertical-grid-lines.js new file mode 100644 index 000000000..220165193 --- /dev/null +++ b/dist/plot/vertical-grid-lines.js @@ -0,0 +1,64 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _gridLines = require('./grid-lines'); + +var _gridLines2 = _interopRequireDefault(_gridLines); + +var _axisUtils = require('../utils/axis-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var VERTICAL = _axisUtils.DIRECTION.VERTICAL; + + +var propTypes = _extends({}, _gridLines2.default.propTypes, { + direction: _propTypes2.default.oneOf([VERTICAL]) +}); + +var defaultProps = { + direction: VERTICAL, + attr: 'x' +}; + +function VerticalGridLines(props) { + return _react2.default.createElement(_gridLines2.default, props); +} + +VerticalGridLines.displayName = 'VerticalGridLines'; +VerticalGridLines.propTypes = propTypes; +VerticalGridLines.defaultProps = defaultProps; +VerticalGridLines.requiresSVG = true; + +exports.default = VerticalGridLines; \ No newline at end of file diff --git a/dist/plot/voronoi.js b/dist/plot/voronoi.js new file mode 100644 index 000000000..45517bb4f --- /dev/null +++ b/dist/plot/voronoi.js @@ -0,0 +1,148 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Voronoi = require('d3-voronoi'); + +var _scalesUtils = require('../utils/scales-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var NOOP = function NOOP(f) { + return f; +}; + +// Find the index of the node at coordinates of a touch point +function getNodeIndex(evt) { + var _evt$nativeEvent = evt.nativeEvent, + pageX = _evt$nativeEvent.pageX, + pageY = _evt$nativeEvent.pageY; + + var target = document.elementFromPoint(pageX, pageY); + if (!target) { + return -1; + } + var parentNode = target.parentNode; + + return Array.prototype.indexOf.call(parentNode.childNodes, target); +} + +function getExtent(_ref) { + var innerWidth = _ref.innerWidth, + innerHeight = _ref.innerHeight, + marginLeft = _ref.marginLeft, + marginTop = _ref.marginTop; + + return [[marginLeft, marginTop], [innerWidth + marginLeft, innerHeight + marginTop]]; +} + +function Voronoi(props) { + var className = props.className, + extent = props.extent, + nodes = props.nodes, + onBlur = props.onBlur, + _onClick = props.onClick, + _onMouseUp = props.onMouseUp, + _onMouseDown = props.onMouseDown, + onHover = props.onHover, + polygonStyle = props.polygonStyle, + style = props.style, + x = props.x, + y = props.y; + // Create a voronoi with each node center points + + var voronoiInstance = (0, _d3Voronoi.voronoi)().x(x || (0, _scalesUtils.getAttributeFunctor)(props, 'x')).y(y || (0, _scalesUtils.getAttributeFunctor)(props, 'y')).extent(extent || getExtent(props)); + + // Create an array of polygons corresponding to the cells in voronoi + var polygons = voronoiInstance.polygons(nodes); + + // Create helper function to handle special logic for touch events + var handleTouchEvent = function handleTouchEvent(handler) { + return function (evt) { + evt.preventDefault(); + var index = getNodeIndex(evt); + if (index > -1 && index < polygons.length) { + var d = polygons[index]; + handler(d.data); + } + }; + }; + + return _react2.default.createElement( + 'g', + { + className: className + ' rv-voronoi', + style: style + // Because of the nature of how touch events, and more specifically touchmove + // and how it differs from mouseover, we must manage touch events on the parent + , onTouchEnd: handleTouchEvent(_onMouseUp), + onTouchStart: handleTouchEvent(_onMouseDown), + onTouchMove: handleTouchEvent(onHover), + onTouchCancel: handleTouchEvent(onBlur) + }, + polygons.map(function (d, i) { + return _react2.default.createElement('path', { + className: 'rv-voronoi__cell ' + (d.data && d.data.className || ''), + d: 'M' + d.join('L') + 'Z', + onClick: function onClick() { + return _onClick(d.data); + }, + onMouseUp: function onMouseUp() { + return _onMouseUp(d.data); + }, + onMouseDown: function onMouseDown() { + return _onMouseDown(d.data); + }, + onMouseOver: function onMouseOver() { + return onHover(d.data); + }, + onMouseOut: function onMouseOut() { + return onBlur(d.data); + }, + fill: 'none', + style: _extends({ + pointerEvents: 'all' + }, polygonStyle, d.data && d.data.style), + key: i + }); + }) + ); +} + +Voronoi.requiresSVG = true; +Voronoi.displayName = 'Voronoi'; +Voronoi.defaultProps = { + className: '', + onBlur: NOOP, + onClick: NOOP, + onHover: NOOP, + onMouseDown: NOOP, + onMouseUp: NOOP +}; + +Voronoi.propTypes = { + className: _propTypes2.default.string, + extent: _propTypes2.default.arrayOf(_propTypes2.default.arrayOf(_propTypes2.default.number)), + nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + onBlur: _propTypes2.default.func, + onClick: _propTypes2.default.func, + onHover: _propTypes2.default.func, + onMouseDown: _propTypes2.default.func, + onMouseUp: _propTypes2.default.func, + x: _propTypes2.default.func, + y: _propTypes2.default.func +}; + +exports.default = Voronoi; \ No newline at end of file diff --git a/dist/plot/xy-plot.js b/dist/plot/xy-plot.js new file mode 100644 index 000000000..5d5eec470 --- /dev/null +++ b/dist/plot/xy-plot.js @@ -0,0 +1,660 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _deepEqual = require('deep-equal'); + +var _deepEqual2 = _interopRequireDefault(_deepEqual); + +var _scalesUtils = require('../utils/scales-utils'); + +var _seriesUtils = require('../utils/series-utils'); + +var _chartUtils = require('../utils/chart-utils'); + +var _animation = require('../animation'); + +var _theme = require('../theme'); + +var _canvasWrapper = require('./series/canvas-wrapper'); + +var _canvasWrapper2 = _interopRequireDefault(_canvasWrapper); + +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 _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; } + +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; } + +var ATTRIBUTES = ['x', 'y', 'radius', 'angle', 'color', 'fill', 'stroke', 'opacity', 'size']; + +/** + * Remove parents from tree formatted data. deep-equal doesnt play nice with data + * that has circular structures, so we make every node single directional by pruning the parents. + * @param {Array} data - the data object to have circular deps resolved in + * @returns {Array} the sanitized data + */ +function cleanseData(data) { + return data.map(function (series) { + if (!Array.isArray(series)) { + return series; + } + return series.map(function (row) { + return _extends({}, row, { parent: null }); + }); + }); +} + +/** + * Wrapper on the deep-equal method for checking equality of next props vs current props + * @param {Object} scaleMixins - Scale object. + * @param {Object} nextScaleMixins - Scale object. + * @param {Boolean} hasTreeStructure - Whether or not to cleanse the data of possible cyclic structures + * @returns {Boolean} whether or not the two mixins objects are equal + */ +function checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, hasTreeStructure) { + var newMixins = _extends({}, nextScaleMixins, { + _allData: hasTreeStructure ? cleanseData(nextScaleMixins._allData) : nextScaleMixins._allData + }); + var oldMixins = _extends({}, scaleMixins, { + _allData: hasTreeStructure ? cleanseData(scaleMixins._allData) : scaleMixins._allData + }); + // it's hard to say if this function is reasonable? + return (0, _deepEqual2.default)(newMixins, oldMixins); +} + +var XYPlot = function (_React$Component) { + _inherits(XYPlot, _React$Component); + + _createClass(XYPlot, null, [{ + key: 'defaultProps', + get: function get() { + return { + className: '' + }; + } + }, { + key: 'propTypes', + get: function get() { + return { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + dontCheckIfEmpty: _propTypes2.default.bool, + height: _propTypes2.default.number.isRequired, + margin: _chartUtils.MarginPropType, + onClick: _propTypes2.default.func, + onDoubleClick: _propTypes2.default.func, + onMouseDown: _propTypes2.default.func, + onMouseUp: _propTypes2.default.func, + onMouseEnter: _propTypes2.default.func, + onMouseLeave: _propTypes2.default.func, + onMouseMove: _propTypes2.default.func, + onTouchStart: _propTypes2.default.func, + onTouchMove: _propTypes2.default.func, + onTouchEnd: _propTypes2.default.func, + onTouchCancel: _propTypes2.default.func, + onWheel: _propTypes2.default.func, + stackBy: _propTypes2.default.oneOf(ATTRIBUTES), + style: _propTypes2.default.object, + width: _propTypes2.default.number.isRequired + }; + } + }]); + + function XYPlot(props) { + _classCallCheck(this, XYPlot); + + var _this = _possibleConstructorReturn(this, (XYPlot.__proto__ || Object.getPrototypeOf(XYPlot)).call(this, props)); + + _initialiseProps.call(_this); + + var stackBy = props.stackBy; + + var children = (0, _seriesUtils.getSeriesChildren)(props.children); + var data = (0, _seriesUtils.getStackedData)(children, stackBy); + _this.state = { + scaleMixins: _this._getScaleMixins(data, props), + data: data + }; + return _this; + } + + _createClass(XYPlot, [{ + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + var children = (0, _seriesUtils.getSeriesChildren)(nextProps.children); + var nextData = (0, _seriesUtils.getStackedData)(children, nextProps.stackBy); + var scaleMixins = this.state.scaleMixins; + + var nextScaleMixins = this._getScaleMixins(nextData, nextProps); + if (!checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, nextProps.hasTreeStructure)) { + this.setState({ + scaleMixins: nextScaleMixins, + data: nextData + }); + } + } + + /** + * Trigger click related callbacks if they are available. + * @param {React.SyntheticEvent} event Click event. + * @private + */ + + + /** + * Trigger doule-click related callbacks if they are available. + * @param {React.SyntheticEvent} event Double-click event. + * @private + */ + + }, { + key: '_getClonedChildComponents', + + + /** + * Prepare the child components (including series) for rendering. + * @returns {Array} Array of child components. + * @private + */ + value: function _getClonedChildComponents() { + var _this2 = this; + + var props = this.props; + var animation = this.props.animation; + var _state = this.state, + scaleMixins = _state.scaleMixins, + data = _state.data; + + var dimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS); + var children = _react2.default.Children.toArray(this.props.children); + var seriesProps = (0, _seriesUtils.getSeriesPropsFromChildren)(children); + var XYPlotValues = (0, _scalesUtils.getXYPlotValues)(props, children); + return children.map(function (child, index) { + var dataProps = null; + if (seriesProps[index]) { + // Get the index of the series in the list of props and retrieve + // the data property from it. + var seriesIndex = seriesProps[index].seriesIndex; + + dataProps = { data: data[seriesIndex] }; + } + return _react2.default.cloneElement(child, _extends({}, dimensions, { + animation: animation + }, dataProps && child.type.prototype && child.type.prototype.render ? { + ref: function ref(_ref) { + return _this2['series' + seriesProps[index].seriesIndex] = _ref; + } + } : {}, seriesProps[index], scaleMixins, child.props, XYPlotValues[index], dataProps)); + }); + } + /** + * Get the list of scale-related settings that should be applied by default. + * @param {Object} props Object of props. + * @returns {Object} Defaults. + * @private + */ + + }, { + key: '_getDefaultScaleProps', + value: function _getDefaultScaleProps(props) { + var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(props, _chartUtils.DEFAULT_MARGINS), + innerWidth = _getInnerDimensions.innerWidth, + innerHeight = _getInnerDimensions.innerHeight; + + var colorRanges = ['color', 'fill', 'stroke'].reduce(function (acc, attr) { + var range = props[attr + 'Type'] === 'category' ? _theme.EXTENDED_DISCRETE_COLOR_RANGE : _theme.CONTINUOUS_COLOR_RANGE; + return _extends({}, acc, _defineProperty({}, attr + 'Range', range)); + }, {}); + + return _extends({ + xRange: [0, innerWidth], + yRange: [innerHeight, 0] + }, colorRanges, { + opacityType: _theme.OPACITY_TYPE, + sizeRange: _theme.SIZE_RANGE + }); + } + + /** + * Get the map of scales from the props, apply defaults to them and then pass + * them further. + * @param {Object} data Array of all data. + * @param {Object} props Props of the component. + * @returns {Object} Map of scale-related props. + * @private + */ + + }, { + key: '_getScaleMixins', + value: function _getScaleMixins(data, props) { + var _ref2; + + var filteredData = data.filter(function (d) { + return d; + }); + var allData = (_ref2 = []).concat.apply(_ref2, _toConsumableArray(filteredData)); + + var defaultScaleProps = this._getDefaultScaleProps(props); + var optionalScaleProps = (0, _scalesUtils.getOptionalScaleProps)(props); + var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); + var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, optionalScaleProps, userScaleProps), allData, ATTRIBUTES); + var children = (0, _seriesUtils.getSeriesChildren)(props.children); + var zeroBaseProps = {}; + var adjustBy = new Set(); + var adjustWhat = new Set(); + children.forEach(function (child, index) { + if (!child || !data[index]) { + return; + } + ATTRIBUTES.forEach(function (attr) { + var _child$type$getParent = child.type.getParentConfig(attr, child.props), + isDomainAdjustmentNeeded = _child$type$getParent.isDomainAdjustmentNeeded, + zeroBaseValue = _child$type$getParent.zeroBaseValue; + + if (isDomainAdjustmentNeeded) { + adjustBy.add(attr); + adjustWhat.add(index); + } + if (zeroBaseValue) { + var specifiedDomain = props[attr + 'Domain']; + zeroBaseProps[attr + 'BaseValue'] = specifiedDomain ? specifiedDomain[0] : 0; + } + }); + }); + return _extends({}, defaultScaleProps, zeroBaseProps, userScaleProps, missingScaleProps, { + _allData: data, + _adjustBy: Array.from(adjustBy), + _adjustWhat: Array.from(adjustWhat), + _stackBy: props.stackBy + }); + } + + /** + * Checks if the plot is empty or not. + * Currently checks the data only. + * @returns {boolean} True for empty. + * @private + */ + + }, { + key: '_isPlotEmpty', + value: function _isPlotEmpty() { + var data = this.state.data; + + return !data || !data.length || !data.some(function (series) { + return series && series.some(function (d) { + return d; + }); + }); + } + + /** + * Trigger mouse-down related callbacks if they are available. + * @param {React.SyntheticEvent} event Mouse down event. + * @private + */ + + + /** + * Trigger onMouseEnter handler if it was passed in props. + * @param {React.SyntheticEvent} event Mouse enter event. + * @private + */ + + + /** + * Trigger onMouseLeave handler if it was passed in props. + * @param {React.SyntheticEvent} event Mouse leave event. + * @private + */ + + + /** + * Trigger movement-related callbacks if they are available. + * @param {React.SyntheticEvent} event Mouse move event. + * @private + */ + + + /** + * Trigger mouse-up related callbacks if they are available. + * @param {React.SyntheticEvent} event Mouse up event. + * @private + */ + + + /** + * Trigger onTouchCancel handler if it was passed in props. + * @param {React.SyntheticEvent} event Touch Cancel event. + * @private + */ + + + /** + * Trigger onTouchEnd handler if it was passed in props. + * @param {React.SyntheticEvent} event Touch End event. + * @private + */ + + + /** + * Trigger touch movement-related callbacks if they are available. + * @param {React.SyntheticEvent} event Touch move event. + * @private + */ + + + /** + * Trigger touch-start related callbacks if they are available. + * @param {React.SyntheticEvent} event Touch start event. + * @private + */ + + + /** + * Trigger doule-click related callbacks if they are available. + * @param {React.SyntheticEvent} event Double-click event. + * @private + */ + + }, { + key: 'renderCanvasComponents', + value: function renderCanvasComponents(components, props) { + var componentsToRender = components.filter(function (c) { + return c && !c.type.requiresSVG && c.type.isCanvas; + }); + + if (componentsToRender.length === 0) { + return null; + } + var _componentsToRender$ = componentsToRender[0].props, + marginLeft = _componentsToRender$.marginLeft, + marginTop = _componentsToRender$.marginTop, + marginBottom = _componentsToRender$.marginBottom, + marginRight = _componentsToRender$.marginRight, + innerHeight = _componentsToRender$.innerHeight, + innerWidth = _componentsToRender$.innerWidth; + + return _react2.default.createElement( + _canvasWrapper2.default, + { + innerHeight: innerHeight, + innerWidth: innerWidth, + marginLeft: marginLeft, + marginTop: marginTop, + marginBottom: marginBottom, + marginRight: marginRight + }, + componentsToRender + ); + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + className = _props.className, + dontCheckIfEmpty = _props.dontCheckIfEmpty, + style = _props.style, + width = _props.width, + height = _props.height; + + + if (!dontCheckIfEmpty && this._isPlotEmpty()) { + return _react2.default.createElement('div', { + className: 'rv-xy-plot ' + className, + style: _extends({ + width: width + 'px', + height: height + 'px' + }, this.props.style) + }); + } + var components = this._getClonedChildComponents(); + return _react2.default.createElement( + 'div', + { + style: { + width: width + 'px', + height: height + 'px' + }, + className: 'rv-xy-plot ' + className + }, + _react2.default.createElement( + 'svg', + { + className: 'rv-xy-plot__inner', + width: width, + height: height, + style: style, + onClick: this._clickHandler, + onDoubleClick: this._doubleClickHandler, + onMouseDown: this._mouseDownHandler, + onMouseUp: this._mouseUpHandler, + onMouseMove: this._mouseMoveHandler, + onMouseLeave: this._mouseLeaveHandler, + onMouseEnter: this._mouseEnterHandler, + onTouchStart: this._mouseDownHandler, + onTouchMove: this._touchMoveHandler, + onTouchEnd: this._touchEndHandler, + onTouchCancel: this._touchCancelHandler, + onWheel: this._wheelHandler + }, + components.filter(function (c) { + return c && c.type.requiresSVG; + }) + ), + this.renderCanvasComponents(components, this.props), + components.filter(function (c) { + return c && !c.type.requiresSVG && !c.type.isCanvas; + }) + ); + } + }]); + + return XYPlot; +}(_react2.default.Component); + +var _initialiseProps = function _initialiseProps() { + var _this3 = this; + + this._clickHandler = function (event) { + var onClick = _this3.props.onClick; + + if (onClick) { + onClick(event); + } + }; + + this._doubleClickHandler = function (event) { + var onDoubleClick = _this3.props.onDoubleClick; + + if (onDoubleClick) { + onDoubleClick(event); + } + }; + + this._mouseDownHandler = function (event) { + var _props2 = _this3.props, + onMouseDown = _props2.onMouseDown, + children = _props2.children; + + if (onMouseDown) { + onMouseDown(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseDown) { + component.onParentMouseDown(event); + } + }); + }; + + this._mouseEnterHandler = function (event) { + var _props3 = _this3.props, + onMouseEnter = _props3.onMouseEnter, + children = _props3.children; + + if (onMouseEnter) { + onMouseEnter(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseEnter) { + component.onParentMouseEnter(event); + } + }); + }; + + this._mouseLeaveHandler = function (event) { + var _props4 = _this3.props, + onMouseLeave = _props4.onMouseLeave, + children = _props4.children; + + if (onMouseLeave) { + onMouseLeave(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseLeave) { + component.onParentMouseLeave(event); + } + }); + }; + + this._mouseMoveHandler = function (event) { + var _props5 = _this3.props, + onMouseMove = _props5.onMouseMove, + children = _props5.children; + + if (onMouseMove) { + onMouseMove(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseMove) { + component.onParentMouseMove(event); + } + }); + }; + + this._mouseUpHandler = function (event) { + var _props6 = _this3.props, + onMouseUp = _props6.onMouseUp, + children = _props6.children; + + if (onMouseUp) { + onMouseUp(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentMouseUp) { + component.onParentMouseUp(event); + } + }); + }; + + this._touchCancelHandler = function (event) { + var onTouchCancel = _this3.props.onTouchCancel; + + if (onTouchCancel) { + onTouchCancel(event); + } + }; + + this._touchEndHandler = function (event) { + var onTouchEnd = _this3.props.onTouchEnd; + + if (onTouchEnd) { + onTouchEnd(event); + } + }; + + this._touchMoveHandler = function (event) { + var _props7 = _this3.props, + onTouchMove = _props7.onTouchMove, + children = _props7.children; + + if (onTouchMove) { + onTouchMove(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentTouchMove) { + component.onParentTouchMove(event); + } + }); + }; + + this._touchStartHandler = function (event) { + var _props8 = _this3.props, + onTouchStart = _props8.onTouchStart, + children = _props8.children; + + if (onTouchStart) { + onTouchStart(event); + } + var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); + seriesChildren.forEach(function (child, index) { + var component = _this3['series' + index]; + if (component && component.onParentTouchStart) { + component.onParentTouchStart(event); + } + }); + }; + + this._wheelHandler = function (event) { + var onWheel = _this3.props.onWheel; + + if (onWheel) { + onWheel(event); + } + }; +}; + +XYPlot.displayName = 'XYPlot'; + +exports.default = XYPlot; \ No newline at end of file diff --git a/dist/radar-chart/index.js b/dist/radar-chart/index.js new file mode 100644 index 000000000..b1f659dfd --- /dev/null +++ b/dist/radar-chart/index.js @@ -0,0 +1,418 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Scale = require('d3-scale'); + +var _d3Format = require('d3-format'); + +var _animation = require('../animation'); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _theme = require('../theme'); + +var _chartUtils = require('../utils/chart-utils'); + +var _markSeries = require('../plot/series/mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +var _polygonSeries = require('../plot/series/polygon-series'); + +var _polygonSeries2 = _interopRequireDefault(_polygonSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _decorativeAxis = require('../plot/axis/decorative-axis'); + +var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var predefinedClassName = 'rv-radar-chart'; +var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); +/** + * Generate axes for each of the domains + * @param {Object} props + - props.animation {Boolean} + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.style {object} style object for the whole chart + - props.tickFormat {Function} formatting function for axes + - props.startingAngle {number} the initial angle offset + * @return {Array} the plotted axis components + */ +function getAxes(props) { + var animation = props.animation, + domains = props.domains, + startingAngle = props.startingAngle, + style = props.style, + tickFormat = props.tickFormat, + hideInnerMostValues = props.hideInnerMostValues; + + return domains.map(function (domain, index) { + var angle = index / domains.length * Math.PI * 2 + startingAngle; + var sortedDomain = domain.domain; + + var domainTickFormat = function domainTickFormat(t) { + if (hideInnerMostValues && t === sortedDomain[0]) { + return ''; + } + return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); + }; + + return _react2.default.createElement(_decorativeAxis2.default, { + animation: animation, + key: index + '-axis', + axisStart: { x: 0, y: 0 }, + axisEnd: { + x: getCoordinate(Math.cos(angle)), + y: getCoordinate(Math.sin(angle)) + }, + axisDomain: sortedDomain, + numberOfTicks: 5, + tickValue: domainTickFormat, + style: style.axes + }); + }); +} + +/** + * Generate x or y coordinate for axisEnd + * @param {Number} axisEndPoint + - epsilon is an arbitrarily chosen small number to approximate axisEndPoints + - to true values resulting from trigonometry functions (sin, cos) on angles + * @return {Number} the x or y coordinate accounting for exact trig values + */ +function getCoordinate(axisEndPoint) { + var epsilon = 10e-13; + if (Math.abs(axisEndPoint) <= epsilon) { + axisEndPoint = 0; + } else if (axisEndPoint > 0) { + if (Math.abs(axisEndPoint - 0.5) <= epsilon) { + axisEndPoint = 0.5; + } + } else if (axisEndPoint < 0) { + if (Math.abs(axisEndPoint + 0.5) <= epsilon) { + axisEndPoint = -0.5; + } + } + return axisEndPoint; +} + +/** + * Generate labels for the ends of the axes + * @param {Object} props + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.startingAngle {number} the initial angle offset + - props.style {object} style object for just the labels + * @return {Array} the prepped data for the labelSeries + */ +function getLabels(props) { + var domains = props.domains, + startingAngle = props.startingAngle, + style = props.style; + + return domains.map(function (_ref, index) { + var name = _ref.name; + + var angle = index / domains.length * Math.PI * 2 + startingAngle; + var radius = 1.2; + return { + x: radius * Math.cos(angle), + y: radius * Math.sin(angle), + label: name, + style: style + }; + }); +} + +/** + * Generate the actual polygons to be plotted + * @param {Object} props + - props.animation {Boolean} + - props.data {Array} array of object specifying what values are to be plotted + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.startingAngle {number} the initial angle offset + - props.style {object} style object for the whole chart + * @return {Array} the plotted axis components + */ +function getPolygons(props) { + var animation = props.animation, + colorRange = props.colorRange, + domains = props.domains, + data = props.data, + style = props.style, + startingAngle = props.startingAngle, + onSeriesMouseOver = props.onSeriesMouseOver, + onSeriesMouseOut = props.onSeriesMouseOut; + + var scales = domains.reduce(function (acc, _ref2) { + var domain = _ref2.domain, + name = _ref2.name; + + acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); + return acc; + }, {}); + + return data.map(function (row, rowIndex) { + var mappedData = domains.map(function (_ref3, index) { + var name = _ref3.name, + getValue = _ref3.getValue; + + var dataPoint = getValue ? getValue(row) : row[name]; + // error handling if point doesn't exist + var angle = index / domains.length * Math.PI * 2 + startingAngle; + // dont let the radius become negative + var radius = Math.max(scales[name](dataPoint), 0); + return { x: radius * Math.cos(angle), y: radius * Math.sin(angle), name: row.name }; + }); + + return _react2.default.createElement(_polygonSeries2.default, { + animation: animation, + className: predefinedClassName + '-polygon', + key: rowIndex + '-polygon', + data: mappedData, + style: _extends({ + stroke: row.color || row.stroke || colorRange[rowIndex % colorRange.length], + fill: row.color || row.fill || colorRange[rowIndex % colorRange.length] + }, style.polygons), + onSeriesMouseOver: onSeriesMouseOver, + onSeriesMouseOut: onSeriesMouseOut + }); + }); +} + +/** + * Generate circles at the polygon points for Hover functionality + * @param {Object} props + - props.animation {Boolean} + - props.data {Array} array of object specifying what values are to be plotted + - props.domains {Array} array of object specifying the way each axis is to be plotted + - props.startingAngle {number} the initial angle offset + - props.style {object} style object for the whole chart + - props.onValueMouseOver {function} function to call on mouse over a polygon point + - props.onValueMouseOver {function} function to call when mouse leaves a polygon point + * @return {Array} the plotted axis components + */ +function getPolygonPoints(props) { + var animation = props.animation, + domains = props.domains, + data = props.data, + startingAngle = props.startingAngle, + style = props.style, + onValueMouseOver = props.onValueMouseOver, + onValueMouseOut = props.onValueMouseOut; + + if (!onValueMouseOver) { + return; + } + var scales = domains.reduce(function (acc, _ref4) { + var domain = _ref4.domain, + name = _ref4.name; + + acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); + return acc; + }, {}); + return data.map(function (row, rowIndex) { + var mappedData = domains.map(function (_ref5, index) { + var name = _ref5.name, + getValue = _ref5.getValue; + + var dataPoint = getValue ? getValue(row) : row[name]; + // error handling if point doesn't exist + var angle = index / domains.length * Math.PI * 2 + startingAngle; + // dont let the radius become negative + var radius = Math.max(scales[name](dataPoint), 0); + return { + x: radius * Math.cos(angle), + y: radius * Math.sin(angle), + domain: name, + value: dataPoint, + dataName: row.name + }; + }); + + return _react2.default.createElement(_markSeries2.default, { + animation: animation, + className: predefinedClassName + '-polygonPoint', + key: rowIndex + '-polygonPoint', + data: mappedData, + size: 10, + style: _extends({}, style.polygons, { + fill: 'transparent', + stroke: 'transparent' + }), + onValueMouseOver: onValueMouseOver, + onValueMouseOut: onValueMouseOut + }); + }); +} + +function RadarChart(props) { + var animation = props.animation, + className = props.className, + children = props.children, + colorRange = props.colorRange, + data = props.data, + domains = props.domains, + height = props.height, + hideInnerMostValues = props.hideInnerMostValues, + margin = props.margin, + onMouseLeave = props.onMouseLeave, + onMouseEnter = props.onMouseEnter, + startingAngle = props.startingAngle, + style = props.style, + tickFormat = props.tickFormat, + width = props.width, + renderAxesOverPolygons = props.renderAxesOverPolygons, + onValueMouseOver = props.onValueMouseOver, + onValueMouseOut = props.onValueMouseOut, + onSeriesMouseOver = props.onSeriesMouseOver, + onSeriesMouseOut = props.onSeriesMouseOut; + + + var axes = getAxes({ + domains: domains, + animation: animation, + hideInnerMostValues: hideInnerMostValues, + startingAngle: startingAngle, + style: style, + tickFormat: tickFormat + }); + + var polygons = getPolygons({ + animation: animation, + colorRange: colorRange, + domains: domains, + data: data, + startingAngle: startingAngle, + style: style, + onSeriesMouseOver: onSeriesMouseOver, + onSeriesMouseOut: onSeriesMouseOut + }); + + var polygonPoints = getPolygonPoints({ + animation: animation, + colorRange: colorRange, + domains: domains, + data: data, + startingAngle: startingAngle, + style: style, + onValueMouseOver: onValueMouseOver, + onValueMouseOut: onValueMouseOut + }); + + var labelSeries = _react2.default.createElement(_labelSeries2.default, { + animation: animation, + key: className, + className: predefinedClassName + '-label', + data: getLabels({ domains: domains, style: style.labels, startingAngle: startingAngle }) }); + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + width: width, + margin: margin, + dontCheckIfEmpty: true, + className: className + ' ' + predefinedClassName, + onMouseLeave: onMouseLeave, + onMouseEnter: onMouseEnter, + xDomain: [-1, 1], + yDomain: [-1, 1] }, + children, + !renderAxesOverPolygons && axes.concat(polygons).concat(labelSeries).concat(polygonPoints), + renderAxesOverPolygons && polygons.concat(labelSeries).concat(axes).concat(polygonPoints) + ); +} + +RadarChart.displayName = 'RadarChart'; +RadarChart.propTypes = { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), + data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + name: _propTypes2.default.string.isRequired, + domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, + tickFormat: _propTypes2.default.func + })).isRequired, + height: _propTypes2.default.number.isRequired, + hideInnerMostValues: _propTypes2.default.bool, + margin: _chartUtils.MarginPropType, + startingAngle: _propTypes2.default.number, + style: _propTypes2.default.shape({ + axes: _propTypes2.default.object, + labels: _propTypes2.default.object, + polygons: _propTypes2.default.object + }), + tickFormat: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired, + renderAxesOverPolygons: _propTypes2.default.bool, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + onSeriesMouseOver: _propTypes2.default.func, + onSeriesMouseOut: _propTypes2.default.func +}; +RadarChart.defaultProps = { + className: '', + colorType: 'category', + colorRange: _theme.DISCRETE_COLOR_RANGE, + hideInnerMostValues: true, + startingAngle: Math.PI / 2, + style: { + axes: { + line: {}, + ticks: {}, + text: {} + }, + labels: { + fontSize: 10, + textAnchor: 'middle' + }, + polygons: { + strokeWidth: 0.5, + strokeOpacity: 1, + fillOpacity: 0.1 + } + }, + tickFormat: DEFAULT_FORMAT, + renderAxesOverPolygons: false +}; + +exports.default = RadarChart; \ No newline at end of file diff --git a/dist/radial-chart/index.js b/dist/radial-chart/index.js new file mode 100644 index 000000000..a43e58552 --- /dev/null +++ b/dist/radial-chart/index.js @@ -0,0 +1,263 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Shape = require('d3-shape'); + +var _animation = require('../animation'); + +var _arcSeries = require('../plot/series/arc-series'); + +var _arcSeries2 = _interopRequireDefault(_arcSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _theme = require('../theme'); + +var _chartUtils = require('../utils/chart-utils'); + +var _seriesUtils = require('../utils/series-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var predefinedClassName = 'rv-radial-chart'; + +var DEFAULT_RADIUS_MARGIN = 15; + +/** + * Create the list of wedges to render. + * @param {Object} props + props.data {Object} - tree structured data (each node has a name anc an array of children) + * @returns {Array} Array of nodes. + */ +function getWedgesToRender(_ref) { + var data = _ref.data, + getAngle = _ref.getAngle; + + var pie = (0, _d3Shape.pie)().sort(null).value(getAngle); + var pieData = pie(data).reverse(); + return pieData.map(function (row, index) { + return _extends({}, row.data, { + angle0: row.startAngle, + angle: row.endAngle, + radius0: row.data.innerRadius || 0, + radius: row.data.radius || 1, + color: row.data.color || index + }); + }); +} + +function generateLabels(mappedData, accessors) { + var labelsRadiusMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.1; + var getLabel = accessors.getLabel, + getSubLabel = accessors.getSubLabel; + + return mappedData.reduce(function (res, row) { + var angle = row.angle, + angle0 = row.angle0, + radius = row.radius; + + var centeredAngle = (angle + angle0) / 2; + + // unfortunate, but true fact: d3 starts its radians at 12 oclock rather than 3 + // and move clockwise rather than counter clockwise. why why why! + var updatedAngle = -1 * centeredAngle + Math.PI / 2; + var newLabels = []; + if (getLabel(row)) { + newLabels.push({ + angle: updatedAngle, + radius: radius * labelsRadiusMultiplier, + label: getLabel(row) + }); + } + + if (getSubLabel(row)) { + newLabels.push({ + angle: updatedAngle, + radius: radius * labelsRadiusMultiplier, + label: getSubLabel(row), + style: { fontSize: 10 }, + yOffset: 12 + }); + } + return res.concat(newLabels); + }, []); + // could add force direction here to make sure the labels dont overlap +} + +/** + * Get the max radius so the chart can extend to the margin. + * @param {Number} width - container width + * @param {Number} height - container height + * @return {Number} radius + */ +function getMaxRadius(width, height) { + return Math.min(width, height) / 2 - DEFAULT_RADIUS_MARGIN; +} + +function RadialChart(props) { + var animation = props.animation, + className = props.className, + children = props.children, + colorType = props.colorType, + data = props.data, + getAngle = props.getAngle, + getLabel = props.getLabel, + getSubLabel = props.getSubLabel, + height = props.height, + hideRootNode = props.hideRootNode, + innerRadius = props.innerRadius, + labelsAboveChildren = props.labelsAboveChildren, + labelsRadiusMultiplier = props.labelsRadiusMultiplier, + labelsStyle = props.labelsStyle, + margin = props.margin, + onMouseLeave = props.onMouseLeave, + onMouseEnter = props.onMouseEnter, + radius = props.radius, + showLabels = props.showLabels, + style = props.style, + width = props.width; + + var mappedData = getWedgesToRender({ + data: data, + height: height, + hideRootNode: hideRootNode, + width: width, + getAngle: getAngle + }); + var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); + var arcProps = _extends({ + colorType: colorType + }, props, { + animation: animation, + radiusDomain: [0, radialDomain], + data: mappedData, + radiusNoFallBack: true, + style: style, + arcClassName: 'rv-radial-chart__series--pie__slice' + }); + if (radius) { + arcProps.radiusDomain = [0, 1]; + arcProps.radiusRange = [innerRadius || 0, radius]; + arcProps.radiusType = 'linear'; + } + var maxRadius = radius ? radius : getMaxRadius(width, height); + var defaultMargin = (0, _chartUtils.getRadialLayoutMargin)(width, height, maxRadius); + + var labels = generateLabels(mappedData, { + getLabel: getLabel, + getSubLabel: getSubLabel + }, labelsRadiusMultiplier); + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + width: width, + margin: _extends({}, margin, defaultMargin), + className: className + ' ' + predefinedClassName, + onMouseLeave: onMouseLeave, + onMouseEnter: onMouseEnter, + xDomain: [-radialDomain, radialDomain], + yDomain: [-radialDomain, radialDomain] + }, + _react2.default.createElement(_arcSeries2.default, _extends({}, arcProps, { getAngle: function getAngle(d) { + return d.angle; + } })), + showLabels && !labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }), + children, + showLabels && labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }) + ); +} + +RadialChart.displayName = 'RadialChart'; +RadialChart.propTypes = { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + angle: _propTypes2.default.number, + className: _propTypes2.default.string, + label: _propTypes2.default.string, + radius: _propTypes2.default.number, + style: _propTypes2.default.object + })).isRequired, + getAngle: _propTypes2.default.func, + getAngle0: _propTypes2.default.func, + padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]), + getRadius: _propTypes2.default.func, + getRadius0: _propTypes2.default.func, + getLabel: _propTypes2.default.func, + height: _propTypes2.default.number.isRequired, + labelsAboveChildren: _propTypes2.default.bool, + labelsStyle: _propTypes2.default.object, + margin: _chartUtils.MarginPropType, + onValueClick: _propTypes2.default.func, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + showLabels: _propTypes2.default.bool, + style: _propTypes2.default.object, + subLabel: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired +}; +RadialChart.defaultProps = { + className: '', + colorType: 'category', + colorRange: _theme.DISCRETE_COLOR_RANGE, + padAngle: 0, + getAngle: function getAngle(d) { + return d.angle; + }, + getAngle0: function getAngle0(d) { + return d.angle0; + }, + getRadius: function getRadius(d) { + return d.radius; + }, + getRadius0: function getRadius0(d) { + return d.radius0; + }, + getLabel: function getLabel(d) { + return d.label; + }, + getSubLabel: function getSubLabel(d) { + return d.subLabel; + } +}; + +exports.default = RadialChart; \ No newline at end of file diff --git a/dist/sankey/index.js b/dist/sankey/index.js new file mode 100644 index 000000000..55b694d88 --- /dev/null +++ b/dist/sankey/index.js @@ -0,0 +1,238 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Sankey = require('d3-sankey'); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _chartUtils = require('../utils/chart-utils'); + +var _verticalRectSeries = require('../plot/series/vertical-rect-series'); + +var _verticalRectSeries2 = _interopRequireDefault(_verticalRectSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _voronoi = require('../plot/voronoi'); + +var _voronoi2 = _interopRequireDefault(_voronoi); + +var _theme = require('../theme'); + +var _sankeyLink = require('./sankey-link'); + +var _sankeyLink2 = _interopRequireDefault(_sankeyLink); + +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); } } + +var NOOP = function NOOP(f) { + return f; +}; + +var ALIGNMENTS = { + justify: _d3Sankey.sankeyJustify, + center: _d3Sankey.sankeyCenter, + left: _d3Sankey.sankeyLeft, + right: _d3Sankey.sankeyRight +}; + +var DEFAULT_MARGINS = { + top: 20, + left: 20, + right: 20, + bottom: 20 +}; + +function Sankey(props) { + var align = props.align, + animation = props.animation, + children = props.children, + className = props.className, + hasVoronoi = props.hasVoronoi, + height = props.height, + hideLabels = props.hideLabels, + labelRotation = props.labelRotation, + layout = props.layout, + links = props.links, + linkOpacity = props.linkOpacity, + margin = props.margin, + nodePadding = props.nodePadding, + nodes = props.nodes, + nodeWidth = props.nodeWidth, + onValueClick = props.onValueClick, + onValueMouseOver = props.onValueMouseOver, + onValueMouseOut = props.onValueMouseOut, + onLinkClick = props.onLinkClick, + onLinkMouseOver = props.onLinkMouseOver, + onLinkMouseOut = props.onLinkMouseOut, + style = props.style, + width = props.width; + + var nodesCopy = [].concat(_toConsumableArray(new Array(nodes.length))).map(function (e, i) { + return _extends({}, nodes[i]); + }); + var linksCopy = [].concat(_toConsumableArray(new Array(links.length))).map(function (e, i) { + return _extends({}, links[i]); + }); + + var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)({ + margin: margin, + height: height, + width: width + }, DEFAULT_MARGINS), + marginLeft = _getInnerDimensions.marginLeft, + marginTop = _getInnerDimensions.marginTop, + marginRight = _getInnerDimensions.marginRight, + marginBottom = _getInnerDimensions.marginBottom; + + var sankeyInstance = (0, _d3Sankey.sankey)().extent([[marginLeft, marginTop], [width - marginRight, height - marginBottom - marginTop]]).nodeWidth(nodeWidth).nodePadding(nodePadding).nodes(nodesCopy).links(linksCopy).nodeAlign(ALIGNMENTS[align]).iterations(layout); + sankeyInstance(nodesCopy); + + var nWidth = sankeyInstance.nodeWidth(); + var path = (0, _d3Sankey.sankeyLinkHorizontal)(); + + return _react2.default.createElement( + _xyPlot2.default, + _extends({}, props, { yType: 'literal', className: 'rv-sankey ' + className }), + linksCopy.map(function (link, i) { + return _react2.default.createElement(_sankeyLink2.default, { + style: style.links, + data: path(link), + opacity: link.opacity || linkOpacity, + color: link.color, + onLinkClick: onLinkClick, + onLinkMouseOver: onLinkMouseOver, + onLinkMouseOut: onLinkMouseOut, + strokeWidth: Math.max(link.width, 1), + node: link, + nWidth: nWidth, + key: 'link-' + i + }); + }), + _react2.default.createElement(_verticalRectSeries2.default, { + animation: animation, + className: className + ' rv-sankey__node', + data: nodesCopy.map(function (node) { + return _extends({}, node, { + y: node.y1 - marginTop, + y0: node.y0 - marginTop, + x: node.x1, + x0: node.x0, + color: node.color || _theme.DISCRETE_COLOR_RANGE[0], + sourceLinks: null, + targetLinks: null + }); + }), + style: style.rects, + onValueClick: onValueClick, + onValueMouseOver: onValueMouseOver, + onValueMouseOut: onValueMouseOut, + colorType: 'literal' + }), + !hideLabels && _react2.default.createElement(_labelSeries2.default, { + animation: animation, + className: className, + rotation: labelRotation, + labelAnchorY: 'text-before-edge', + data: nodesCopy.map(function (node, i) { + return _extends({ + x: node.x0 + (node.x0 < width / 2 ? nWidth + 10 : -10), + y: (node.y0 + node.y1) / 2 - marginTop, + label: node.name, + style: _extends({ + textAnchor: node.x0 < width / 2 ? 'start' : 'end', + dy: '-.5em' + }, style.labels) + }, nodes[i]); + }) + }), + hasVoronoi && _react2.default.createElement(_voronoi2.default, { + className: 'rv-sankey__voronoi', + extent: [[-marginLeft, -marginTop], [width + marginRight, height + marginBottom]], + nodes: nodesCopy, + onClick: onValueClick, + onHover: onValueMouseOver, + onBlur: onValueMouseOut, + x: function x(d) { + return d.x0 + (d.x1 - d.x0) / 2; + }, + y: function y(d) { + return d.y0 + (d.y1 - d.y0) / 2; + } + }), + children + ); +} + +Sankey.defaultProps = { + align: 'justify', + className: '', + hasVoronoi: false, + hideLabels: false, + labelRotation: 0, + layout: 50, + margin: DEFAULT_MARGINS, + nodePadding: 10, + nodeWidth: 10, + onValueMouseOver: NOOP, + onValueClick: NOOP, + onValueMouseOut: NOOP, + onLinkClick: NOOP, + onLinkMouseOver: NOOP, + onLinkMouseOut: NOOP, + style: { + links: {}, + rects: {}, + labels: {} + } +}; + +Sankey.propTypes = { + align: _propTypes2.default.oneOf(['justify', 'left', 'right', 'center']), + className: _propTypes2.default.string, + hasVoronoi: _propTypes2.default.bool, + height: _propTypes2.default.number.isRequired, + hideLabels: _propTypes2.default.bool, + labelRotation: _propTypes2.default.number, + layout: _propTypes2.default.number, + links: _propTypes2.default.arrayOf(_propTypes2.default.shape({ + source: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired, + target: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired + })).isRequired, + margin: _chartUtils.MarginPropType, + nodePadding: _propTypes2.default.number, + nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, + nodeWidth: _propTypes2.default.number, + onValueMouseOver: _propTypes2.default.func, + onValueClick: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + onLinkClick: _propTypes2.default.func, + onLinkMouseOver: _propTypes2.default.func, + onLinkMouseOut: _propTypes2.default.func, + style: _propTypes2.default.shape({ + links: _propTypes2.default.object, + rects: _propTypes2.default.object, + labels: _propTypes2.default.object + }), + width: _propTypes2.default.number.isRequired +}; +exports.default = Sankey; \ No newline at end of file diff --git a/dist/sankey/sankey-link.js b/dist/sankey/sankey-link.js new file mode 100644 index 000000000..d664e22d6 --- /dev/null +++ b/dist/sankey/sankey-link.js @@ -0,0 +1,85 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _theme = require('../theme'); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _seriesUtils = require('../utils/series-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var DEFAULT_LINK_COLOR = _theme.DISCRETE_COLOR_RANGE[1]; +var DEFAULT_LINK_OPACITY = 0.7; + +function SankeyLink(props) { + var animation = props.animation, + data = props.data, + node = props.node, + opacity = props.opacity, + color = props.color, + strokeWidth = props.strokeWidth, + style = props.style, + onLinkClick = props.onLinkClick, + onLinkMouseOver = props.onLinkMouseOver, + onLinkMouseOut = props.onLinkMouseOut; + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), + _react2.default.createElement(SankeyLink, _extends({}, props, { animation: null })) + ); + } + return _react2.default.createElement('path', _extends({ + d: data + }, style, { + className: 'rv-sankey__link', + opacity: Number.isFinite(opacity) ? opacity : DEFAULT_LINK_OPACITY, + stroke: color || DEFAULT_LINK_COLOR, + onClick: function onClick(e) { + return onLinkClick(node, e); + }, + onMouseOver: function onMouseOver(e) { + return onLinkMouseOver(node, e); + }, + onMouseOut: function onMouseOut(e) { + return onLinkMouseOut(node, e); + }, + strokeWidth: strokeWidth, + fill: 'none' + })); +} + +SankeyLink.displayName = 'SankeyLink'; +SankeyLink.requiresSVG = true; +exports.default = SankeyLink; \ No newline at end of file diff --git a/dist/style.css b/dist/style.css new file mode 100644 index 000000000..42d247c14 --- /dev/null +++ b/dist/style.css @@ -0,0 +1 @@ +.react-vis-magic-css-import-rule{display:inherit}.rv-treemap{font-size:12px;position:relative}.rv-treemap__leaf{overflow:hidden;position:absolute}.rv-treemap__leaf--circle{align-items:center;border-radius:100%;display:flex;justify-content:center}.rv-treemap__leaf__content{overflow:hidden;padding:10px;text-overflow:ellipsis}.rv-xy-plot{color:#c3c3c3;position:relative}.rv-xy-plot canvas{pointer-events:none}.rv-xy-plot .rv-xy-canvas{pointer-events:none;position:absolute}.rv-xy-plot__inner{display:block}.rv-xy-plot__axis__line{fill:none;stroke-width:2px;stroke:#e6e6e9}.rv-xy-plot__axis__tick__line{stroke:#e6e6e9}.rv-xy-plot__axis__tick__text{fill:#6b6b76;font-size:11px}.rv-xy-plot__axis__title text{fill:#6b6b76;font-size:11px}.rv-xy-plot__grid-lines__line{stroke:#e6e6e9}.rv-xy-plot__circular-grid-lines__line{fill-opacity:0;stroke:#e6e6e9}.rv-xy-plot__series,.rv-xy-plot__series path{pointer-events:all}.rv-xy-plot__series--line{fill:none;stroke:#000;stroke-width:2px}.rv-crosshair{position:absolute;font-size:11px;pointer-events:none}.rv-crosshair__line{background:#47d3d9;width:1px}.rv-crosshair__inner{position:absolute;text-align:left;top:0}.rv-crosshair__inner__content{border-radius:4px;background:#3a3a48;color:#fff;font-size:12px;padding:7px 10px;box-shadow:0 2px 4px rgba(0,0,0,0.5)}.rv-crosshair__inner--left{right:4px}.rv-crosshair__inner--right{left:4px}.rv-crosshair__title{font-weight:bold;white-space:nowrap}.rv-crosshair__item{white-space:nowrap}.rv-hint{position:absolute;pointer-events:none}.rv-hint__content{border-radius:4px;padding:7px 10px;font-size:12px;background:#3a3a48;box-shadow:0 2px 4px rgba(0,0,0,0.5);color:#fff;text-align:left;white-space:nowrap}.rv-discrete-color-legend{box-sizing:border-box;overflow-y:auto;font-size:12px}.rv-discrete-color-legend.horizontal{white-space:nowrap}.rv-discrete-color-legend-item{color:#3a3a48;border-radius:1px;padding:9px 10px}.rv-discrete-color-legend-item.horizontal{display:inline-block}.rv-discrete-color-legend-item.horizontal .rv-discrete-color-legend-item__title{margin-left:0;display:block}.rv-discrete-color-legend-item__color{display:inline-block;vertical-align:middle;overflow:visible}.rv-discrete-color-legend-item__color__path{stroke:#dcdcdc;stroke-width:2px}.rv-discrete-color-legend-item__title{margin-left:10px}.rv-discrete-color-legend-item.disabled{color:#b8b8b8}.rv-discrete-color-legend-item.clickable{cursor:pointer}.rv-discrete-color-legend-item.clickable:hover{background:#f9f9f9}.rv-search-wrapper{display:flex;flex-direction:column}.rv-search-wrapper__form{flex:0}.rv-search-wrapper__form__input{width:100%;color:#a6a6a5;border:1px solid #e5e5e4;padding:7px 10px;font-size:12px;box-sizing:border-box;border-radius:2px;margin:0 0 9px;outline:0}.rv-search-wrapper__contents{flex:1;overflow:auto}.rv-continuous-color-legend{font-size:12px}.rv-continuous-color-legend .rv-gradient{height:4px;border-radius:2px;margin-bottom:5px}.rv-continuous-size-legend{font-size:12px}.rv-continuous-size-legend .rv-bubbles{text-align:justify;overflow:hidden;margin-bottom:5px;width:100%}.rv-continuous-size-legend .rv-bubble{background:#d8d9dc;display:inline-block;vertical-align:bottom}.rv-continuous-size-legend .rv-spacer{display:inline-block;font-size:0;line-height:0;width:100%}.rv-legend-titles{height:16px;position:relative}.rv-legend-titles__left,.rv-legend-titles__right,.rv-legend-titles__center{position:absolute;white-space:nowrap;overflow:hidden}.rv-legend-titles__center{display:block;text-align:center;width:100%}.rv-legend-titles__right{right:0}.rv-radial-chart .rv-xy-plot__series--label{pointer-events:none} diff --git a/dist/styles/examples.scss b/dist/styles/examples.scss new file mode 100644 index 000000000..420cb2eb1 --- /dev/null +++ b/dist/styles/examples.scss @@ -0,0 +1,461 @@ +@import '../main.scss'; + +$black: #000; +$white: #fff; + +body { + font-family: Sintony, Helvetica, sans-serif; + font-size: 14px; + margin: 0; + padding: 0; +} + +h1, +h2, +h3, +h4, +h5 { + font-weight: normal; +} + +h1 { + font-size: 36px; + margin: 20px 0; +} + +h2 { + font-size: 24px; + margin: 15px 0; +} + +main { + padding: 40px 0; +} + +header { + background: #f0f0f0; + line-height: 40px; + position: fixed; + top: 0; + width: 100%; + z-index: 1000; +} + +.flex { + display: flex; +} + +.docs-link { + font-weight: 500; + font-size: 11px; + margin-right: 5px; + text-transform: uppercase; + border-left: 1px solid #c0c0c0; + padding-left: 5px; + line-height: 1; +} + +.docs-link:first-child { + border-left: 0px; + padding-left: 0px; +} + +.docs-comment { + display: flex; + max-width: 300px; +} + +.header-contents { + align-items: center; + display: flex; + justify-content: space-between; + padding: 0 20px; +} + +.header-logo { + color: $black; + float: left; + font-size: 20px; + text-decoration: none; +} + +.background-overlay { + bottom: 0; + left: 0; + position: fixed; + right: 0; + top: 0; + z-index: 1; +} + +.dropdown-button { + cursor: pointer; + z-index: 10; +} + +.dropdown-wrapper { + display: flex; + position: relative; + + .dropdown-inner-wrapper { + background: $white; + border: 2px solid $black; + display: flex; + flex-direction: column; + font-size: 11px; + height: auto; + list-style: none; + padding: 10px; + position: absolute; + right: -5px; + top: 25px; + width: 150px; + z-index: 10; + } + + a { + display: flex; + height: auto; + line-height: 15px; + text-decoration: none; + } + + li { + display: flex; + height: 100%; + } + + .subsection-label { + font-weight: 600; + line-height: 15px; + } +} + + +article { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: flex-start; + margin: 0 auto; + max-width: 1200px; + min-width: 650px; + padding: 30px 20px 0; + + h1, + h2 { + flex: 1 100%; + + small { + color: #6b6b76; + font-size: 50%; + } + } + + section { + flex-basis: 400px; + flex-grow: 1; + margin: 0 0 40px; + } + + .section-title { + margin-bottom: 5px; + } + + .section-header { + margin-bottom: 1em; + } +} + +.click-me { + border: 0; + background: #ef5d28; + color: $white; + cursor: pointer; + font-family: Sintony, Helvetica, sans-serif; + font-size: 14px; + outline: none; + padding: 11px 20px; + text-transform: uppercase; + + &:hover { + background: #ff9833; + } + + animation: shake 5s 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite; + transform: translate3d(0, 0, 0); +} + +@keyframes shake { + 1%, + 9% { + transform: translate3d(-1px, 0, 0); + } + + 2%, + 8% { + transform: translate3d(2px, 0, 0); + } + + 3%, + 5%, + 7% { + transform: translate3d(-4px, 0, 0); + } + + 4%, + 6% { + transform: translate3d(4px, 0, 0); + } +} + +.example-with-click-me { + position: relative; + text-align: center; + width: 100%; + + &:hover { + .click-me { + animation: none; + } + } + + .chart { + margin-right: 200px; + .rv-xy-plot__axis__tick__line { + stroke: $rv-xy-plot-axis-font-color; + } + } + + .legend { + position: absolute; + text-align: left; + right: 0; + } +} + +.custom-hint { + background: #f9e7bb; + border-radius: 3px; + border: 1px solid #edaf00; + padding: 10px; + color: #333; + font-size: 10px; + position: relative; + margin: 12px 0 0 -10px; + + &::after { + border-radius: 5px; + border: 2px solid #edaf00; + background: $white; + display: block; + content: ' '; + height: 6px; + width: 6px; + top: -17px; + left: 5px; + position: absolute; + } +} + +.complex-hint { + margin-top: 40px; + + .rv-hint { + /* must be positioned in a parent with relative positioning */ + position: absolute; + width: 0; + height: 100%; + $hint-color: black; + $margin-left: 30px; + $margin-right: 10px; + $margin-top: 10px; + $margin-bottom: 25px; + + & .hint--text-container { + position: absolute; + + /* + * set to 0,0 so that its content (including children) + * can overflow out in vertical and horizontal + */ + width: 0; + height: 0; + + /* + * use flex to place its children (centered) and aligned (bottom). + * As its height is 0, align-items flex-end paints its items from cross-axis + * up. flex-start, its items would paint from cross-axis down. + */ + display: flex; + justify-content: center; + + &.rightEdge-top { + flex-direction: column-reverse; + align-items: flex-start; + } + + &.left-topEdge { + flex-direction: row; + align-items: flex-end; + } + + &.left-bottomEdge { + flex-direction: row; + align-items: flex-start; + } + + &.leftEdge-top { + flex-direction: column; + align-items: flex-end; + } + + & .hint--text { + /* text content uses -micro padding */ + padding: 4px; + border: 2px solid $hint-color; + color: $hint-color; + white-space: nowrap; + } + } + + & .hint--pole { + position: absolute; + + &.rightEdge-top { + top: -1px; + left: -$margin-right; + border-top: 2px solid $hint-color; + width: $margin-right; + height: 0; + } + + &.left-topEdge { + border-left: 2px solid $hint-color; + left: -1px; + height: $margin-top; + width: 0; + top: 0; + } + + &.left-bottomEdge { + border-left: 2px solid $hint-color; + left: -1px; + height: $margin-bottom; + width: 0; + top: -$margin-bottom; + } + + &.leftEdge-top { + top: -1px; + border-top: 2px solid $hint-color; + width: $margin-left; + height: 0; + } + } + } + + .rv-hint--horizontalAlign-rightEdge.rv-hint--verticalAlign-top { + width: 0; + height: 0; + } + + .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-topEdge { + width: 0; + height: 100%; + } + + .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-bottomEdge { + width: 0; + height: 0; + } + + .rv-hint--horizontalAlign-leftEdge.rv-hint--verticalAlign-top { + width: 100%; + height: 0; + } +} + +.centered-and-flexed { + align-items: center; + display: flex; + flex-direction: column; + justify-content: center; + padding: 0 10px; + + .centered-and-flexed-controls { + align-items: center; + display: flex; + justify-content: space-between; + padding: 10px 0; + width: 75%; + } +} + +.dynamic-treemap-example { + .rv-treemap__leaf--circle { + border: thin solid white; + } +} + +.clustered-stacked-bar-chart-example { + .rv-discrete-color-legend { + left: 40px; + position: absolute; + top: 0; + } +} + +.basic-sunburst-example-path-name { + height: 20px; +} + +.showcase-button { + background: $white; + border: thin solid #333; + border-radius: 5px; + cursor: pointer; + font-size: 10px; + font-weight: 600; + padding: 5px 10px; +} + +.donut-chart-example { + .rv-radial-chart__series--pie__slice:hover { + stroke: $black !important; + stroke-width: 2px !important; + } +} + +.parallel-coordinates-example { + .rv-xy-plot__series--line { + stroke: #12939A !important; + + &:hover { + stroke: #F15C17 !important; + } + } +} + + +.canvas-example-controls { + display: flex; +} + +.canvas-wrapper { + align-items: center; + display: flex; + flex-direction: column; + width: 100%; +} + +.highlight-container { + cursor: crosshair; +} + +.no-select { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/dist/styles/legends.scss b/dist/styles/legends.scss new file mode 100644 index 000000000..f79e9c850 --- /dev/null +++ b/dist/styles/legends.scss @@ -0,0 +1,137 @@ +$rv-legend-enabled-color: #3a3a48; +$rv-legend-disabled-color: #b8b8b8; + +.rv-discrete-color-legend { + box-sizing: border-box; + overflow-y: auto; + font-size: 12px; + + &.horizontal { + white-space: nowrap; + } +} + +.rv-discrete-color-legend-item { + color: $rv-legend-enabled-color; + border-radius: 1px; + padding: 9px 10px; + + &.horizontal { + display: inline-block; + + .rv-discrete-color-legend-item__title { + margin-left: 0; + display: block; + } + } +} + +.rv-discrete-color-legend-item__color { + display: inline-block; + vertical-align: middle; + overflow: visible; +} + +.rv-discrete-color-legend-item__color__path { + stroke: #dcdcdc; + stroke-width: 2px; +} + +.rv-discrete-color-legend-item__title { + margin-left: 10px; +} + +.rv-discrete-color-legend-item.disabled { + color: $rv-legend-disabled-color; +} + +.rv-discrete-color-legend-item.clickable { + cursor: pointer; + + &:hover { + background: #f9f9f9; + } +} + +.rv-search-wrapper { + display: flex; + flex-direction: column; +} + +.rv-search-wrapper__form { + flex: 0; +} + +.rv-search-wrapper__form__input { + width: 100%; + color: #a6a6a5; + border: 1px solid #e5e5e4; + padding: 7px 10px; + font-size: 12px; + box-sizing: border-box; + border-radius: 2px; + margin: 0 0 9px; + outline: 0; +} + +.rv-search-wrapper__contents { + flex: 1; + overflow: auto; +} + +.rv-continuous-color-legend { + font-size: 12px; + + .rv-gradient { + height: 4px; + border-radius: 2px; + margin-bottom: 5px; + } +} + +.rv-continuous-size-legend { + font-size: 12px; + + .rv-bubbles { + text-align: justify; + overflow: hidden; + margin-bottom: 5px; + width: 100%; + } + + .rv-bubble { + background: #d8d9dc; + display: inline-block; + vertical-align: bottom; + } + + .rv-spacer { + display: inline-block; + font-size: 0; + line-height: 0; + width: 100%; + } +} + +.rv-legend-titles { + height: 16px; + position: relative; +} + +.rv-legend-titles__left, +.rv-legend-titles__right, +.rv-legend-titles__center { + position: absolute; + white-space: nowrap; + overflow: hidden; +} + +.rv-legend-titles__center { + display: block; + text-align: center; + width: 100%; +} + +.rv-legend-titles__right { + right: 0; +} diff --git a/dist/styles/plot.scss b/dist/styles/plot.scss new file mode 100644 index 000000000..8d1f75ca2 --- /dev/null +++ b/dist/styles/plot.scss @@ -0,0 +1,128 @@ +$rv-xy-plot-axis-font-color: #6b6b76; +$rv-xy-plot-axis-line-color: #e6e6e9; +$rv-xy-plot-axis-font-size: 11px; +$rv-xy-plot-tooltip-background: #3a3a48; +$rv-xy-plot-tooltip-color: #fff; +$rv-xy-plot-tooltip-font-size: 12px; +$rv-xy-plot-tooltip-border-radius: 4px; +$rv-xy-plot-tooltip-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); +$rv-xy-plot-tooltip-padding: 7px 10px; + +.rv-xy-plot { + color: #c3c3c3; + position: relative; + + canvas { + pointer-events: none; + } + + .rv-xy-canvas { + pointer-events: none; + position: absolute; + } +} + +.rv-xy-plot__inner { + display: block; +} + +.rv-xy-plot__axis__line { + fill: none; + stroke-width: 2px; + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__axis__tick__line { + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__axis__tick__text { + fill: $rv-xy-plot-axis-font-color; + font-size: $rv-xy-plot-axis-font-size; +} + +.rv-xy-plot__axis__title { + text { + fill: $rv-xy-plot-axis-font-color; + font-size: $rv-xy-plot-axis-font-size; + } +} + +.rv-xy-plot__grid-lines__line { + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__circular-grid-lines__line { + fill-opacity: 0; + stroke: $rv-xy-plot-axis-line-color; +} + +.rv-xy-plot__series, +.rv-xy-plot__series path { + pointer-events: all; +} + +.rv-xy-plot__series--line { + fill: none; + stroke: #000; + stroke-width: 2px; +} + +.rv-crosshair { + position: absolute; + font-size: 11px; + pointer-events: none; +} + +.rv-crosshair__line { + background: #47d3d9; + width: 1px; +} + +.rv-crosshair__inner { + position: absolute; + text-align: left; + top: 0; +} + +.rv-crosshair__inner__content { + border-radius: $rv-xy-plot-tooltip-border-radius; + background: $rv-xy-plot-tooltip-background; + color: $rv-xy-plot-tooltip-color; + font-size: $rv-xy-plot-tooltip-font-size; + padding: $rv-xy-plot-tooltip-padding; + box-shadow: $rv-xy-plot-tooltip-shadow; +} + +.rv-crosshair__inner--left { + right: 4px; +} + +.rv-crosshair__inner--right { + left: 4px; +} + +.rv-crosshair__title { + font-weight: bold; + white-space: nowrap; +} + +.rv-crosshair__item { + white-space: nowrap; +} + +.rv-hint { + position: absolute; + pointer-events: none; +} + +.rv-hint__content { + border-radius: $rv-xy-plot-tooltip-border-radius; + padding: $rv-xy-plot-tooltip-padding; + font-size: $rv-xy-plot-tooltip-font-size; + background: $rv-xy-plot-tooltip-background; + box-shadow: $rv-xy-plot-tooltip-shadow; + color: $rv-xy-plot-tooltip-color; + text-align: left; + white-space: nowrap; +} diff --git a/dist/styles/radial-chart.scss b/dist/styles/radial-chart.scss new file mode 100644 index 000000000..854a57d4b --- /dev/null +++ b/dist/styles/radial-chart.scss @@ -0,0 +1,6 @@ +.rv-radial-chart { + + .rv-xy-plot__series--label { + pointer-events: none; + } +} diff --git a/dist/styles/treemap.scss b/dist/styles/treemap.scss new file mode 100644 index 000000000..4626d66ea --- /dev/null +++ b/dist/styles/treemap.scss @@ -0,0 +1,22 @@ +.rv-treemap { + font-size: 12px; + position: relative; +} + +.rv-treemap__leaf { + overflow: hidden; + position: absolute; +} + +.rv-treemap__leaf--circle { + align-items: center; + border-radius: 100%; + display: flex; + justify-content: center; +} + +.rv-treemap__leaf__content { + overflow: hidden; + padding: 10px; + text-overflow: ellipsis; +} diff --git a/dist/sunburst/index.js b/dist/sunburst/index.js new file mode 100644 index 000000000..a9c12d6c2 --- /dev/null +++ b/dist/sunburst/index.js @@ -0,0 +1,253 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Hierarchy = require('d3-hierarchy'); + +var _d3Scale = require('d3-scale'); + +var _animation = require('../animation'); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +var _arcSeries = require('../plot/series/arc-series'); + +var _arcSeries2 = _interopRequireDefault(_arcSeries); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _seriesUtils = require('../utils/series-utils'); + +var _chartUtils = require('../utils/chart-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var predefinedClassName = 'rv-sunburst'; + +var LISTENERS_TO_OVERWRITE = ['onValueMouseOver', 'onValueMouseOut', 'onValueClick', 'onValueRightClick', 'onSeriesMouseOver', 'onSeriesMouseOut', 'onSeriesClick', 'onSeriesRightClick']; + +/** + * Create the list of nodes to render. + * @param {Object} props + props.data {Object} - tree structured data (each node has a name anc an array of children) + props.height {number} - the height of the graphic to be rendered + props.hideRootNode {boolean} - whether or not to hide the root node + props.width {number} - the width of the graphic to be rendered + props.getSize {function} - accessor for the size + * @returns {Array} Array of nodes. + */ +function getNodesToRender(_ref) { + var data = _ref.data, + height = _ref.height, + hideRootNode = _ref.hideRootNode, + width = _ref.width, + getSize = _ref.getSize; + + var partitionFunction = (0, _d3Hierarchy.partition)(); + var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize); + var radius = Math.min(width, height) / 2 - 10; + var x = (0, _d3Scale.scaleLinear)().range([0, 2 * Math.PI]); + var y = (0, _d3Scale.scaleSqrt)().range([0, radius]); + + return partitionFunction(structuredInput).descendants().reduce(function (res, cell, index) { + if (hideRootNode && index === 0) { + return res; + } + + return res.concat([_extends({ + angle0: Math.max(0, Math.min(2 * Math.PI, x(cell.x0))), + angle: Math.max(0, Math.min(2 * Math.PI, x(cell.x1))), + radius0: Math.max(0, y(cell.y0)), + radius: Math.max(0, y(cell.y1)), + depth: cell.depth, + parent: cell.parent + }, cell.data)]); + }, []); +} + +/** + * Convert arc nodes into label rows. + * Important to use mappedData rather than regular data, bc it is already unrolled + * @param {Array} mappedData - Array of nodes. + * @param {Object} accessors - object of accessors + * @returns {Array} array of node for rendering as labels + */ +function buildLabels(mappedData, accessors) { + var getAngle = accessors.getAngle, + getAngle0 = accessors.getAngle0, + getLabel = accessors.getLabel, + getRadius0 = accessors.getRadius0; + + + return mappedData.filter(getLabel).map(function (row) { + var truedAngle = -1 * getAngle(row) + Math.PI / 2; + var truedAngle0 = -1 * getAngle0(row) + Math.PI / 2; + var angle = (truedAngle0 + truedAngle) / 2; + var rotateLabels = !row.dontRotateLabel; + var rotAngle = -angle / (2 * Math.PI) * 360; + + return _extends({}, row, { + children: null, + angle: null, + radius: null, + x: getRadius0(row) * Math.cos(angle), + y: getRadius0(row) * Math.sin(angle), + style: _extends({ + textAnchor: rotAngle > 90 ? 'end' : 'start' + }, row.labelStyle), + rotation: rotateLabels ? rotAngle > 90 ? rotAngle + 180 : rotAngle === 90 ? 90 : rotAngle : null + }); + }); +} + +var NOOP = function NOOP() {}; + +function Sunburst(props) { + var getAngle = props.getAngle, + getAngle0 = props.getAngle0, + animation = props.animation, + className = props.className, + children = props.children, + data = props.data, + height = props.height, + hideRootNode = props.hideRootNode, + getLabel = props.getLabel, + width = props.width, + getSize = props.getSize, + colorType = props.colorType; + + var mappedData = getNodesToRender({ + data: data, + height: height, + hideRootNode: hideRootNode, + width: width, + getSize: getSize + }); + var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); + var margin = (0, _chartUtils.getRadialLayoutMargin)(width, height, radialDomain); + + var labelData = buildLabels(mappedData, { + getAngle: getAngle, + getAngle0: getAngle0, + getLabel: getLabel, + getRadius0: function getRadius0(d) { + return d.radius0; + } + }); + + var hofBuilder = function hofBuilder(f) { + return function (e, i) { + return f ? f(mappedData[e.index], i) : NOOP; + }; + }; + return _react2.default.createElement( + _xyPlot2.default, + { + height: height, + hasTreeStructure: true, + width: width, + className: predefinedClassName + ' ' + className, + margin: margin, + xDomain: [-radialDomain, radialDomain], + yDomain: [-radialDomain, radialDomain] + }, + _react2.default.createElement(_arcSeries2.default, _extends({ + colorType: colorType + }, props, { + animation: animation, + radiusDomain: [0, radialDomain], + // need to present a stripped down version for interpolation + data: animation ? mappedData.map(function (row, index) { + return _extends({}, row, { + parent: null, + children: null, + index: index + }); + }) : mappedData, + _data: animation ? mappedData : null, + arcClassName: predefinedClassName + '__series--radial__arc' + }, LISTENERS_TO_OVERWRITE.reduce(function (acc, propName) { + var prop = props[propName]; + acc[propName] = animation ? hofBuilder(prop) : prop; + return acc; + }, {}))), + labelData.length > 0 && _react2.default.createElement(_labelSeries2.default, { data: labelData, getLabel: getLabel }), + children + ); +} + +Sunburst.displayName = 'Sunburst'; +Sunburst.propTypes = { + animation: _animation.AnimationPropType, + getAngle: _propTypes2.default.func, + getAngle0: _propTypes2.default.func, + className: _propTypes2.default.string, + colorType: _propTypes2.default.string, + data: _propTypes2.default.object.isRequired, + height: _propTypes2.default.number.isRequired, + hideRootNode: _propTypes2.default.bool, + getLabel: _propTypes2.default.func, + onValueClick: _propTypes2.default.func, + onValueMouseOver: _propTypes2.default.func, + onValueMouseOut: _propTypes2.default.func, + getSize: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired, + padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) +}; +Sunburst.defaultProps = { + getAngle: function getAngle(d) { + return d.angle; + }, + getAngle0: function getAngle0(d) { + return d.angle0; + }, + className: '', + colorType: 'literal', + getColor: function getColor(d) { + return d.color; + }, + hideRootNode: false, + getLabel: function getLabel(d) { + return d.label; + }, + getSize: function getSize(d) { + return d.size; + }, + padAngle: 0 +}; + +exports.default = Sunburst; \ No newline at end of file diff --git a/dist/theme.js b/dist/theme.js new file mode 100644 index 000000000..3807452c3 --- /dev/null +++ b/dist/theme.js @@ -0,0 +1,42 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var DISCRETE_COLOR_RANGE = exports.DISCRETE_COLOR_RANGE = ['#12939A', '#79C7E3', '#1A3177', '#FF9833', '#EF5D28']; + +var EXTENDED_DISCRETE_COLOR_RANGE = exports.EXTENDED_DISCRETE_COLOR_RANGE = ['#19CDD7', '#DDB27C', '#88572C', '#FF991F', '#F15C17', '#223F9A', '#DA70BF', '#125C77', '#4DC19C', '#776E57', '#12939A', '#17B8BE', '#F6D18A', '#B7885E', '#FFCB99', '#F89570', '#829AE3', '#E79FD5', '#1E96BE', '#89DAC1', '#B3AD9E']; + +var CONTINUOUS_COLOR_RANGE = exports.CONTINUOUS_COLOR_RANGE = ['#EF5D28', '#FF9833']; + +var SIZE_RANGE = exports.SIZE_RANGE = [1, 10]; + +var OPACITY_RANGE = exports.OPACITY_RANGE = [0.1, 1]; +var OPACITY_TYPE = exports.OPACITY_TYPE = 'literal'; +var DEFAULT_OPACITY = exports.DEFAULT_OPACITY = 1; + +var DEFAULT_SIZE = exports.DEFAULT_SIZE = 5; + +var DEFAULT_COLOR = exports.DEFAULT_COLOR = DISCRETE_COLOR_RANGE[0]; + +var DEFAULT_TICK_SIZE = exports.DEFAULT_TICK_SIZE = 7; \ No newline at end of file diff --git a/dist/treemap/index.js b/dist/treemap/index.js new file mode 100644 index 000000000..27244fe2d --- /dev/null +++ b/dist/treemap/index.js @@ -0,0 +1,254 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _d3Hierarchy = require('d3-hierarchy'); + +var _theme = require('../theme'); + +var _animation = require('../animation'); + +var _scalesUtils = require('../utils/scales-utils'); + +var _chartUtils = require('../utils/chart-utils'); + +var _treemapDom = require('./treemap-dom'); + +var _treemapDom2 = _interopRequireDefault(_treemapDom); + +var _treemapSvg = require('./treemap-svg'); + +var _treemapSvg2 = _interopRequireDefault(_treemapSvg); + +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; } + +var TREEMAP_TILE_MODES = { + squarify: _d3Hierarchy.treemapSquarify, + resquarify: _d3Hierarchy.treemapResquarify, + slice: _d3Hierarchy.treemapSlice, + dice: _d3Hierarchy.treemapDice, + slicedice: _d3Hierarchy.treemapSliceDice, + binary: _d3Hierarchy.treemapBinary +}; + +var TREEMAP_LAYOUT_MODES = ['circlePack', 'partition', 'partition-pivot']; + +var NOOP = function NOOP(d) { + return d; +}; + +var ATTRIBUTES = ['opacity', 'color']; + +var DEFAULT_MARGINS = { + left: 40, + right: 10, + top: 10, + bottom: 40 +}; + +/** + * Get the map of scale functions from the given props. + * @param {Object} props Props for the component. + * @returns {Object} Map of scale functions. + * @private + */ +function _getScaleFns(props) { + var data = props.data; + + var allData = data.children || []; + + // Adding _allData property to the object to reuse the existing + // getAttributeFunctor function. + var compatibleProps = _extends({}, props, (0, _scalesUtils.getMissingScaleProps)(props, allData, ATTRIBUTES), { + _allData: allData + }); + return { + opacity: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'opacity'), + color: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'color') + }; +} + +var Treemap = function (_React$Component) { + _inherits(Treemap, _React$Component); + + function Treemap(props) { + _classCallCheck(this, Treemap); + + var _this = _possibleConstructorReturn(this, (Treemap.__proto__ || Object.getPrototypeOf(Treemap)).call(this, props)); + + _this.state = _extends({ + scales: _getScaleFns(props) + }, (0, _chartUtils.getInnerDimensions)(props, props.margin)); + return _this; + } + + _createClass(Treemap, [{ + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(props) { + this.setState(_extends({ + scales: _getScaleFns(props) + }, (0, _chartUtils.getInnerDimensions)(props, props.margin))); + } + + /** + * Create the list of nodes to render. + * @returns {Array} Array of nodes. + * @private + */ + + }, { + key: '_getNodesToRender', + value: function _getNodesToRender() { + var _state = this.state, + innerWidth = _state.innerWidth, + innerHeight = _state.innerHeight; + var _props = this.props, + data = _props.data, + mode = _props.mode, + padding = _props.padding, + sortFunction = _props.sortFunction, + getSize = _props.getSize; + + if (!data) { + return []; + } + + if (mode === 'partition' || mode === 'partition-pivot') { + var partitionFunction = (0, _d3Hierarchy.partition)().size(mode === 'partition-pivot' ? [innerHeight, innerWidth] : [innerWidth, innerHeight]).padding(padding); + var _structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { + return sortFunction(a, b, getSize); + }); + var mappedNodes = partitionFunction(_structuredInput).descendants(); + if (mode === 'partition-pivot') { + return mappedNodes.map(function (node) { + return _extends({}, node, { + x0: node.y0, + x1: node.y1, + y0: node.x0, + y1: node.x1 + }); + }); + } + return mappedNodes; + } + if (mode === 'circlePack') { + var packingFunction = (0, _d3Hierarchy.pack)().size([innerWidth, innerHeight]).padding(padding); + var _structuredInput2 = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { + return sortFunction(a, b, getSize); + }); + return packingFunction(_structuredInput2).descendants(); + } + + var tileFn = TREEMAP_TILE_MODES[mode]; + var treemapingFunction = (0, _d3Hierarchy.treemap)(tileFn).tile(tileFn).size([innerWidth, innerHeight]).padding(padding); + var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { + return sortFunction(a, b, getSize); + }); + return treemapingFunction(structuredInput).descendants(); + } + }, { + key: 'render', + value: function render() { + var renderMode = this.props.renderMode; + var scales = this.state.scales; + + var nodes = this._getNodesToRender(); + var TreemapElement = renderMode === 'SVG' ? _treemapSvg2.default : _treemapDom2.default; + return _react2.default.createElement(TreemapElement, _extends({}, this.props, { nodes: nodes, scales: scales })); + } + }]); + + return Treemap; +}(_react2.default.Component); + +Treemap.displayName = 'Treemap'; +Treemap.propTypes = { + animation: _animation.AnimationPropType, + className: _propTypes2.default.string, + data: _propTypes2.default.object.isRequired, + height: _propTypes2.default.number.isRequired, + hideRootNode: _propTypes2.default.bool, + margin: _chartUtils.MarginPropType, + mode: _propTypes2.default.oneOf(Object.keys(TREEMAP_TILE_MODES).concat(TREEMAP_LAYOUT_MODES)), + onLeafClick: _propTypes2.default.func, + onLeafMouseOver: _propTypes2.default.func, + onLeafMouseOut: _propTypes2.default.func, + useCirclePacking: _propTypes2.default.bool, + padding: _propTypes2.default.number.isRequired, + sortFunction: _propTypes2.default.func, + width: _propTypes2.default.number.isRequired, + getSize: _propTypes2.default.func, + getColor: _propTypes2.default.func +}; + +Treemap.defaultProps = { + className: '', + colorRange: _theme.CONTINUOUS_COLOR_RANGE, + _colorValue: _theme.DEFAULT_COLOR, + data: { + children: [] + }, + hideRootNode: false, + margin: DEFAULT_MARGINS, + mode: 'squarify', + onLeafClick: NOOP, + onLeafMouseOver: NOOP, + onLeafMouseOut: NOOP, + opacityType: _theme.OPACITY_TYPE, + _opacityValue: _theme.DEFAULT_OPACITY, + padding: 1, + sortFunction: function sortFunction(a, b, accessor) { + if (!accessor) { + return 0; + } + return accessor(a) - accessor(b); + }, + getSize: function getSize(d) { + return d.size; + }, + getColor: function getColor(d) { + return d.color; + }, + getLabel: function getLabel(d) { + return d.title; + } +}; +exports.default = Treemap; \ No newline at end of file diff --git a/dist/treemap/treemap-dom.js b/dist/treemap/treemap-dom.js new file mode 100644 index 000000000..b8112f0a9 --- /dev/null +++ b/dist/treemap/treemap-dom.js @@ -0,0 +1,82 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _treemapLeaf = require('./treemap-leaf'); + +var _treemapLeaf2 = _interopRequireDefault(_treemapLeaf); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function TreemapDOM(props) { + var animation = props.animation, + className = props.className, + height = props.height, + hideRootNode = props.hideRootNode, + getLabel = props.getLabel, + mode = props.mode, + nodes = props.nodes, + width = props.width, + scales = props.scales, + style = props.style; + + var useCirclePacking = mode === 'circlePack'; + return _react2.default.createElement( + 'div', + { + className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, + style: { height: height, width: width } + }, + nodes.map(function (node, index) { + // throw out the rootest node + if (hideRootNode && !index) { + return null; + } + + var nodeProps = _extends({ + animation: animation, + node: node, + getLabel: getLabel + }, props, { + x0: useCirclePacking ? node.x : node.x0, + x1: useCirclePacking ? node.x : node.x1, + y0: useCirclePacking ? node.y : node.y0, + y1: useCirclePacking ? node.y : node.y1, + r: useCirclePacking ? node.r : 1, + scales: scales, + style: style + }); + return _react2.default.createElement(_treemapLeaf2.default, _extends({}, nodeProps, { key: 'leaf-' + index })); + }) + ); +} + +TreemapDOM.displayName = 'TreemapDOM'; +exports.default = TreemapDOM; \ No newline at end of file diff --git a/dist/treemap/treemap-leaf.js b/dist/treemap/treemap-leaf.js new file mode 100644 index 000000000..d0a67615f --- /dev/null +++ b/dist/treemap/treemap-leaf.js @@ -0,0 +1,125 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _animation = require('../animation'); + +var _animation2 = _interopRequireDefault(_animation); + +var _scalesUtils = require('../utils/scales-utils'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var ANIMATED_PROPS = ['colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'x0', 'x1', 'y0', 'y1', 'r']; + +function TreemapLeaf(props) { + var animation = props.animation, + getLabel = props.getLabel, + mode = props.mode, + node = props.node, + onLeafClick = props.onLeafClick, + onLeafMouseOver = props.onLeafMouseOver, + onLeafMouseOut = props.onLeafMouseOut, + r = props.r, + scales = props.scales, + x0 = props.x0, + x1 = props.x1, + y0 = props.y0, + y1 = props.y1, + style = props.style; + + + if (animation) { + return _react2.default.createElement( + _animation2.default, + _extends({}, props, { animatedProps: ANIMATED_PROPS }), + _react2.default.createElement(TreemapLeaf, _extends({}, props, { animation: null })) + ); + } + var useCirclePacking = mode === 'circlePack'; + var background = scales.color(node); + var opacity = scales.opacity(node); + var color = (0, _scalesUtils.getFontColorFromBackground)(background); + var data = node.data; + + var title = getLabel(data); + var leafStyle = _extends({ + top: useCirclePacking ? y0 - r : y0, + left: useCirclePacking ? x0 - r : x0, + width: useCirclePacking ? r * 2 : x1 - x0, + height: useCirclePacking ? r * 2 : y1 - y0, + background: background, + opacity: opacity, + color: color + }, style, node.data.style); + + return _react2.default.createElement( + 'div', + { + className: 'rv-treemap__leaf ' + (useCirclePacking ? 'rv-treemap__leaf--circle' : ''), + onMouseEnter: function onMouseEnter(event) { + return onLeafMouseOver(node, event); + }, + onMouseLeave: function onMouseLeave(event) { + return onLeafMouseOut(node, event); + }, + onClick: function onClick(event) { + return onLeafClick(node, event); + }, + style: leafStyle + }, + _react2.default.createElement( + 'div', + { className: 'rv-treemap__leaf__content' }, + title + ) + ); +} + +TreemapLeaf.propTypes = { + animation: _animation.AnimationPropType, + height: _propTypes2.default.number.isRequired, + mode: _propTypes2.default.string, + node: _propTypes2.default.object.isRequired, + onLeafClick: _propTypes2.default.func, + onLeafMouseOver: _propTypes2.default.func, + onLeafMouseOut: _propTypes2.default.func, + scales: _propTypes2.default.object.isRequired, + width: _propTypes2.default.number.isRequired, + r: _propTypes2.default.number.isRequired, + x0: _propTypes2.default.number.isRequired, + x1: _propTypes2.default.number.isRequired, + y0: _propTypes2.default.number.isRequired, + y1: _propTypes2.default.number.isRequired +}; +exports.default = TreemapLeaf; \ No newline at end of file diff --git a/dist/treemap/treemap-svg.js b/dist/treemap/treemap-svg.js new file mode 100644 index 000000000..6255dafbc --- /dev/null +++ b/dist/treemap/treemap-svg.js @@ -0,0 +1,246 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +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); + +var _xyPlot = require('../plot/xy-plot'); + +var _xyPlot2 = _interopRequireDefault(_xyPlot); + +var _polygonSeries = require('../plot/series/polygon-series'); + +var _polygonSeries2 = _interopRequireDefault(_polygonSeries); + +var _markSeries = require('../plot/series/mark-series'); + +var _markSeries2 = _interopRequireDefault(_markSeries); + +var _labelSeries = require('../plot/series/label-series'); + +var _labelSeries2 = _interopRequireDefault(_labelSeries); + +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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var MARGIN_ADJUST = 1.2; + +var TreemapSVG = function (_React$Component) { + _inherits(TreemapSVG, _React$Component); + + function TreemapSVG() { + _classCallCheck(this, TreemapSVG); + + return _possibleConstructorReturn(this, (TreemapSVG.__proto__ || Object.getPrototypeOf(TreemapSVG)).apply(this, arguments)); + } + + _createClass(TreemapSVG, [{ + key: 'getCircularNodes', + value: function getCircularNodes() { + var _props = this.props, + animation = _props.animation, + hideRootNode = _props.hideRootNode, + nodes = _props.nodes, + onLeafMouseOver = _props.onLeafMouseOver, + onLeafMouseOut = _props.onLeafMouseOut, + onLeafClick = _props.onLeafClick, + scales = _props.scales, + style = _props.style; + + var _nodes$reduce = nodes.reduce(function (acc, node, index) { + if (!index && hideRootNode) { + return acc; + } + var x = node.x, + y = node.y, + r = node.r; + + return { + maxY: Math.max(y + r, acc.maxY), + minY: Math.min(y - r, acc.minY), + maxX: Math.max(x + MARGIN_ADJUST * r, acc.maxX), + minX: Math.min(x - MARGIN_ADJUST * r, acc.minX), + rows: acc.rows.concat([{ + x: x, + y: y, + size: r, + color: scales.color(node) + }]) + }; + }, { + rows: [], + maxY: -Infinity, + minY: Infinity, + maxX: -Infinity, + minX: Infinity + }), + rows = _nodes$reduce.rows, + minY = _nodes$reduce.minY, + maxY = _nodes$reduce.maxY, + minX = _nodes$reduce.minX, + maxX = _nodes$reduce.maxX; + + return { + updatedNodes: _react2.default.createElement(_markSeries2.default, { + animation: animation, + className: 'rv-treemap__leaf rv-treemap__leaf--circle', + onSeriesMouseEnter: onLeafMouseOver, + onSeriesMouseLeave: onLeafMouseOut, + onSeriesClick: onLeafClick, + data: rows, + colorType: 'literal', + getColor: function getColor(d) { + return d.color; + }, + sizeType: 'literal', + getSize: function getSize(d) { + return d.size; + }, + style: style + }), + minY: minY, + maxY: maxY, + minX: minX, + maxX: maxX + }; + } + }, { + key: 'getNonCircularNodes', + value: function getNonCircularNodes() { + var _props2 = this.props, + animation = _props2.animation, + hideRootNode = _props2.hideRootNode, + nodes = _props2.nodes, + onLeafMouseOver = _props2.onLeafMouseOver, + onLeafMouseOut = _props2.onLeafMouseOut, + onLeafClick = _props2.onLeafClick, + scales = _props2.scales, + style = _props2.style; + var color = scales.color; + + return nodes.reduce(function (acc, node, index) { + if (!index && hideRootNode) { + return acc; + } + var x0 = node.x0, + x1 = node.x1, + y1 = node.y1, + y0 = node.y0; + + var x = x0; + var y = y0; + var nodeHeight = y1 - y0; + var nodeWidth = x1 - x0; + + acc.maxY = Math.max(y + nodeHeight, acc.maxY); + acc.minY = Math.min(y, acc.minY); + acc.maxX = Math.max(x + nodeWidth, acc.maxX); + acc.minX = Math.min(x, acc.minX); + + var data = [{ x: x, y: y }, { x: x, y: y + nodeHeight }, { x: x + nodeWidth, y: y + nodeHeight }, { x: x + nodeWidth, y: y }]; + + acc.updatedNodes = acc.updatedNodes.concat([_react2.default.createElement(_polygonSeries2.default, { + animation: animation, + className: 'rv-treemap__leaf', + key: index, + color: color(node), + type: 'literal', + onSeriesMouseEnter: onLeafMouseOver, + onSeriesMouseLeave: onLeafMouseOut, + onSeriesClick: onLeafClick, + data: data, + style: _extends({}, style, node.style) + })]); + return acc; + }, { + updatedNodes: [], + maxY: -Infinity, + minY: Infinity, + maxX: -Infinity, + minX: Infinity + }); + } + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + className = _props3.className, + height = _props3.height, + mode = _props3.mode, + nodes = _props3.nodes, + width = _props3.width; + + var useCirclePacking = mode === 'circlePack'; + + var _ref = useCirclePacking ? this.getCircularNodes() : this.getNonCircularNodes(), + minY = _ref.minY, + maxY = _ref.maxY, + minX = _ref.minX, + maxX = _ref.maxX, + updatedNodes = _ref.updatedNodes; + + var labels = nodes.reduce(function (acc, node) { + if (!node.data.title) { + return acc; + } + return acc.concat(_extends({}, node.data, { + x: node.x0 || node.x, + y: node.y0 || node.y, + label: '' + node.data.title + })); + }, []); + + return _react2.default.createElement( + _xyPlot2.default, + _extends({ + className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, + width: width, + height: height, + yDomain: [maxY, minY], + xDomain: [minX, maxX], + colorType: 'literal', + hasTreeStructure: true + }, this.props), + updatedNodes, + _react2.default.createElement(_labelSeries2.default, { data: labels }) + ); + } + }]); + + return TreemapSVG; +}(_react2.default.Component); + +TreemapSVG.displayName = 'TreemapSVG'; + +exports.default = TreemapSVG; \ No newline at end of file diff --git a/dist/utils/axis-utils.js b/dist/utils/axis-utils.js new file mode 100644 index 000000000..db9f09fa9 --- /dev/null +++ b/dist/utils/axis-utils.js @@ -0,0 +1,167 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.DIRECTION = exports.ORIENTATION = undefined; +exports.getTicksTotalFromSize = getTicksTotalFromSize; +exports.getTickValues = getTickValues; +exports.generateFit = generateFit; +exports.generatePoints = generatePoints; +exports.getAxisAngle = getAxisAngle; + +var _d3Array = require('d3-array'); + +var _d3Scale = require('d3-scale'); + +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +var ORIENTATION = exports.ORIENTATION = { + TOP: 'top', + LEFT: 'left', + RIGHT: 'right', + BOTTOM: 'bottom', + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' +}; + +var DIRECTION = exports.DIRECTION = { + VERTICAL: 'vertical', + HORIZONTAL: 'horizontal' +}; + +/** + * Get total amount of ticks from a given size in pixels. + * @param {number} size Size of the axis in pixels. + * @returns {number} Total amount of ticks. + */ +function getTicksTotalFromSize(size) { + if (size < 700) { + if (size > 300) { + return 10; + } + return 5; + } + return 20; +} + +/** + * Get the tick values from a given d3 scale. + * @param {d3.scale} scale Scale function. + * @param {number} tickTotal Total number of ticks + * @param {Array} tickValues Array of tick values if they exist. + * @returns {Array} Array of tick values. + */ +function getTickValues(scale, tickTotal, tickValues) { + return !tickValues ? scale.ticks ? scale.ticks(tickTotal) : scale.domain() : tickValues; +} + +/** + * Generate a description of a decorative axis in terms of a linear equation + * y = slope * x + offset in coordinates + * @param {Object} axisStart Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @param {Object} axisEnd Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @returns {Number} Object describing each the line in coordinates + */ +function generateFit(axisStart, axisEnd) { + // address the special case when the slope is infinite + if (axisStart.x === axisEnd.x) { + return { + left: axisStart.y, + right: axisEnd.y, + slope: 0, + offset: axisStart.x + }; + } + var slope = (axisStart.y - axisEnd.y) / (axisStart.x - axisEnd.x); + return { + left: axisStart.x, + right: axisEnd.x, + // generate the linear projection of the axis direction + slope: slope, + offset: axisStart.y - slope * axisStart.x + }; +} + +/** + * Generate a description of a decorative axis in terms of a linear equation + * y = slope * x + offset in coordinates + * @param props + * props.@param {Object} axisStart Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * props.@param {Object} axisEnd Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * props.@param {Number} numberOfTicks The number of ticks on the axis + * props.@param {Array.Numbers} axisDomain The values to be interpolated across for the axis + * @returns {Number} Object describing the slope and the specific coordinates of the points + */ +function generatePoints(_ref) { + var axisStart = _ref.axisStart, + axisEnd = _ref.axisEnd, + numberOfTicks = _ref.numberOfTicks, + axisDomain = _ref.axisDomain; + + var _generateFit = generateFit(axisStart, axisEnd), + left = _generateFit.left, + right = _generateFit.right, + slope = _generateFit.slope, + offset = _generateFit.offset; + // construct a linear band of points, then map them + + + var pointSlope = (right - left) / numberOfTicks; + var axisScale = (0, _d3Scale.scaleLinear)().domain([left, right]).range(axisDomain); + + var slopeVertical = axisStart.x === axisEnd.x; + return { + slope: slopeVertical ? Infinity : slope, + points: (0, _d3Array.range)(left, right + pointSlope, pointSlope).map(function (val) { + if (slopeVertical) { + return { y: val, x: slope * val + offset, text: axisScale(val) }; + } + return { x: val, y: slope * val + offset, text: axisScale(val) }; + }).slice(0, numberOfTicks + 1) + }; +} + +/** + * Compute the angle (in radians) of a decorative axis + * @param {Object} axisStart Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @param {Object} axisEnd Object of format {x, y} describing in coordinates + * the start position of the decorative axis + * @returns {Number} Angle in radials + */ +function getAxisAngle(axisStart, axisEnd) { + if (axisStart.x === axisEnd.x) { + return axisEnd.y > axisStart.y ? Math.PI / 2 : 3 * Math.PI / 2; + } + return Math.atan((axisEnd.y - axisStart.y) / (axisEnd.x - axisStart.x)); +} + +exports.default = { + DIRECTION: DIRECTION, + ORIENTATION: ORIENTATION, + getTicksTotalFromSize: getTicksTotalFromSize, + getTickValues: getTickValues +}; \ No newline at end of file diff --git a/dist/utils/chart-utils.js b/dist/utils/chart-utils.js new file mode 100644 index 000000000..296899ae8 --- /dev/null +++ b/dist/utils/chart-utils.js @@ -0,0 +1,104 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.DEFAULT_MARGINS = exports.MarginPropType = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.getInnerDimensions = getInnerDimensions; +exports.getRadialLayoutMargin = getRadialLayoutMargin; + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Get the dimensions of the component for the future use. + * @param {Object} props Props. + * @param {Object} defaultMargins Object with default margins. + * @returns {Object} Dimensions of the component. + */ +function getInnerDimensions(props, defaultMargins) { + var margin = props.margin, + width = props.width, + height = props.height; + + var marginProps = _extends({}, defaultMargins, typeof margin === 'number' ? { + left: margin, + right: margin, + top: margin, + bottom: margin + } : margin); + var _marginProps$left = marginProps.left, + marginLeft = _marginProps$left === undefined ? 0 : _marginProps$left, + _marginProps$top = marginProps.top, + marginTop = _marginProps$top === undefined ? 0 : _marginProps$top, + _marginProps$right = marginProps.right, + marginRight = _marginProps$right === undefined ? 0 : _marginProps$right, + _marginProps$bottom = marginProps.bottom, + marginBottom = _marginProps$bottom === undefined ? 0 : _marginProps$bottom; + + return { + marginLeft: marginLeft, + marginTop: marginTop, + marginRight: marginRight, + marginBottom: marginBottom, + innerHeight: height - marginBottom - marginTop, + innerWidth: width - marginLeft - marginRight + }; +} + +/** + * Calculate the margin of the sunburst, + * so it can be at the center of the container + * @param {Number} width - the width of the container + * @param {Number} height - the height of the container + * @param {Number} radius - the max radius of the sunburst + * @return {Object} an object includes {bottom, left, right, top} + */ +function getRadialLayoutMargin(width, height, radius) { + var marginX = width / 2 - radius; + var marginY = height / 2 - radius; + return { + bottom: marginY, + left: marginX, + right: marginX, + top: marginY + }; +} + +var MarginPropType = exports.MarginPropType = _propTypes2.default.oneOfType([_propTypes2.default.shape({ + left: _propTypes2.default.number, + top: _propTypes2.default.number, + right: _propTypes2.default.number, + bottom: _propTypes2.default.number +}), _propTypes2.default.number]); + +var DEFAULT_MARGINS = exports.DEFAULT_MARGINS = { + left: 40, + right: 10, + top: 10, + bottom: 40 +}; \ No newline at end of file diff --git a/dist/utils/data-utils.js b/dist/utils/data-utils.js new file mode 100644 index 000000000..af24379d4 --- /dev/null +++ b/dist/utils/data-utils.js @@ -0,0 +1,54 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getUniquePropertyValues = getUniquePropertyValues; +exports.addValueToArray = addValueToArray; +// Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/** + * Get unique property values from an array. + * @param {Array} arr Array of data. + * @param {string} propertyName Prop name. + * @returns {Array} Array of unique values. + */ +function getUniquePropertyValues(arr, accessor) { + var setOfValues = new Set(arr.map(accessor)); + return Array.from(setOfValues); +} + +/** + * Add zero to the domain. + * @param {Array} arr Add zero to the domain. + * @param {Number} value Add zero to domain. + * @returns {Array} Adjusted domain. + */ +function addValueToArray(arr, value) { + var result = [].concat(arr); + if (result[0] > value) { + result[0] = value; + } + if (result[result.length - 1] < value) { + result[result.length - 1] = value; + } + return result; +} \ No newline at end of file diff --git a/dist/utils/react-utils.js b/dist/utils/react-utils.js new file mode 100644 index 000000000..7bc856814 --- /dev/null +++ b/dist/utils/react-utils.js @@ -0,0 +1,95 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getDOMNode = exports.isReactDOMSupported = undefined; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.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 (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.warning = warning; +exports.warnOnce = warnOnce; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _React$version$split = _react2.default.version.split('.'), + _React$version$split2 = _slicedToArray(_React$version$split, 2), + major = _React$version$split2[0], + minor = _React$version$split2[1]; + +var versionHigherThanThirteen = Number(minor) > 13 || Number(major) > 13; + +var isReactDOMSupported = exports.isReactDOMSupported = function isReactDOMSupported() { + return versionHigherThanThirteen; +}; + +/** + * Support React 0.13 and greater where refs are React components, not DOM + * nodes. + * @param {*} ref React's ref. + * @returns {Element} DOM element. + */ +var getDOMNode = exports.getDOMNode = function getDOMNode(ref) { + if (!isReactDOMSupported()) { + return ref && ref.getDOMNode(); + } + return ref; +}; + +var USED_MESSAGES = {}; +var HIDDEN_PROCESSES = { + test: true, + production: true +}; + +/** + * Warn the user about something + * @param {String} message - the message to be shown + * @param {Boolean} onlyShowMessageOnce - whether or not we allow the + - message to be show multiple times + */ +function warning(message) { + var onlyShowMessageOnce = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + /* eslint-disable no-undef, no-process-env */ + if (global.process && HIDDEN_PROCESSES[process.env.NODE_ENV]) { + return; + } + /* eslint-enable no-undef, no-process-env */ + if (!onlyShowMessageOnce || !USED_MESSAGES[message]) { + /* eslint-disable no-console */ + console.warn(message); + /* eslint-enable no-console */ + USED_MESSAGES[message] = true; + } +} + +/** + * Convience wrapper for warning + * @param {String} message - the message to be shown + */ +function warnOnce(message) { + warning(message, true); +} \ No newline at end of file diff --git a/dist/utils/series-utils.js b/dist/utils/series-utils.js new file mode 100644 index 000000000..7e1796dbe --- /dev/null +++ b/dist/utils/series-utils.js @@ -0,0 +1,268 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ANIMATED_SERIES_PROPS = undefined; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +exports.isSeriesChild = isSeriesChild; +exports.getSeriesChildren = getSeriesChildren; +exports.getStackedData = getStackedData; +exports.getSeriesPropsFromChildren = getSeriesPropsFromChildren; +exports.getRadialDomain = getRadialDomain; +exports.getStackParams = getStackParams; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _abstractSeries = require('../plot/series/abstract-series'); + +var _abstractSeries2 = _interopRequireDefault(_abstractSeries); + +var _theme = require('../theme'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +/** + * Check if the component is series or not. + * @param {React.Component} child Component. + * @returns {boolean} True if the child is series, false otherwise. + */ +function isSeriesChild(child) { + var prototype = child.type.prototype; + + return prototype instanceof _abstractSeries2.default; +} + +/** + * Get all series from the 'children' object of the component. + * @param {Object} children Children. + * @returns {Array} Array of children. + */ +function getSeriesChildren(children) { + return _react2.default.Children.toArray(children).filter(function (child) { + return child && isSeriesChild(child); + }); +} + +/** + * Collect the map of repetitions of the series type for all children. + * @param {Array} children Array of children. + * @returns {{}} Map of repetitions where sameTypeTotal is the total amount and + * sameTypeIndex is always 0. + */ +function collectSeriesTypesInfo(children) { + var result = {}; + children.filter(isSeriesChild).forEach(function (child) { + var displayName = child.type.displayName; + var cluster = child.props.cluster; + + if (!result[displayName]) { + result[displayName] = { + sameTypeTotal: 0, + sameTypeIndex: 0, + clusters: new Set() + }; + } + result[displayName].clusters.add(cluster); + result[displayName].sameTypeTotal++; + }); + return result; +} + +/** + * Check series to see if it has angular data that needs to be converted + * @param {Array} data - an array of objects to check + * @returns {Boolean} whether or not this series contains polar configuration + */ +function seriesHasAngleRadius() { + var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (!data) { + return false; + } + return data.some(function (row) { + return row.radius && row.angle; + }); +} + +/** + * Possibly convert polar coordinates to x/y for computing domain + * @param {Array} data - an array of objects to check + * @param {String} attr - the property being checked + * @returns {Boolean} whether or not this series contains polar configuration + */ +function prepareData(data) { + if (!seriesHasAngleRadius(data)) { + return data; + } + + return data.map(function (row) { + return _extends({}, row, { + x: row.radius * Math.cos(row.angle), + y: row.radius * Math.sin(row.angle) + }); + }); +} + +/** + * Collect the stacked data for all children in use. If the children don't have + * the data (e.g. the child is invalid series or something else), then the child + * is skipped. + * Each next value of attr is equal to the previous value plus the difference + * between attr0 and attr. + * @param {Array} children Array of children. + * @param {string} attr Attribute to stack by. + * @returns {Array} New array of children for the series. + */ +function getStackedData(children, attr) { + var areSomeSeriesStacked = children.some(function (series) { + return series && series.props.stack; + }); + // It stores the last segment position added to each bar, separated by cluster. + var latestAttrPositions = {}; + + return children.reduce(function (accumulator, series, seriesIndex) { + // Skip the children that are not series (e.g. don't have any data). + if (!series) { + accumulator.push(null); + return accumulator; + } + + var _series$props = series.props, + data = _series$props.data, + _series$props$cluster = _series$props.cluster, + cluster = _series$props$cluster === undefined ? 'default' : _series$props$cluster, + stack = _series$props.stack; + + var preppedData = prepareData(data, attr); + + if (!attr || !preppedData || !preppedData.length || areSomeSeriesStacked && !stack) { + accumulator.push(preppedData); + return accumulator; + } + + var attr0 = attr + '0'; + var baseAttr = attr === 'y' ? 'x' : 'y'; + + accumulator.push(preppedData.map(function (d, dIndex) { + var _extends2, _latestAttrPositions$2; + + if (!latestAttrPositions[cluster]) { + latestAttrPositions[cluster] = {}; + } + + var prevD = latestAttrPositions[cluster][d[baseAttr]]; + // It is the first segment of a bar. + if (!prevD) { + var _latestAttrPositions$; + + latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$ = {}, _defineProperty(_latestAttrPositions$, attr0, d[attr0]), _defineProperty(_latestAttrPositions$, attr, d[attr]), _latestAttrPositions$); + + return _extends({}, d); + } + + // Calculate the position of the next segment in a bar. + var nextD = _extends({}, d, (_extends2 = {}, _defineProperty(_extends2, attr0, prevD[attr]), _defineProperty(_extends2, attr, prevD[attr] + d[attr] - (d[attr0] || 0)), _extends2)); + + latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$2 = {}, _defineProperty(_latestAttrPositions$2, attr0, nextD[attr0]), _defineProperty(_latestAttrPositions$2, attr, nextD[attr]), _latestAttrPositions$2); + + return nextD; + })); + + return accumulator; + }, []); +} + +/** + * Get the list of series props for a child. + * @param {Array} children Array of all children. + * @returns {Array} Array of series props for each child. If a child is not a + * series, than it's undefined. + */ +function getSeriesPropsFromChildren(children) { + var result = []; + var seriesTypesInfo = collectSeriesTypesInfo(children); + var seriesIndex = 0; + var _opacityValue = _theme.DEFAULT_OPACITY; + children.forEach(function (child) { + var props = void 0; + if (isSeriesChild(child)) { + var seriesTypeInfo = seriesTypesInfo[child.type.displayName]; + var _colorValue = _theme.DISCRETE_COLOR_RANGE[seriesIndex % _theme.DISCRETE_COLOR_RANGE.length]; + props = _extends({}, seriesTypeInfo, { + seriesIndex: seriesIndex, + _colorValue: _colorValue, + _opacityValue: _opacityValue + }); + seriesTypeInfo.sameTypeIndex++; + seriesIndex++; + if (child.props.cluster) { + props.cluster = child.props.cluster; + // Using Array.from() so we can use .indexOf + props.clusters = Array.from(seriesTypeInfo.clusters); + props.sameTypeTotal = props.clusters.length; + props.sameTypeIndex = props.clusters.indexOf(child.props.cluster); + } + } + result.push(props); + }); + return result; +} + +/** + * Find the max radius value from the nodes to be rendered after they have been + * transformed into an array + * @param {Array} data - the tree data after it has been broken into a iterable + * it is an array of objects! + * @returns {number} the maximum value in coordinates for the radial variable + */ +function getRadialDomain(data) { + return data.reduce(function (res, row) { + return Math.max(row.radius, res); + }, 0); +} + +var ANIMATED_SERIES_PROPS = exports.ANIMATED_SERIES_PROPS = ['xRange', 'xDomain', 'x', 'yRange', 'yDomain', 'y', 'colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'strokeRange', 'strokeDomain', 'stroke', 'fillRange', 'fillDomain', 'fill', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'data', 'angleDomain', 'angleRange', 'angle', 'radiusDomain', 'radiusRange', 'radius', 'innerRadiusDomain', 'innerRadiusRange', 'innerRadius']; + +function getStackParams(props) { + var _stackBy = props._stackBy, + valuePosAttr = props.valuePosAttr, + cluster = props.cluster; + var _props$sameTypeTotal = props.sameTypeTotal, + sameTypeTotal = _props$sameTypeTotal === undefined ? 1 : _props$sameTypeTotal, + _props$sameTypeIndex = props.sameTypeIndex, + sameTypeIndex = _props$sameTypeIndex === undefined ? 0 : _props$sameTypeIndex; + + // If bars are stacked, but not clustering, override `sameTypeTotal` and + // `sameTypeIndex` such that bars are stacked and not staggered. + + if (_stackBy === valuePosAttr && !cluster) { + sameTypeTotal = 1; + sameTypeIndex = 0; + } + return { sameTypeTotal: sameTypeTotal, sameTypeIndex: sameTypeIndex }; +} \ No newline at end of file From b187601d1162298e29cf32621b2a6fac15d9a63f Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Wed, 21 Nov 2018 12:25:06 +0100 Subject: [PATCH 08/10] Removing redundant temp dist. --- dist/animation.js | 188 ---- dist/dist.min.js | 23 - dist/index.js | 340 ------- dist/legends/continuous-color-legend.js | 107 -- dist/legends/continuous-size-legend.js | 116 --- dist/legends/discrete-color-legend-item.js | 103 -- dist/legends/discrete-color-legend.js | 107 -- .../searchable-discrete-color-legend.js | 107 -- dist/main.scss | 9 - dist/make-vis-flexible.js | 250 ----- dist/parallel-coordinates/index.js | 360 ------- dist/plot/axis/axis-line.js | 99 -- dist/plot/axis/axis-ticks.js | 271 ------ dist/plot/axis/axis-title.js | 186 ---- dist/plot/axis/axis.js | 264 ----- dist/plot/axis/decorative-axis-ticks.js | 99 -- dist/plot/axis/decorative-axis.js | 174 ---- dist/plot/axis/x-axis.js | 66 -- dist/plot/axis/y-axis.js | 66 -- dist/plot/borders.js | 125 --- dist/plot/chart-label.js | 112 --- dist/plot/circular-grid-lines.js | 165 ---- dist/plot/crosshair.js | 262 ----- dist/plot/gradient-defs.js | 58 -- dist/plot/grid-lines.js | 178 ---- dist/plot/highlight.js | 426 -------- dist/plot/hint.js | 454 --------- dist/plot/horizontal-grid-lines.js | 64 -- dist/plot/series/abstract-series.js | 415 -------- dist/plot/series/arc-series.js | 279 ------ dist/plot/series/area-series.js | 160 --- dist/plot/series/bar-series-canvas.js | 161 --- dist/plot/series/bar-series.js | 180 ---- dist/plot/series/canvas-wrapper.js | 256 ----- dist/plot/series/contour-series.js | 164 ---- dist/plot/series/custom-svg-series.js | 237 ----- dist/plot/series/heatmap-series.js | 147 --- dist/plot/series/hexbin-series.js | 180 ---- .../series/horizontal-bar-series-canvas.js | 97 -- dist/plot/series/horizontal-bar-series.js | 85 -- .../series/horizontal-rect-series-canvas.js | 97 -- dist/plot/series/horizontal-rect-series.js | 85 -- dist/plot/series/label-series.js | 200 ---- dist/plot/series/line-mark-series-canvas.js | 87 -- dist/plot/series/line-mark-series.js | 102 -- dist/plot/series/line-series-canvas.js | 146 --- dist/plot/series/line-series.js | 177 ---- dist/plot/series/mark-series-canvas.js | 109 --- dist/plot/series/mark-series.js | 179 ---- dist/plot/series/polygon-series.js | 126 --- dist/plot/series/rect-series-canvas.js | 136 --- dist/plot/series/rect-series.js | 151 --- .../plot/series/vertical-bar-series-canvas.js | 97 -- dist/plot/series/vertical-bar-series.js | 85 -- .../series/vertical-rect-series-canvas.js | 97 -- dist/plot/series/vertical-rect-series.js | 85 -- dist/plot/series/whisker-series.js | 274 ------ dist/plot/vertical-grid-lines.js | 64 -- dist/plot/voronoi.js | 148 --- dist/plot/xy-plot.js | 660 ------------- dist/radar-chart/index.js | 418 -------- dist/radial-chart/index.js | 263 ----- dist/sankey/index.js | 238 ----- dist/sankey/sankey-link.js | 85 -- dist/style.css | 1 - dist/styles/examples.scss | 461 --------- dist/styles/legends.scss | 137 --- dist/styles/plot.scss | 128 --- dist/styles/radial-chart.scss | 6 - dist/styles/treemap.scss | 22 - dist/sunburst/index.js | 253 ----- dist/theme.js | 42 - dist/treemap/index.js | 254 ----- dist/treemap/treemap-dom.js | 82 -- dist/treemap/treemap-leaf.js | 125 --- dist/treemap/treemap-svg.js | 246 ----- dist/utils/axis-utils.js | 167 ---- dist/utils/chart-utils.js | 104 -- dist/utils/data-utils.js | 54 -- dist/utils/react-utils.js | 95 -- dist/utils/scales-utils.js | 916 ------------------ dist/utils/series-utils.js | 268 ----- 82 files changed, 14610 deletions(-) delete mode 100644 dist/animation.js delete mode 100644 dist/dist.min.js delete mode 100644 dist/index.js delete mode 100644 dist/legends/continuous-color-legend.js delete mode 100644 dist/legends/continuous-size-legend.js delete mode 100644 dist/legends/discrete-color-legend-item.js delete mode 100644 dist/legends/discrete-color-legend.js delete mode 100644 dist/legends/searchable-discrete-color-legend.js delete mode 100644 dist/main.scss delete mode 100644 dist/make-vis-flexible.js delete mode 100644 dist/parallel-coordinates/index.js delete mode 100644 dist/plot/axis/axis-line.js delete mode 100644 dist/plot/axis/axis-ticks.js delete mode 100644 dist/plot/axis/axis-title.js delete mode 100644 dist/plot/axis/axis.js delete mode 100644 dist/plot/axis/decorative-axis-ticks.js delete mode 100644 dist/plot/axis/decorative-axis.js delete mode 100644 dist/plot/axis/x-axis.js delete mode 100644 dist/plot/axis/y-axis.js delete mode 100644 dist/plot/borders.js delete mode 100644 dist/plot/chart-label.js delete mode 100644 dist/plot/circular-grid-lines.js delete mode 100644 dist/plot/crosshair.js delete mode 100644 dist/plot/gradient-defs.js delete mode 100644 dist/plot/grid-lines.js delete mode 100644 dist/plot/highlight.js delete mode 100644 dist/plot/hint.js delete mode 100644 dist/plot/horizontal-grid-lines.js delete mode 100644 dist/plot/series/abstract-series.js delete mode 100644 dist/plot/series/arc-series.js delete mode 100644 dist/plot/series/area-series.js delete mode 100644 dist/plot/series/bar-series-canvas.js delete mode 100644 dist/plot/series/bar-series.js delete mode 100644 dist/plot/series/canvas-wrapper.js delete mode 100644 dist/plot/series/contour-series.js delete mode 100644 dist/plot/series/custom-svg-series.js delete mode 100644 dist/plot/series/heatmap-series.js delete mode 100644 dist/plot/series/hexbin-series.js delete mode 100644 dist/plot/series/horizontal-bar-series-canvas.js delete mode 100644 dist/plot/series/horizontal-bar-series.js delete mode 100644 dist/plot/series/horizontal-rect-series-canvas.js delete mode 100644 dist/plot/series/horizontal-rect-series.js delete mode 100644 dist/plot/series/label-series.js delete mode 100644 dist/plot/series/line-mark-series-canvas.js delete mode 100644 dist/plot/series/line-mark-series.js delete mode 100644 dist/plot/series/line-series-canvas.js delete mode 100644 dist/plot/series/line-series.js delete mode 100644 dist/plot/series/mark-series-canvas.js delete mode 100644 dist/plot/series/mark-series.js delete mode 100644 dist/plot/series/polygon-series.js delete mode 100644 dist/plot/series/rect-series-canvas.js delete mode 100644 dist/plot/series/rect-series.js delete mode 100644 dist/plot/series/vertical-bar-series-canvas.js delete mode 100644 dist/plot/series/vertical-bar-series.js delete mode 100644 dist/plot/series/vertical-rect-series-canvas.js delete mode 100644 dist/plot/series/vertical-rect-series.js delete mode 100644 dist/plot/series/whisker-series.js delete mode 100644 dist/plot/vertical-grid-lines.js delete mode 100644 dist/plot/voronoi.js delete mode 100644 dist/plot/xy-plot.js delete mode 100644 dist/radar-chart/index.js delete mode 100644 dist/radial-chart/index.js delete mode 100644 dist/sankey/index.js delete mode 100644 dist/sankey/sankey-link.js delete mode 100644 dist/style.css delete mode 100644 dist/styles/examples.scss delete mode 100644 dist/styles/legends.scss delete mode 100644 dist/styles/plot.scss delete mode 100644 dist/styles/radial-chart.scss delete mode 100644 dist/styles/treemap.scss delete mode 100644 dist/sunburst/index.js delete mode 100644 dist/theme.js delete mode 100644 dist/treemap/index.js delete mode 100644 dist/treemap/treemap-dom.js delete mode 100644 dist/treemap/treemap-leaf.js delete mode 100644 dist/treemap/treemap-svg.js delete mode 100644 dist/utils/axis-utils.js delete mode 100644 dist/utils/chart-utils.js delete mode 100644 dist/utils/data-utils.js delete mode 100644 dist/utils/react-utils.js delete mode 100644 dist/utils/scales-utils.js delete mode 100644 dist/utils/series-utils.js diff --git a/dist/animation.js b/dist/animation.js deleted file mode 100644 index 9638ef2d6..000000000 --- a/dist/animation.js +++ /dev/null @@ -1,188 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.AnimationPropType = undefined; - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -exports.extractAnimatedPropValues = extractAnimatedPropValues; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Interpolate = require('d3-interpolate'); - -var _reactMotion = require('react-motion'); - -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; } - -function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - -var ANIMATION_PROPTYPES = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({ - stiffness: _propTypes2.default.number, - nonAnimatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string), - damping: _propTypes2.default.number -}), _propTypes2.default.bool]); - -var propTypes = { - animatedProps: _propTypes2.default.arrayOf(_propTypes2.default.string).isRequired, - animation: ANIMATION_PROPTYPES, - onStart: _propTypes2.default.func, - onEnd: _propTypes2.default.func -}; - -/** - * Format the animation style object - * @param {Object|String} animationStyle - The animation style property, either the name of a - * presets are one of noWobble, gentle, wobbly, stiff - */ -function getAnimationStyle() { - var animationStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _reactMotion.presets.noWobble; - - if (typeof animationStyle === 'string') { - return _reactMotion.presets[animationStyle] || _reactMotion.presets.noWobble; - } - var damping = animationStyle.damping, - stiffness = animationStyle.stiffness; - - return _extends({ - damping: damping || _reactMotion.presets.noWobble.damping, - stiffness: stiffness || _reactMotion.presets.noWobble.stiffness - }, animationStyle); -} - -/** - * Extract the animated props from the entire props object. - * @param {Object} props Props. - * @returns {Object} Object of animated props. - */ -function extractAnimatedPropValues(props) { - var animatedProps = props.animatedProps, - otherProps = _objectWithoutProperties(props, ['animatedProps']); - - return animatedProps.reduce(function (result, animatedPropName) { - if (otherProps.hasOwnProperty(animatedPropName)) { - result[animatedPropName] = otherProps[animatedPropName]; - } - return result; - }, {}); -} - -var Animation = function (_PureComponent) { - _inherits(Animation, _PureComponent); - - function Animation(props) { - _classCallCheck(this, Animation); - - var _this = _possibleConstructorReturn(this, (Animation.__proto__ || Object.getPrototypeOf(Animation)).call(this, props)); - - _this._motionEndHandler = function () { - if (_this.props.onEnd) { - _this.props.onEnd(); - } - }; - - _this._renderChildren = function (_ref) { - var i = _ref.i; - var children = _this.props.children; - - var interpolator = _this._interpolator; - var child = _react2.default.Children.only(children); - var interpolatedProps = interpolator ? interpolator(i) : interpolator; - - // interpolator doesnt play nice with deeply nested objected - // so we expose an additional prop for situations like these, soit _data, - // which stores the full tree and can be recombined with the sanitized version - // after interpolation - var data = interpolatedProps && interpolatedProps.data || null; - if (data && child.props._data) { - data = data.map(function (row, index) { - var correspondingCell = child.props._data[index]; - return _extends({}, row, { - parent: correspondingCell.parent, - children: correspondingCell.children - }); - }); - } - - return _react2.default.cloneElement(child, _extends({}, child.props, interpolatedProps, { - data: data || child.props.data || null, - // enforce re-rendering - _animation: Math.random() - })); - }; - - _this._updateInterpolator(props); - return _this; - } - - _createClass(Animation, [{ - key: 'componentWillUpdate', - value: function componentWillUpdate(props) { - this._updateInterpolator(this.props, props); - if (props.onStart) { - props.onStart(); - } - } - - /** - * Render the child into the parent. - * @param {Number} i Number generated by the spring. - * @returns {React.Component} Rendered react element. - * @private - */ - - }, { - key: '_updateInterpolator', - - - /** - * Update the interpolator function and assign it to this._interpolator. - * @param {Object} oldProps Old props. - * @param {Object} newProps New props. - * @private - */ - value: function _updateInterpolator(oldProps, newProps) { - this._interpolator = (0, _d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps), newProps ? extractAnimatedPropValues(newProps) : null); - } - }, { - key: 'render', - value: function render() { - var animationStyle = getAnimationStyle(this.props.animation); - var defaultStyle = { i: 0 }; - var style = { i: (0, _reactMotion.spring)(1, animationStyle) }; - // In order to make Motion re-run animations each time, the random key is - // always passed. - // TODO: find a better solution for the spring. - var key = Math.random(); - return _react2.default.createElement( - _reactMotion.Motion, - _extends({ defaultStyle: defaultStyle, style: style, key: key }, { onRest: this._motionEndHandler }), - this._renderChildren - ); - } - }]); - - return Animation; -}(_react.PureComponent); - -Animation.propTypes = propTypes; -Animation.displayName = 'Animation'; - -exports.default = Animation; -var AnimationPropType = exports.AnimationPropType = ANIMATION_PROPTYPES; \ No newline at end of file diff --git a/dist/dist.min.js b/dist/dist.min.js deleted file mode 100644 index 7e2599c21..000000000 --- a/dist/dist.min.js +++ /dev/null @@ -1,23 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.reactVis=f()}})(function(){var define,module,exports;return function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o1){for(var i=1;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}if(newThis!==component&&newThis!==null){if(process.env.NODE_ENV!=="production"){warning(false,"bind(): React component methods may only be bound to the "+"component instance. See %s",componentName)}}else if(!args.length){if(process.env.NODE_ENV!=="production"){warning(false,"bind(): You are binding a component method to the component. "+"React does this for you automatically in a high-performance "+"way, so you can safely remove this call. See %s",componentName)}return boundMethod}var reboundMethod=_bind.apply(boundMethod,arguments);reboundMethod.__reactBoundContext=component;reboundMethod.__reactBoundMethod=method;reboundMethod.__reactBoundArguments=args;return reboundMethod}}return boundMethod}function bindAutoBindMethods(component){var pairs=component.__reactAutoBindPairs;for(var i=0;ib?1:a>=b?0:NaN};var bisector=function(compare){if(compare.length===1)compare=ascendingComparator(compare);return{left:function(a,x,lo,hi){if(lo==null)lo=0;if(hi==null)hi=a.length;while(lo>>1;if(compare(a[mid],x)<0)lo=mid+1;else hi=mid}return lo},right:function(a,x,lo,hi){if(lo==null)lo=0;if(hi==null)hi=a.length;while(lo>>1;if(compare(a[mid],x)>0)hi=mid;else lo=mid+1}return lo}}};function ascendingComparator(f){return function(d,x){return ascending(f(d),x)}}var ascendingBisect=bisector(ascending);var bisectRight=ascendingBisect.right;var bisectLeft=ascendingBisect.left;var pairs=function(array,f){if(f==null)f=pair;var i=0,n=array.length-1,p=array[0],pairs=new Array(n<0?0:n);while(ia?1:b>=a?0:NaN};var number=function(x){return x===null?NaN:+x};var variance=function(values,valueof){var n=values.length,m=0,i=-1,mean=0,value,delta,sum=0;if(valueof==null){while(++i1)return sum/(m-1)};var deviation=function(array,f){var v=variance(array,f);return v?Math.sqrt(v):v};var extent=function(values,valueof){var n=values.length,i=-1,value,min,max;if(valueof==null){while(++i=value){min=max=value;while(++ivalue)min=value;if(max=value){min=max=value;while(++ivalue)min=value;if(max0)return[start];if(reverse=stop0){start=Math.ceil(start/step);stop=Math.floor(stop/step);ticks=new Array(n=Math.ceil(stop-start+1));while(++i=0?(error>=e10?10:error>=e5?5:error>=e2?2:1)*Math.pow(10,power):-Math.pow(10,-power)/(error>=e10?10:error>=e5?5:error>=e2?2:1)}function tickStep(start,stop,count){var step0=Math.abs(stop-start)/Math.max(0,count),step1=Math.pow(10,Math.floor(Math.log(step0)/Math.LN10)),error=step0/step1;if(error>=e10)step1*=10;else if(error>=e5)step1*=5;else if(error>=e2)step1*=2;return stopx1)tz.pop(),--m;var bins=new Array(m+1),bin;for(i=0;i<=m;++i){bin=bins[i]=[];bin.x0=i>0?tz[i-1]:x0;bin.x1=i=1)return+valueof(values[n-1],n-1,values);var n,i=(n-1)*p,i0=Math.floor(i),value0=+valueof(values[i0],i0,values),value1=+valueof(values[i0+1],i0+1,values);return value0+(value1-value0)*(i-i0)};var freedmanDiaconis=function(values,min,max){values=map.call(values,number).sort(ascending);return Math.ceil((max-min)/(2*(quantile(values,.75)-quantile(values,.25))*Math.pow(values.length,-1/3)))};var scott=function(values,min,max){return Math.ceil((max-min)/(3.5*deviation(values)*Math.pow(values.length,-1/3)))};var max=function(values,valueof){var n=values.length,i=-1,value,max;if(valueof==null){while(++i=value){max=value;while(++imax){max=value}}}}}else{while(++i=value){max=value;while(++imax){max=value}}}}}return max};var mean=function(values,valueof){var n=values.length,m=n,i=-1,value,sum=0;if(valueof==null){while(++i=0){array=arrays[n];m=array.length;while(--m>=0){merged[--j]=array[m]}}return merged};var min=function(values,valueof){var n=values.length,i=-1,value,min;if(valueof==null){while(++i=value){min=value;while(++ivalue){min=value}}}}}else{while(++i=value){min=value;while(++ivalue){min=value}}}}}return min};var permute=function(array,indexes){var i=indexes.length,permutes=new Array(i);while(i--)permutes[i]=array[indexes[i]];return permutes};var scan=function(values,compare){if(!(n=values.length))return;var n,i=0,j=0,xi,xj=values[j];if(compare==null)compare=ascending;while(++i=keys.length){if(sortValues!=null)array.sort(sortValues);return rollup!=null?rollup(array):array}var i=-1,n=array.length,key=keys[depth++],keyValue,value,valuesByKey=map(),values,result=createResult();while(++ikeys.length)return map$$1;var array,sortKey=sortKeys[depth-1];if(rollup!=null&&depth>=keys.length)array=map$$1.entries();else array=[],map$$1.each(function(v,k){array.push({key:k,values:entries(v,depth)})});return sortKey!=null?array.sort(function(a,b){return sortKey(a.key,b.key)}):array}return nest={object:function(array){return apply(array,0,createObject,setObject)},map:function(array){return apply(array,0,createMap,setMap)},entries:function(array){return entries(apply(array,0,createMap,setMap),0)},key:function(d){keys.push(d);return nest},sortKeys:function(order){sortKeys[keys.length-1]=order;return nest},sortValues:function(order){sortValues=order;return nest},rollup:function(f){rollup=f;return nest}}};function createObject(){return{}}function setObject(object,key,value){object[key]=value}function createMap(){return map()}function setMap(map$$1,key,value){map$$1.set(key,value)}function Set(){}var proto=map.prototype;Set.prototype=set.prototype={constructor:Set,has:proto.has,add:function(value){value+="";this[prefix+value]=value;return this},remove:proto.remove,clear:proto.clear,values:proto.keys,size:proto.size,empty:proto.empty,each:proto.each};function set(object,f){var set=new Set;if(object instanceof Set)object.each(function(value){set.add(value)});else if(object){var i=-1,n=object.length;if(f==null)while(++i>8&15|m>>4&240,m>>4&15|m&240,(m&15)<<4|m&15,1)):(m=reHex6.exec(format))?rgbn(parseInt(m[1],16)):(m=reRgbInteger.exec(format))?new Rgb(m[1],m[2],m[3],1):(m=reRgbPercent.exec(format))?new Rgb(m[1]*255/100,m[2]*255/100,m[3]*255/100,1):(m=reRgbaInteger.exec(format))?rgba(m[1],m[2],m[3],m[4]):(m=reRgbaPercent.exec(format))?rgba(m[1]*255/100,m[2]*255/100,m[3]*255/100,m[4]):(m=reHslPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,1):(m=reHslaPercent.exec(format))?hsla(m[1],m[2]/100,m[3]/100,m[4]):named.hasOwnProperty(format)?rgbn(named[format]):format==="transparent"?new Rgb(NaN,NaN,NaN,0):null}function rgbn(n){return new Rgb(n>>16&255,n>>8&255,n&255,1)}function rgba(r,g,b,a){if(a<=0)r=g=b=NaN;return new Rgb(r,g,b,a)}function rgbConvert(o){if(!(o instanceof Color))o=color(o);if(!o)return new Rgb;o=o.rgb();return new Rgb(o.r,o.g,o.b,o.opacity)}function rgb(r,g,b,opacity){return arguments.length===1?rgbConvert(r):new Rgb(r,g,b,opacity==null?1:opacity)}function Rgb(r,g,b,opacity){this.r=+r;this.g=+g;this.b=+b;this.opacity=+opacity}define(Rgb,rgb,extend(Color,{brighter:function(k){k=k==null?brighter:Math.pow(brighter,k);return new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},darker:function(k){k=k==null?darker:Math.pow(darker,k);return new Rgb(this.r*k,this.g*k,this.b*k,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&(0<=this.g&&this.g<=255)&&(0<=this.b&&this.b<=255)&&(0<=this.opacity&&this.opacity<=1)},toString:function(){var a=this.opacity;a=isNaN(a)?1:Math.max(0,Math.min(1,a));return(a===1?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(a===1?")":", "+a+")")}}));function hsla(h,s,l,a){if(a<=0)h=s=l=NaN;else if(l<=0||l>=1)h=s=NaN;else if(s<=0)h=NaN;return new Hsl(h,s,l,a)}function hslConvert(o){if(o instanceof Hsl)return new Hsl(o.h,o.s,o.l,o.opacity);if(!(o instanceof Color))o=color(o);if(!o)return new Hsl;if(o instanceof Hsl)return o;o=o.rgb();var r=o.r/255,g=o.g/255,b=o.b/255,min=Math.min(r,g,b),max=Math.max(r,g,b),h=NaN,s=max-min,l=(max+min)/2;if(s){if(r===max)h=(g-b)/s+(g0&&l<1?0:h}return new Hsl(h,s,l,o.opacity)}function hsl(h,s,l,opacity){return arguments.length===1?hslConvert(h):new Hsl(h,s,l,opacity==null?1:opacity)}function Hsl(h,s,l,opacity){this.h=+h;this.s=+s;this.l=+l;this.opacity=+opacity}define(Hsl,hsl,extend(Color,{brighter:function(k){k=k==null?brighter:Math.pow(brighter,k);return new Hsl(this.h,this.s,this.l*k,this.opacity)},darker:function(k){k=k==null?darker:Math.pow(darker,k);return new Hsl(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=this.h%360+(this.h<0)*360,s=isNaN(h)||isNaN(this.s)?0:this.s,l=this.l,m2=l+(l<.5?l:1-l)*s,m1=2*l-m2;return new Rgb(hsl2rgb(h>=240?h-240:h+120,m1,m2),hsl2rgb(h,m1,m2),hsl2rgb(h<120?h+240:h-120,m1,m2),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&(0<=this.l&&this.l<=1)&&(0<=this.opacity&&this.opacity<=1)}}));function hsl2rgb(h,m1,m2){return(h<60?m1+(m2-m1)*h/60:h<180?m2:h<240?m1+(m2-m1)*(240-h)/60:m1)*255}var deg2rad=Math.PI/180;var rad2deg=180/Math.PI;var Kn=18;var Xn=.95047;var Yn=1;var Zn=1.08883;var t0=4/29;var t1=6/29;var t2=3*t1*t1;var t3=t1*t1*t1;function labConvert(o){if(o instanceof Lab)return new Lab(o.l,o.a,o.b,o.opacity);if(o instanceof Hcl){var h=o.h*deg2rad;return new Lab(o.l,Math.cos(h)*o.c,Math.sin(h)*o.c,o.opacity)}if(!(o instanceof Rgb))o=rgbConvert(o);var b=rgb2xyz(o.r),a=rgb2xyz(o.g),l=rgb2xyz(o.b),x=xyz2lab((.4124564*b+.3575761*a+.1804375*l)/Xn),y=xyz2lab((.2126729*b+.7151522*a+.072175*l)/Yn),z=xyz2lab((.0193339*b+.119192*a+.9503041*l)/Zn);return new Lab(116*y-16,500*(x-y),200*(y-z),o.opacity)}function lab(l,a,b,opacity){return arguments.length===1?labConvert(l):new Lab(l,a,b,opacity==null?1:opacity)}function Lab(l,a,b,opacity){this.l=+l;this.a=+a;this.b=+b;this.opacity=+opacity}define(Lab,lab,extend(Color,{brighter:function(k){return new Lab(this.l+Kn*(k==null?1:k),this.a,this.b,this.opacity)},darker:function(k){return new Lab(this.l-Kn*(k==null?1:k),this.a,this.b,this.opacity)},rgb:function(){var y=(this.l+16)/116,x=isNaN(this.a)?y:y+this.a/500,z=isNaN(this.b)?y:y-this.b/200;y=Yn*lab2xyz(y);x=Xn*lab2xyz(x);z=Zn*lab2xyz(z);return new Rgb(xyz2rgb(3.2404542*x-1.5371385*y-.4985314*z),xyz2rgb(-.969266*x+1.8760108*y+.041556*z),xyz2rgb(.0556434*x-.2040259*y+1.0572252*z),this.opacity)}}));function xyz2lab(t){return t>t3?Math.pow(t,1/3):t/t2+t0}function lab2xyz(t){return t>t1?t*t*t:t2*(t-t0)}function xyz2rgb(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function rgb2xyz(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function hclConvert(o){if(o instanceof Hcl)return new Hcl(o.h,o.c,o.l,o.opacity);if(!(o instanceof Lab))o=labConvert(o);var h=Math.atan2(o.b,o.a)*rad2deg;return new Hcl(h<0?h+360:h,Math.sqrt(o.a*o.a+o.b*o.b),o.l,o.opacity)}function hcl(h,c,l,opacity){return arguments.length===1?hclConvert(h):new Hcl(h,c,l,opacity==null?1:opacity)}function Hcl(h,c,l,opacity){this.h=+h;this.c=+c;this.l=+l;this.opacity=+opacity}define(Hcl,hcl,extend(Color,{brighter:function(k){return new Hcl(this.h,this.c,this.l+Kn*(k==null?1:k),this.opacity)},darker:function(k){return new Hcl(this.h,this.c,this.l-Kn*(k==null?1:k),this.opacity)},rgb:function(){return labConvert(this).rgb()}}));var A=-.14861;var B=+1.78277;var C=-.29227;var D=-.90649;var E=+1.97294;var ED=E*D;var EB=E*B;var BC_DA=B*C-D*A;function cubehelixConvert(o){if(o instanceof Cubehelix)return new Cubehelix(o.h,o.s,o.l,o.opacity);if(!(o instanceof Rgb))o=rgbConvert(o);var r=o.r/255,g=o.g/255,b=o.b/255,l=(BC_DA*b+ED*r-EB*g)/(BC_DA+ED-EB),bl=b-l,k=(E*(g-l)-C*bl)/D,s=Math.sqrt(k*k+bl*bl)/(E*l*(1-l)),h=s?Math.atan2(k,bl)*rad2deg-120:NaN;return new Cubehelix(h<0?h+360:h,s,l,o.opacity)}function cubehelix(h,s,l,opacity){return arguments.length===1?cubehelixConvert(h):new Cubehelix(h,s,l,opacity==null?1:opacity)}function Cubehelix(h,s,l,opacity){this.h=+h;this.s=+s;this.l=+l;this.opacity=+opacity}define(Cubehelix,cubehelix,extend(Color,{brighter:function(k){k=k==null?brighter:Math.pow(brighter,k);return new Cubehelix(this.h,this.s,this.l*k,this.opacity)},darker:function(k){k=k==null?darker:Math.pow(darker,k);return new Cubehelix(this.h,this.s,this.l*k,this.opacity)},rgb:function(){var h=isNaN(this.h)?0:(this.h+120)*deg2rad,l=+this.l,a=isNaN(this.s)?0:this.s*l*(1-l),cosh=Math.cos(h),sinh=Math.sin(h);return new Rgb(255*(l+a*(A*cosh+B*sinh)),255*(l+a*(C*cosh+D*sinh)),255*(l+a*(E*cosh)),this.opacity)}}));exports.color=color;exports.rgb=rgb;exports.hsl=hsl;exports.lab=lab;exports.hcl=hcl;exports.cubehelix=cubehelix;Object.defineProperty(exports,"__esModule",{value:true})})},{}],6:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array")):typeof define==="function"&&define.amd?define(["exports","d3-array"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Array){"use strict";var array=Array.prototype;var slice=array.slice;var ascending=function(a,b){return a-b};var area=function(ring){var i=0,n=ring.length,area=ring[n-1][1]*ring[0][0]-ring[n-1][0]*ring[0][1];while(++iy!==yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi)contains=-contains}return contains}function segmentContains(a,b,c){var i;return collinear(a,b,c)&&within(a[i=+(a[0]===b[0])],c[i],b[i])}function collinear(a,b,c){return(b[0]-a[0])*(c[1]-a[1])===(c[0]-a[0])*(b[1]-a[1])}function within(p,q,r){return p<=q&&q<=r||r<=q&&q<=p}var noop=function(){};var cases=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];var contours=function(){var dx=1,dy=1,threshold=d3Array.thresholdSturges,smooth=smoothLinear;function contours(values){var tz=threshold(values);if(!Array.isArray(tz)){var domain=d3Array.extent(values),start=domain[0],stop=domain[1];tz=d3Array.tickStep(start,stop,tz);tz=d3Array.range(Math.floor(start/tz)*tz,Math.floor(stop/tz)*tz,tz)}else{tz=tz.slice().sort(ascending)}return tz.map(function(value){return contour(values,value)})}function contour(values,value){var polygons=[],holes=[];isorings(values,value,function(ring){smooth(ring,values,value);if(area(ring)>0)polygons.push([ring]);else holes.push(ring)});holes.forEach(function(hole){for(var i=0,n=polygons.length,polygon;i=value;cases[t1<<1].forEach(stitch);while(++x=value;cases[t0|t1<<1].forEach(stitch)}cases[t1<<0].forEach(stitch);while(++y=value;t2=values[y*dx]>=value;cases[t1<<1|t2<<2].forEach(stitch);while(++x=value;t3=t2,t2=values[y*dx+x+1]>=value;cases[t0|t1<<1|t2<<2|t3<<3].forEach(stitch)}cases[t1|t2<<3].forEach(stitch)}x=-1;t2=values[y*dx]>=value;cases[t2<<2].forEach(stitch);while(++x=value;cases[t2<<2|t3<<3].forEach(stitch)}cases[t2<<3].forEach(stitch);function stitch(line){var start=[line[0][0]+x,line[0][1]+y],end=[line[1][0]+x,line[1][1]+y],startIndex=index(start),endIndex=index(end),f,g;if(f=fragmentByEnd[startIndex]){if(g=fragmentByStart[endIndex]){delete fragmentByEnd[f.end];delete fragmentByStart[g.start];if(f===g){f.ring.push(end);callback(f.ring)}else{fragmentByStart[f.start]=fragmentByEnd[g.end]={start:f.start,end:g.end,ring:f.ring.concat(g.ring)}}}else{delete fragmentByEnd[f.end];f.ring.push(end);fragmentByEnd[f.end=endIndex]=f}}else if(f=fragmentByStart[endIndex]){if(g=fragmentByEnd[startIndex]){delete fragmentByStart[f.start];delete fragmentByEnd[g.end];if(f===g){f.ring.push(end);callback(f.ring)}else{fragmentByStart[g.start]=fragmentByEnd[f.end]={start:g.start,end:f.end,ring:g.ring.concat(f.ring)}}}else{delete fragmentByStart[f.start];f.ring.unshift(start);fragmentByStart[f.start=startIndex]=f}}else{fragmentByStart[startIndex]=fragmentByEnd[endIndex]={start:startIndex,end:endIndex,ring:[start,end]}}}}function index(point){return point[0]*2+point[1]*(dx+1)*4}function smoothLinear(ring,values,value){ring.forEach(function(point){var x=point[0],y=point[1],xt=x|0,yt=y|0,v0,v1=values[yt*dx+xt];if(x>0&&x0&&y0)||!(_1>0))throw new Error("invalid size");return dx=_0,dy=_1,contours};contours.thresholds=function(_){return arguments.length?(threshold=typeof _==="function"?_:Array.isArray(_)?constant(slice.call(_)):constant(_),contours):threshold};contours.smooth=function(_){return arguments.length?(smooth=_?smoothLinear:noop,contours):smooth===smoothLinear};return contours};function blurX(source,target,r){var n=source.width,m=source.height,w=(r<<1)+1;for(var j=0;j=r){if(i>=w){sr-=source.data[i-w+j*n]}target.data[i-r+j*n]=sr/Math.min(i+1,n-1+w-i,w)}}}}function blurY(source,target,r){var n=source.width,m=source.height,w=(r<<1)+1;for(var i=0;i=r){if(j>=w){sr-=source.data[i+(j-w)*n]}target.data[i+(j-r)*n]=sr/Math.min(j+1,m-1+w-j,w)}}}}function defaultX(d){return d[0]}function defaultY(d){return d[1]}var density=function(){var x=defaultX,y=defaultY,dx=960,dy=500,r=20,k=2,o=r*3,n=dx+o*2>>k,m=dy+o*2>>k,threshold=constant(20);function density(data){var values0=new Float32Array(n*m),values1=new Float32Array(n*m);data.forEach(function(d,i,data){var xi=x(d,i,data)+o>>k,yi=y(d,i,data)+o>>k;if(xi>=0&&xi=0&&yi>k);blurY({width:n,height:m,data:values1},{width:n,height:m,data:values0},r>>k);blurX({width:n,height:m,data:values0},{width:n,height:m,data:values1},r>>k);blurY({width:n,height:m,data:values1},{width:n,height:m,data:values0},r>>k);blurX({width:n,height:m,data:values0},{width:n,height:m,data:values1},r>>k);blurY({width:n,height:m,data:values1},{width:n,height:m,data:values0},r>>k);var tz=threshold(values0);if(!Array.isArray(tz)){var stop=d3Array.max(values0);tz=d3Array.tickStep(0,stop,tz);tz=d3Array.range(0,Math.floor(stop/tz)*tz,tz);tz.shift()}return contours().thresholds(tz).size([n,m])(values0).map(transform)}function transform(geometry){geometry.value*=Math.pow(2,-2*k);geometry.coordinates.forEach(transformPolygon);return geometry}function transformPolygon(coordinates){coordinates.forEach(transformRing)}function transformRing(coordinates){coordinates.forEach(transformPoint)}function transformPoint(coordinates){coordinates[0]=coordinates[0]*Math.pow(2,k)-o;coordinates[1]=coordinates[1]*Math.pow(2,k)-o}function resize(){o=r*3;n=dx+o*2>>k;m=dy+o*2>>k;return density}density.x=function(_){return arguments.length?(x=typeof _==="function"?_:constant(+_),density):x};density.y=function(_){return arguments.length?(y=typeof _==="function"?_:constant(+_),density):y};density.size=function(_){if(!arguments.length)return[dx,dy];var _0=Math.ceil(_[0]),_1=Math.ceil(_[1]);if(!(_0>=0)&&!(_0>=0))throw new Error("invalid size");return dx=_0,dy=_1,resize()};density.cellSize=function(_){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return k=Math.floor(Math.log(_)/Math.LN2),resize()};density.thresholds=function(_){return arguments.length?(threshold=typeof _==="function"?_:Array.isArray(_)?constant(slice.call(_)):constant(_),density):threshold};density.bandwidth=function(_){if(!arguments.length)return Math.sqrt(r*(r+1));if(!((_=+_)>=0))throw new Error("invalid bandwidth");return r=Math.round((Math.sqrt(4*_*_+1)-1)/2),resize()};return density};exports.contours=contours;exports.contourDensity=density;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3}],7:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var formatDecimal=function(x,p){if((i=(x=p?x.toExponential(p-1):x.toExponential()).indexOf("e"))<0)return null;var i,coefficient=x.slice(0,i);return[coefficient.length>1?coefficient[0]+coefficient.slice(2):coefficient,+x.slice(i+1)]};var exponent=function(x){return x=formatDecimal(Math.abs(x)),x?x[1]:NaN};var formatGroup=function(grouping,thousands){return function(value,width){var i=value.length,t=[],j=0,g=grouping[0],length=0;while(i>0&&g>0){if(length+g+1>width)g=Math.max(1,width-length);t.push(value.substring(i-=g,i+g));if((length+=g+1)>width)break;g=grouping[j=(j+1)%grouping.length]}return t.reverse().join(thousands)}};var formatNumerals=function(numerals){return function(value){return value.replace(/[0-9]/g,function(i){return numerals[+i]})}};var formatDefault=function(x,p){x=x.toPrecision(p);out:for(var n=x.length,i=1,i0=-1,i1;i0)i0=0;break}}return i0>0?x.slice(0,i0)+x.slice(i1+1):x};var prefixExponent;var formatPrefixAuto=function(x,p){var d=formatDecimal(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1],i=exponent-(prefixExponent=Math.max(-8,Math.min(8,Math.floor(exponent/3)))*3)+1,n=coefficient.length;return i===n?coefficient:i>n?coefficient+new Array(i-n+1).join("0"):i>0?coefficient.slice(0,i)+"."+coefficient.slice(i):"0."+new Array(1-i).join("0")+formatDecimal(x,Math.max(0,p+i-1))[0]};var formatRounded=function(x,p){var d=formatDecimal(x,p);if(!d)return x+"";var coefficient=d[0],exponent=d[1];return exponent<0?"0."+new Array(-exponent).join("0")+coefficient:coefficient.length>exponent+1?coefficient.slice(0,exponent+1)+"."+coefficient.slice(exponent+1):coefficient+new Array(exponent-coefficient.length+2).join("0")};var formatTypes={"":formatDefault,"%":function(x,p){return(x*100).toFixed(p)},b:function(x){return Math.round(x).toString(2)},c:function(x){return x+""},d:function(x){return Math.round(x).toString(10)},e:function(x,p){return x.toExponential(p)},f:function(x,p){return x.toFixed(p)},g:function(x,p){return x.toPrecision(p)},o:function(x){return Math.round(x).toString(8)},p:function(x,p){return formatRounded(x*100,p)},r:formatRounded,s:formatPrefixAuto,X:function(x){return Math.round(x).toString(16).toUpperCase()},x:function(x){return Math.round(x).toString(16)}};var re=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;function formatSpecifier(specifier){return new FormatSpecifier(specifier)}formatSpecifier.prototype=FormatSpecifier.prototype;function FormatSpecifier(specifier){if(!(match=re.exec(specifier)))throw new Error("invalid format: "+specifier);var match,fill=match[1]||" ",align=match[2]||">",sign=match[3]||"-",symbol=match[4]||"",zero=!!match[5],width=match[6]&&+match[6],comma=!!match[7],precision=match[8]&&+match[8].slice(1),type=match[9]||"";if(type==="n")comma=true,type="g";else if(!formatTypes[type])type="";if(zero||fill==="0"&&align==="=")zero=true,fill="0",align="=";this.fill=fill;this.align=align;this.sign=sign;this.symbol=symbol;this.zero=zero;this.width=width;this.comma=comma;this.precision=precision;this.type=type}FormatSpecifier.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width==null?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision==null?"":"."+Math.max(0,this.precision|0))+this.type};var identity=function(x){return x};var prefixes=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];var formatLocale=function(locale){var group=locale.grouping&&locale.thousands?formatGroup(locale.grouping,locale.thousands):identity,currency=locale.currency,decimal=locale.decimal,numerals=locale.numerals?formatNumerals(locale.numerals):identity,percent=locale.percent||"%";function newFormat(specifier){specifier=formatSpecifier(specifier);var fill=specifier.fill,align=specifier.align,sign=specifier.sign,symbol=specifier.symbol,zero=specifier.zero,width=specifier.width,comma=specifier.comma,precision=specifier.precision,type=specifier.type;var prefix=symbol==="$"?currency[0]:symbol==="#"&&/[boxX]/.test(type)?"0"+type.toLowerCase():"",suffix=symbol==="$"?currency[1]:/[%p]/.test(type)?percent:"";var formatType=formatTypes[type],maybeSuffix=!type||/[defgprs%]/.test(type);precision=precision==null?type?6:12:/[gprs]/.test(type)?Math.max(1,Math.min(21,precision)):Math.max(0,Math.min(20,precision));function format(value){var valuePrefix=prefix,valueSuffix=suffix,i,n,c;if(type==="c"){valueSuffix=formatType(value)+valueSuffix;value=""}else{value=+value;var valueNegative=value<0;value=formatType(Math.abs(value),precision);if(valueNegative&&+value===0)valueNegative=false;valuePrefix=(valueNegative?sign==="("?sign:"-":sign==="-"||sign==="("?"":sign)+valuePrefix;valueSuffix=(type==="s"?prefixes[8+prefixExponent/3]:"")+valueSuffix+(valueNegative&&sign==="("?")":"");if(maybeSuffix){i=-1,n=value.length;while(++ic||c>57){valueSuffix=(c===46?decimal+value.slice(i+1):value.slice(i))+valueSuffix;value=value.slice(0,i);break}}}}if(comma&&!zero)value=group(value,Infinity);var length=valuePrefix.length+value.length+valueSuffix.length,padding=length>1)+valuePrefix+value+valueSuffix+padding.slice(length);break;default:value=padding+valuePrefix+value+valueSuffix;break}return numerals(value)}format.toString=function(){return specifier+""};return format}function formatPrefix(specifier,value){var f=newFormat((specifier=formatSpecifier(specifier),specifier.type="f",specifier)),e=Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))*3,k=Math.pow(10,-e),prefix=prefixes[8+e/3];return function(value){return f(k*value)+prefix}}return{format:newFormat,formatPrefix:formatPrefix}};var locale;defaultLocale({decimal:".",thousands:",",grouping:[3],currency:["$",""]});function defaultLocale(definition){locale=formatLocale(definition);exports.format=locale.format;exports.formatPrefix=locale.formatPrefix;return locale}var precisionFixed=function(step){return Math.max(0,-exponent(Math.abs(step)))};var precisionPrefix=function(step,value){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))*3-exponent(Math.abs(step)))};var precisionRound=function(step,max){step=Math.abs(step),max=Math.abs(max)-step;return Math.max(0,exponent(max)-exponent(step))+1};exports.formatDefaultLocale=defaultLocale;exports.formatLocale=formatLocale;exports.formatSpecifier=formatSpecifier;exports.precisionFixed=precisionFixed;exports.precisionPrefix=precisionPrefix;exports.precisionRound=precisionRound;Object.defineProperty(exports,"__esModule",{value:true})})},{}],8:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array")):typeof define==="function"&&define.amd?define(["exports","d3-array"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Array){"use strict";var adder=function(){return new Adder};function Adder(){this.reset()}Adder.prototype={constructor:Adder,reset:function(){this.s=this.t=0},add:function(y){add(temp,y,this.t);add(this,temp.s,this.s);if(this.s)this.t+=temp.t;else this.s=temp.t},valueOf:function(){return this.s}};var temp=new Adder;function add(adder,a,b){var x=adder.s=a+b,bv=x-a,av=x-bv;adder.t=a-av+(b-bv)}var epsilon=1e-6;var epsilon2=1e-12;var pi=Math.PI;var halfPi=pi/2;var quarterPi=pi/4;var tau=pi*2;var degrees=180/pi;var radians=pi/180;var abs=Math.abs;var atan=Math.atan;var atan2=Math.atan2;var cos=Math.cos;var ceil=Math.ceil;var exp=Math.exp;var log=Math.log;var pow=Math.pow;var sin=Math.sin;var sign=Math.sign||function(x){return x>0?1:x<0?-1:0};var sqrt=Math.sqrt;var tan=Math.tan;function acos(x){return x>1?0:x<-1?pi:Math.acos(x)}function asin(x){return x>1?halfPi:x<-1?-halfPi:Math.asin(x)}function haversin(x){return(x=sin(x/2))*x}function noop(){}function streamGeometry(geometry,stream){if(geometry&&streamGeometryType.hasOwnProperty(geometry.type)){streamGeometryType[geometry.type](geometry,stream)}}var streamObjectType={Feature:function(object,stream){streamGeometry(object.geometry,stream)},FeatureCollection:function(object,stream){var features=object.features,i=-1,n=features.length;while(++i=0?1:-1,adLambda=sdLambda*dLambda,cosPhi=cos(phi),sinPhi=sin(phi),k=sinPhi0*sinPhi,u=cosPhi0*cosPhi+k*cos(adLambda),v=k*sdLambda*sin(adLambda);areaRingSum.add(atan2(v,u));lambda0=lambda,cosPhi0=cosPhi,sinPhi0=sinPhi}var area=function(object){areaSum.reset();geoStream(object,areaStream);return areaSum*2};function spherical(cartesian){return[atan2(cartesian[1],cartesian[0]),asin(cartesian[2])]}function cartesian(spherical){var lambda=spherical[0],phi=spherical[1],cosPhi=cos(phi);return[cosPhi*cos(lambda),cosPhi*sin(lambda),sin(phi)]}function cartesianDot(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function cartesianCross(a,b){return[a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]]}function cartesianAddInPlace(a,b){a[0]+=b[0],a[1]+=b[1],a[2]+=b[2]}function cartesianScale(vector,k){return[vector[0]*k,vector[1]*k,vector[2]*k]}function cartesianNormalizeInPlace(d){var l=sqrt(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]);d[0]/=l,d[1]/=l,d[2]/=l}var lambda0$1;var phi0;var lambda1;var phi1;var lambda2;var lambda00$1;var phi00$1;var p0;var deltaSum=adder();var ranges;var range$1;var boundsStream={point:boundsPoint,lineStart:boundsLineStart,lineEnd:boundsLineEnd,polygonStart:function(){boundsStream.point=boundsRingPoint;boundsStream.lineStart=boundsRingStart;boundsStream.lineEnd=boundsRingEnd;deltaSum.reset();areaStream.polygonStart()},polygonEnd:function(){areaStream.polygonEnd();boundsStream.point=boundsPoint;boundsStream.lineStart=boundsLineStart;boundsStream.lineEnd=boundsLineEnd;if(areaRingSum<0)lambda0$1=-(lambda1=180),phi0=-(phi1=90);else if(deltaSum>epsilon)phi1=90;else if(deltaSum<-epsilon)phi0=-90;range$1[0]=lambda0$1,range$1[1]=lambda1}};function boundsPoint(lambda,phi){ranges.push(range$1=[lambda0$1=lambda,lambda1=lambda]);if(phiphi1)phi1=phi}function linePoint(lambda,phi){var p=cartesian([lambda*radians,phi*radians]);if(p0){var normal=cartesianCross(p0,p),equatorial=[normal[1],-normal[0],0],inflection=cartesianCross(equatorial,normal);cartesianNormalizeInPlace(inflection);inflection=spherical(inflection);var delta=lambda-lambda2,sign$$1=delta>0?1:-1,lambdai=inflection[0]*degrees*sign$$1,phii,antimeridian=abs(delta)>180;if(antimeridian^(sign$$1*lambda2phi1)phi1=phii}else if(lambdai=(lambdai+360)%360-180,antimeridian^(sign$$1*lambda2phi1)phi1=phi}if(antimeridian){if(lambdaangle(lambda0$1,lambda1))lambda1=lambda}else{if(angle(lambda,lambda1)>angle(lambda0$1,lambda1))lambda0$1=lambda}}else{if(lambda1>=lambda0$1){if(lambdalambda1)lambda1=lambda}else{if(lambda>lambda2){if(angle(lambda0$1,lambda)>angle(lambda0$1,lambda1))lambda1=lambda}else{if(angle(lambda,lambda1)>angle(lambda0$1,lambda1))lambda0$1=lambda}}}}else{ranges.push(range$1=[lambda0$1=lambda,lambda1=lambda])}if(phiphi1)phi1=phi;p0=p,lambda2=lambda}function boundsLineStart(){boundsStream.point=linePoint}function boundsLineEnd(){range$1[0]=lambda0$1,range$1[1]=lambda1;boundsStream.point=boundsPoint;p0=null}function boundsRingPoint(lambda,phi){if(p0){var delta=lambda-lambda2;deltaSum.add(abs(delta)>180?delta+(delta>0?360:-360):delta)}else{lambda00$1=lambda,phi00$1=phi}areaStream.point(lambda,phi);linePoint(lambda,phi)}function boundsRingStart(){areaStream.lineStart()}function boundsRingEnd(){boundsRingPoint(lambda00$1,phi00$1);areaStream.lineEnd();if(abs(deltaSum)>epsilon)lambda0$1=-(lambda1=180);range$1[0]=lambda0$1,range$1[1]=lambda1;p0=null}function angle(lambda0,lambda1){return(lambda1-=lambda0)<0?lambda1+360:lambda1}function rangeCompare(a,b){return a[0]-b[0]} -function rangeContains(range$$1,x){return range$$1[0]<=range$$1[1]?range$$1[0]<=x&&x<=range$$1[1]:xangle(a[0],a[1]))a[1]=b[1];if(angle(b[0],a[1])>angle(a[0],a[1]))a[0]=b[0]}else{merged.push(a=b)}}for(deltaMax=-Infinity,n=merged.length-1,i=0,a=merged[n];i<=n;a=b,++i){b=merged[i];if((delta=angle(a[1],b[0]))>deltaMax)deltaMax=delta,lambda0$1=b[0],lambda1=a[1]}}ranges=range$1=null;return lambda0$1===Infinity||phi0===Infinity?[[NaN,NaN],[NaN,NaN]]:[[lambda0$1,phi0],[lambda1,phi1]]};var W0;var W1;var X0;var Y0;var Z0;var X1;var Y1;var Z1;var X2;var Y2;var Z2;var lambda00$2;var phi00$2;var x0;var y0;var z0;var centroidStream={sphere:noop,point:centroidPoint,lineStart:centroidLineStart,lineEnd:centroidLineEnd,polygonStart:function(){centroidStream.lineStart=centroidRingStart;centroidStream.lineEnd=centroidRingEnd},polygonEnd:function(){centroidStream.lineStart=centroidLineStart;centroidStream.lineEnd=centroidLineEnd}};function centroidPoint(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi);centroidPointCartesian(cosPhi*cos(lambda),cosPhi*sin(lambda),sin(phi))}function centroidPointCartesian(x,y,z){++W0;X0+=(x-X0)/W0;Y0+=(y-Y0)/W0;Z0+=(z-Z0)/W0}function centroidLineStart(){centroidStream.point=centroidLinePointFirst}function centroidLinePointFirst(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi);x0=cosPhi*cos(lambda);y0=cosPhi*sin(lambda);z0=sin(phi);centroidStream.point=centroidLinePoint;centroidPointCartesian(x0,y0,z0)}function centroidLinePoint(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi),x=cosPhi*cos(lambda),y=cosPhi*sin(lambda),z=sin(phi),w=atan2(sqrt((w=y0*z-z0*y)*w+(w=z0*x-x0*z)*w+(w=x0*y-y0*x)*w),x0*x+y0*y+z0*z);W1+=w;X1+=w*(x0+(x0=x));Y1+=w*(y0+(y0=y));Z1+=w*(z0+(z0=z));centroidPointCartesian(x0,y0,z0)}function centroidLineEnd(){centroidStream.point=centroidPoint}function centroidRingStart(){centroidStream.point=centroidRingPointFirst}function centroidRingEnd(){centroidRingPoint(lambda00$2,phi00$2);centroidStream.point=centroidPoint}function centroidRingPointFirst(lambda,phi){lambda00$2=lambda,phi00$2=phi;lambda*=radians,phi*=radians;centroidStream.point=centroidRingPoint;var cosPhi=cos(phi);x0=cosPhi*cos(lambda);y0=cosPhi*sin(lambda);z0=sin(phi);centroidPointCartesian(x0,y0,z0)}function centroidRingPoint(lambda,phi){lambda*=radians,phi*=radians;var cosPhi=cos(phi),x=cosPhi*cos(lambda),y=cosPhi*sin(lambda),z=sin(phi),cx=y0*z-z0*y,cy=z0*x-x0*z,cz=x0*y-y0*x,m=sqrt(cx*cx+cy*cy+cz*cz),w=asin(m),v=m&&-w/m;X2+=v*cx;Y2+=v*cy;Z2+=v*cz;W1+=w;X1+=w*(x0+(x0=x));Y1+=w*(y0+(y0=y));Z1+=w*(z0+(z0=z));centroidPointCartesian(x0,y0,z0)}var centroid=function(object){W0=W1=X0=Y0=Z0=X1=Y1=Z1=X2=Y2=Z2=0;geoStream(object,centroidStream);var x=X2,y=Y2,z=Z2,m=x*x+y*y+z*z;if(mpi?lambda-tau:lambda<-pi?lambda+tau:lambda,phi]}rotationIdentity.invert=rotationIdentity;function rotateRadians(deltaLambda,deltaPhi,deltaGamma){return(deltaLambda%=tau)?deltaPhi||deltaGamma?compose(rotationLambda(deltaLambda),rotationPhiGamma(deltaPhi,deltaGamma)):rotationLambda(deltaLambda):deltaPhi||deltaGamma?rotationPhiGamma(deltaPhi,deltaGamma):rotationIdentity}function forwardRotationLambda(deltaLambda){return function(lambda,phi){return lambda+=deltaLambda,[lambda>pi?lambda-tau:lambda<-pi?lambda+tau:lambda,phi]}}function rotationLambda(deltaLambda){var rotation=forwardRotationLambda(deltaLambda);rotation.invert=forwardRotationLambda(-deltaLambda);return rotation}function rotationPhiGamma(deltaPhi,deltaGamma){var cosDeltaPhi=cos(deltaPhi),sinDeltaPhi=sin(deltaPhi),cosDeltaGamma=cos(deltaGamma),sinDeltaGamma=sin(deltaGamma);function rotation(lambda,phi){var cosPhi=cos(phi),x=cos(lambda)*cosPhi,y=sin(lambda)*cosPhi,z=sin(phi),k=z*cosDeltaPhi+x*sinDeltaPhi;return[atan2(y*cosDeltaGamma-k*sinDeltaGamma,x*cosDeltaPhi-z*sinDeltaPhi),asin(k*cosDeltaGamma+y*sinDeltaGamma)]}rotation.invert=function(lambda,phi){var cosPhi=cos(phi),x=cos(lambda)*cosPhi,y=sin(lambda)*cosPhi,z=sin(phi),k=z*cosDeltaGamma-y*sinDeltaGamma;return[atan2(y*cosDeltaGamma+z*sinDeltaGamma,x*cosDeltaPhi+k*sinDeltaPhi),asin(k*cosDeltaPhi-x*sinDeltaPhi)]};return rotation}var rotation=function(rotate){rotate=rotateRadians(rotate[0]*radians,rotate[1]*radians,rotate.length>2?rotate[2]*radians:0);function forward(coordinates){coordinates=rotate(coordinates[0]*radians,coordinates[1]*radians);return coordinates[0]*=degrees,coordinates[1]*=degrees,coordinates}forward.invert=function(coordinates){coordinates=rotate.invert(coordinates[0]*radians,coordinates[1]*radians);return coordinates[0]*=degrees,coordinates[1]*=degrees,coordinates};return forward};function circleStream(stream,radius,delta,direction,t0,t1){if(!delta)return;var cosRadius=cos(radius),sinRadius=sin(radius),step=direction*delta;if(t0==null){t0=radius+direction*tau;t1=radius-step/2}else{t0=circleRadius(cosRadius,t0);t1=circleRadius(cosRadius,t1);if(direction>0?t0t1)t0+=direction*tau}for(var point,t=t0;direction>0?t>t1:t1)lines.push(lines.pop().concat(lines.shift()))},result:function(){var result=lines;lines=[];line=null;return result}}};var pointEqual=function(a,b){return abs(a[0]-b[0])=0;--i)stream.point((point=points[i])[0],point[1])}else{interpolate(current.x,current.p.x,-1,stream)}current=current.p}current=current.o;points=current.z;isSubject=!isSubject}while(!current.v);stream.lineEnd()}};function link(array){if(!(n=array.length))return;var n,i=0,a=array[0],b;while(++i=0?1:-1,absDelta=sign$$1*delta,antimeridian=absDelta>pi,k=sinPhi0*sinPhi1;sum.add(atan2(k*sign$$1*sin(absDelta),cosPhi0*cosPhi1+k*cos(absDelta)));angle+=antimeridian?delta+sign$$1*tau:delta;if(antimeridian^lambda0>=lambda^lambda1>=lambda){var arc=cartesianCross(cartesian(point0),cartesian(point1));cartesianNormalizeInPlace(arc);var intersection=cartesianCross(normal,arc);cartesianNormalizeInPlace(intersection);var phiArc=(antimeridian^delta>=0?-1:1)*asin(intersection[2]);if(phi>phiArc||phi===phiArc&&(arc[0]||arc[1])){winding+=antimeridian^delta>=0?1:-1}}}}return(angle<-epsilon||angle0){if(!polygonStarted)sink.polygonStart(),polygonStarted=true;sink.lineStart();for(i=0;i1&&clean&2)ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));segments.push(ringSegments.filter(validSegment))}return clip}};function validSegment(segment){return segment.length>1}function compareIntersection(a,b){return((a=a.x)[0]<0?a[1]-halfPi-epsilon:halfPi-a[1])-((b=b.x)[0]<0?b[1]-halfPi-epsilon:halfPi-b[1])}var clipAntimeridian=clip(function(){return true},clipAntimeridianLine,clipAntimeridianInterpolate,[-pi,-halfPi]);function clipAntimeridianLine(stream){var lambda0=NaN,phi0=NaN,sign0=NaN,clean;return{lineStart:function(){stream.lineStart();clean=1},point:function(lambda1,phi1){var sign1=lambda1>0?pi:-pi,delta=abs(lambda1-lambda0);if(abs(delta-pi)0?halfPi:-halfPi);stream.point(sign0,phi0);stream.lineEnd();stream.lineStart();stream.point(sign1,phi0);stream.point(lambda1,phi0);clean=0}else if(sign0!==sign1&&delta>=pi){if(abs(lambda0-sign0)epsilon?atan((sin(phi0)*(cosPhi1=cos(phi1))*sin(lambda1)-sin(phi1)*(cosPhi0=cos(phi0))*sin(lambda0))/(cosPhi0*cosPhi1*sinLambda0Lambda1)):(phi0+phi1)/2}function clipAntimeridianInterpolate(from,to,direction,stream){var phi;if(from==null){phi=direction*halfPi;stream.point(-pi,phi);stream.point(0,phi);stream.point(pi,phi);stream.point(pi,0);stream.point(pi,-phi);stream.point(0,-phi);stream.point(-pi,-phi);stream.point(-pi,0);stream.point(-pi,phi)}else if(abs(from[0]-to[0])>epsilon){var lambda=from[0]0,notHemisphere=abs(cr)>epsilon;function interpolate(from,to,direction,stream){circleStream(stream,radius,delta,direction,from,to)}function visible(lambda,phi){return cos(lambda)*cos(phi)>cr}function clipLine(stream){var point0,c0,v0,v00,clean;return{lineStart:function(){v00=v0=false;clean=1},point:function(lambda,phi){var point1=[lambda,phi],point2,v=visible(lambda,phi),c=smallRadius?v?0:code(lambda,phi):v?code(lambda+(lambda<0?pi:-pi),phi):0;if(!point0&&(v00=v0=v))stream.lineStart();if(v!==v0){point2=intersect(point0,point1);if(!point2||pointEqual(point0,point2)||pointEqual(point1,point2)){point1[0]+=epsilon;point1[1]+=epsilon;v=visible(point1[0],point1[1])}}if(v!==v0){clean=0;if(v){stream.lineStart();point2=intersect(point1,point0);stream.point(point2[0],point2[1])}else{point2=intersect(point0,point1);stream.point(point2[0],point2[1]);stream.lineEnd()}point0=point2}else if(notHemisphere&&point0&&smallRadius^v){var t;if(!(c&c0)&&(t=intersect(point1,point0,true))){clean=0;if(smallRadius){stream.lineStart();stream.point(t[0][0],t[0][1]);stream.point(t[1][0],t[1][1]);stream.lineEnd()}else{stream.point(t[1][0],t[1][1]);stream.lineEnd();stream.lineStart();stream.point(t[0][0],t[0][1])}}}if(v&&(!point0||!pointEqual(point0,point1))){stream.point(point1[0],point1[1])}point0=point1,v0=v,c0=c},lineEnd:function(){if(v0)stream.lineEnd();point0=null},clean:function(){return clean|(v00&&v0)<<1}}}function intersect(a,b,two){var pa=cartesian(a),pb=cartesian(b);var n1=[1,0,0],n2=cartesianCross(pa,pb),n2n2=cartesianDot(n2,n2),n1n2=n2[0],determinant=n2n2-n1n2*n1n2;if(!determinant)return!two&&a;var c1=cr*n2n2/determinant,c2=-cr*n1n2/determinant,n1xn2=cartesianCross(n1,n2),A=cartesianScale(n1,c1),B=cartesianScale(n2,c2);cartesianAddInPlace(A,B);var u=n1xn2,w=cartesianDot(A,u),uu=cartesianDot(u,u),t2=w*w-uu*(cartesianDot(A,A)-1);if(t2<0)return;var t=sqrt(t2),q=cartesianScale(u,(-w-t)/uu);cartesianAddInPlace(q,A);q=spherical(q);if(!two)return q;var lambda0=a[0],lambda1=b[0],phi0=a[1],phi1=b[1],z;if(lambda10^q[1]<(abs(q[0]-lambda0)pi^(lambda0<=q[0]&&q[0]<=lambda1)){var q1=cartesianScale(u,(-w+t)/uu);cartesianAddInPlace(q1,A);return[q,spherical(q1)]}}function code(lambda,phi){var r=smallRadius?radius:pi-radius,code=0;if(lambda<-r)code|=1;else if(lambda>r)code|=2;if(phi<-r)code|=4;else if(phi>r)code|=8;return code}return clip(visible,clipLine,interpolate,smallRadius?[0,-radius]:[-pi,radius-pi])};var clipLine=function(a,b,x0,y0,x1,y1){var ax=a[0],ay=a[1],bx=b[0],by=b[1],t0=0,t1=1,dx=bx-ax,dy=by-ay,r;r=x0-ax;if(!dx&&r>0)return;r/=dx;if(dx<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=x1-ax;if(!dx&&r<0)return;r/=dx;if(dx<0){if(r>t1)return;if(r>t0)t0=r}else if(dx>0){if(r0)return;r/=dy;if(dy<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=y1-ay;if(!dy&&r<0)return;r/=dy;if(dy<0){if(r>t1)return;if(r>t0)t0=r}else if(dy>0){if(r0)a[0]=ax+t0*dx,a[1]=ay+t0*dy;if(t1<1)b[0]=ax+t1*dx,b[1]=ay+t1*dy;return true};var clipMax=1e9;var clipMin=-clipMax;function clipRectangle(x0,y0,x1,y1){function visible(x,y){return x0<=x&&x<=x1&&y0<=y&&y<=y1}function interpolate(from,to,direction,stream){var a=0,a1=0;if(from==null||(a=corner(from,direction))!==(a1=corner(to,direction))||comparePoint(from,to)<0^direction>0){do{stream.point(a===0||a===3?x0:x1,a>1?y1:y0)}while((a=(a+direction+4)%4)!==a1)}else{stream.point(to[0],to[1])}}function corner(p,direction){return abs(p[0]-x0)0?0:3:abs(p[0]-x1)0?2:1:abs(p[1]-y0)0?1:0:direction>0?3:2}function compareIntersection(a,b){return comparePoint(a.x,b.x)}function comparePoint(a,b){var ca=corner(a,1),cb=corner(b,1);return ca!==cb?ca-cb:ca===0?b[1]-a[1]:ca===1?a[0]-b[0]:ca===2?a[1]-b[1]:b[0]-a[0]}return function(stream){var activeStream=stream,bufferStream=clipBuffer(),segments,polygon,ring,x__,y__,v__,x_,y_,v_,first,clean;var clipStream={point:point,lineStart:lineStart,lineEnd:lineEnd,polygonStart:polygonStart,polygonEnd:polygonEnd};function point(x,y){if(visible(x,y))activeStream.point(x,y)}function polygonInside(){var winding=0;for(var i=0,n=polygon.length;iy1&&(b0-a0)*(y1-a1)>(b1-a1)*(x0-a0))++winding}else{if(b1<=y1&&(b0-a0)*(y1-a1)<(b1-a1)*(x0-a0))--winding}}}return winding}function polygonStart(){activeStream=bufferStream,segments=[],polygon=[],clean=true}function polygonEnd(){var startInside=polygonInside(),cleanInside=clean&&startInside,visible=(segments=d3Array.merge(segments)).length;if(cleanInside||visible){stream.polygonStart();if(cleanInside){stream.lineStart();interpolate(null,null,1,stream);stream.lineEnd()}if(visible){clipRejoin(segments,compareIntersection,startInside,interpolate,stream)}stream.polygonEnd()}activeStream=stream,segments=polygon=ring=null}function lineStart(){clipStream.point=linePoint;if(polygon)polygon.push(ring=[]);first=true;v_=false;x_=y_=NaN}function lineEnd(){if(segments){linePoint(x__,y__);if(v__&&v_)bufferStream.rejoin();segments.push(bufferStream.result())}clipStream.point=point;if(v_)activeStream.lineEnd()}function linePoint(x,y){var v=visible(x,y);if(polygon)ring.push([x,y]);if(first){x__=x,y__=y,v__=v;first=false;if(v){activeStream.lineStart();activeStream.point(x,y)}}else{if(v&&v_)activeStream.point(x,y);else{var a=[x_=Math.max(clipMin,Math.min(clipMax,x_)),y_=Math.max(clipMin,Math.min(clipMax,y_))],b=[x=Math.max(clipMin,Math.min(clipMax,x)),y=Math.max(clipMin,Math.min(clipMax,y))];if(clipLine(a,b,x0,y0,x1,y1)){if(!v_){activeStream.lineStart();activeStream.point(a[0],a[1])}activeStream.point(b[0],b[1]);if(!v)activeStream.lineEnd();clean=false}else if(v){activeStream.lineStart();activeStream.point(x,y);clean=false}}}x_=x,y_=y,v_=v}return clipStream}}var extent=function(){var x0=0,y0=0,x1=960,y1=500,cache,cacheStream,clip;return clip={stream:function(stream){return cache&&cacheStream===stream?cache:cache=clipRectangle(x0,y0,x1,y1)(cacheStream=stream)},extent:function(_){return arguments.length?(x0=+_[0][0],y0=+_[0][1],x1=+_[1][0],y1=+_[1][1],cache=cacheStream=null,clip):[[x0,y0],[x1,y1]]}}};var lengthSum=adder();var lambda0$2;var sinPhi0$1;var cosPhi0$1;var lengthStream={sphere:noop,point:noop,lineStart:lengthLineStart,lineEnd:noop,polygonStart:noop,polygonEnd:noop};function lengthLineStart(){lengthStream.point=lengthPointFirst;lengthStream.lineEnd=lengthLineEnd}function lengthLineEnd(){lengthStream.point=lengthStream.lineEnd=noop}function lengthPointFirst(lambda,phi){lambda*=radians,phi*=radians;lambda0$2=lambda,sinPhi0$1=sin(phi),cosPhi0$1=cos(phi);lengthStream.point=lengthPoint}function lengthPoint(lambda,phi){lambda*=radians,phi*=radians;var sinPhi=sin(phi),cosPhi=cos(phi),delta=abs(lambda-lambda0$2),cosDelta=cos(delta),sinDelta=sin(delta),x=cosPhi*sinDelta,y=cosPhi0$1*sinPhi-sinPhi0$1*cosPhi*cosDelta,z=sinPhi0$1*sinPhi+cosPhi0$1*cosPhi*cosDelta;lengthSum.add(atan2(sqrt(x*x+y*y),z));lambda0$2=lambda,sinPhi0$1=sinPhi,cosPhi0$1=cosPhi}var length=function(object){lengthSum.reset();geoStream(object,lengthStream);return+lengthSum};var coordinates=[null,null];var object={type:"LineString",coordinates:coordinates};var distance=function(a,b){coordinates[0]=a;coordinates[1]=b;return length(object)};var containsObjectType={Feature:function(object,point){return containsGeometry(object.geometry,point)},FeatureCollection:function(object,point){var features=object.features,i=-1,n=features.length;while(++iepsilon}).map(x)).concat(d3Array.range(ceil(y0/dy)*dy,y1,dy).filter(function(y){return abs(y%DY)>epsilon}).map(y))}graticule.lines=function(){return lines().map(function(coordinates){return{type:"LineString",coordinates:coordinates}})};graticule.outline=function(){return{type:"Polygon",coordinates:[X(X0).concat(Y(Y1).slice(1),X(X1).reverse().slice(1),Y(Y0).reverse().slice(1))]}};graticule.extent=function(_){if(!arguments.length)return graticule.extentMinor();return graticule.extentMajor(_).extentMinor(_)};graticule.extentMajor=function(_){if(!arguments.length)return[[X0,Y0],[X1,Y1]];X0=+_[0][0],X1=+_[1][0];Y0=+_[0][1],Y1=+_[1][1];if(X0>X1)_=X0,X0=X1,X1=_;if(Y0>Y1)_=Y0,Y0=Y1,Y1=_;return graticule.precision(precision)};graticule.extentMinor=function(_){if(!arguments.length)return[[x0,y0],[x1,y1]];x0=+_[0][0],x1=+_[1][0];y0=+_[0][1],y1=+_[1][1];if(x0>x1)_=x0,x0=x1,x1=_;if(y0>y1)_=y0,y0=y1,y1=_;return graticule.precision(precision)};graticule.step=function(_){if(!arguments.length)return graticule.stepMinor();return graticule.stepMajor(_).stepMinor(_)};graticule.stepMajor=function(_){if(!arguments.length)return[DX,DY];DX=+_[0],DY=+_[1];return graticule};graticule.stepMinor=function(_){if(!arguments.length)return[dx,dy];dx=+_[0],dy=+_[1];return graticule};graticule.precision=function(_){if(!arguments.length)return precision;precision=+_;x=graticuleX(y0,y1,90);y=graticuleY(x0,x1,precision);X=graticuleX(Y0,Y1,90);Y=graticuleY(X0,X1,precision);return graticule};return graticule.extentMajor([[-180,-90+epsilon],[180,90-epsilon]]).extentMinor([[-180,-80-epsilon],[180,80+epsilon]])}function graticule10(){return graticule()()}var interpolate=function(a,b){var x0=a[0]*radians,y0=a[1]*radians,x1=b[0]*radians,y1=b[1]*radians,cy0=cos(y0),sy0=sin(y0),cy1=cos(y1),sy1=sin(y1),kx0=cy0*cos(x0),ky0=cy0*sin(x0),kx1=cy1*cos(x1),ky1=cy1*sin(x1),d=2*asin(sqrt(haversin(y1-y0)+cy0*cy1*haversin(x1-x0))),k=sin(d);var interpolate=d?function(t){var B=sin(t*=d)/k,A=sin(d-t)/k,x=A*kx0+B*kx1,y=A*ky0+B*ky1,z=A*sy0+B*sy1;return[atan2(y,x)*degrees,atan2(z,sqrt(x*x+y*y))*degrees]}:function(){return[x0*degrees,y0*degrees]};interpolate.distance=d;return interpolate};var identity=function(x){return x};var areaSum$1=adder();var areaRingSum$1=adder();var x00;var y00;var x0$1;var y0$1;var areaStream$1={point:noop,lineStart:noop,lineEnd:noop,polygonStart:function(){areaStream$1.lineStart=areaRingStart$1;areaStream$1.lineEnd=areaRingEnd$1},polygonEnd:function(){areaStream$1.lineStart=areaStream$1.lineEnd=areaStream$1.point=noop;areaSum$1.add(abs(areaRingSum$1));areaRingSum$1.reset()},result:function(){var area=areaSum$1/2;areaSum$1.reset();return area}};function areaRingStart$1(){areaStream$1.point=areaPointFirst$1}function areaPointFirst$1(x,y){areaStream$1.point=areaPoint$1;x00=x0$1=x,y00=y0$1=y}function areaPoint$1(x,y){areaRingSum$1.add(y0$1*x-x0$1*y);x0$1=x,y0$1=y}function areaRingEnd$1(){areaPoint$1(x00,y00)}var x0$2=Infinity;var y0$2=x0$2;var x1=-x0$2;var y1=x1;var boundsStream$1={point:boundsPoint$1,lineStart:noop,lineEnd:noop,polygonStart:noop,polygonEnd:noop,result:function(){var bounds=[[x0$2,y0$2],[x1,y1]];x1=y1=-(y0$2=x0$2=Infinity);return bounds}};function boundsPoint$1(x,y){if(xx1)x1=x;if(yy1)y1=y}var X0$1=0;var Y0$1=0;var Z0$1=0;var X1$1=0;var Y1$1=0;var Z1$1=0;var X2$1=0;var Y2$1=0;var Z2$1=0;var x00$1;var y00$1;var x0$3;var y0$3;var centroidStream$1={point:centroidPoint$1,lineStart:centroidLineStart$1,lineEnd:centroidLineEnd$1,polygonStart:function(){centroidStream$1.lineStart=centroidRingStart$1;centroidStream$1.lineEnd=centroidRingEnd$1},polygonEnd:function(){centroidStream$1.point=centroidPoint$1;centroidStream$1.lineStart=centroidLineStart$1;centroidStream$1.lineEnd=centroidLineEnd$1},result:function(){var centroid=Z2$1?[X2$1/Z2$1,Y2$1/Z2$1]:Z1$1?[X1$1/Z1$1,Y1$1/Z1$1]:Z0$1?[X0$1/Z0$1,Y0$1/Z0$1]:[NaN,NaN];X0$1=Y0$1=Z0$1=X1$1=Y1$1=Z1$1=X2$1=Y2$1=Z2$1=0;return centroid}};function centroidPoint$1(x,y){X0$1+=x;Y0$1+=y;++Z0$1}function centroidLineStart$1(){centroidStream$1.point=centroidPointFirstLine}function centroidPointFirstLine(x,y){centroidStream$1.point=centroidPointLine;centroidPoint$1(x0$3=x,y0$3=y)}function centroidPointLine(x,y){var dx=x-x0$3,dy=y-y0$3,z=sqrt(dx*dx+dy*dy);X1$1+=z*(x0$3+x)/2;Y1$1+=z*(y0$3+y)/2;Z1$1+=z;centroidPoint$1(x0$3=x,y0$3=y)}function centroidLineEnd$1(){centroidStream$1.point=centroidPoint$1}function centroidRingStart$1(){centroidStream$1.point=centroidPointFirstRing}function centroidRingEnd$1(){centroidPointRing(x00$1,y00$1)}function centroidPointFirstRing(x,y){centroidStream$1.point=centroidPointRing;centroidPoint$1(x00$1=x0$3=x,y00$1=y0$3=y)}function centroidPointRing(x,y){var dx=x-x0$3,dy=y-y0$3,z=sqrt(dx*dx+dy*dy);X1$1+=z*(x0$3+x)/2;Y1$1+=z*(y0$3+y)/2;Z1$1+=z;z=y0$3*x-x0$3*y;X2$1+=z*(x0$3+x);Y2$1+=z*(y0$3+y);Z2$1+=z*3;centroidPoint$1(x0$3=x,y0$3=y)}function PathContext(context){this._context=context}PathContext.prototype={_radius:4.5,pointRadius:function(_){return this._radius=_,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){if(this._line===0)this._context.closePath();this._point=NaN},point:function(x,y){switch(this._point){case 0:{this._context.moveTo(x,y);this._point=1;break}case 1:{this._context.lineTo(x,y);break}default:{this._context.moveTo(x+this._radius,y);this._context.arc(x,y,this._radius,0,tau);break}}},result:noop};var lengthSum$1=adder();var lengthRing;var x00$2;var y00$2;var x0$4;var y0$4;var lengthStream$1={point:noop,lineStart:function(){lengthStream$1.point=lengthPointFirst$1},lineEnd:function(){if(lengthRing)lengthPoint$1(x00$2,y00$2);lengthStream$1.point=noop},polygonStart:function(){lengthRing=true},polygonEnd:function(){lengthRing=null},result:function(){var length=+lengthSum$1;lengthSum$1.reset();return length}};function lengthPointFirst$1(x,y){lengthStream$1.point=lengthPoint$1;x00$2=x0$4=x,y00$2=y0$4=y}function lengthPoint$1(x,y){x0$4-=x,y0$4-=y;lengthSum$1.add(sqrt(x0$4*x0$4+y0$4*y0$4));x0$4=x,y0$4=y}function PathString(){this._string=[]}PathString.prototype={_radius:4.5,_circle:circle$1(4.5),pointRadius:function(_){if((_=+_)!==this._radius)this._radius=_,this._circle=null;return this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){if(this._line===0)this._string.push("Z");this._point=NaN},point:function(x,y){switch(this._point){case 0:{this._string.push("M",x,",",y);this._point=1;break}case 1:{this._string.push("L",x,",",y);break}default:{if(this._circle==null)this._circle=circle$1(this._radius);this._string.push("M",x,",",y,this._circle);break}}},result:function(){if(this._string.length){var result=this._string.join("");this._string=[];return result}else{return null}}};function circle$1(radius){return"m0,"+radius+"a"+radius+","+radius+" 0 1,1 0,"+-2*radius+"a"+radius+","+radius+" 0 1,1 0,"+2*radius+"z"}var index=function(projection,context){var pointRadius=4.5,projectionStream,contextStream;function path(object){if(object){if(typeof pointRadius==="function")contextStream.pointRadius(+pointRadius.apply(this,arguments));geoStream(object,projectionStream(contextStream))}return contextStream.result()}path.area=function(object){geoStream(object,projectionStream(areaStream$1));return areaStream$1.result()};path.measure=function(object){geoStream(object,projectionStream(lengthStream$1)) -;return lengthStream$1.result()};path.bounds=function(object){geoStream(object,projectionStream(boundsStream$1));return boundsStream$1.result()};path.centroid=function(object){geoStream(object,projectionStream(centroidStream$1));return centroidStream$1.result()};path.projection=function(_){return arguments.length?(projectionStream=_==null?(projection=null,identity):(projection=_).stream,path):projection};path.context=function(_){if(!arguments.length)return context;contextStream=_==null?(context=null,new PathString):new PathContext(context=_);if(typeof pointRadius!=="function")contextStream.pointRadius(pointRadius);return path};path.pointRadius=function(_){if(!arguments.length)return pointRadius;pointRadius=typeof _==="function"?_:(contextStream.pointRadius(+_),+_);return path};return path.projection(projection).context(context)};var transform=function(methods){return{stream:transformer(methods)}};function transformer(methods){return function(stream){var s=new TransformStream;for(var key in methods)s[key]=methods[key];s.stream=stream;return s}}function TransformStream(){}TransformStream.prototype={constructor:TransformStream,point:function(x,y){this.stream.point(x,y)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function fit(projection,fitBounds,object){var clip=projection.clipExtent&&projection.clipExtent();projection.scale(150).translate([0,0]);if(clip!=null)projection.clipExtent(null);geoStream(object,projection.stream(boundsStream$1));fitBounds(boundsStream$1.result());if(clip!=null)projection.clipExtent(clip);return projection}function fitExtent(projection,extent,object){return fit(projection,function(b){var w=extent[1][0]-extent[0][0],h=extent[1][1]-extent[0][1],k=Math.min(w/(b[1][0]-b[0][0]),h/(b[1][1]-b[0][1])),x=+extent[0][0]+(w-k*(b[1][0]+b[0][0]))/2,y=+extent[0][1]+(h-k*(b[1][1]+b[0][1]))/2;projection.scale(150*k).translate([x,y])},object)}function fitSize(projection,size,object){return fitExtent(projection,[[0,0],size],object)}function fitWidth(projection,width,object){return fit(projection,function(b){var w=+width,k=w/(b[1][0]-b[0][0]),x=(w-k*(b[1][0]+b[0][0]))/2,y=-k*b[0][1];projection.scale(150*k).translate([x,y])},object)}function fitHeight(projection,height,object){return fit(projection,function(b){var h=+height,k=h/(b[1][1]-b[0][1]),x=-k*b[0][0],y=(h-k*(b[1][1]+b[0][1]))/2;projection.scale(150*k).translate([x,y])},object)}var maxDepth=16;var cosMinDistance=cos(30*radians);var resample=function(project,delta2){return+delta2?resample$1(project,delta2):resampleNone(project)};function resampleNone(project){return transformer({point:function(x,y){x=project(x,y);this.stream.point(x[0],x[1])}})}function resample$1(project,delta2){function resampleLineTo(x0,y0,lambda0,a0,b0,c0,x1,y1,lambda1,a1,b1,c1,depth,stream){var dx=x1-x0,dy=y1-y0,d2=dx*dx+dy*dy;if(d2>4*delta2&&depth--){var a=a0+a1,b=b0+b1,c=c0+c1,m=sqrt(a*a+b*b+c*c),phi2=asin(c/=m),lambda2=abs(abs(c)-1)delta2||abs((dx*dx2+dy*dy2)/d2-.5)>.3||a0*a1+b0*b1+c0*c12?_[2]%360*radians:0,recenter()):[deltaLambda*degrees,deltaPhi*degrees,deltaGamma*degrees]};projection.precision=function(_){return arguments.length?(projectResample=resample(projectTransform,delta2=_*_),reset()):sqrt(delta2)};projection.fitExtent=function(extent,object){return fitExtent(projection,extent,object)};projection.fitSize=function(size,object){return fitSize(projection,size,object)};projection.fitWidth=function(width,object){return fitWidth(projection,width,object)};projection.fitHeight=function(height,object){return fitHeight(projection,height,object)};function recenter(){projectRotate=compose(rotate=rotateRadians(deltaLambda,deltaPhi,deltaGamma),project);var center=project(lambda,phi);dx=x-center[0]*k;dy=y+center[1]*k;return reset()}function reset(){cache=cacheStream=null;return projection}return function(){project=projectAt.apply(this,arguments);projection.invert=project.invert&&invert;return recenter()}}function conicProjection(projectAt){var phi0=0,phi1=pi/3,m=projectionMutator(projectAt),p=m(phi0,phi1);p.parallels=function(_){return arguments.length?m(phi0=_[0]*radians,phi1=_[1]*radians):[phi0*degrees,phi1*degrees]};return p}function cylindricalEqualAreaRaw(phi0){var cosPhi0=cos(phi0);function forward(lambda,phi){return[lambda*cosPhi0,sin(phi)/cosPhi0]}forward.invert=function(x,y){return[x/cosPhi0,asin(y*cosPhi0)]};return forward}function conicEqualAreaRaw(y0,y1){var sy0=sin(y0),n=(sy0+sin(y1))/2;if(abs(n)=.12&&y<.234&&x>=-.425&&x<-.214?alaska:y>=.166&&y<.234&&x>=-.214&&x<-.115?hawaii:lower48).invert(coordinates)};albersUsa.stream=function(stream){return cache&&cacheStream===stream?cache:cache=multiplex([lower48.stream(cacheStream=stream),alaska.stream(stream),hawaii.stream(stream)])};albersUsa.precision=function(_){if(!arguments.length)return lower48.precision();lower48.precision(_),alaska.precision(_),hawaii.precision(_);return reset()};albersUsa.scale=function(_){if(!arguments.length)return lower48.scale();lower48.scale(_),alaska.scale(_*.35),hawaii.scale(_);return albersUsa.translate(lower48.translate())};albersUsa.translate=function(_){if(!arguments.length)return lower48.translate();var k=lower48.scale(),x=+_[0],y=+_[1];lower48Point=lower48.translate(_).clipExtent([[x-.455*k,y-.238*k],[x+.455*k,y+.238*k]]).stream(pointStream);alaskaPoint=alaska.translate([x-.307*k,y+.201*k]).clipExtent([[x-.425*k+epsilon,y+.12*k+epsilon],[x-.214*k-epsilon,y+.234*k-epsilon]]).stream(pointStream);hawaiiPoint=hawaii.translate([x-.205*k,y+.212*k]).clipExtent([[x-.214*k+epsilon,y+.166*k+epsilon],[x-.115*k-epsilon,y+.234*k-epsilon]]).stream(pointStream);return reset()};albersUsa.fitExtent=function(extent,object){return fitExtent(albersUsa,extent,object)};albersUsa.fitSize=function(size,object){return fitSize(albersUsa,size,object)};albersUsa.fitWidth=function(width,object){return fitWidth(albersUsa,width,object)};albersUsa.fitHeight=function(height,object){return fitHeight(albersUsa,height,object)};function reset(){cache=cacheStream=null;return albersUsa}return albersUsa.scale(1070)};function azimuthalRaw(scale){return function(x,y){var cx=cos(x),cy=cos(y),k=scale(cx*cy);return[k*cy*sin(x),k*sin(y)]}}function azimuthalInvert(angle){return function(x,y){var z=sqrt(x*x+y*y),c=angle(z),sc=sin(c),cc=cos(c);return[atan2(x*sc,z*cc),asin(z&&y*sc/z)]}}var azimuthalEqualAreaRaw=azimuthalRaw(function(cxcy){return sqrt(2/(1+cxcy))});azimuthalEqualAreaRaw.invert=azimuthalInvert(function(z){return 2*asin(z/2)});var azimuthalEqualArea=function(){return projection(azimuthalEqualAreaRaw).scale(124.75).clipAngle(180-.001)};var azimuthalEquidistantRaw=azimuthalRaw(function(c){return(c=acos(c))&&c/sin(c)});azimuthalEquidistantRaw.invert=azimuthalInvert(function(z){return z});var azimuthalEquidistant=function(){return projection(azimuthalEquidistantRaw).scale(79.4188).clipAngle(180-.001)};function mercatorRaw(lambda,phi){return[lambda,log(tan((halfPi+phi)/2))]}mercatorRaw.invert=function(x,y){return[x,2*atan(exp(y))-halfPi]};var mercator=function(){return mercatorProjection(mercatorRaw).scale(961/tau)};function mercatorProjection(project){var m=projection(project),center=m.center,scale=m.scale,translate=m.translate,clipExtent=m.clipExtent,x0=null,y0,x1,y1;m.scale=function(_){return arguments.length?(scale(_),reclip()):scale()};m.translate=function(_){return arguments.length?(translate(_),reclip()):translate()};m.center=function(_){return arguments.length?(center(_),reclip()):center()};m.clipExtent=function(_){return arguments.length?(_==null?x0=y0=x1=y1=null:(x0=+_[0][0],y0=+_[0][1],x1=+_[1][0],y1=+_[1][1]),reclip()):x0==null?null:[[x0,y0],[x1,y1]]};function reclip(){var k=pi*scale(),t=m(rotation(m.rotate()).invert([0,0]));return clipExtent(x0==null?[[t[0]-k,t[1]-k],[t[0]+k,t[1]+k]]:project===mercatorRaw?[[Math.max(t[0]-k,x0),y0],[Math.min(t[0]+k,x1),y1]]:[[x0,Math.max(t[1]-k,y0)],[x1,Math.min(t[1]+k,y1)]])}return reclip()}function tany(y){return tan((halfPi+y)/2)}function conicConformalRaw(y0,y1){var cy0=cos(y0),n=y0===y1?sin(y0):log(cy0/cos(y1))/log(tany(y1)/tany(y0)),f=cy0*pow(tany(y0),n)/n;if(!n)return mercatorRaw;function project(x,y){if(f>0){if(y<-halfPi+epsilon)y=-halfPi+epsilon}else{if(y>halfPi-epsilon)y=halfPi-epsilon}var r=f/pow(tany(y),n);return[r*sin(n*x),f-r*cos(n*x)]}project.invert=function(x,y){var fy=f-y,r=sign(n)*sqrt(x*x+fy*fy);return[atan2(x,abs(fy))/n*sign(fy),2*atan(pow(f/r,1/n))-halfPi]};return project}var conicConformal=function(){return conicProjection(conicConformalRaw).scale(109.5).parallels([30,30])};function equirectangularRaw(lambda,phi){return[lambda,phi]}equirectangularRaw.invert=equirectangularRaw;var equirectangular=function(){return projection(equirectangularRaw).scale(152.63)};function conicEquidistantRaw(y0,y1){var cy0=cos(y0),n=y0===y1?sin(y0):(cy0-cos(y1))/(y1-y0),g=cy0/n+y0;if(abs(n)epsilon&&--i>0);return[x/(.8707+(phi2=phi*phi)*(-.131979+phi2*(-.013791+phi2*phi2*phi2*(.003971-.001529*phi2)))),phi]};var naturalEarth1=function(){return projection(naturalEarth1Raw).scale(175.295)};function orthographicRaw(x,y){return[cos(y)*sin(x),sin(y)]}orthographicRaw.invert=azimuthalInvert(asin);var orthographic=function(){return projection(orthographicRaw).scale(249.5).clipAngle(90+epsilon)};function stereographicRaw(x,y){var cy=cos(y),k=1+cos(x)*cy;return[cy*sin(x)/k,sin(y)/k]}stereographicRaw.invert=azimuthalInvert(function(z){return 2*atan(z)});var stereographic=function(){return projection(stereographicRaw).scale(250).clipAngle(142)};function transverseMercatorRaw(lambda,phi){return[log(tan((halfPi+phi)/2)),-lambda]}transverseMercatorRaw.invert=function(x,y){return[-y,2*atan(exp(x))-halfPi]};var transverseMercator=function(){var m=mercatorProjection(transverseMercatorRaw),center=m.center,rotate=m.rotate;m.center=function(_){return arguments.length?center([-_[1],_[0]]):(_=center(),[_[1],-_[0]])};m.rotate=function(_){return arguments.length?rotate([_[0],_[1],_.length>2?_[2]+90:90]):(_=rotate(),[_[0],_[1],_[2]-90])};return rotate([0,0,90]).scale(159.155)};exports.geoArea=area;exports.geoBounds=bounds;exports.geoCentroid=centroid;exports.geoCircle=circle;exports.geoClipAntimeridian=clipAntimeridian;exports.geoClipCircle=clipCircle;exports.geoClipExtent=extent;exports.geoClipRectangle=clipRectangle;exports.geoContains=contains;exports.geoDistance=distance;exports.geoGraticule=graticule;exports.geoGraticule10=graticule10;exports.geoInterpolate=interpolate;exports.geoLength=length;exports.geoPath=index;exports.geoAlbers=albers;exports.geoAlbersUsa=albersUsa;exports.geoAzimuthalEqualArea=azimuthalEqualArea;exports.geoAzimuthalEqualAreaRaw=azimuthalEqualAreaRaw;exports.geoAzimuthalEquidistant=azimuthalEquidistant;exports.geoAzimuthalEquidistantRaw=azimuthalEquidistantRaw;exports.geoConicConformal=conicConformal;exports.geoConicConformalRaw=conicConformalRaw;exports.geoConicEqualArea=conicEqualArea;exports.geoConicEqualAreaRaw=conicEqualAreaRaw;exports.geoConicEquidistant=conicEquidistant;exports.geoConicEquidistantRaw=conicEquidistantRaw;exports.geoEquirectangular=equirectangular;exports.geoEquirectangularRaw=equirectangularRaw;exports.geoGnomonic=gnomonic;exports.geoGnomonicRaw=gnomonicRaw;exports.geoIdentity=identity$1;exports.geoProjection=projection;exports.geoProjectionMutator=projectionMutator;exports.geoMercator=mercator;exports.geoMercatorRaw=mercatorRaw;exports.geoNaturalEarth1=naturalEarth1;exports.geoNaturalEarth1Raw=naturalEarth1Raw;exports.geoOrthographic=orthographic;exports.geoOrthographicRaw=orthographicRaw;exports.geoStereographic=stereographic;exports.geoStereographicRaw=stereographicRaw;exports.geoTransverseMercator=transverseMercator;exports.geoTransverseMercatorRaw=transverseMercatorRaw;exports.geoRotation=rotation;exports.geoStream=geoStream;exports.geoTransform=transform;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3}],9:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var thirdPi=Math.PI/3;var angles=[0,thirdPi,2*thirdPi,3*thirdPi,4*thirdPi,5*thirdPi];function pointX(d){return d[0]}function pointY(d){return d[1]}var hexbin=function(){var x0=0,y0=0,x1=1,y1=1,x=pointX,y=pointY,r,dx,dy;function hexbin(points){var binsById={},bins=[],i,n=points.length;for(i=0;i1){var px1=px-pi,pi2=pi+(pxpx2*px2+py2*py2)pi=pi2+(pj&1?1:-1)/2,pj=pj2}var id=pi+"-"+pj,bin=binsById[id];if(bin)bin.push(point);else{bins.push(bin=binsById[id]=[point]);bin.x=(pi+(pj&1)/2)*dx;bin.y=pj*dy}}return bins}function hexagon(radius){var x0=0,y0=0;return angles.map(function(angle){var x1=Math.sin(angle)*radius,y1=-Math.cos(angle)*radius,dx=x1-x0,dy=y1-y0;x0=x1,y0=y1;return[dx,dy]})}hexbin.hexagon=function(radius){return"m"+hexagon(radius==null?r:+radius).join("l")+"z"};hexbin.centers=function(){var centers=[],j=Math.round(y0/dy),i=Math.round(x0/dx);for(var y=j*dy;y=0)sum+=children[i].value;node.value=sum}var node_count=function(){return this.eachAfter(count)};var node_each=function(callback){var node=this,current,next=[node],children,i,n;do{current=next.reverse(),next=[];while(node=current.pop()){callback(node),children=node.children;if(children)for(i=0,n=children.length;i=0;--i){nodes.push(children[i])}}return this};var node_eachAfter=function(callback){var node=this,nodes=[node],next=[],children,i,n;while(node=nodes.pop()){next.push(node),children=node.children;if(children)for(i=0,n=children.length;i=0)sum+=children[i].value;node.value=sum})};var node_sort=function(compare){return this.eachBefore(function(node){if(node.children){node.children.sort(compare)}})};var node_path=function(end){var start=this,ancestor=leastCommonAncestor(start,end),nodes=[start];while(start!==ancestor){start=start.parent;nodes.push(start)}var k=nodes.length;while(end!==ancestor){nodes.splice(k,0,end);end=end.parent}return nodes};function leastCommonAncestor(a,b){if(a===b)return a;var aNodes=a.ancestors(),bNodes=b.ancestors(),c=null;a=aNodes.pop();b=bNodes.pop();while(a===b){c=a;a=aNodes.pop();b=bNodes.pop()}return c}var node_ancestors=function(){var node=this,nodes=[node];while(node=node.parent){nodes.push(node)}return nodes};var node_descendants=function(){var nodes=[];this.each(function(node){nodes.push(node)});return nodes};var node_leaves=function(){var leaves=[];this.eachBefore(function(node){if(!node.children){leaves.push(node)}});return leaves};var node_links=function(){var root=this,links=[];root.each(function(node){if(node!==root){links.push({source:node.parent,target:node})}});return links};function hierarchy(data,children){var root=new Node(data),valued=+data.value&&(root.value=data.value),node,nodes=[root],child,childs,i,n;if(children==null)children=defaultChildren;while(node=nodes.pop()){if(valued)node.value=+node.data.value;if((childs=children(node.data))&&(n=childs.length)){node.children=new Array(n);for(i=n-1;i>=0;--i){nodes.push(child=node.children[i]=new Node(childs[i]));child.parent=node;child.depth=node.depth+1}}}return root.eachBefore(computeHeight)}function node_copy(){return hierarchy(this).eachBefore(copyData)}function defaultChildren(d){return d.children}function copyData(node){node.data=node.data.data}function computeHeight(node){var height=0;do{node.height=height}while((node=node.parent)&&node.height<++height)}function Node(data){this.data=data;this.depth=this.height=0;this.parent=null}Node.prototype=hierarchy.prototype={constructor:Node,count:node_count,each:node_each,eachAfter:node_eachAfter,eachBefore:node_eachBefore,sum:node_sum,sort:node_sort,path:node_path,ancestors:node_ancestors,descendants:node_descendants,leaves:node_leaves,links:node_links,copy:node_copy};var slice=Array.prototype.slice;function shuffle(array){var m=array.length,t,i;while(m){i=Math.random()*m--|0;t=array[m];array[m]=array[i];array[i]=t}return array}var enclose=function(circles){var i=0,n=(circles=shuffle(slice.call(circles))).length,B=[],p,e;while(i0&&dr*dr>dx*dx+dy*dy}function enclosesWeakAll(a,B){for(var i=0;idx*dx+dy*dy}function score(node){var a=node._,b=node.next._,ab=a.r+b.r,dx=(a.x*b.r+b.x*a.r)/ab,dy=(a.y*b.r+b.y*a.r)/ab;return dx*dx+dy*dy}function Node$1(circle){this._=circle;this.next=null;this.previous=null}function packEnclose(circles){if(!(n=circles.length))return 0;var a,b,c,n,aa,ca,i,j,k,sj,sk;a=circles[0],a.x=0,a.y=0;if(!(n>1))return a.r;b=circles[1],a.x=-b.r,b.x=a.r,b.y=0;if(!(n>2))return a.r+b.r;place(b,a,c=circles[2]);a=new Node$1(a),b=new Node$1(b),c=new Node$1(c);a.next=c.previous=b;b.next=a.previous=c;c.next=b.previous=a;pack:for(i=3;i0)throw new Error("cycle");return root}stratify.id=function(x){return arguments.length?(id=required(x),stratify):id};stratify.parentId=function(x){return arguments.length?(parentId=required(x),stratify):parentId};return stratify};function defaultSeparation$1(a,b){return a.parent===b.parent?1:2}function nextLeft(v){var children=v.children;return children?children[0]:v.t}function nextRight(v){var children=v.children;return children?children[children.length-1]:v.t}function moveSubtree(wm,wp,shift){var change=shift/(wp.i-wm.i);wp.c-=change;wp.s+=shift;wm.c+=change;wp.z+=shift;wp.m+=shift}function executeShifts(v){var shift=0,change=0,children=v.children,i=children.length,w;while(--i>=0){w=children[i];w.z+=shift;w.m+=shift;shift+=w.s+(change+=w.c)}}function nextAncestor(vim,v,ancestor){return vim.a.parent===v.parent?vim.a:ancestor}function TreeNode(node,i){this._=node;this.parent=null;this.children=null;this.A=null;this.a=this;this.z=0;this.m=0;this.c=0;this.s=0;this.t=null;this.i=i}TreeNode.prototype=Object.create(Node.prototype);function treeRoot(root){var tree=new TreeNode(root,0),node,nodes=[tree],child,children,i,n;while(node=nodes.pop()){if(children=node._.children){node.children=new Array(n=children.length);for(i=n-1;i>=0;--i){nodes.push(child=node.children[i]=new TreeNode(children[i],i));child.parent=node}}}(tree.parent=new TreeNode(null,0)).children=[tree];return tree}var tree=function(){var separation=defaultSeparation$1,dx=1,dy=1,nodeSize=null;function tree(root){var t=treeRoot(root);t.eachAfter(firstWalk),t.parent.m=-t.z;t.eachBefore(secondWalk);if(nodeSize)root.eachBefore(sizeNode);else{var left=root,right=root,bottom=root;root.eachBefore(function(node){if(node.xright.x)right=node;if(node.depth>bottom.depth)bottom=node});var s=left===right?1:separation(left,right)/2,tx=s-left.x,kx=dx/(right.x+s+tx),ky=dy/(bottom.depth||1);root.eachBefore(function(node){node.x=(node.x+tx)*kx;node.y=node.depth*ky})}return root}function firstWalk(v){var children=v.children,siblings=v.parent.children,w=v.i?siblings[v.i-1]:null;if(children){executeShifts(v);var midpoint=(children[0].z+children[children.length-1].z)/2;if(w){v.z=w.z+separation(v._,w._);v.m=v.z-midpoint}else{v.z=midpoint}}else if(w){v.z=w.z+separation(v._,w._)}v.parent.A=apportion(v,w,v.parent.A||siblings[0])}function secondWalk(v){v._.x=v.z+v.parent.m;v.m+=v.parent.m}function apportion(v,w,ancestor){if(w){var vip=v,vop=v,vim=w,vom=vip.parent.children[0],sip=vip.m,sop=vop.m,sim=vim.m,som=vom.m,shift;while(vim=nextRight(vim),vip=nextLeft(vip),vim&&vip){vom=nextLeft(vom);vop=nextRight(vop);vop.a=v;shift=vim.z+sim-vip.z-sip+separation(vim._,vip._);if(shift>0){moveSubtree(nextAncestor(vim,v,ancestor),v,shift);sip+=shift;sop+=shift}sim+=vim.m;sip+=vip.m;som+=vom.m;sop+=vop.m}if(vim&&!nextRight(vop)){vop.t=vim;vop.m+=sim-sop}if(vip&&!nextLeft(vom)){vom.t=vip;vom.m+=sip-som;ancestor=v}}return ancestor}function sizeNode(node){node.x*=dx;node.y=node.depth*dy}tree.separation=function(x){return arguments.length?(separation=x,tree):separation};tree.size=function(x){return arguments.length?(nodeSize=false,dx=+x[0],dy=+x[1],tree):nodeSize?null:[dx,dy]};tree.nodeSize=function(x){return arguments.length?(nodeSize=true,dx=+x[0],dy=+x[1],tree):nodeSize?[dx,dy]:null};return tree};var treemapSlice=function(parent,x0,y0,x1,y1){var nodes=parent.children,node,i=-1,n=nodes.length,k=parent.value&&(y1-y0)/parent.value;while(++imaxValue)maxValue=nodeValue;beta=sumValue*sumValue*alpha;newRatio=Math.max(maxValue/beta,beta/minValue);if(newRatio>minRatio){sumValue-=nodeValue;break}minRatio=newRatio}rows.push(row={value:sumValue,dice:dx1?x:1)};return squarify}(phi);var index$1=function(){var tile=squarify,round=false,dx=1,dy=1,paddingStack=[0],paddingInner=constantZero,paddingTop=constantZero,paddingRight=constantZero,paddingBottom=constantZero,paddingLeft=constantZero;function treemap(root){root.x0=root.y0=0;root.x1=dx;root.y1=dy;root.eachBefore(positionNode);paddingStack=[0];if(round)root.eachBefore(roundNode);return root}function positionNode(node){var p=paddingStack[node.depth],x0=node.x0+p,y0=node.y0+p,x1=node.x1-p,y1=node.y1-p;if(x1=j-1){var node=nodes[i];node.x0=x0,node.y0=y0;node.x1=x1,node.y1=y1;return}var valueOffset=sums[i],valueTarget=value/2+valueOffset,k=i+1,hi=j-1;while(k>>1;if(sums[mid]y1-y0){var xk=(x0*valueRight+x1*valueLeft)/value;partition(i,k,valueLeft,x0,y0,xk,y1);partition(k,j,valueRight,xk,y0,x1,y1)}else{var yk=(y0*valueRight+y1*valueLeft)/value;partition(i,k,valueLeft,x0,y0,x1,yk);partition(k,j,valueRight,x0,yk,x1,y1)}}};var sliceDice=function(parent,x0,y0,x1,y1){(parent.depth&1?treemapSlice:treemapDice)(parent,x0,y0,x1,y1)};var resquarify=function custom(ratio){function resquarify(parent,x0,y0,x1,y1){if((rows=parent._squarify)&&rows.ratio===ratio){var rows,row,nodes,i,j=-1,n,m=rows.length,value=parent.value;while(++j1?x:1)};return resquarify}(phi);exports.cluster=cluster;exports.hierarchy=hierarchy;exports.pack=index;exports.packSiblings=siblings;exports.packEnclose=enclose;exports.partition=partition;exports.stratify=stratify;exports.tree=tree;exports.treemap=index$1;exports.treemapBinary=binary;exports.treemapDice=treemapDice;exports.treemapSlice=treemapSlice;exports.treemapSliceDice=sliceDice;exports.treemapSquarify=squarify;exports.treemapResquarify=resquarify;Object.defineProperty(exports,"__esModule",{value:true})})},{}],11:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-color")):typeof define==="function"&&define.amd?define(["exports","d3-color"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Color){"use strict";function basis(t1,v0,v1,v2,v3){var t2=t1*t1,t3=t2*t1;return((1-3*t1+3*t2-t3)*v0+(4-6*t2+3*t3)*v1+(1+3*t1+3*t2-3*t3)*v2+t3*v3)/6}var basis$1=function(values){var n=values.length-1;return function(t){var i=t<=0?t=0:t>=1?(t=1,n-1):Math.floor(t*n),v1=values[i],v2=values[i+1],v0=i>0?values[i-1]:2*v1-v2,v3=i180||d<-180?d-360*Math.round(d/360):d):constant(isNaN(a)?b:a)}function gamma(y){return(y=+y)===1?nogamma:function(a,b){return b-a?exponential(a,b,y):constant(isNaN(a)?b:a)}}function nogamma(a,b){var d=b-a;return d?linear(a,d):constant(isNaN(a)?b:a)}var rgb$1=function rgbGamma(y){var color$$1=gamma(y);function rgb$$1(start,end){var r=color$$1((start=d3Color.rgb(start)).r,(end=d3Color.rgb(end)).r),g=color$$1(start.g,end.g),b=color$$1(start.b,end.b),opacity=nogamma(start.opacity,end.opacity);return function(t){start.r=r(t);start.g=g(t);start.b=b(t);start.opacity=opacity(t);return start+""}}rgb$$1.gamma=rgbGamma;return rgb$$1}(1);function rgbSpline(spline){return function(colors){var n=colors.length,r=new Array(n),g=new Array(n),b=new Array(n),i,color$$1;for(i=0;ibi){bs=b.slice(bi,bs);if(s[i])s[i]+=bs;else s[++i]=bs}if((am=am[0])===(bm=bm[0])){if(s[i])s[i]+=bm;else s[++i]=bm}else{s[++i]=null;q.push({i:i,x:number(am,bm)})}bi=reB.lastIndex}if(bi180)b+=360;else if(b-a>180)a+=360;q.push({i:s.push(pop(s)+"rotate(",null,degParen)-2,x:number(a,b)})}else if(b){s.push(pop(s)+"rotate("+b+degParen)}}function skewX(a,b,s,q){if(a!==b){q.push({i:s.push(pop(s)+"skewX(",null,degParen)-2,x:number(a,b)})}else if(b){s.push(pop(s)+"skewX("+b+degParen)}}function scale(xa,ya,xb,yb,s,q){if(xa!==xb||ya!==yb){var i=s.push(pop(s)+"scale(",null,",",null,")");q.push({i:i-4,x:number(xa,xb)},{i:i-2,x:number(ya,yb)})}else if(xb!==1||yb!==1){s.push(pop(s)+"scale("+xb+","+yb+")")}}return function(a,b){var s=[],q=[];a=parse(a),b=parse(b);translate(a.translateX,a.translateY,b.translateX,b.translateY,s,q);rotate(a.rotate,b.rotate,s,q);skewX(a.skewX,b.skewX,s,q);scale(a.scaleX,a.scaleY,b.scaleX,b.scaleY,s,q);a=b=null;return function(t){var i=-1,n=q.length,o;while(++iepsilon)){}else if(!(Math.abs(y01*x21-y21*x01)>epsilon)||!r){this._+="L"+(this._x1=x1)+","+(this._y1=y1)}else{var x20=x2-x0,y20=y2-y0,l21_2=x21*x21+y21*y21,l20_2=x20*x20+y20*y20,l21=Math.sqrt(l21_2),l01=Math.sqrt(l01_2),l=r*Math.tan((pi-Math.acos((l21_2+l01_2-l20_2)/(2*l21*l01)))/2),t01=l/l01,t21=l/l21;if(Math.abs(t01-1)>epsilon){this._+="L"+(x1+t01*x01)+","+(y1+t01*y01)}this._+="A"+r+","+r+",0,0,"+ +(y01*x20>x01*y20)+","+(this._x1=x1+t21*x21)+","+(this._y1=y1+t21*y21)}},arc:function(x,y,r,a0,a1,ccw){x=+x,y=+y,r=+r;var dx=r*Math.cos(a0),dy=r*Math.sin(a0),x0=x+dx,y0=y+dy,cw=1^ccw,da=ccw?a0-a1:a1-a0;if(r<0)throw new Error("negative radius: "+r);if(this._x1===null){this._+="M"+x0+","+y0}else if(Math.abs(this._x1-x0)>epsilon||Math.abs(this._y1-y0)>epsilon){this._+="L"+x0+","+y0}if(!r)return;if(da<0)da=da%tau+tau;if(da>tauEpsilon){this._+="A"+r+","+r+",0,1,"+cw+","+(x-dx)+","+(y-dy)+"A"+r+","+r+",0,1,"+cw+","+(this._x1=x0)+","+(this._y1=y0)}else if(da>epsilon){this._+="A"+r+","+r+",0,"+ +(da>=pi)+","+cw+","+(this._x1=x+r*Math.cos(a1))+","+(this._y1=y+r*Math.sin(a1))}},rect:function(x,y,w,h){this._+="M"+(this._x0=this._x1=+x)+","+(this._y0=this._y1=+y)+"h"+ +w+"v"+ +h+"h"+-w+"Z"},toString:function(){return this._}};exports.path=path;Object.defineProperty(exports,"__esModule",{value:true})})},{}],13:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array"),require("d3-collection"),require("d3-shape")):typeof define==="function"&&define.amd?define(["exports","d3-array","d3-collection","d3-shape"],factory):factory(global.d3=global.d3||{},global.d3,global.d3,global.d3)})(this,function(exports,d3Array,d3Collection,d3Shape){"use strict";function targetDepth(d){return d.target.depth}function left(node){return node.depth}function right(node,n){return n-1-node.height}function justify(node,n){return node.sourceLinks.length?node.depth:n-1}function center(node){return node.targetLinks.length?node.depth:node.sourceLinks.length?d3Array.min(node.sourceLinks,targetDepth)-1:0}function constant(x){return function(){return x}}function ascendingSourceBreadth(a,b){return ascendingBreadth(a.source,b.source)||a.index-b.index}function ascendingTargetBreadth(a,b){return ascendingBreadth(a.target,b.target)||a.index-b.index}function ascendingBreadth(a,b){return a.y0-b.y0}function value(d){return d.value}function nodeCenter(node){return(node.y0+node.y1)/2}function weightedSource(link){return nodeCenter(link.source)*link.value}function weightedTarget(link){return nodeCenter(link.target)*link.value}function defaultId(d){return d.index}function defaultNodes(graph){return graph.nodes}function defaultLinks(graph){return graph.links}function find(nodeById,id){var node=nodeById.get(id);if(!node)throw new Error("missing: "+id);return node}var sankey=function(){var x0=0,y0=0,x1=1,y1=1,dx=24,py=8,id=defaultId,align=justify,nodes=defaultNodes,links=defaultLinks,iterations=32;function sankey(){var graph={nodes:nodes.apply(null,arguments),links:links.apply(null,arguments)};computeNodeLinks(graph);computeNodeValues(graph);computeNodeDepths(graph);computeNodeBreadths(graph,iterations);computeLinkBreadths(graph);return graph}sankey.update=function(graph){computeLinkBreadths(graph);return graph};sankey.nodeId=function(_){return arguments.length?(id=typeof _==="function"?_:constant(_),sankey):id};sankey.nodeAlign=function(_){return arguments.length?(align=typeof _==="function"?_:constant(_),sankey):align};sankey.nodeWidth=function(_){return arguments.length?(dx=+_,sankey):dx};sankey.nodePadding=function(_){return arguments.length?(py=+_,sankey):py};sankey.nodes=function(_){return arguments.length?(nodes=typeof _==="function"?_:constant(_),sankey):nodes};sankey.links=function(_){return arguments.length?(links=typeof _==="function"?_:constant(_),sankey):links};sankey.size=function(_){return arguments.length?(x0=y0=0,x1=+_[0],y1=+_[1],sankey):[x1-x0,y1-y0]};sankey.extent=function(_){return arguments.length?(x0=+_[0][0],x1=+_[1][0],y0=+_[0][1],y1=+_[1][1],sankey):[[x0,y0],[x1,y1]]};sankey.iterations=function(_){return arguments.length?(iterations=+_,sankey):iterations};function computeNodeLinks(graph){graph.nodes.forEach(function(node,i){node.index=i;node.sourceLinks=[];node.targetLinks=[]});var nodeById=d3Collection.map(graph.nodes,id);graph.links.forEach(function(link,i){link.index=i;var source=link.source,target=link.target;if(typeof source!=="object")source=link.source=find(nodeById,source);if(typeof target!=="object")target=link.target=find(nodeById,target);source.sourceLinks.push(link);target.targetLinks.push(link)})}function computeNodeValues(graph){graph.nodes.forEach(function(node){node.value=Math.max(d3Array.sum(node.sourceLinks,value),d3Array.sum(node.targetLinks,value))})}function computeNodeDepths(graph){var nodes,next,x;for(nodes=graph.nodes,next=[],x=0;nodes.length;++x,nodes=next,next=[]){nodes.forEach(function(node){node.depth=x;node.sourceLinks.forEach(function(link){if(next.indexOf(link.target)<0){next.push(link.target)}})})}for(nodes=graph.nodes,next=[],x=0;nodes.length;++x,nodes=next,next=[]){nodes.forEach(function(node){node.height=x;node.targetLinks.forEach(function(link){if(next.indexOf(link.source)<0){next.push(link.source)}})})}var kx=(x1-x0-dx)/(x-1);graph.nodes.forEach(function(node){node.x1=(node.x0=x0+Math.max(0,Math.min(x-1,Math.floor(align.call(null,node,x))))*kx)+dx})}function computeNodeBreadths(graph){var columns=d3Collection.nest().key(function(d){return d.x0}).sortKeys(d3Array.ascending).entries(graph.nodes).map(function(d){return d.values});initializeNodeBreadth();resolveCollisions();for(var alpha=1,n=iterations;n>0;--n){relaxRightToLeft(alpha*=.99);resolveCollisions();relaxLeftToRight(alpha);resolveCollisions()}function initializeNodeBreadth(){var ky=d3Array.min(columns,function(nodes){return(y1-y0-(nodes.length-1)*py)/d3Array.sum(nodes,value)});columns.forEach(function(nodes){nodes.forEach(function(node,i){node.y1=(node.y0=i)+node.value*ky})});graph.links.forEach(function(link){link.width=link.value*ky})}function relaxLeftToRight(alpha){columns.forEach(function(nodes){nodes.forEach(function(node){if(node.targetLinks.length){var dy=(d3Array.sum(node.targetLinks,weightedSource)/d3Array.sum(node.targetLinks,value)-nodeCenter(node))*alpha;node.y0+=dy,node.y1+=dy}})})}function relaxRightToLeft(alpha){columns.slice().reverse().forEach(function(nodes){nodes.forEach(function(node){if(node.sourceLinks.length){var dy=(d3Array.sum(node.sourceLinks,weightedTarget)/d3Array.sum(node.sourceLinks,value)-nodeCenter(node))*alpha;node.y0+=dy,node.y1+=dy}})})}function resolveCollisions(){columns.forEach(function(nodes){var node,dy,y=y0,n=nodes.length,i;nodes.sort(ascendingBreadth);for(i=0;i0)node.y0+=dy,node.y1+=dy;y=node.y1+py}dy=y-py-y1;if(dy>0){y=node.y0-=dy,node.y1-=dy;for(i=n-2;i>=0;--i){node=nodes[i];dy=node.y1+py-y;if(dy>0)node.y0-=dy,node.y1-=dy;y=node.y0}}})}}function computeLinkBreadths(graph){graph.nodes.forEach(function(node){node.sourceLinks.sort(ascendingTargetBreadth);node.targetLinks.sort(ascendingSourceBreadth)});graph.nodes.forEach(function(node){var y0=node.y0,y1=y0;node.sourceLinks.forEach(function(link){link.y0=y0+link.width/2,y0+=link.width});node.targetLinks.forEach(function(link){link.y1=y1+link.width/2,y1+=link.width})})}return sankey};function horizontalSource(d){return[d.source.x1,d.y0]}function horizontalTarget(d){return[d.target.x0,d.y1]}var sankeyLinkHorizontal=function(){return d3Shape.linkHorizontal().source(horizontalSource).target(horizontalTarget)};exports.sankey=sankey;exports.sankeyCenter=center;exports.sankeyLeft=left;exports.sankeyRight=right;exports.sankeyJustify=justify;exports.sankeyLinkHorizontal=sankeyLinkHorizontal;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3,"d3-collection":4,"d3-shape":15}],14:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-array"),require("d3-collection"),require("d3-interpolate"),require("d3-format"),require("d3-time"),require("d3-time-format"),require("d3-color")):typeof define==="function"&&define.amd?define(["exports","d3-array","d3-collection","d3-interpolate","d3-format","d3-time","d3-time-format","d3-color"],factory):factory(global.d3=global.d3||{},global.d3,global.d3,global.d3,global.d3,global.d3,global.d3,global.d3)})(this,function(exports,d3Array,d3Collection,d3Interpolate,d3Format,d3Time,d3TimeFormat,d3Color){"use strict";var array=Array.prototype;var map$1=array.map;var slice=array.slice;var implicit={name:"implicit"};function ordinal(range$$1){var index=d3Collection.map(),domain=[],unknown=implicit;range$$1=range$$1==null?[]:slice.call(range$$1);function scale(d){var key=d+"",i=index.get(key);if(!i){if(unknown!==implicit)return unknown;index.set(key,i=domain.push(d))}return range$$1[(i-1)%range$$1.length]}scale.domain=function(_){if(!arguments.length)return domain.slice();domain=[],index=d3Collection.map();var i=-1,n=_.length,d,key;while(++i=b?1:d(x)}}}function reinterpolateClamp(reinterpolate){return function(a,b){var r=reinterpolate(a=+a,b=+b);return function(t){return t<=0?a:t>=1?b:r(t)}}}function bimap(domain,range$$1,deinterpolate,reinterpolate){var d0=domain[0],d1=domain[1],r0=range$$1[0],r1=range$$1[1];if(d12?polymap:bimap;output=input=null;return scale}function scale(x){return(output||(output=piecewise(domain,range$$1,clamp?deinterpolateClamp(deinterpolate):deinterpolate,interpolate$$1)))(+x)}scale.invert=function(y){return(input||(input=piecewise(range$$1,domain,deinterpolateLinear,clamp?reinterpolateClamp(reinterpolate):reinterpolate)))(+y)};scale.domain=function(_){return arguments.length?(domain=map$1.call(_,number),rescale()):domain.slice()};scale.range=function(_){return arguments.length?(range$$1=slice.call(_),rescale()):range$$1.slice()};scale.rangeRound=function(_){return range$$1=slice.call(_),interpolate$$1=d3Interpolate.interpolateRound,rescale()};scale.clamp=function(_){return arguments.length?(clamp=!!_,rescale()):clamp};scale.interpolate=function(_){return arguments.length?(interpolate$$1=_,rescale()):interpolate$$1};return rescale()}var tickFormat=function(domain,count,specifier){var start=domain[0],stop=domain[domain.length-1],step=d3Array.tickStep(start,stop,count==null?10:count),precision;specifier=d3Format.formatSpecifier(specifier==null?",f":specifier);switch(specifier.type){case"s":{var value=Math.max(Math.abs(start),Math.abs(stop));if(specifier.precision==null&&!isNaN(precision=d3Format.precisionPrefix(step,value)))specifier.precision=precision;return d3Format.formatPrefix(specifier,value)}case"":case"e":case"g":case"p":case"r":{if(specifier.precision==null&&!isNaN(precision=d3Format.precisionRound(step,Math.max(Math.abs(start),Math.abs(stop)))))specifier.precision=precision-(specifier.type==="e");break}case"f":case"%":{if(specifier.precision==null&&!isNaN(precision=d3Format.precisionFixed(step)))specifier.precision=precision-(specifier.type==="%")*2;break}}return d3Format.format(specifier)};function linearish(scale){var domain=scale.domain;scale.ticks=function(count){var d=domain();return d3Array.ticks(d[0],d[d.length-1],count==null?10:count)};scale.tickFormat=function(count,specifier){return tickFormat(domain(),count,specifier)};scale.nice=function(count){if(count==null)count=10;var d=domain(),i0=0,i1=d.length-1,start=d[i0],stop=d[i1],step;if(stop0){start=Math.floor(start/step)*step;stop=Math.ceil(stop/step)*step;step=d3Array.tickIncrement(start,stop,count)}else if(step<0){start=Math.ceil(start*step)/step;stop=Math.floor(stop*step)/step;step=d3Array.tickIncrement(start,stop,count)}if(step>0){d[i0]=Math.floor(start/step)*step;d[i1]=Math.ceil(stop/step)*step;domain(d)}else if(step<0){d[i0]=Math.ceil(start*step)/step;d[i1]=Math.floor(stop*step)/step;domain(d)}return scale};return scale}function linear(){var scale=continuous(deinterpolateLinear,d3Interpolate.interpolateNumber);scale.copy=function(){return copy(scale,linear())};return linearish(scale)}function identity(){var domain=[0,1];function scale(x){return+x}scale.invert=scale;scale.domain=scale.range=function(_){return arguments.length?(domain=map$1.call(_,number),scale):domain.slice()};scale.copy=function(){return identity().domain(domain)};return linearish(scale)}var nice=function(domain,interval){domain=domain.slice();var i0=0,i1=domain.length-1,x0=domain[i0],x1=domain[i1],t;if(x10)for(;iv)break;z.push(t)}}else for(;i=1;--k){t=p*k;if(tv)break;z.push(t)}}}else{z=d3Array.ticks(i,j,Math.min(j-i,n)).map(pows)}return r?z.reverse():z};scale.tickFormat=function(count,specifier){if(specifier==null)specifier=base===10?".0e":",";if(typeof specifier!=="function")specifier=d3Format.format(specifier);if(count===Infinity)return specifier;if(count==null)count=10;var k=Math.max(1,base*count/scale.ticks().length);return function(d){var i=d/pows(Math.round(logs(d)));if(i*base0?thresholds[i-1]:domain[0],i=n?[domain[n-1],x1]:[domain[i-1],domain[i]]};scale.copy=function(){return quantize().domain([x0,x1]).range(range$$1)};return linearish(scale)}function threshold(){var domain=[.5],range$$1=[0,1],n=1;function scale(x){if(x<=x)return range$$1[d3Array.bisect(domain,x,0,n)]}scale.domain=function(_){return arguments.length?(domain=slice.call(_),n=Math.min(domain.length,range$$1.length-1),scale):domain.slice()};scale.range=function(_){return arguments.length?(range$$1=slice.call(_),n=Math.min(domain.length,range$$1.length-1),scale):range$$1.slice()};scale.invertExtent=function(y){var i=range$$1.indexOf(y);return[domain[i-1],domain[i]]};scale.copy=function(){return threshold().domain(domain).range(range$$1)};return scale}var durationSecond=1e3;var durationMinute=durationSecond*60;var durationHour=durationMinute*60;var durationDay=durationHour*24;var durationWeek=durationDay*7;var durationMonth=durationDay*30;var durationYear=durationDay*365;function date(t){return new Date(t)}function number$1(t){return t instanceof Date?+t:+new Date(+t)}function calendar(year,month,week,day,hour,minute,second,millisecond,format$$1){var scale=continuous(deinterpolateLinear,d3Interpolate.interpolateNumber),invert=scale.invert,domain=scale.domain;var formatMillisecond=format$$1(".%L"),formatSecond=format$$1(":%S"),formatMinute=format$$1("%I:%M"),formatHour=format$$1("%I %p"),formatDay=format$$1("%a %d"),formatWeek=format$$1("%b %d"),formatMonth=format$$1("%B"),formatYear=format$$1("%Y");var tickIntervals=[[second,1,durationSecond],[second,5,5*durationSecond],[second,15,15*durationSecond],[second,30,30*durationSecond],[minute,1,durationMinute],[minute,5,5*durationMinute],[minute,15,15*durationMinute],[minute,30,30*durationMinute],[hour,1,durationHour],[hour,3,3*durationHour],[hour,6,6*durationHour],[hour,12,12*durationHour],[day,1,durationDay],[day,2,2*durationDay],[week,1,durationWeek],[month,1,durationMonth],[month,3,3*durationMonth],[year,1,durationYear]];function tickFormat(date){return(second(date)1)t-=Math.floor(t);var ts=Math.abs(t-.5);rainbow.h=360*t-100;rainbow.s=1.5-1.5*ts;rainbow.l=.8-.9*ts;return rainbow+""};function ramp(range$$1){var n=range$$1.length;return function(t){return range$$1[Math.max(0,Math.min(n-1,Math.floor(t*n)))]}}var viridis=ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var magma=ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));var inferno=ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));var plasma=ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function sequential(interpolator){var x0=0,x1=1,clamp=false;function scale(x){var t=(x-x0)/(x1-x0);return interpolator(clamp?Math.max(0,Math.min(1,t)):t)}scale.domain=function(_){return arguments.length?(x0=+_[0],x1=+_[1],scale):[x0,x1]};scale.clamp=function(_){return arguments.length?(clamp=!!_,scale):clamp};scale.interpolator=function(_){return arguments.length?(interpolator=_,scale):interpolator};scale.copy=function(){return sequential(interpolator).domain([x0,x1]).clamp(clamp)};return linearish(scale)}exports.scaleBand=band;exports.scalePoint=point;exports.scaleIdentity=identity;exports.scaleLinear=linear;exports.scaleLog=log;exports.scaleOrdinal=ordinal;exports.scaleImplicit=implicit;exports.scalePow=pow;exports.scaleSqrt=sqrt;exports.scaleQuantile=quantile$1;exports.scaleQuantize=quantize;exports.scaleThreshold=threshold;exports.scaleTime=time;exports.scaleUtc=utcTime;exports.schemeCategory10=category10;exports.schemeCategory20b=category20b;exports.schemeCategory20c=category20c;exports.schemeCategory20=category20;exports.interpolateCubehelixDefault=cubehelix$1;exports.interpolateRainbow=rainbow$1;exports.interpolateWarm=warm;exports.interpolateCool=cool;exports.interpolateViridis=viridis;exports.interpolateMagma=magma;exports.interpolateInferno=inferno;exports.interpolatePlasma=plasma;exports.scaleSequential=sequential;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-array":3,"d3-collection":4,"d3-color":5,"d3-format":7,"d3-interpolate":11,"d3-time":17,"d3-time-format":16}],15:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("d3-path")):typeof define==="function"&&define.amd?define(["exports","d3-path"],factory):factory(global.d3=global.d3||{},global.d3)})(this,function(exports,d3Path){"use strict";var constant=function(x){return function constant(){return x}};var abs=Math.abs;var atan2=Math.atan2;var cos=Math.cos;var max=Math.max;var min=Math.min;var sin=Math.sin;var sqrt=Math.sqrt;var epsilon=1e-12;var pi=Math.PI;var halfPi=pi/2;var tau=2*pi;function acos(x){return x>1?0:x<-1?pi:Math.acos(x)}function asin(x){return x>=1?halfPi:x<=-1?-halfPi:Math.asin(x)}function arcInnerRadius(d){return d.innerRadius}function arcOuterRadius(d){return d.outerRadius}function arcStartAngle(d){return d.startAngle}function arcEndAngle(d){return d.endAngle}function arcPadAngle(d){return d&&d.padAngle}function intersect(x0,y0,x1,y1,x2,y2,x3,y3){var x10=x1-x0,y10=y1-y0,x32=x3-x2,y32=y3-y2,t=(x32*(y0-y2)-y32*(x0-x2))/(y32*x10-x32*y10);return[x0+t*x10,y0+t*y10]}function cornerTangents(x0,y0,x1,y1,r1,rc,cw){var x01=x0-x1,y01=y0-y1,lo=(cw?rc:-rc)/sqrt(x01*x01+y01*y01),ox=lo*y01,oy=-lo*x01,x11=x0+ox,y11=y0+oy,x10=x1+ox,y10=y1+oy,x00=(x11+x10)/2,y00=(y11+y10)/2,dx=x10-x11,dy=y10-y11,d2=dx*dx+dy*dy,r=r1-rc,D=x11*y10-x10*y11,d=(dy<0?-1:1)*sqrt(max(0,r*r*d2-D*D)),cx0=(D*dy-dx*d)/d2,cy0=(-D*dx-dy*d)/d2,cx1=(D*dy+dx*d)/d2,cy1=(-D*dx+dy*d)/d2,dx0=cx0-x00,dy0=cy0-y00,dx1=cx1-x00,dy1=cy1-y00;if(dx0*dx0+dy0*dy0>dx1*dx1+dy1*dy1)cx0=cx1,cy0=cy1;return{cx:cx0,cy:cy0,x01:-ox,y01:-oy,x11:cx0*(r1/r-1),y11:cy0*(r1/r-1)}}var arc=function(){var innerRadius=arcInnerRadius,outerRadius=arcOuterRadius,cornerRadius=constant(0),padRadius=null,startAngle=arcStartAngle,endAngle=arcEndAngle,padAngle=arcPadAngle,context=null;function arc(){var buffer,r,r0=+innerRadius.apply(this,arguments),r1=+outerRadius.apply(this,arguments),a0=startAngle.apply(this,arguments)-halfPi,a1=endAngle.apply(this,arguments)-halfPi,da=abs(a1-a0),cw=a1>a0;if(!context)context=buffer=d3Path.path();if(r1epsilon))context.moveTo(0,0);else if(da>tau-epsilon){context.moveTo(r1*cos(a0),r1*sin(a0));context.arc(0,0,r1,a0,a1,!cw);if(r0>epsilon){context.moveTo(r0*cos(a1),r0*sin(a1));context.arc(0,0,r0,a1,a0,cw)}}else{var a01=a0,a11=a1,a00=a0,a10=a1,da0=da,da1=da,ap=padAngle.apply(this,arguments)/2,rp=ap>epsilon&&(padRadius?+padRadius.apply(this,arguments):sqrt(r0*r0+r1*r1)),rc=min(abs(r1-r0)/2,+cornerRadius.apply(this,arguments)),rc0=rc,rc1=rc,t0,t1;if(rp>epsilon){var p0=asin(rp/r0*sin(ap)),p1=asin(rp/r1*sin(ap));if((da0-=p0*2)>epsilon)p0*=cw?1:-1,a00+=p0,a10-=p0;else da0=0,a00=a10=(a0+a1)/2;if((da1-=p1*2)>epsilon)p1*=cw?1:-1,a01+=p1,a11-=p1;else da1=0,a01=a11=(a0+a1)/2}var x01=r1*cos(a01),y01=r1*sin(a01),x10=r0*cos(a10),y10=r0*sin(a10);if(rc>epsilon){var x11=r1*cos(a11),y11=r1*sin(a11),x00=r0*cos(a00),y00=r0*sin(a00);if(daepsilon?intersect(x01,y01,x00,y00,x11,y11,x10,y10):[x10,y10],ax=x01-oc[0],ay=y01-oc[1],bx=x11-oc[0],by=y11-oc[1],kc=1/sin(acos((ax*bx+ay*by)/(sqrt(ax*ax+ay*ay)*sqrt(bx*bx+by*by)))/2),lc=sqrt(oc[0]*oc[0]+oc[1]*oc[1]);rc0=min(rc,(r0-lc)/(kc-1));rc1=min(rc,(r1-lc)/(kc+1))}}if(!(da1>epsilon))context.moveTo(x01,y01);else if(rc1>epsilon){t0=cornerTangents(x00,y00,x01,y01,r1,rc1,cw);t1=cornerTangents(x11,y11,x10,y10,r1,rc1,cw);context.moveTo(t0.cx+t0.x01,t0.cy+t0.y01);if(rc1epsilon)||!(da0>epsilon))context.lineTo(x10,y10);else if(rc0>epsilon){t0=cornerTangents(x10,y10,x11,y11,r0,-rc0,cw);t1=cornerTangents(x01,y01,x00,y00,r0,-rc0,cw);context.lineTo(t0.cx+t0.x01,t0.cy+t0.y01);if(rc0=j;--k){output.point(x0z[k],y0z[k])}output.lineEnd();output.areaEnd()}}if(defined0){x0z[i]=+x0(d,i,data),y0z[i]=+y0(d,i,data);output.point(x1?+x1(d,i,data):x0z[i],y1?+y1(d,i,data):y0z[i])}}if(buffer)return output=null,buffer+""||null}function arealine(){return line().defined(defined).curve(curve).context(context)}area.x=function(_){return arguments.length?(x0=typeof _==="function"?_:constant(+_),x1=null,area):x0};area.x0=function(_){ -return arguments.length?(x0=typeof _==="function"?_:constant(+_),area):x0};area.x1=function(_){return arguments.length?(x1=_==null?null:typeof _==="function"?_:constant(+_),area):x1};area.y=function(_){return arguments.length?(y0=typeof _==="function"?_:constant(+_),y1=null,area):y0};area.y0=function(_){return arguments.length?(y0=typeof _==="function"?_:constant(+_),area):y0};area.y1=function(_){return arguments.length?(y1=_==null?null:typeof _==="function"?_:constant(+_),area):y1};area.lineX0=area.lineY0=function(){return arealine().x(x0).y(y0)};area.lineY1=function(){return arealine().x(x0).y(y1)};area.lineX1=function(){return arealine().x(x1).y(y0)};area.defined=function(_){return arguments.length?(defined=typeof _==="function"?_:constant(!!_),area):defined};area.curve=function(_){return arguments.length?(curve=_,context!=null&&(output=curve(context)),area):curve};area.context=function(_){return arguments.length?(_==null?context=output=null:output=curve(context=_),area):context};return area};var descending=function(a,b){return ba?1:b>=a?0:NaN};var identity=function(d){return d};var pie=function(){var value=identity,sortValues=descending,sort=null,startAngle=constant(0),endAngle=constant(tau),padAngle=constant(0);function pie(data){var i,n=data.length,j,k,sum=0,index=new Array(n),arcs=new Array(n),a0=+startAngle.apply(this,arguments),da=Math.min(tau,Math.max(-tau,endAngle.apply(this,arguments)-a0)),a1,p=Math.min(Math.abs(da)/n,padAngle.apply(this,arguments)),pa=p*(da<0?-1:1),v;for(i=0;i0){sum+=v}}if(sortValues!=null)index.sort(function(i,j){return sortValues(arcs[i],arcs[j])});else if(sort!=null)index.sort(function(i,j){return sort(data[i],data[j])});for(i=0,k=sum?(da-n*pa)/sum:0;i0?v*k:0)+pa,arcs[j]={data:data[j],index:i,value:v,startAngle:a0,endAngle:a1,padAngle:p}}return arcs}pie.value=function(_){return arguments.length?(value=typeof _==="function"?_:constant(+_),pie):value};pie.sortValues=function(_){return arguments.length?(sortValues=_,sort=null,pie):sortValues};pie.sort=function(_){return arguments.length?(sort=_,sortValues=null,pie):sort};pie.startAngle=function(_){return arguments.length?(startAngle=typeof _==="function"?_:constant(+_),pie):startAngle};pie.endAngle=function(_){return arguments.length?(endAngle=typeof _==="function"?_:constant(+_),pie):endAngle};pie.padAngle=function(_){return arguments.length?(padAngle=typeof _==="function"?_:constant(+_),pie):padAngle};return pie};var curveRadialLinear=curveRadial(curveLinear);function Radial(curve){this._curve=curve}Radial.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(a,r){this._curve.point(r*Math.sin(a),r*-Math.cos(a))}};function curveRadial(curve){function radial(context){return new Radial(curve(context))}radial._curve=curve;return radial}function lineRadial(l){var c=l.curve;l.angle=l.x,delete l.x;l.radius=l.y,delete l.y;l.curve=function(_){return arguments.length?c(curveRadial(_)):c()._curve};return l}var lineRadial$1=function(){return lineRadial(line().curve(curveRadialLinear))};var areaRadial=function(){var a=area().curve(curveRadialLinear),c=a.curve,x0=a.lineX0,x1=a.lineX1,y0=a.lineY0,y1=a.lineY1;a.angle=a.x,delete a.x;a.startAngle=a.x0,delete a.x0;a.endAngle=a.x1,delete a.x1;a.radius=a.y,delete a.y;a.innerRadius=a.y0,delete a.y0;a.outerRadius=a.y1,delete a.y1;a.lineStartAngle=function(){return lineRadial(x0())},delete a.lineX0;a.lineEndAngle=function(){return lineRadial(x1())},delete a.lineX1;a.lineInnerRadius=function(){return lineRadial(y0())},delete a.lineY0;a.lineOuterRadius=function(){return lineRadial(y1())},delete a.lineY1;a.curve=function(_){return arguments.length?c(curveRadial(_)):c()._curve};return a};var pointRadial=function(x,y){return[(y=+y)*Math.cos(x-=Math.PI/2),y*Math.sin(x)]};var slice=Array.prototype.slice;function linkSource(d){return d.source}function linkTarget(d){return d.target}function link(curve){var source=linkSource,target=linkTarget,x$$1=x,y$$1=y,context=null;function link(){var buffer,argv=slice.call(arguments),s=source.apply(this,argv),t=target.apply(this,argv);if(!context)context=buffer=d3Path.path();curve(context,+x$$1.apply(this,(argv[0]=s,argv)),+y$$1.apply(this,argv),+x$$1.apply(this,(argv[0]=t,argv)),+y$$1.apply(this,argv));if(buffer)return context=null,buffer+""||null}link.source=function(_){return arguments.length?(source=_,link):source};link.target=function(_){return arguments.length?(target=_,link):target};link.x=function(_){return arguments.length?(x$$1=typeof _==="function"?_:constant(+_),link):x$$1};link.y=function(_){return arguments.length?(y$$1=typeof _==="function"?_:constant(+_),link):y$$1};link.context=function(_){return arguments.length?(context=_==null?null:_,link):context};return link}function curveHorizontal(context,x0,y0,x1,y1){context.moveTo(x0,y0);context.bezierCurveTo(x0=(x0+x1)/2,y0,x0,y1,x1,y1)}function curveVertical(context,x0,y0,x1,y1){context.moveTo(x0,y0);context.bezierCurveTo(x0,y0=(y0+y1)/2,x1,y0,x1,y1)}function curveRadial$1(context,x0,y0,x1,y1){var p0=pointRadial(x0,y0),p1=pointRadial(x0,y0=(y0+y1)/2),p2=pointRadial(x1,y0),p3=pointRadial(x1,y1);context.moveTo(p0[0],p0[1]);context.bezierCurveTo(p1[0],p1[1],p2[0],p2[1],p3[0],p3[1])}function linkHorizontal(){return link(curveHorizontal)}function linkVertical(){return link(curveVertical)}function linkRadial(){var l=link(curveRadial$1);l.angle=l.x,delete l.x;l.radius=l.y,delete l.y;return l}var circle={draw:function(context,size){var r=Math.sqrt(size/pi);context.moveTo(r,0);context.arc(0,0,r,0,tau)}};var cross={draw:function(context,size){var r=Math.sqrt(size/5)/2;context.moveTo(-3*r,-r);context.lineTo(-r,-r);context.lineTo(-r,-3*r);context.lineTo(r,-3*r);context.lineTo(r,-r);context.lineTo(3*r,-r);context.lineTo(3*r,r);context.lineTo(r,r);context.lineTo(r,3*r);context.lineTo(-r,3*r);context.lineTo(-r,r);context.lineTo(-3*r,r);context.closePath()}};var tan30=Math.sqrt(1/3);var tan30_2=tan30*2;var diamond={draw:function(context,size){var y=Math.sqrt(size/tan30_2),x=y*tan30;context.moveTo(0,-y);context.lineTo(x,0);context.lineTo(0,y);context.lineTo(-x,0);context.closePath()}};var ka=.8908130915292852;var kr=Math.sin(pi/10)/Math.sin(7*pi/10);var kx=Math.sin(tau/10)*kr;var ky=-Math.cos(tau/10)*kr;var star={draw:function(context,size){var r=Math.sqrt(size*ka),x=kx*r,y=ky*r;context.moveTo(0,-r);context.lineTo(x,y);for(var i=1;i<5;++i){var a=tau*i/5,c=Math.cos(a),s=Math.sin(a);context.lineTo(s*r,-c*r);context.lineTo(c*x-s*y,s*x+c*y)}context.closePath()}};var square={draw:function(context,size){var w=Math.sqrt(size),x=-w/2;context.rect(x,x,w,w)}};var sqrt3=Math.sqrt(3);var triangle={draw:function(context,size){var y=-Math.sqrt(size/(sqrt3*3));context.moveTo(0,y*2);context.lineTo(-sqrt3*y,-y);context.lineTo(sqrt3*y,-y);context.closePath()}};var c=-.5;var s=Math.sqrt(3)/2;var k=1/Math.sqrt(12);var a=(k/2+1)*3;var wye={draw:function(context,size){var r=Math.sqrt(size/a),x0=r/2,y0=r*k,x1=x0,y1=r*k+r,x2=-x1,y2=y1;context.moveTo(x0,y0);context.lineTo(x1,y1);context.lineTo(x2,y2);context.lineTo(c*x0-s*y0,s*x0+c*y0);context.lineTo(c*x1-s*y1,s*x1+c*y1);context.lineTo(c*x2-s*y2,s*x2+c*y2);context.lineTo(c*x0+s*y0,c*y0-s*x0);context.lineTo(c*x1+s*y1,c*y1-s*x1);context.lineTo(c*x2+s*y2,c*y2-s*x2);context.closePath()}};var symbols=[circle,cross,diamond,square,star,triangle,wye];var symbol=function(){var type=constant(circle),size=constant(64),context=null;function symbol(){var buffer;if(!context)context=buffer=d3Path.path();type.apply(this,arguments).draw(context,+size.apply(this,arguments));if(buffer)return context=null,buffer+""||null}symbol.type=function(_){return arguments.length?(type=typeof _==="function"?_:constant(_),symbol):type};symbol.size=function(_){return arguments.length?(size=typeof _==="function"?_:constant(+_),symbol):size};symbol.context=function(_){return arguments.length?(context=_==null?null:_,symbol):context};return symbol};var noop=function(){};function point(that,x,y){that._context.bezierCurveTo((2*that._x0+that._x1)/3,(2*that._y0+that._y1)/3,(that._x0+2*that._x1)/3,(that._y0+2*that._y1)/3,(that._x0+4*that._x1+x)/6,(that._y0+4*that._y1+y)/6)}function Basis(context){this._context=context}Basis.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN;this._point=0},lineEnd:function(){switch(this._point){case 3:point(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:point(this,x,y);break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y}};var basis=function(context){return new Basis(context)};function BasisClosed(context){this._context=context}BasisClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN;this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2);this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3);this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3);this._context.closePath();break}case 3:{this.point(this._x2,this._y2);this.point(this._x3,this._y3);this.point(this._x4,this._y4);break}}},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._x2=x,this._y2=y;break;case 1:this._point=2;this._x3=x,this._y3=y;break;case 2:this._point=3;this._x4=x,this._y4=y;this._context.moveTo((this._x0+4*this._x1+x)/6,(this._y0+4*this._y1+y)/6);break;default:point(this,x,y);break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y}};var basisClosed=function(context){return new BasisClosed(context)};function BasisOpen(context){this._context=context}BasisOpen.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN;this._point=0},lineEnd:function(){if(this._line||this._line!==0&&this._point===3)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var x0=(this._x0+4*this._x1+x)/6,y0=(this._y0+4*this._y1+y)/6;this._line?this._context.lineTo(x0,y0):this._context.moveTo(x0,y0);break;case 3:this._point=4;default:point(this,x,y);break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y}};var basisOpen=function(context){return new BasisOpen(context)};function Bundle(context,beta){this._basis=new Basis(context);this._beta=beta}Bundle.prototype={lineStart:function(){this._x=[];this._y=[];this._basis.lineStart()},lineEnd:function(){var x=this._x,y=this._y,j=x.length-1;if(j>0){var x0=x[0],y0=y[0],dx=x[j]-x0,dy=y[j]-y0,i=-1,t;while(++i<=j){t=i/j;this._basis.point(this._beta*x[i]+(1-this._beta)*(x0+t*dx),this._beta*y[i]+(1-this._beta)*(y0+t*dy))}}this._x=this._y=null;this._basis.lineEnd()},point:function(x,y){this._x.push(+x);this._y.push(+y)}};var bundle=function custom(beta){function bundle(context){return beta===1?new Basis(context):new Bundle(context,beta)}bundle.beta=function(beta){return custom(+beta)};return bundle}(.85);function point$1(that,x,y){that._context.bezierCurveTo(that._x1+that._k*(that._x2-that._x0),that._y1+that._k*(that._y2-that._y0),that._x2+that._k*(that._x1-x),that._y2+that._k*(that._y1-y),that._x2,that._y2)}function Cardinal(context,tension){this._context=context;this._k=(1-tension)/6}Cardinal.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:point$1(this,this._x1,this._y1);break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;this._x1=x,this._y1=y;break;case 2:this._point=3;default:point$1(this,x,y);break}this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var cardinal=function custom(tension){function cardinal(context){return new Cardinal(context,tension)}cardinal.tension=function(tension){return custom(+tension)};return cardinal}(0);function CardinalClosed(context,tension){this._context=context;this._k=(1-tension)/6}CardinalClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN;this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3);this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3);this._context.closePath();break}case 3:{this.point(this._x3,this._y3);this.point(this._x4,this._y4);this.point(this._x5,this._y5);break}}},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._x3=x,this._y3=y;break;case 1:this._point=2;this._context.moveTo(this._x4=x,this._y4=y);break;case 2:this._point=3;this._x5=x,this._y5=y;break;default:point$1(this,x,y);break}this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var cardinalClosed=function custom(tension){function cardinal(context){return new CardinalClosed(context,tension)}cardinal.tension=function(tension){return custom(+tension)};return cardinal}(0);function CardinalOpen(context,tension){this._context=context;this._k=(1-tension)/6}CardinalOpen.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._point=0},lineEnd:function(){if(this._line||this._line!==0&&this._point===3)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:point$1(this,x,y);break}this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var cardinalOpen=function custom(tension){function cardinal(context){return new CardinalOpen(context,tension)}cardinal.tension=function(tension){return custom(+tension)};return cardinal}(0);function point$2(that,x,y){var x1=that._x1,y1=that._y1,x2=that._x2,y2=that._y2;if(that._l01_a>epsilon){var a=2*that._l01_2a+3*that._l01_a*that._l12_a+that._l12_2a,n=3*that._l01_a*(that._l01_a+that._l12_a);x1=(x1*a-that._x0*that._l12_2a+that._x2*that._l01_2a)/n;y1=(y1*a-that._y0*that._l12_2a+that._y2*that._l01_2a)/n}if(that._l23_a>epsilon){var b=2*that._l23_2a+3*that._l23_a*that._l12_a+that._l12_2a,m=3*that._l23_a*(that._l23_a+that._l12_a);x2=(x2*b+that._x1*that._l23_2a-x*that._l12_2a)/m;y2=(y2*b+that._y1*that._l23_2a-y*that._l12_2a)/m}that._context.bezierCurveTo(x1,y1,x2,y2,that._x2,that._y2)}function CatmullRom(context,alpha){this._context=context;this._alpha=alpha}CatmullRom.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;if(this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;default:point$2(this,x,y);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a;this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a;this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var catmullRom=function custom(alpha){function catmullRom(context){return alpha?new CatmullRom(context,alpha):new Cardinal(context,0)}catmullRom.alpha=function(alpha){return custom(+alpha)};return catmullRom}(.5);function CatmullRomClosed(context,alpha){this._context=context;this._alpha=alpha}CatmullRomClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN;this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3);this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3);this._context.closePath();break}case 3:{this.point(this._x3,this._y3);this.point(this._x4,this._y4);this.point(this._x5,this._y5);break}}},point:function(x,y){x=+x,y=+y;if(this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1;this._x3=x,this._y3=y;break;case 1:this._point=2;this._context.moveTo(this._x4=x,this._y4=y);break;case 2:this._point=3;this._x5=x,this._y5=y;break;default:point$2(this,x,y);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a;this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a;this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var catmullRomClosed=function custom(alpha){function catmullRom(context){return alpha?new CatmullRomClosed(context,alpha):new CardinalClosed(context,0)}catmullRom.alpha=function(alpha){return custom(+alpha)};return catmullRom}(.5);function CatmullRomOpen(context,alpha){this._context=context;this._alpha=alpha}CatmullRomOpen.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN;this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){if(this._line||this._line!==0&&this._point===3)this._context.closePath();this._line=1-this._line},point:function(x,y){x=+x,y=+y;if(this._point){var x23=this._x2-x,y23=this._y2-y;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(x23*x23+y23*y23,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:point$2(this,x,y);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a;this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a;this._x0=this._x1,this._x1=this._x2,this._x2=x;this._y0=this._y1,this._y1=this._y2,this._y2=y}};var catmullRomOpen=function custom(alpha){function catmullRom(context){return alpha?new CatmullRomOpen(context,alpha):new CardinalOpen(context,0)}catmullRom.alpha=function(alpha){return custom(+alpha)};return catmullRom}(.5);function LinearClosed(context){this._context=context}LinearClosed.prototype={areaStart:noop,areaEnd:noop,lineStart:function(){this._point=0},lineEnd:function(){if(this._point)this._context.closePath()},point:function(x,y){x=+x,y=+y;if(this._point)this._context.lineTo(x,y);else this._point=1,this._context.moveTo(x,y)}};var linearClosed=function(context){return new LinearClosed(context)};function sign(x){return x<0?-1:1}function slope3(that,x2,y2){var h0=that._x1-that._x0,h1=x2-that._x1,s0=(that._y1-that._y0)/(h0||h1<0&&-0),s1=(y2-that._y1)/(h1||h0<0&&-0),p=(s0*h1+s1*h0)/(h0+h1);return(sign(s0)+sign(s1))*Math.min(Math.abs(s0),Math.abs(s1),.5*Math.abs(p))||0}function slope2(that,t){var h=that._x1-that._x0;return h?(3*(that._y1-that._y0)/h-t)/2:t}function point$3(that,t0,t1){var x0=that._x0,y0=that._y0,x1=that._x1,y1=that._y1,dx=(x1-x0)/3;that._context.bezierCurveTo(x0+dx,y0+dx*t0,x1-dx,y1-dx*t1,x1,y1)}function MonotoneX(context){this._context=context}MonotoneX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN;this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:point$3(this,this._t0,slope2(this,this._t0));break}if(this._line||this._line!==0&&this._point===1)this._context.closePath();this._line=1-this._line},point:function(x,y){var t1=NaN;x=+x,y=+y;if(x===this._x1&&y===this._y1)return;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;break;case 2:this._point=3;point$3(this,slope2(this,t1=slope3(this,x,y)),t1);break;default:point$3(this,this._t0,t1=slope3(this,x,y));break}this._x0=this._x1,this._x1=x;this._y0=this._y1,this._y1=y;this._t0=t1}};function MonotoneY(context){this._context=new ReflectContext(context)}(MonotoneY.prototype=Object.create(MonotoneX.prototype)).point=function(x,y){MonotoneX.prototype.point.call(this,y,x)};function ReflectContext(context){this._context=context}ReflectContext.prototype={moveTo:function(x,y){this._context.moveTo(y,x)},closePath:function(){this._context.closePath()},lineTo:function(x,y){this._context.lineTo(y,x)},bezierCurveTo:function(x1,y1,x2,y2,x,y){this._context.bezierCurveTo(y1,x1,y2,x2,y,x)}};function monotoneX(context){return new MonotoneX(context)}function monotoneY(context){return new MonotoneY(context)}function Natural(context){this._context=context}Natural.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[];this._y=[]},lineEnd:function(){var x=this._x,y=this._y,n=x.length;if(n){this._line?this._context.lineTo(x[0],y[0]):this._context.moveTo(x[0],y[0]);if(n===2){this._context.lineTo(x[1],y[1])}else{var px=controlPoints(x),py=controlPoints(y);for(var i0=0,i1=1;i1=0;--i)a[i]=(r[i]-a[i+1])/b[i];b[n-1]=(x[n]+a[n-1])/2;for(i=0;i=0)this._t=1-this._t,this._line=1-this._line},point:function(x,y){x=+x,y=+y;switch(this._point){case 0:this._point=1;this._line?this._context.lineTo(x,y):this._context.moveTo(x,y);break;case 1:this._point=2;default:{if(this._t<=0){this._context.lineTo(this._x,y);this._context.lineTo(x,y)}else{var x1=this._x*(1-this._t)+x*this._t;this._context.lineTo(x1,this._y);this._context.lineTo(x1,y)}break}}this._x=x,this._y=y}};var step=function(context){return new Step(context,.5)};function stepBefore(context){return new Step(context,0)}function stepAfter(context){return new Step(context,1)}var none=function(series,order){if(!((n=series.length)>1))return;for(var i=1,j,s0,s1=series[order[0]],n,m=s1.length;i=0)o[n]=n;return o};function stackValue(d,key){return d[key]}var stack=function(){var keys=constant([]),order=none$1,offset=none,value=stackValue;function stack(data){var kz=keys.apply(this,arguments),i,m=data.length,n=kz.length,sz=new Array(n),oz;for(i=0;i0))return;for(var i,n,j=0,m=series[0].length,y;j1))return;for(var i,j=0,d,dy,yp,yn,n,m=series[order[0]].length;j=0){d[0]=yp,d[1]=yp+=dy}else if(dy<0){d[1]=yn,d[0]=yn+=dy}else{d[0]=yp}}}};var silhouette=function(series,order){if(!((n=series.length)>0))return;for(var j=0,s0=series[order[0]],n,m=s0.length;j0)||!((m=(s0=series[order[0]]).length)>0))return;for(var y=0,j=1,s0,m,n;j53)return null;if(!("w"in d))d.w=1;if("Z"in d){week=utcDate(newYear(d.y)),day=week.getUTCDay();week=day>4||day===0?d3Time.utcMonday.ceil(week):d3Time.utcMonday(week);week=d3Time.utcDay.offset(week,(d.V-1)*7);d.y=week.getUTCFullYear();d.m=week.getUTCMonth();d.d=week.getUTCDate()+(d.w+6)%7}else{week=newDate(newYear(d.y)),day=week.getDay();week=day>4||day===0?d3Time.timeMonday.ceil(week):d3Time.timeMonday(week);week=d3Time.timeDay.offset(week,(d.V-1)*7);d.y=week.getFullYear();d.m=week.getMonth();d.d=week.getDate()+(d.w+6)%7}}else if("W"in d||"U"in d){if(!("w"in d))d.w="u"in d?d.u%7:"W"in d?1:0;day="Z"in d?utcDate(newYear(d.y)).getUTCDay():newDate(newYear(d.y)).getDay();d.m=0;d.d="W"in d?(d.w+6)%7+d.W*7-(day+5)%7:d.w+d.U*7-(day+6)%7}if("Z"in d){d.H+=d.Z/100|0;d.M+=d.Z%100;return utcDate(d)}return newDate(d)}}function parseSpecifier(d,specifier,string,j){var i=0,n=specifier.length,m=string.length,c,parse;while(i=m)return-1;c=specifier.charCodeAt(i++);if(c===37){c=specifier.charAt(i++);parse=parses[c in pads?specifier.charAt(i++):c];if(!parse||(j=parse(d,string,j))<0)return-1}else if(c!=string.charCodeAt(j++)){return-1}}return j}function parsePeriod(d,string,i){var n=periodRe.exec(string.slice(i));return n?(d.p=periodLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseShortWeekday(d,string,i){var n=shortWeekdayRe.exec(string.slice(i));return n?(d.w=shortWeekdayLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseWeekday(d,string,i){var n=weekdayRe.exec(string.slice(i));return n?(d.w=weekdayLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseShortMonth(d,string,i){var n=shortMonthRe.exec(string.slice(i));return n?(d.m=shortMonthLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseMonth(d,string,i){var n=monthRe.exec(string.slice(i));return n?(d.m=monthLookup[n[0].toLowerCase()],i+n[0].length):-1}function parseLocaleDateTime(d,string,i){return parseSpecifier(d,locale_dateTime,string,i)}function parseLocaleDate(d,string,i){return parseSpecifier(d,locale_date,string,i)}function parseLocaleTime(d,string,i){return parseSpecifier(d,locale_time,string,i)}function formatShortWeekday(d){return locale_shortWeekdays[d.getDay()]}function formatWeekday(d){return locale_weekdays[d.getDay()]}function formatShortMonth(d){return locale_shortMonths[d.getMonth()]}function formatMonth(d){return locale_months[d.getMonth()]}function formatPeriod(d){return locale_periods[+(d.getHours()>=12)]}function formatUTCShortWeekday(d){return locale_shortWeekdays[d.getUTCDay()]}function formatUTCWeekday(d){return locale_weekdays[d.getUTCDay()]}function formatUTCShortMonth(d){return locale_shortMonths[d.getUTCMonth()]}function formatUTCMonth(d){return locale_months[d.getUTCMonth()]}function formatUTCPeriod(d){return locale_periods[+(d.getUTCHours()>=12)]}return{format:function(specifier){var f=newFormat(specifier+="",formats);f.toString=function(){return specifier};return f},parse:function(specifier){var p=newParse(specifier+="",localDate);p.toString=function(){return specifier};return p},utcFormat:function(specifier){var f=newFormat(specifier+="",utcFormats);f.toString=function(){return specifier};return f},utcParse:function(specifier){var p=newParse(specifier,utcDate);p.toString=function(){return specifier};return p}}}var pads={"-":"",_:" ",0:"0"};var numberRe=/^\s*\d+/;var percentRe=/^%/;var requoteRe=/[\\^$*+?|[\]().{}]/g;function pad(value,fill,width){var sign=value<0?"-":"",string=(sign?-value:value)+"",length=string.length;return sign+(length68?1900:2e3),i+n[0].length):-1}function parseZone(d,string,i){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i,i+6));return n?(d.Z=n[1]?0:-(n[2]+(n[3]||"00")),i+n[0].length):-1}function parseMonthNumber(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.m=n[0]-1,i+n[0].length):-1}function parseDayOfMonth(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.d=+n[0],i+n[0].length):-1}function parseDayOfYear(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.m=0,d.d=+n[0],i+n[0].length):-1}function parseHour24(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.H=+n[0],i+n[0].length):-1}function parseMinutes(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.M=+n[0],i+n[0].length):-1}function parseSeconds(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.S=+n[0],i+n[0].length):-1}function parseMilliseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.L=+n[0],i+n[0].length):-1}function parseMicroseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+6));return n?(d.L=Math.floor(n[0]/1e3),i+n[0].length):-1}function parseLiteralPercent(d,string,i){var n=percentRe.exec(string.slice(i,i+1));return n?i+n[0].length:-1}function parseUnixTimestamp(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0],i+n[0].length):-1}function parseUnixTimestampSeconds(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0]*1e3,i+n[0].length):-1}function formatDayOfMonth(d,p){return pad(d.getDate(),p,2)}function formatHour24(d,p){return pad(d.getHours(),p,2)}function formatHour12(d,p){return pad(d.getHours()%12||12,p,2)}function formatDayOfYear(d,p){return pad(1+d3Time.timeDay.count(d3Time.timeYear(d),d),p,3)}function formatMilliseconds(d,p){return pad(d.getMilliseconds(),p,3)}function formatMicroseconds(d,p){return formatMilliseconds(d,p)+"000"}function formatMonthNumber(d,p){return pad(d.getMonth()+1,p,2)}function formatMinutes(d,p){return pad(d.getMinutes(),p,2)}function formatSeconds(d,p){return pad(d.getSeconds(),p,2)}function formatWeekdayNumberMonday(d){var day=d.getDay();return day===0?7:day}function formatWeekNumberSunday(d,p){return pad(d3Time.timeSunday.count(d3Time.timeYear(d),d),p,2)}function formatWeekNumberISO(d,p){var day=d.getDay();d=day>=4||day===0?d3Time.timeThursday(d):d3Time.timeThursday.ceil(d);return pad(d3Time.timeThursday.count(d3Time.timeYear(d),d)+(d3Time.timeYear(d).getDay()===4),p,2)}function formatWeekdayNumberSunday(d){return d.getDay()}function formatWeekNumberMonday(d,p){return pad(d3Time.timeMonday.count(d3Time.timeYear(d),d),p,2)}function formatYear(d,p){return pad(d.getFullYear()%100,p,2)}function formatFullYear(d,p){return pad(d.getFullYear()%1e4,p,4)}function formatZone(d){var z=d.getTimezoneOffset();return(z>0?"-":(z*=-1,"+"))+pad(z/60|0,"0",2)+pad(z%60,"0",2)}function formatUTCDayOfMonth(d,p){return pad(d.getUTCDate(),p,2)}function formatUTCHour24(d,p){return pad(d.getUTCHours(),p,2)}function formatUTCHour12(d,p){return pad(d.getUTCHours()%12||12,p,2)}function formatUTCDayOfYear(d,p){return pad(1+d3Time.utcDay.count(d3Time.utcYear(d),d),p,3)}function formatUTCMilliseconds(d,p){return pad(d.getUTCMilliseconds(),p,3)}function formatUTCMicroseconds(d,p){return formatUTCMilliseconds(d,p)+"000"}function formatUTCMonthNumber(d,p){return pad(d.getUTCMonth()+1,p,2)}function formatUTCMinutes(d,p){return pad(d.getUTCMinutes(),p,2)}function formatUTCSeconds(d,p){return pad(d.getUTCSeconds(),p,2)}function formatUTCWeekdayNumberMonday(d){var dow=d.getUTCDay();return dow===0?7:dow}function formatUTCWeekNumberSunday(d,p){return pad(d3Time.utcSunday.count(d3Time.utcYear(d),d),p,2)}function formatUTCWeekNumberISO(d,p){var day=d.getUTCDay();d=day>=4||day===0?d3Time.utcThursday(d):d3Time.utcThursday.ceil(d);return pad(d3Time.utcThursday.count(d3Time.utcYear(d),d)+(d3Time.utcYear(d).getUTCDay()===4),p,2)}function formatUTCWeekdayNumberSunday(d){return d.getUTCDay()}function formatUTCWeekNumberMonday(d,p){return pad(d3Time.utcMonday.count(d3Time.utcYear(d),d),p,2)}function formatUTCYear(d,p){return pad(d.getUTCFullYear()%100,p,2)}function formatUTCFullYear(d,p){return pad(d.getUTCFullYear()%1e4,p,4)}function formatUTCZone(){return"+0000"}function formatLiteralPercent(){return"%"}function formatUnixTimestamp(d){return+d}function formatUnixTimestampSeconds(d){return Math.floor(+d/1e3)}var locale;defaultLocale({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function defaultLocale(definition){locale=formatLocale(definition);exports.timeFormat=locale.format;exports.timeParse=locale.parse;exports.utcFormat=locale.utcFormat;exports.utcParse=locale.utcParse;return locale}var isoSpecifier="%Y-%m-%dT%H:%M:%S.%LZ";function formatIsoNative(date){return date.toISOString()}var formatIso=Date.prototype.toISOString?formatIsoNative:exports.utcFormat(isoSpecifier);function parseIsoNative(string){var date=new Date(string);return isNaN(date)?null:date}var parseIso=+new Date("2000-01-01T00:00:00.000Z")?parseIsoNative:exports.utcParse(isoSpecifier);exports.timeFormatDefaultLocale=defaultLocale;exports.timeFormatLocale=formatLocale;exports.isoFormat=formatIso;exports.isoParse=parseIso;Object.defineProperty(exports,"__esModule",{value:true})})},{"d3-time":17}],17:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var t0=new Date;var t1=new Date;function newInterval(floori,offseti,count,field){function interval(date){return floori(date=new Date(+date)),date}interval.floor=interval;interval.ceil=function(date){return floori(date=new Date(date-1)),offseti(date,1),floori(date),date};interval.round=function(date){var d0=interval(date),d1=interval.ceil(date);return date-d00))return range;do{range.push(previous=new Date(+start)),offseti(start,step),floori(start)}while(previous=date)while(floori(date),!test(date))date.setTime(date-1)},function(date,step){if(date>=date){if(step<0)while(++step<=0){while(offseti(date,-1),!test(date)){}}else while(--step>=0){while(offseti(date,+1),!test(date)){}}}})};if(count){interval.count=function(start,end){t0.setTime(+start),t1.setTime(+end);floori(t0),floori(t1);return Math.floor(count(t0,t1))};interval.every=function(step){step=Math.floor(step);return!isFinite(step)||!(step>0)?null:!(step>1)?interval:interval.filter(field?function(d){return field(d)%step===0}:function(d){return interval.count(0,d)%step===0})}}return interval}var millisecond=newInterval(function(){},function(date,step){date.setTime(+date+step)},function(start,end){return end-start});millisecond.every=function(k){k=Math.floor(k);if(!isFinite(k)||!(k>0))return null;if(!(k>1))return millisecond;return newInterval(function(date){date.setTime(Math.floor(date/k)*k)},function(date,step){date.setTime(+date+step*k)},function(start,end){return(end-start)/k})};var milliseconds=millisecond.range;var durationSecond=1e3;var durationMinute=6e4;var durationHour=36e5;var durationDay=864e5;var durationWeek=6048e5;var second=newInterval(function(date){date.setTime(Math.floor(date/durationSecond)*durationSecond)},function(date,step){date.setTime(+date+step*durationSecond)},function(start,end){return(end-start)/durationSecond},function(date){return date.getUTCSeconds()});var seconds=second.range;var minute=newInterval(function(date){date.setTime(Math.floor(date/durationMinute)*durationMinute)},function(date,step){date.setTime(+date+step*durationMinute)},function(start,end){return(end-start)/durationMinute},function(date){return date.getMinutes()});var minutes=minute.range;var hour=newInterval(function(date){var offset=date.getTimezoneOffset()*durationMinute%durationHour;if(offset<0)offset+=durationHour;date.setTime(Math.floor((+date-offset)/durationHour)*durationHour+offset)},function(date,step){date.setTime(+date+step*durationHour)},function(start,end){return(end-start)/durationHour},function(date){return date.getHours()});var hours=hour.range;var day=newInterval(function(date){date.setHours(0,0,0,0)},function(date,step){date.setDate(date.getDate()+step)},function(start,end){return(end-start-(end.getTimezoneOffset()-start.getTimezoneOffset())*durationMinute)/durationDay},function(date){return date.getDate()-1});var days=day.range;function weekday(i){return newInterval(function(date){date.setDate(date.getDate()-(date.getDay()+7-i)%7);date.setHours(0,0,0,0)},function(date,step){date.setDate(date.getDate()+step*7)},function(start,end){return(end-start-(end.getTimezoneOffset()-start.getTimezoneOffset())*durationMinute)/durationWeek})}var sunday=weekday(0);var monday=weekday(1);var tuesday=weekday(2);var wednesday=weekday(3);var thursday=weekday(4);var friday=weekday(5);var saturday=weekday(6);var sundays=sunday.range;var mondays=monday.range;var tuesdays=tuesday.range;var wednesdays=wednesday.range;var thursdays=thursday.range;var fridays=friday.range;var saturdays=saturday.range;var month=newInterval(function(date){date.setDate(1);date.setHours(0,0,0,0)},function(date,step){date.setMonth(date.getMonth()+step)},function(start,end){return end.getMonth()-start.getMonth()+(end.getFullYear()-start.getFullYear())*12},function(date){return date.getMonth()});var months=month.range;var year=newInterval(function(date){date.setMonth(0,1);date.setHours(0,0,0,0)},function(date,step){date.setFullYear(date.getFullYear()+step)},function(start,end){return end.getFullYear()-start.getFullYear()},function(date){return date.getFullYear()});year.every=function(k){return!isFinite(k=Math.floor(k))||!(k>0)?null:newInterval(function(date){date.setFullYear(Math.floor(date.getFullYear()/k)*k);date.setMonth(0,1);date.setHours(0,0,0,0)},function(date,step){date.setFullYear(date.getFullYear()+step*k)})};var years=year.range;var utcMinute=newInterval(function(date){date.setUTCSeconds(0,0)},function(date,step){date.setTime(+date+step*durationMinute)},function(start,end){return(end-start)/durationMinute},function(date){return date.getUTCMinutes()});var utcMinutes=utcMinute.range;var utcHour=newInterval(function(date){date.setUTCMinutes(0,0,0)},function(date,step){date.setTime(+date+step*durationHour)},function(start,end){return(end-start)/durationHour},function(date){return date.getUTCHours()});var utcHours=utcHour.range;var utcDay=newInterval(function(date){date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCDate(date.getUTCDate()+step)},function(start,end){return(end-start)/durationDay},function(date){return date.getUTCDate()-1});var utcDays=utcDay.range;function utcWeekday(i){return newInterval(function(date){date.setUTCDate(date.getUTCDate()-(date.getUTCDay()+7-i)%7);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCDate(date.getUTCDate()+step*7)},function(start,end){return(end-start)/durationWeek})}var utcSunday=utcWeekday(0);var utcMonday=utcWeekday(1);var utcTuesday=utcWeekday(2);var utcWednesday=utcWeekday(3);var utcThursday=utcWeekday(4);var utcFriday=utcWeekday(5);var utcSaturday=utcWeekday(6);var utcSundays=utcSunday.range;var utcMondays=utcMonday.range;var utcTuesdays=utcTuesday.range;var utcWednesdays=utcWednesday.range;var utcThursdays=utcThursday.range;var utcFridays=utcFriday.range;var utcSaturdays=utcSaturday.range;var utcMonth=newInterval(function(date){date.setUTCDate(1);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCMonth(date.getUTCMonth()+step)},function(start,end){return end.getUTCMonth()-start.getUTCMonth()+(end.getUTCFullYear()-start.getUTCFullYear())*12},function(date){return date.getUTCMonth()});var utcMonths=utcMonth.range;var utcYear=newInterval(function(date){date.setUTCMonth(0,1);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCFullYear(date.getUTCFullYear()+step)},function(start,end){return end.getUTCFullYear()-start.getUTCFullYear()},function(date){return date.getUTCFullYear()});utcYear.every=function(k){return!isFinite(k=Math.floor(k))||!(k>0)?null:newInterval(function(date){date.setUTCFullYear(Math.floor(date.getUTCFullYear()/k)*k);date.setUTCMonth(0,1);date.setUTCHours(0,0,0,0)},function(date,step){date.setUTCFullYear(date.getUTCFullYear()+step*k)})};var utcYears=utcYear.range;exports.timeInterval=newInterval;exports.timeMillisecond=millisecond;exports.timeMilliseconds=milliseconds;exports.utcMillisecond=millisecond;exports.utcMilliseconds=milliseconds;exports.timeSecond=second;exports.timeSeconds=seconds;exports.utcSecond=second;exports.utcSeconds=seconds;exports.timeMinute=minute;exports.timeMinutes=minutes;exports.timeHour=hour;exports.timeHours=hours;exports.timeDay=day;exports.timeDays=days;exports.timeWeek=sunday;exports.timeWeeks=sundays;exports.timeSunday=sunday;exports.timeSundays=sundays;exports.timeMonday=monday;exports.timeMondays=mondays;exports.timeTuesday=tuesday;exports.timeTuesdays=tuesdays;exports.timeWednesday=wednesday;exports.timeWednesdays=wednesdays;exports.timeThursday=thursday;exports.timeThursdays=thursdays;exports.timeFriday=friday;exports.timeFridays=fridays;exports.timeSaturday=saturday;exports.timeSaturdays=saturdays;exports.timeMonth=month;exports.timeMonths=months;exports.timeYear=year;exports.timeYears=years;exports.utcMinute=utcMinute;exports.utcMinutes=utcMinutes;exports.utcHour=utcHour;exports.utcHours=utcHours;exports.utcDay=utcDay;exports.utcDays=utcDays;exports.utcWeek=utcSunday;exports.utcWeeks=utcSundays;exports.utcSunday=utcSunday;exports.utcSundays=utcSundays;exports.utcMonday=utcMonday;exports.utcMondays=utcMondays;exports.utcTuesday=utcTuesday;exports.utcTuesdays=utcTuesdays;exports.utcWednesday=utcWednesday;exports.utcWednesdays=utcWednesdays;exports.utcThursday=utcThursday;exports.utcThursdays=utcThursdays;exports.utcFriday=utcFriday;exports.utcFridays=utcFridays;exports.utcSaturday=utcSaturday;exports.utcSaturdays=utcSaturdays;exports.utcMonth=utcMonth;exports.utcMonths=utcMonths;exports.utcYear=utcYear;exports.utcYears=utcYears;Object.defineProperty(exports,"__esModule",{value:true})})},{}],18:[function(require,module,exports){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.d3=global.d3||{})})(this,function(exports){"use strict";var constant=function(x){return function(){return x}};function x(d){return d[0]}function y(d){return d[1]}function RedBlackTree(){this._=null}function RedBlackNode(node){node.U=node.C=node.L=node.R=node.P=node.N=null}RedBlackTree.prototype={constructor:RedBlackTree,insert:function(after,node){var parent,grandpa,uncle;if(after){node.P=after;node.N=after.N;if(after.N)after.N.P=node;after.N=node;if(after.R){after=after.R;while(after.L)after=after.L;after.L=node}else{after.R=node}parent=after}else if(this._){after=RedBlackFirst(this._);node.P=null;node.N=after;after.P=after.L=node;parent=after}else{node.P=node.N=null;this._=node;parent=null}node.L=node.R=null;node.U=parent;node.C=true;after=node;while(parent&&parent.C){grandpa=parent.U;if(parent===grandpa.L){uncle=grandpa.R;if(uncle&&uncle.C){parent.C=uncle.C=false;grandpa.C=true;after=grandpa}else{if(after===parent.R){RedBlackRotateLeft(this,parent);after=parent;parent=after.U}parent.C=false;grandpa.C=true;RedBlackRotateRight(this,grandpa)}}else{uncle=grandpa.L;if(uncle&&uncle.C){parent.C=uncle.C=false;grandpa.C=true;after=grandpa}else{if(after===parent.L){RedBlackRotateRight(this,parent);after=parent;parent=after.U}parent.C=false;grandpa.C=true;RedBlackRotateLeft(this,grandpa)}}parent=after.U}this._.C=false},remove:function(node){if(node.N)node.N.P=node.P;if(node.P)node.P.N=node.N;node.N=node.P=null;var parent=node.U,sibling,left=node.L,right=node.R,next,red;if(!left)next=right;else if(!right)next=left;else next=RedBlackFirst(right);if(parent){if(parent.L===node)parent.L=next;else parent.R=next}else{this._=next}if(left&&right){red=next.C;next.C=node.C;next.L=left;left.U=next;if(next!==right){parent=next.U;next.U=node.U;node=next.R;parent.L=node;next.R=right;right.U=next}else{next.U=parent;parent=next;node=next.R}}else{red=node.C;node=next}if(node)node.U=parent;if(red)return;if(node&&node.C){node.C=false;return}do{if(node===this._)break;if(node===parent.L){sibling=parent.R;if(sibling.C){sibling.C=false;parent.C=true;RedBlackRotateLeft(this,parent);sibling=parent.R}if(sibling.L&&sibling.L.C||sibling.R&&sibling.R.C){if(!sibling.R||!sibling.R.C){sibling.L.C=false;sibling.C=true;RedBlackRotateRight(this,sibling);sibling=parent.R}sibling.C=parent.C;parent.C=sibling.R.C=false;RedBlackRotateLeft(this,parent);node=this._;break}}else{sibling=parent.L;if(sibling.C){sibling.C=false;parent.C=true;RedBlackRotateRight(this,parent);sibling=parent.L}if(sibling.L&&sibling.L.C||sibling.R&&sibling.R.C){if(!sibling.L||!sibling.L.C){sibling.R.C=false;sibling.C=true;RedBlackRotateLeft(this,sibling);sibling=parent.L}sibling.C=parent.C;parent.C=sibling.L.C=false;RedBlackRotateRight(this,parent);node=this._;break}}sibling.C=true;node=parent;parent=parent.U}while(!node.C);if(node)node.C=false}};function RedBlackRotateLeft(tree,node){var p=node,q=node.R,parent=p.U;if(parent){if(parent.L===p)parent.L=q;else parent.R=q}else{tree._=q}q.U=parent;p.U=q;p.R=q.L;if(p.R)p.R.U=p;q.L=p}function RedBlackRotateRight(tree,node){var p=node,q=node.L,parent=p.U;if(parent){if(parent.L===p)parent.L=q;else parent.R=q}else{tree._=q}q.U=parent;p.U=q;p.L=q.R;if(p.L)p.L.U=p;q.R=p}function RedBlackFirst(node){while(node.L)node=node.L;return node}function createEdge(left,right,v0,v1){var edge=[null,null],index=edges.push(edge)-1;edge.left=left;edge.right=right;if(v0)setEdgeEnd(edge,left,right,v0);if(v1)setEdgeEnd(edge,right,left,v1);cells[left.index].halfedges.push(index);cells[right.index].halfedges.push(index);return edge}function createBorderEdge(left,v0,v1){var edge=[v0,v1];edge.left=left;return edge}function setEdgeEnd(edge,left,right,vertex){if(!edge[0]&&!edge[1]){edge[0]=vertex;edge.left=left;edge.right=right}else if(edge.left===right){edge[1]=vertex}else{edge[0]=vertex}}function clipEdge(edge,x0,y0,x1,y1){var a=edge[0],b=edge[1],ax=a[0],ay=a[1],bx=b[0],by=b[1],t0=0,t1=1,dx=bx-ax,dy=by-ay,r;r=x0-ax;if(!dx&&r>0)return;r/=dx;if(dx<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=x1-ax;if(!dx&&r<0)return;r/=dx;if(dx<0){if(r>t1)return;if(r>t0)t0=r}else if(dx>0){if(r0)return;r/=dy;if(dy<0){if(r0){if(r>t1)return;if(r>t0)t0=r}r=y1-ay;if(!dy&&r<0)return;r/=dy;if(dy<0){if(r>t1)return;if(r>t0)t0=r}else if(dy>0){if(r0)&&!(t1<1))return true;if(t0>0)edge[0]=[ax+t0*dx,ay+t0*dy];if(t1<1)edge[1]=[ax+t1*dx,ay+t1*dy];return true}function connectEdge(edge,x0,y0,x1,y1){var v1=edge[1];if(v1)return true;var v0=edge[0],left=edge.left,right=edge.right,lx=left[0],ly=left[1],rx=right[0],ry=right[1],fx=(lx+rx)/2,fy=(ly+ry)/2,fm,fb;if(ry===ly){if(fx=x1)return;if(lx>rx){if(!v0)v0=[fx,y0];else if(v0[1]>=y1)return;v1=[fx,y1]}else{if(!v0)v0=[fx,y1];else if(v0[1]1){if(lx>rx){if(!v0)v0=[(y0-fb)/fm,y0];else if(v0[1]>=y1)return;v1=[(y1-fb)/fm,y1]}else{if(!v0)v0=[(y1-fb)/fm,y1];else if(v0[1]=x1)return;v1=[x1,fm*x1+fb]}else{if(!v0)v0=[x1,fm*x1+fb];else if(v0[0]epsilon||Math.abs(edge[0][1]-edge[1][1])>epsilon)){delete edges[i]}}}function createCell(site){return cells[site.index]={site:site,halfedges:[]}}function cellHalfedgeAngle(cell,edge){var site=cell.site,va=edge.left,vb=edge.right;if(site===vb)vb=va,va=site;if(vb)return Math.atan2(vb[1]-va[1],vb[0]-va[0]);if(site===va)va=edge[1],vb=edge[0];else va=edge[0],vb=edge[1];return Math.atan2(va[0]-vb[0],vb[1]-va[1])}function cellHalfedgeStart(cell,edge){return edge[+(edge.left!==cell.site)]}function cellHalfedgeEnd(cell,edge){return edge[+(edge.left===cell.site)]}function sortCellHalfedges(){for(var i=0,n=cells.length,cell,halfedges,j,m;iepsilon||Math.abs(endY-startY)>epsilon){halfedges.splice(iHalfedge,0,edges.push(createBorderEdge(site,end,Math.abs(endX-x0)epsilon?[x0,Math.abs(startX-x0)epsilon?[Math.abs(startY-y1)epsilon?[x1,Math.abs(startX-x1)epsilon?[Math.abs(startY-y0)=-epsilon2)return;var ha=ax*ax+ay*ay,hc=cx*cx+cy*cy,x=(cy*ha-ay*hc)/d,y=(ax*hc-cx*ha)/d;var circle=circlePool.pop()||new Circle;circle.arc=arc;circle.site=cSite;circle.x=x+bx;circle.y=(circle.cy=y+by)+Math.sqrt(x*x+y*y);arc.circle=circle;var before=null,node=circles._;while(node){if(circle.yepsilon)node=node.L;else{dxr=x-rightBreakPoint(node,directrix);if(dxr>epsilon){if(!node.R){lArc=node;break}node=node.R}else{if(dxl>-epsilon){lArc=node.P;rArc=node}else if(dxr>-epsilon){lArc=node;rArc=node.N}else{lArc=rArc=node}break}}}createCell(site);var newArc=createBeach(site);beaches.insert(lArc,newArc);if(!lArc&&!rArc)return;if(lArc===rArc){detachCircle(lArc);rArc=createBeach(lArc.site);beaches.insert(newArc,rArc);newArc.edge=rArc.edge=createEdge(lArc.site,newArc.site);attachCircle(lArc);attachCircle(rArc);return}if(!rArc){newArc.edge=createEdge(lArc.site,newArc.site);return}detachCircle(lArc);detachCircle(rArc);var lSite=lArc.site,ax=lSite[0],ay=lSite[1],bx=site[0]-ax,by=site[1]-ay,rSite=rArc.site,cx=rSite[0]-ax,cy=rSite[1]-ay,d=2*(bx*cy-by*cx),hb=bx*bx+by*by,hc=cx*cx+cy*cy,vertex=[(cy*hb-by*hc)/d+ax,(bx*hc-cx*hb)/d+ay] -;setEdgeEnd(rArc.edge,lSite,rSite,vertex);newArc.edge=createEdge(lSite,site,null,vertex);rArc.edge=createEdge(site,rSite,null,vertex);attachCircle(lArc);attachCircle(rArc)}function leftBreakPoint(arc,directrix){var site=arc.site,rfocx=site[0],rfocy=site[1],pby2=rfocy-directrix;if(!pby2)return rfocx;var lArc=arc.P;if(!lArc)return-Infinity;site=lArc.site;var lfocx=site[0],lfocy=site[1],plby2=lfocy-directrix;if(!plby2)return lfocx;var hl=lfocx-rfocx,aby2=1/pby2-1/plby2,b=hl/plby2;if(aby2)return(-b+Math.sqrt(b*b-2*aby2*(hl*hl/(-2*plby2)-lfocy+plby2/2+rfocy-pby2/2)))/aby2+rfocx;return(rfocx+lfocx)/2}function rightBreakPoint(arc,directrix){var rArc=arc.N;if(rArc)return leftBreakPoint(rArc,directrix);var site=arc.site;return site[1]===directrix?site[0]:Infinity}var epsilon=1e-6;var epsilon2=1e-12;var beaches;var cells;var circles;var edges;function triangleArea(a,b,c){return(a[0]-c[0])*(b[1]-a[1])-(a[0]-b[0])*(c[1]-a[1])}function lexicographic(a,b){return b[1]-a[1]||b[0]-a[0]}function Diagram(sites,extent){var site=sites.sort(lexicographic).pop(),x,y,circle;edges=[];cells=new Array(sites.length);beaches=new RedBlackTree;circles=new RedBlackTree;while(true){circle=firstCircle;if(site&&(!circle||site[1]=n)return null;var dx=x-cell.site[0],dy=y-cell.site[1],d2=dx*dx+dy*dy;do{cell=that.cells[i0=i1],i1=null;cell.halfedges.forEach(function(e){var edge=that.edges[e],v=edge.left;if((v===cell.site||!v)&&!(v=edge.right))return;var vx=x-v[0],vy=y-v[1],v2=vx*vx+vy*vy;if(v20&&typeof x[0]!=="number")return false;return true}function objEquiv(a,b,opts){var i,key;if(isUndefinedOrNull(a)||isUndefinedOrNull(b))return false;if(a.prototype!==b.prototype)return false;if(isArguments(a)){if(!isArguments(b)){return false}a=pSlice.call(a);b=pSlice.call(b);return deepEqual(a,b,opts)}if(isBuffer(a)){if(!isBuffer(b)){return false}if(a.length!==b.length)return false;for(i=0;i=0;i--){if(ka[i]!=kb[i])return false}for(i=ka.length-1;i>=0;i--){key=ka[i];if(!deepEqual(a[key],b[key],opts))return false}return typeof a===typeof b}},{"./lib/is_arguments.js":20,"./lib/keys.js":21}],20:[function(require,module,exports){var supportsArgumentsClass=function(){return Object.prototype.toString.call(arguments)}()=="[object Arguments]";exports=module.exports=supportsArgumentsClass?supported:unsupported;exports.supported=supported;function supported(object){return Object.prototype.toString.call(object)=="[object Arguments]"}exports.unsupported=unsupported;function unsupported(object){return object&&typeof object=="object"&&typeof object.length=="number"&&Object.prototype.hasOwnProperty.call(object,"callee")&&!Object.prototype.propertyIsEnumerable.call(object,"callee")||false}},{}],21:[function(require,module,exports){exports=module.exports=typeof Object.keys==="function"?Object.keys:shim;exports.shim=shim;function shim(obj){var keys=[];for(var key in obj)keys.push(key);return keys}},{}],22:[function(require,module,exports){"use strict";function makeEmptyFunction(arg){return function(){return arg}}var emptyFunction=function emptyFunction(){};emptyFunction.thatReturns=makeEmptyFunction;emptyFunction.thatReturnsFalse=makeEmptyFunction(false);emptyFunction.thatReturnsTrue=makeEmptyFunction(true);emptyFunction.thatReturnsNull=makeEmptyFunction(null);emptyFunction.thatReturnsThis=function(){return this};emptyFunction.thatReturnsArgument=function(arg){return arg};module.exports=emptyFunction},{}],23:[function(require,module,exports){(function(process){"use strict";var emptyObject={};if(process.env.NODE_ENV!=="production"){Object.freeze(emptyObject)}module.exports=emptyObject}).call(this,require("_process"))},{_process:1}],24:[function(require,module,exports){(function(process){"use strict";var validateFormat=function validateFormat(format){};if(process.env.NODE_ENV!=="production"){validateFormat=function validateFormat(format){if(format===undefined){throw new Error("invariant requires an error message argument")}}}function invariant(condition,format,a,b,c,d,e,f){validateFormat(format);if(!condition){var error;if(format===undefined){error=new Error("Minified exception occurred; use the non-minified dev environment "+"for the full error message and additional helpful warnings.")}else{var args=[a,b,c,d,e,f];var argIndex=0;error=new Error(format.replace(/%s/g,function(){return args[argIndex++]}));error.name="Invariant Violation"}error.framesToPop=1;throw error}}module.exports=invariant}).call(this,require("_process"))},{_process:1}],25:[function(require,module,exports){(function(process){"use strict";var emptyFunction=require("./emptyFunction");var warning=emptyFunction;if(process.env.NODE_ENV!=="production"){var printWarning=function printWarning(format){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.error(message)}try{throw new Error(message)}catch(x){}};warning=function warning(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(format.indexOf("Failed Composite propType: ")===0){return}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=warning}).call(this,require("_process"))},{"./emptyFunction":22,_process:1}],26:[function(require,module,exports){(function(global){var win;if(typeof window!=="undefined"){win=window}else if(typeof global!=="undefined"){win=global}else if(typeof self!=="undefined"){win=self}else{win={}}module.exports=win}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],27:[function(require,module,exports){"use strict";var getOwnPropertySymbols=Object.getOwnPropertySymbols;var hasOwnProperty=Object.prototype.hasOwnProperty;var propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(val===null||val===undefined){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(val)}function shouldUseNative(){try{if(!Object.assign){return false}var test1=new String("abc");test1[5]="de";if(Object.getOwnPropertyNames(test1)[0]==="5"){return false}var test2={};for(var i=0;i<10;i++){test2["_"+String.fromCharCode(i)]=i}var order2=Object.getOwnPropertyNames(test2).map(function(n){return test2[n]});if(order2.join("")!=="0123456789"){return false}var test3={};"abcdefghijklmnopqrst".split("").forEach(function(letter){test3[letter]=letter});if(Object.keys(Object.assign({},test3)).join("")!=="abcdefghijklmnopqrst"){return false}return true}catch(err){return false}}module.exports=shouldUseNative()?Object.assign:function(target,source){var from;var to=toObject(target);var symbols;for(var s=1;smsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var newLastIdealStyle={};var newLastIdealVelocity={};var newCurrentStyle={};var newCurrentVelocity={};for(var key in propsStyle){if(!Object.prototype.hasOwnProperty.call(propsStyle,key)){continue}var styleValue=propsStyle[key];if(typeof styleValue==="number"){newCurrentStyle[key]=styleValue;newCurrentVelocity[key]=0;newLastIdealStyle[key]=styleValue;newLastIdealVelocity[key]=0}else{var newLastIdealStyleValue=_this.state.lastIdealStyle[key];var newLastIdealVelocityValue=_this.state.lastIdealVelocity[key];for(var i=0;imsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var newLastIdealStyles=[];var newLastIdealVelocities=[];var newCurrentStyles=[];var newCurrentVelocities=[];for(var i=0;imsPerFrame*10){_this.accumulatedTime=0}if(_this.accumulatedTime===0){_this.animationID=null;_this.startAnimationIfNecessary();return}var currentFrameCompletion=(_this.accumulatedTime-Math.floor(_this.accumulatedTime/msPerFrame)*msPerFrame)/msPerFrame;var framesToCatchUp=Math.floor(_this.accumulatedTime/msPerFrame);var _mergeAndSync2=mergeAndSync(_this.props.willEnter,_this.props.willLeave,_this.props.didLeave,_this.state.mergedPropsStyles,destStyles,_this.state.currentStyles,_this.state.currentVelocities,_this.state.lastIdealStyles,_this.state.lastIdealVelocities);var newMergedPropsStyles=_mergeAndSync2[0];var newCurrentStyles=_mergeAndSync2[1];var newCurrentVelocities=_mergeAndSync2[2];var newLastIdealStyles=_mergeAndSync2[3];var newLastIdealVelocities=_mergeAndSync2[4];for(var i=0;iprevKeyIndex[pivot]){return-1}else if(nextOrderA>nextKeyIndex[pivot]&&prevOrderBprevKeyIndex[pivot]){return 1}else if(nextOrderB>nextKeyIndex[pivot]&&prevOrderA1){var childArray=Array(childrenLength);for(var i=0;i1){var childArray=Array(childrenLength);for(var i=0;i."}}return info}function validateExplicitKey(element,parentType){if(!element._store||element._store.validated||element.key!=null){return}element._store.validated=true;var memoizer=ownerHasKeyUseWarning.uniqueKey||(ownerHasKeyUseWarning.uniqueKey={});var currentComponentErrorInfo=getCurrentComponentErrorInfo(parentType);if(memoizer[currentComponentErrorInfo]){return}memoizer[currentComponentErrorInfo]=true;var childOwner="";if(element&&element._owner&&element._owner!==ReactCurrentOwner.current){childOwner=" It was passed a child from "+element._owner.getName()+"."}process.env.NODE_ENV!=="production"?warning(false,'Each child in an array or iterator should have a unique "key" prop.'+"%s%s See https://fb.me/react-warning-keys for more information.%s",currentComponentErrorInfo,childOwner,ReactComponentTreeHook.getCurrentStackAddendum(element)):void 0}function validateChildKeys(node,parentType){if(typeof node!=="object"){return}if(Array.isArray(node)){for(var i=0;i1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var argIndex=0;var message="Warning: "+format.replace(/%s/g,function(){return args[argIndex++]});if(typeof console!=="undefined"){console.warn(message)}try{throw new Error(message)}catch(x){}};lowPriorityWarning=function(condition,format){if(format===undefined){throw new Error("`warning(condition, format, ...args)` requires a warning "+"message argument")}if(!condition){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}printWarning.apply(undefined,[format].concat(args))}}}module.exports=lowPriorityWarning}).call(this,require("_process"))},{_process:1}],70:[function(require,module,exports){(function(process){"use strict";var _prodInvariant=require("./reactProdInvariant");var ReactElement=require("./ReactElement");var invariant=require("fbjs/lib/invariant");function onlyChild(children){!ReactElement.isValidElement(children)?process.env.NODE_ENV!=="production"?invariant(false,"React.Children.only expected to receive a single React element child."):_prodInvariant("143"):void 0;return children}module.exports=onlyChild}).call(this,require("_process"))},{"./ReactElement":57,"./reactProdInvariant":71,_process:1,"fbjs/lib/invariant":24}],71:[function(require,module,exports){"use strict";function reactProdInvariant(code){var argCount=arguments.length-1;var message="Minified React error #"+code+"; visit "+"http://facebook.github.io/react/docs/error-decoder.html?invariant="+code;for(var argIdx=0;argIdx=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}var ANIMATION_PROPTYPES=_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.shape({stiffness:_propTypes2.default.number,nonAnimatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string),damping:_propTypes2.default.number}),_propTypes2.default.bool]);var propTypes={animatedProps:_propTypes2.default.arrayOf(_propTypes2.default.string).isRequired,animation:ANIMATION_PROPTYPES,onStart:_propTypes2.default.func,onEnd:_propTypes2.default.func};function getAnimationStyle(){var animationStyle=arguments.length>0&&arguments[0]!==undefined?arguments[0]:_reactMotion.presets.noWobble;if(typeof animationStyle==="string"){return _reactMotion.presets[animationStyle]||_reactMotion.presets.noWobble}var damping=animationStyle.damping,stiffness=animationStyle.stiffness;return _extends({damping:damping||_reactMotion.presets.noWobble.damping,stiffness:stiffness||_reactMotion.presets.noWobble.stiffness},animationStyle)}function extractAnimatedPropValues(props){var animatedProps=props.animatedProps,otherProps=_objectWithoutProperties(props,["animatedProps"]);return animatedProps.reduce(function(result,animatedPropName){if(otherProps.hasOwnProperty(animatedPropName)){result[animatedPropName]=otherProps[animatedPropName]}return result},{})}var Animation=function(_PureComponent){_inherits(Animation,_PureComponent);function Animation(props){_classCallCheck(this,Animation);var _this=_possibleConstructorReturn(this,(Animation.__proto__||Object.getPrototypeOf(Animation)).call(this,props));_this._motionEndHandler=function(){if(_this.props.onEnd){_this.props.onEnd()}};_this._renderChildren=function(_ref){var i=_ref.i;var children=_this.props.children;var interpolator=_this._interpolator;var child=_react2.default.Children.only(children);var interpolatedProps=interpolator?interpolator(i):interpolator;var data=interpolatedProps&&interpolatedProps.data||null;if(data&&child.props._data){data=data.map(function(row,index){var correspondingCell=child.props._data[index];return _extends({},row,{parent:correspondingCell.parent,children:correspondingCell.children})})}return _react2.default.cloneElement(child,_extends({},child.props,interpolatedProps,{data:data||child.props.data||null,_animation:Math.random()}))};_this._updateInterpolator(props);return _this}_createClass(Animation,[{key:"componentWillUpdate",value:function componentWillUpdate(props){this._updateInterpolator(this.props,props);if(props.onStart){props.onStart()}}},{key:"_updateInterpolator",value:function _updateInterpolator(oldProps,newProps){this._interpolator=(0,_d3Interpolate.interpolate)(extractAnimatedPropValues(oldProps),newProps?extractAnimatedPropValues(newProps):null)}},{key:"render",value:function render(){var animationStyle=getAnimationStyle(this.props.animation);var defaultStyle={i:0};var style={i:(0,_reactMotion.spring)(1,animationStyle)};var key=Math.random();return _react2.default.createElement(_reactMotion.Motion,_extends({defaultStyle:defaultStyle,style:style,key:key},{onRest:this._motionEndHandler}),this._renderChildren)}}]);return Animation}(_react.PureComponent);Animation.propTypes=propTypes;Animation.displayName="Animation";exports.default=Animation;var AnimationPropType=exports.AnimationPropType=ANIMATION_PROPTYPES},{"d3-interpolate":11,"prop-types":33,react:73,"react-motion":43}],75:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ScaleUtils=exports.AxisUtils=exports.FlexibleHeightXYPlot=exports.FlexibleWidthXYPlot=exports.FlexibleXYPlot=exports.makeWidthFlexible=exports.makeVisFlexible=exports.makeHeightFlexible=exports.Sunburst=exports.Sankey=exports.ParallelCoordinates=exports.RadarChart=exports.RadialChart=exports.Treemap=exports.ContinuousSizeLegend=exports.ContinuousColorLegend=exports.SearchableDiscreteColorLegend=exports.DiscreteColorLegend=exports.Highlight=exports.Voronoi=exports.HorizontalGridLines=exports.VerticalGridLines=exports.GradientDefs=exports.GridLines=exports.ChartLabel=exports.CircularGridLines=exports.YAxis=exports.XAxis=exports.DecorativeAxis=exports.XYPlot=exports.Crosshair=exports.Borders=exports.Hint=exports.LineMarkSeriesCanvas=exports.LineMarkSeries=exports.ArcSeries=exports.AreaSeries=exports.CustomSVGSeries=exports.ContourSeries=exports.HexbinSeries=exports.HeatmapSeries=exports.WhiskerSeries=exports.MarkSeriesCanvas=exports.MarkSeries=exports.RectSeriesCanvas=exports.RectSeries=exports.PolygonSeries=exports.LabelSeries=exports.HorizontalRectSeriesCanvas=exports.HorizontalRectSeries=exports.VerticalRectSeriesCanvas=exports.VerticalRectSeries=exports.VerticalBarSeriesCanvas=exports.VerticalBarSeries=exports.HorizontalBarSeriesCanvas=exports.HorizontalBarSeries=exports.LineSeriesCanvas=exports.LineSeries=exports.AbstractSeries=undefined;var _makeVisFlexible=require("./make-vis-flexible");Object.defineProperty(exports,"makeHeightFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeHeightFlexible}});Object.defineProperty(exports,"makeVisFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeVisFlexible}});Object.defineProperty(exports,"makeWidthFlexible",{enumerable:true,get:function get(){return _makeVisFlexible.makeWidthFlexible}});Object.defineProperty(exports,"FlexibleXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleXYPlot}});Object.defineProperty(exports,"FlexibleWidthXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleWidthXYPlot}});Object.defineProperty(exports,"FlexibleHeightXYPlot",{enumerable:true,get:function get(){return _makeVisFlexible.FlexibleHeightXYPlot}});var _abstractSeries=require("./plot/series/abstract-series");var _abstractSeries2=_interopRequireDefault(_abstractSeries);var _lineSeries=require("./plot/series/line-series");var _lineSeries2=_interopRequireDefault(_lineSeries);var _lineSeriesCanvas=require("./plot/series/line-series-canvas");var _lineSeriesCanvas2=_interopRequireDefault(_lineSeriesCanvas);var _horizontalBarSeries=require("./plot/series/horizontal-bar-series");var _horizontalBarSeries2=_interopRequireDefault(_horizontalBarSeries);var _horizontalBarSeriesCanvas=require("./plot/series/horizontal-bar-series-canvas");var _horizontalBarSeriesCanvas2=_interopRequireDefault(_horizontalBarSeriesCanvas);var _verticalBarSeries=require("./plot/series/vertical-bar-series");var _verticalBarSeries2=_interopRequireDefault(_verticalBarSeries);var _verticalBarSeriesCanvas=require("./plot/series/vertical-bar-series-canvas");var _verticalBarSeriesCanvas2=_interopRequireDefault(_verticalBarSeriesCanvas);var _verticalRectSeries=require("./plot/series/vertical-rect-series");var _verticalRectSeries2=_interopRequireDefault(_verticalRectSeries);var _verticalRectSeriesCanvas=require("./plot/series/vertical-rect-series-canvas");var _verticalRectSeriesCanvas2=_interopRequireDefault(_verticalRectSeriesCanvas);var _horizontalRectSeries=require("./plot/series/horizontal-rect-series");var _horizontalRectSeries2=_interopRequireDefault(_horizontalRectSeries);var _horizontalRectSeriesCanvas=require("./plot/series/horizontal-rect-series-canvas");var _horizontalRectSeriesCanvas2=_interopRequireDefault(_horizontalRectSeriesCanvas);var _labelSeries=require("./plot/series/label-series");var _labelSeries2=_interopRequireDefault(_labelSeries);var _polygonSeries=require("./plot/series/polygon-series");var _polygonSeries2=_interopRequireDefault(_polygonSeries);var _rectSeries=require("./plot/series/rect-series");var _rectSeries2=_interopRequireDefault(_rectSeries);var _rectSeriesCanvas=require("./plot/series/rect-series-canvas");var _rectSeriesCanvas2=_interopRequireDefault(_rectSeriesCanvas);var _markSeries=require("./plot/series/mark-series");var _markSeries2=_interopRequireDefault(_markSeries);var _markSeriesCanvas=require("./plot/series/mark-series-canvas");var _markSeriesCanvas2=_interopRequireDefault(_markSeriesCanvas);var _whiskerSeries=require("./plot/series/whisker-series");var _whiskerSeries2=_interopRequireDefault(_whiskerSeries);var _heatmapSeries=require("./plot/series/heatmap-series");var _heatmapSeries2=_interopRequireDefault(_heatmapSeries);var _hexbinSeries=require("./plot/series/hexbin-series");var _hexbinSeries2=_interopRequireDefault(_hexbinSeries);var _contourSeries=require("./plot/series/contour-series");var _contourSeries2=_interopRequireDefault(_contourSeries);var _customSvgSeries=require("./plot/series/custom-svg-series");var _customSvgSeries2=_interopRequireDefault(_customSvgSeries);var _areaSeries=require("./plot/series/area-series");var _areaSeries2=_interopRequireDefault(_areaSeries);var _arcSeries=require("./plot/series/arc-series");var _arcSeries2=_interopRequireDefault(_arcSeries);var _lineMarkSeries=require("./plot/series/line-mark-series");var _lineMarkSeries2=_interopRequireDefault(_lineMarkSeries);var _lineMarkSeriesCanvas=require("./plot/series/line-mark-series-canvas");var _lineMarkSeriesCanvas2=_interopRequireDefault(_lineMarkSeriesCanvas);var _hint=require("./plot/hint");var _hint2=_interopRequireDefault(_hint);var _borders=require("./plot/borders");var _borders2=_interopRequireDefault(_borders);var _crosshair=require("./plot/crosshair");var _crosshair2=_interopRequireDefault(_crosshair);var _xyPlot=require("./plot/xy-plot");var _xyPlot2=_interopRequireDefault(_xyPlot);var _decorativeAxis=require("./plot/axis/decorative-axis");var _decorativeAxis2=_interopRequireDefault(_decorativeAxis);var _xAxis=require("./plot/axis/x-axis");var _xAxis2=_interopRequireDefault(_xAxis);var _yAxis=require("./plot/axis/y-axis");var _yAxis2=_interopRequireDefault(_yAxis);var _circularGridLines=require("./plot/circular-grid-lines");var _circularGridLines2=_interopRequireDefault(_circularGridLines);var _chartLabel=require("./plot/chart-label");var _chartLabel2=_interopRequireDefault(_chartLabel);var _gridLines=require("./plot/grid-lines");var _gridLines2=_interopRequireDefault(_gridLines);var _gradientDefs=require("./plot/gradient-defs");var _gradientDefs2=_interopRequireDefault(_gradientDefs);var _verticalGridLines=require("./plot/vertical-grid-lines");var _verticalGridLines2=_interopRequireDefault(_verticalGridLines);var _horizontalGridLines=require("./plot/horizontal-grid-lines");var _horizontalGridLines2=_interopRequireDefault(_horizontalGridLines);var _voronoi=require("./plot/voronoi");var _voronoi2=_interopRequireDefault(_voronoi);var _highlight=require("./plot/highlight");var _highlight2=_interopRequireDefault(_highlight);var _discreteColorLegend=require("./legends/discrete-color-legend");var _discreteColorLegend2=_interopRequireDefault(_discreteColorLegend);var _searchableDiscreteColorLegend=require("./legends/searchable-discrete-color-legend");var _searchableDiscreteColorLegend2=_interopRequireDefault(_searchableDiscreteColorLegend);var _continuousColorLegend=require("./legends/continuous-color-legend");var _continuousColorLegend2=_interopRequireDefault(_continuousColorLegend);var _continuousSizeLegend=require("./legends/continuous-size-legend") -;var _continuousSizeLegend2=_interopRequireDefault(_continuousSizeLegend);var _treemap=require("./treemap");var _treemap2=_interopRequireDefault(_treemap);var _radialChart=require("./radial-chart");var _radialChart2=_interopRequireDefault(_radialChart);var _radarChart=require("./radar-chart");var _radarChart2=_interopRequireDefault(_radarChart);var _parallelCoordinates=require("./parallel-coordinates");var _parallelCoordinates2=_interopRequireDefault(_parallelCoordinates);var _sankey=require("./sankey");var _sankey2=_interopRequireDefault(_sankey);var _sunburst=require("./sunburst");var _sunburst2=_interopRequireDefault(_sunburst);var _axisUtils=require("./utils/axis-utils");var _axisUtils2=_interopRequireDefault(_axisUtils);var _scalesUtils=require("./utils/scales-utils");var _scalesUtils2=_interopRequireDefault(_scalesUtils);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.AbstractSeries=_abstractSeries2.default;exports.LineSeries=_lineSeries2.default;exports.LineSeriesCanvas=_lineSeriesCanvas2.default;exports.HorizontalBarSeries=_horizontalBarSeries2.default;exports.HorizontalBarSeriesCanvas=_horizontalBarSeriesCanvas2.default;exports.VerticalBarSeries=_verticalBarSeries2.default;exports.VerticalBarSeriesCanvas=_verticalBarSeriesCanvas2.default;exports.VerticalRectSeries=_verticalRectSeries2.default;exports.VerticalRectSeriesCanvas=_verticalRectSeriesCanvas2.default;exports.HorizontalRectSeries=_horizontalRectSeries2.default;exports.HorizontalRectSeriesCanvas=_horizontalRectSeriesCanvas2.default;exports.LabelSeries=_labelSeries2.default;exports.PolygonSeries=_polygonSeries2.default;exports.RectSeries=_rectSeries2.default;exports.RectSeriesCanvas=_rectSeriesCanvas2.default;exports.MarkSeries=_markSeries2.default;exports.MarkSeriesCanvas=_markSeriesCanvas2.default;exports.WhiskerSeries=_whiskerSeries2.default;exports.HeatmapSeries=_heatmapSeries2.default;exports.HexbinSeries=_hexbinSeries2.default;exports.ContourSeries=_contourSeries2.default;exports.CustomSVGSeries=_customSvgSeries2.default;exports.AreaSeries=_areaSeries2.default;exports.ArcSeries=_arcSeries2.default;exports.LineMarkSeries=_lineMarkSeries2.default;exports.LineMarkSeriesCanvas=_lineMarkSeriesCanvas2.default;exports.Hint=_hint2.default;exports.Borders=_borders2.default;exports.Crosshair=_crosshair2.default;exports.XYPlot=_xyPlot2.default;exports.DecorativeAxis=_decorativeAxis2.default;exports.XAxis=_xAxis2.default;exports.YAxis=_yAxis2.default;exports.CircularGridLines=_circularGridLines2.default;exports.ChartLabel=_chartLabel2.default;exports.GridLines=_gridLines2.default;exports.GradientDefs=_gradientDefs2.default;exports.VerticalGridLines=_verticalGridLines2.default;exports.HorizontalGridLines=_horizontalGridLines2.default;exports.Voronoi=_voronoi2.default;exports.Highlight=_highlight2.default;exports.DiscreteColorLegend=_discreteColorLegend2.default;exports.SearchableDiscreteColorLegend=_searchableDiscreteColorLegend2.default;exports.ContinuousColorLegend=_continuousColorLegend2.default;exports.ContinuousSizeLegend=_continuousSizeLegend2.default;exports.Treemap=_treemap2.default;exports.RadialChart=_radialChart2.default;exports.RadarChart=_radarChart2.default;exports.ParallelCoordinates=_parallelCoordinates2.default;exports.Sankey=_sankey2.default;exports.Sunburst=_sunburst2.default;exports.AxisUtils=_axisUtils2.default;exports.ScaleUtils=_scalesUtils2.default},{"./legends/continuous-color-legend":76,"./legends/continuous-size-legend":77,"./legends/discrete-color-legend":79,"./legends/searchable-discrete-color-legend":80,"./make-vis-flexible":81,"./parallel-coordinates":82,"./plot/axis/decorative-axis":88,"./plot/axis/x-axis":89,"./plot/axis/y-axis":90,"./plot/borders":91,"./plot/chart-label":92,"./plot/circular-grid-lines":93,"./plot/crosshair":94,"./plot/gradient-defs":95,"./plot/grid-lines":96,"./plot/highlight":97,"./plot/hint":98,"./plot/horizontal-grid-lines":99,"./plot/series/abstract-series":100,"./plot/series/arc-series":101,"./plot/series/area-series":102,"./plot/series/contour-series":106,"./plot/series/custom-svg-series":107,"./plot/series/heatmap-series":108,"./plot/series/hexbin-series":109,"./plot/series/horizontal-bar-series":111,"./plot/series/horizontal-bar-series-canvas":110,"./plot/series/horizontal-rect-series":113,"./plot/series/horizontal-rect-series-canvas":112,"./plot/series/label-series":114,"./plot/series/line-mark-series":116,"./plot/series/line-mark-series-canvas":115,"./plot/series/line-series":118,"./plot/series/line-series-canvas":117,"./plot/series/mark-series":120,"./plot/series/mark-series-canvas":119,"./plot/series/polygon-series":121,"./plot/series/rect-series":123,"./plot/series/rect-series-canvas":122,"./plot/series/vertical-bar-series":125,"./plot/series/vertical-bar-series-canvas":124,"./plot/series/vertical-rect-series":127,"./plot/series/vertical-rect-series-canvas":126,"./plot/series/whisker-series":128,"./plot/vertical-grid-lines":129,"./plot/voronoi":130,"./plot/xy-plot":131,"./radar-chart":132,"./radial-chart":133,"./sankey":134,"./sunburst":136,"./treemap":138,"./utils/axis-utils":142,"./utils/scales-utils":146}],76:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _theme=require("../theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,height:_propTypes2.default.number,endColor:_propTypes2.default.string,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,midColor:_propTypes2.default.string,midTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]),startColor:_propTypes2.default.string,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={className:"",startColor:_theme.CONTINUOUS_COLOR_RANGE[0],endColor:_theme.CONTINUOUS_COLOR_RANGE[1]};function ContinuousColorLegend(_ref){var startColor=_ref.startColor,midColor=_ref.midColor,endColor=_ref.endColor,startTitle=_ref.startTitle,midTitle=_ref.midTitle,endTitle=_ref.endTitle,height=_ref.height,width=_ref.width,className=_ref.className;var colors=[startColor];if(midColor){colors.push(midColor)}colors.push(endColor);return _react2.default.createElement("div",{className:"rv-continuous-color-legend "+className,style:{width:width,height:height}},_react2.default.createElement("div",{className:"rv-gradient",style:{background:"linear-gradient(to right, "+colors.join(",")+")"}}),_react2.default.createElement("div",{className:"rv-legend-titles"},_react2.default.createElement("span",{className:"rv-legend-titles__left"},startTitle),_react2.default.createElement("span",{className:"rv-legend-titles__right"},endTitle),midTitle?_react2.default.createElement("span",{className:"rv-legend-titles__center"},midTitle):null))}ContinuousColorLegend.displayName="ContinuousColorLegend";ContinuousColorLegend.propTypes=propTypes;ContinuousColorLegend.defaultProps=defaultProps;exports.default=ContinuousColorLegend},{"../theme":137,"prop-types":33,react:73}],77:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var propTypes={className:_propTypes2.default.string,circlesTotal:_propTypes2.default.number,endSize:_propTypes2.default.number,endTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,height:_propTypes2.default.number,startSize:_propTypes2.default.number,startTitle:_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string]).isRequired,width:_propTypes2.default.number};var defaultProps={circlesTotal:10,className:"",endSize:20,startSize:2};function ContinuousSizeLegend(_ref){var startTitle=_ref.startTitle,endTitle=_ref.endTitle,startSize=_ref.startSize,endSize=_ref.endSize,circlesTotal=_ref.circlesTotal,height=_ref.height,width=_ref.width,className=_ref.className;var circles=[];var step=(endSize-startSize)/(circlesTotal-1);for(var i=0;i=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}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}var CONTAINER_REF="container";var resizeSubscribers=[];var DEBOUNCE_DURATION=100;var timeoutId=null;function debounceEmitResize(){_window2.default.clearTimeout(timeoutId);timeoutId=_window2.default.setTimeout(emitResize,DEBOUNCE_DURATION)}function emitResize(){resizeSubscribers.forEach(function(cb){return cb()})}function subscribeToDebouncedResize(cb){resizeSubscribers.push(cb);if(resizeSubscribers.length===1){_window2.default.addEventListener("resize",debounceEmitResize)}return function unsubscribe(){removeSubscriber(cb);if(resizeSubscribers.length===0){_window2.default.clearTimeout(timeoutId);_window2.default.removeEventListener("resize",debounceEmitResize)}}}function removeSubscriber(cb){var index=resizeSubscribers.indexOf(cb);if(index>-1){resizeSubscribers.splice(index,1)}}function getDisplayName(Component){return Component.displayName||Component.name||"Component"}function makeFlexible(Component,isWidthFlexible,isHeightFlexible){var ResultClass=function(_React$Component){_inherits(ResultClass,_React$Component);_createClass(ResultClass,null,[{key:"propTypes",get:function get(){var _Component$propTypes=Component.propTypes,height=_Component$propTypes.height,width=_Component$propTypes.width,otherPropTypes=_objectWithoutProperties(_Component$propTypes,["height","width"]);return otherPropTypes}}]);function ResultClass(props){_classCallCheck(this,ResultClass);var _this=_possibleConstructorReturn(this,(ResultClass.__proto__||Object.getPrototypeOf(ResultClass)).call(this,props));_this._onResize=function(){var containerElement=(0,_reactUtils.getDOMNode)(_this[CONTAINER_REF]);var offsetHeight=containerElement.offsetHeight,offsetWidth=containerElement.offsetWidth;var newHeight=_this.state.height===offsetHeight?{}:{height:offsetHeight};var newWidth=_this.state.width===offsetWidth?{}:{width:offsetWidth};_this.setState(_extends({},newHeight,newWidth))};_this.state={height:0,width:0};return _this}_createClass(ResultClass,[{key:"componentDidMount",value:function componentDidMount(){this._onResize();this.cancelSubscription=subscribeToDebouncedResize(this._onResize)}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(){this._onResize()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.cancelSubscription()}},{key:"render",value:function render(){var _this2=this;var _state=this.state,height=_state.height,width=_state.width;var props=_extends({},this.props,{animation:height===0&&width===0?null:this.props.animation});var updatedDimensions=_extends({},isHeightFlexible?{height:height}:{},isWidthFlexible?{width:width}:{});return _react2.default.createElement("div",{ref:function ref(_ref){return _this2[CONTAINER_REF]=_ref},style:{width:"100%",height:"100%"}},_react2.default.createElement(Component,_extends({},updatedDimensions,props)))}}]);return ResultClass}(_react2.default.Component);ResultClass.displayName="Flexible"+getDisplayName(Component);return ResultClass}function makeHeightFlexible(component){return makeFlexible(component,false,true)}function makeVisFlexible(component){return makeFlexible(component,true,true)}function makeWidthFlexible(component){return makeFlexible(component,true,false)}var FlexibleWidthXYPlot=exports.FlexibleWidthXYPlot=makeWidthFlexible(_xyPlot2.default);var FlexibleHeightXYPlot=exports.FlexibleHeightXYPlot=makeHeightFlexible(_xyPlot2.default);var FlexibleXYPlot=exports.FlexibleXYPlot=makeVisFlexible(_xyPlot2.default)},{"./plot/xy-plot":131,"./utils/react-utils":145,"global/window":26,react:73}],82:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;ifilter.max)){withinFilteredRange=false}return{x:name,y:yVal}});var selectedName=predefinedClassName+"-line";var unselectedName=selectedName+" "+predefinedClassName+"-line-unselected";var lineProps={animation:animation,className:withinFilteredRange?selectedName:unselectedName,key:rowIndex+"-polygon",data:mappedData,color:row.color||colorRange[rowIndex%colorRange.length],style:_extends({},style.lines,row.style||{})};if(!withinFilteredRange){lineProps.style=_extends({},lineProps.style,style.deselectedLineStyle)}return showMarks?_react2.default.createElement(_lineMarkSeries2.default,lineProps):_react2.default.createElement(_lineSeries2.default,lineProps)})}var ParallelCoordinates=function(_Component){_inherits(ParallelCoordinates,_Component);function ParallelCoordinates(){var _ref2;var _temp,_this,_ret;_classCallCheck(this,ParallelCoordinates);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}return _ret=(_temp=(_this=_possibleConstructorReturn(this,(_ref2=ParallelCoordinates.__proto__||Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2,[this].concat(args))),_this),_this.state={brushFilters:{}},_temp),_possibleConstructorReturn(_this,_ret)}_createClass(ParallelCoordinates,[{key:"render",value:function render(){var _this2=this;var brushFilters=this.state.brushFilters;var _props=this.props,animation=_props.animation,brushing=_props.brushing,className=_props.className,children=_props.children,colorRange=_props.colorRange,data=_props.data,domains=_props.domains,height=_props.height,hideInnerMostValues=_props.hideInnerMostValues,margin=_props.margin,onMouseLeave=_props.onMouseLeave,onMouseEnter=_props.onMouseEnter,showMarks=_props.showMarks,style=_props.style,tickFormat=_props.tickFormat,width=_props.width;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,style:style,tickFormat:tickFormat});var lines=getLines({animation:animation,brushFilters:brushFilters,colorRange:colorRange,domains:domains,data:data,showMarks:showMarks,style:style});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:true,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels})});var _getInnerDimensions=(0,_chartUtils.getInnerDimensions)(this.props,_chartUtils.DEFAULT_MARGINS),marginLeft=_getInnerDimensions.marginLeft,marginRight=_getInnerDimensions.marginRight;return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xType:"ordinal",yDomain:[0,1]},children,axes.concat(lines).concat(labelSeries),brushing&&domains.map(function(d){var trigger=function trigger(row){_this2.setState({brushFilters:_extends({},brushFilters,_defineProperty({},d.name,row?{min:row.bottom,max:row.top}:null))})};return _react2.default.createElement(_highlight2.default,{key:d.name,drag:true,highlightX:d.name,onBrushEnd:trigger,onDragEnd:trigger,highlightWidth:(width-marginLeft-marginRight)/domains.length,enableX:false})}))}}]);return ParallelCoordinates}(_react.Component);ParallelCoordinates.displayName="ParallelCoordinates";ParallelCoordinates.propTypes={animation:_animation.AnimationPropType,brushing:_propTypes2.default.bool,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,margin:_chartUtils.MarginPropType,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,lines:_propTypes2.default.object}),showMarks:_propTypes2.default.bool,tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};ParallelCoordinates.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},lines:{strokeWidth:1,strokeOpacity:1},deselectedLineStyle:{strokeOpacity:.1}},tickFormat:DEFAULT_FORMAT};exports.default=ParallelCoordinates},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/highlight":97,"../plot/series/label-series":114,"../plot/series/line-mark-series":116, -"../plot/series/line-series":118,"../plot/xy-plot":131,"../theme":137,"../utils/chart-utils":143,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],83:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i-1;var axisClassName=isVertical?VERTICAL_CLASS_NAME:HORIZONTAL_CLASS_NAME;var leftPos=left;var topPos=top;if(on0){var scale=(0,_scalesUtils.getAttributeScale)(props,attrAxis);if(isVertical){leftPos=scale(0)}else{topPos=marginTop+scale(0)}}return _react2.default.createElement("g",{transform:"translate("+leftPos+","+topPos+")",className:predefinedClassName+" "+axisClassName+" "+className,style:style},!hideLine&&_react2.default.createElement(_axisLine2.default,{height:height,width:width,orientation:orientation,style:_extends({},style,style.line)}),!hideTicks&&_react2.default.createElement(_axisTicks2.default,_extends({},props,{style:_extends({},style,style.ticks)})),title?_react2.default.createElement(_axisTitle2.default,{position:position,title:title,height:height,width:width,style:_extends({},style,style.title),orientation:orientation}):null)}}]);return Axis}(_react.PureComponent);Axis.displayName="Axis";Axis.propTypes=propTypes;Axis.defaultProps=defaultProps;Axis.requiresSVG=true;exports.default=Axis},{"../../animation":74,"../../utils/axis-utils":142,"../../utils/scales-utils":146,"./axis-line":83,"./axis-ticks":84,"./axis-title":85,"prop-types":33,react:73}],87:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;irRange[1])){return res}return res.concat([_react2.default.createElement("circle",_extends({cx:0,cy:0,r:radius},{key:index,className:"rv-xy-plot__circular-grid-lines__line",style:style}))])},[]))}}]);return CircularGridLines}(_react.PureComponent);CircularGridLines.displayName="CircularGridLines";CircularGridLines.propTypes={centerX:_propTypes2.default.number,centerY:_propTypes2.default.number,width:_propTypes2.default.number,height:_propTypes2.default.number,top:_propTypes2.default.number,left:_propTypes2.default.number,rRange:_propTypes2.default.arrayOf(_propTypes2.default.number),style:_propTypes2.default.object,tickValues:_propTypes2.default.arrayOf(_propTypes2.default.number),tickTotal:_propTypes2.default.number,animation:_animation.AnimationPropType,marginTop:_propTypes2.default.number,marginBottom:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginRight:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number};CircularGridLines.defaultProps={centerX:0,centerY:0};CircularGridLines.requiresSVG=true;exports.default=CircularGridLines},{"../animation":74,"../utils/axis-utils":142,"../utils/scales-utils":146,"prop-types":33,react:73}],94:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?"left":"right":_props$orientation;var left=marginLeft+innerLeft;var top=marginTop;var innerClassName="rv-crosshair__inner rv-crosshair__inner--"+orientation;return _react2.default.createElement("div",{className:"rv-crosshair "+className,style:{left:left+"px",top:top+"px"}},_react2.default.createElement("div",{className:"rv-crosshair__line",style:_extends({height:innerHeight+"px"},style.line)}),_react2.default.createElement("div",{className:innerClassName},children?children:_react2.default.createElement("div",{className:"rv-crosshair__inner__content",style:style.box},_react2.default.createElement("div",null,this._renderCrosshairTitle(),this._renderCrosshairItems()))))}}],[{key:"defaultProps",get:function get(){return{titleFormat:defaultTitleFormat,itemsFormat:defaultItemsFormat,style:{line:{},title:{},box:{}}}}},{key:"propTypes",get:function get(){return{className:_propTypes2.default.string,values:_propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number,_propTypes2.default.string,_propTypes2.default.object])),series:_propTypes2.default.object,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,orientation:_propTypes2.default.oneOf(["left","right"]),itemsFormat:_propTypes2.default.func,titleFormat:_propTypes2.default.func,style:_propTypes2.default.shape({line:_propTypes2.default.object,title:_propTypes2.default.object,box:_propTypes2.default.object})}}}]);return Crosshair}(_react.PureComponent);Crosshair.displayName="Crosshair";exports.default=Crosshair},{"../utils/scales-utils":146,"prop-types":33,react:73}],95:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var predefinedClassName="rv-gradient-defs";function GradientDefs(props){var className=props.className;return _react2.default.createElement("defs",{className:predefinedClassName+" "+className},props.children)}GradientDefs.displayName="GradientDefs";GradientDefs.requiresSVG=true;GradientDefs.propTypes={className:_propTypes2.default.string};GradientDefs.defaultProps={className:""};exports.default=GradientDefs},{"prop-types":33,react:73}],96:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iright);var clickedOutsideDragY=dragArea&&(yLocbottom);if(enableX&&enableY){return clickedOutsideDragX||clickedOutsideDragY}if(enableX){return clickedOutsideDragX}if(enableY){return clickedOutsideDragY}return true}},{key:"_convertAreaToCoordinates",value:function _convertAreaToCoordinates(brushArea){var _props4=this.props,enableX=_props4.enableX,enableY=_props4.enableY,marginLeft=_props4.marginLeft,marginTop=_props4.marginTop;var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");if(enableX&&enableY){return{bottom:yScale.invert(brushArea.bottom),left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft),top:yScale.invert(brushArea.top)}}if(enableY){return{bottom:yScale.invert(brushArea.bottom-marginTop),top:yScale.invert(brushArea.top-marginTop)}}if(enableX){return{left:xScale.invert(brushArea.left-marginLeft),right:xScale.invert(brushArea.right-marginLeft)}}return{}}},{key:"startBrushing",value:function startBrushing(e){var _this2=this;var _props5=this.props,onBrushStart=_props5.onBrushStart,onDragStart=_props5.onDragStart,drag=_props5.drag;var dragArea=this.state.dragArea;var _getLocs=getLocs(e.nativeEvent),xLoc=_getLocs.xLoc,yLoc=_getLocs.yLoc;var startArea=function startArea(dragging,resetDrag){var emptyBrush={bottom:yLoc,left:xLoc,right:xLoc,top:yLoc};_this2.setState({dragging:dragging,brushArea:dragArea&&!resetDrag?dragArea:emptyBrush,brushing:!dragging,startLocX:xLoc,startLocY:yLoc})};var clickedOutsideDrag=this._clickedOutsideDrag(xLoc,yLoc);if(drag&&!dragArea||!drag||clickedOutsideDrag){startArea(false,clickedOutsideDrag);if(onBrushStart){onBrushStart(e)}return}if(drag&&dragArea){startArea(true,clickedOutsideDrag);if(onDragStart){onDragStart(e)}}}},{key:"stopBrushing",value:function stopBrushing(e){var _state4=this.state,brushing=_state4.brushing,dragging=_state4.dragging,brushArea=_state4.brushArea;if(!brushing&&!dragging){return}var _props6=this.props,onBrushEnd=_props6.onBrushEnd,onDragEnd=_props6.onDragEnd,drag=_props6.drag;var noHorizontal=Math.abs(brushArea.right-brushArea.left)<5;var noVertical=Math.abs(brushArea.top-brushArea.bottom)<5;var isNulled=noVertical||noHorizontal;this.setState({brushing:false,dragging:false,brushArea:drag?brushArea:{top:0,right:0,bottom:0,left:0},startLocX:0,startLocY:0,dragArea:drag&&!isNulled&&brushArea});if(brushing&&onBrushEnd){onBrushEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}if(drag&&onDragEnd){onDragEnd(!isNulled?this._convertAreaToCoordinates(brushArea):null)}}},{key:"onBrush",value:function onBrush(e){var _props7=this.props,onBrush=_props7.onBrush,onDrag=_props7.onDrag,drag=_props7.drag;var _state5=this.state,brushing=_state5.brushing,dragging=_state5.dragging;var _getLocs2=getLocs(e.nativeEvent),xLoc=_getLocs2.xLoc,yLoc=_getLocs2.yLoc;if(brushing){var brushArea=this._getDrawArea(xLoc,yLoc);this.setState({brushArea:brushArea});if(onBrush){onBrush(this._convertAreaToCoordinates(brushArea))}}if(drag&&dragging){var _brushArea=this._getDragArea(xLoc,yLoc);this.setState({brushArea:_brushArea});if(onDrag){onDrag(this._convertAreaToCoordinates(_brushArea))}}}},{key:"render",value:function render(){var _this3=this;var _props8=this.props,color=_props8.color,className=_props8.className,highlightHeight=_props8.highlightHeight,highlightWidth=_props8.highlightWidth,highlightX=_props8.highlightX,highlightY=_props8.highlightY,innerWidth=_props8.innerWidth,innerHeight=_props8.innerHeight,marginLeft=_props8.marginLeft,marginRight=_props8.marginRight,marginTop=_props8.marginTop,marginBottom=_props8.marginBottom,opacity=_props8.opacity;var _state$brushArea=this.state.brushArea,left=_state$brushArea.left,right=_state$brushArea.right,top=_state$brushArea.top,bottom=_state$brushArea.bottom;var leftPos=0;if(highlightX){var xScale=(0,_scalesUtils.getAttributeScale)(this.props,"x");leftPos=xScale(highlightX)}var topPos=0;if(highlightY){var yScale=(0,_scalesUtils.getAttributeScale)(this.props,"y");topPos=yScale(highlightY)}var plotWidth=marginLeft+marginRight+innerWidth;var plotHeight=marginTop+marginBottom+innerHeight;var touchWidth=highlightWidth||plotWidth;var touchHeight=highlightHeight||plotHeight;return _react2.default.createElement("g",{transform:"translate("+leftPos+", "+topPos+")",className:className+" rv-highlight-container"},_react2.default.createElement("rect",{className:"rv-mouse-target",fill:"black",opacity:"0",x:"0",y:"0",width:Math.max(touchWidth,0),height:Math.max(touchHeight,0),onMouseDown:function onMouseDown(e){return _this3.startBrushing(e)},onMouseMove:function onMouseMove(e){return _this3.onBrush(e)},onMouseUp:function onMouseUp(e){return _this3.stopBrushing(e)},onMouseLeave:function onMouseLeave(e){return _this3.stopBrushing(e)},onTouchEnd:function onTouchEnd(e){e.preventDefault();_this3.stopBrushing(e)},onTouchCancel:function onTouchCancel(e){e.preventDefault();_this3.stopBrushing(e)},onContextMenu:function onContextMenu(e){return e.preventDefault()},onContextMenuCapture:function onContextMenuCapture(e){return e.preventDefault()}}),_react2.default.createElement("rect",{className:"rv-highlight",pointerEvents:"none",opacity:opacity,fill:color,x:left,y:top,width:Math.min(Math.max(0,right-left),touchWidth),height:Math.min(Math.max(0,bottom-top),touchHeight)}))}}]);return Highlight}(_abstractSeries2.default);Highlight.displayName="HighlightOverlay";Highlight.defaultProps={color:"rgb(77, 182, 172)",className:"",enableX:true,enableY:true,opacity:.3};Highlight.propTypes=_extends({},_abstractSeries2.default.propTypes,{enableX:_propTypes2.default.bool,enableY:_propTypes2.default.bool,highlightHeight:_propTypes2.default.number,highlightWidth:_propTypes2.default.number,highlightX:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),highlightY:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]),onBrushStart:_propTypes2.default.func,onDragStart:_propTypes2.default.func,onBrush:_propTypes2.default.func,onDrag:_propTypes2.default.func,onBrushEnd:_propTypes2.default.func,onDragEnd:_propTypes2.default.func});exports.default=Highlight},{"../utils/scales-utils":146,"./series/abstract-series":100,"prop-types":33,react:73}],98:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iinnerWidth/2?ALIGN.LEFT:ALIGN.RIGHT}if(vertical===ALIGN.AUTO){align.vertical=y>innerHeight/2?ALIGN.TOP:ALIGN.BOTTOM}return align}},{key:"_getAlignClassNames",value:function _getAlignClassNames(align){var orientation=this.props.orientation;var orientationClass=orientation?"rv-hint--orientation-"+orientation:"";return orientationClass+" rv-hint--horizontalAlign-"+align.horizontal+"\n rv-hint--verticalAlign-"+align.vertical}},{key:"_getAlignStyle",value:function _getAlignStyle(align,x,y){return _extends({},this._getXCSS(align.horizontal,x),this._getYCSS(align.vertical,y))}},{key:"_getCSSBottom",value:function _getCSSBottom(y){if(y===undefined||y===null){return{bottom:0}}var _props2=this.props,innerHeight=_props2.innerHeight,marginBottom=_props2.marginBottom;return{bottom:marginBottom+innerHeight-y}}},{key:"_getCSSLeft",value:function _getCSSLeft(x){if(x===undefined||x===null){return{left:0}}var marginLeft=this.props.marginLeft;return{left:marginLeft+x}}},{key:"_getCSSRight",value:function _getCSSRight(x){if(x===undefined||x===null){return{right:0}}var _props3=this.props,innerWidth=_props3.innerWidth,marginRight=_props3.marginRight;return{right:marginRight+innerWidth-x}}},{key:"_getCSSTop",value:function _getCSSTop(y){if(y===undefined||y===null){return{top:0}}var marginTop=this.props.marginTop;return{top:marginTop+y}}},{key:"_getPositionInfo",value:function _getPositionInfo(){var _props4=this.props,value=_props4.value,getAlignStyle=_props4.getAlignStyle;var x=(0,_scalesUtils.getAttributeFunctor)(this.props,"x")(value);var y=(0,_scalesUtils.getAttributeFunctor)(this.props,"y")(value);var align=this._getAlign(x,y);return{position:getAlignStyle?getAlignStyle(align,x,y):this._getAlignStyle(align,x,y),className:this._getAlignClassNames(align)}}},{key:"_getXCSS",value:function _getXCSS(horizontal,x){switch(horizontal){case ALIGN.LEFT_EDGE:return this._getCSSLeft(null);case ALIGN.RIGHT_EDGE:return this._getCSSRight(null);case ALIGN.LEFT:return this._getCSSRight(x);case ALIGN.RIGHT:default:return this._getCSSLeft(x)}}},{key:"_getYCSS",value:function _getYCSS(verticalAlign,y){switch(verticalAlign){case ALIGN.TOP_EDGE:return this._getCSSTop(null);case ALIGN.BOTTOM_EDGE:return this._getCSSBottom(null);case ALIGN.BOTTOM:return this._getCSSTop(y);case ALIGN.TOP:default:return this._getCSSBottom(y)}}},{key:"_mapOrientationToAlign",value:function _mapOrientationToAlign(orientation){switch(orientation){case ORIENTATION.BOTTOM_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.BOTTOM};case ORIENTATION.BOTTOM_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.BOTTOM};case ORIENTATION.TOP_LEFT:return{horizontal:ALIGN.LEFT,vertical:ALIGN.TOP};case ORIENTATION.TOP_RIGHT:return{horizontal:ALIGN.RIGHT,vertical:ALIGN.TOP};default:break}}},{key:"render",value:function render(){var _props5=this.props,value=_props5.value,format=_props5.format,children=_props5.children,style=_props5.style;var _getPositionInfo2=this._getPositionInfo(),position=_getPositionInfo2.position,className=_getPositionInfo2.className;return _react2.default.createElement("div",{className:"rv-hint "+className,style:_extends({},style,position,{position:"absolute"})},children?children:_react2.default.createElement("div",{className:"rv-hint__content",style:style.content},format(value).map(function(formattedProp,i){return _react2.default.createElement("div",{key:"rv-hint"+i,style:style.row},_react2.default.createElement("span",{className:"rv-hint__title",style:style.title},formattedProp.title),": ",_react2.default.createElement("span",{className:"rv-hint__value",style:style.value},formattedProp.value))})))}}],[{key:"defaultProps",get:function get(){return{format:defaultFormat,align:{horizontal:ALIGN.AUTO,vertical:ALIGN.AUTO},style:{}}}},{key:"propTypes",get:function get(){return{marginTop:_propTypes2.default.number,marginLeft:_propTypes2.default.number,innerWidth:_propTypes2.default.number,innerHeight:_propTypes2.default.number,scales:_propTypes2.default.object,value:_propTypes2.default.object,format:_propTypes2.default.func,style:_propTypes2.default.object,align:_propTypes2.default.shape({horizontal:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.LEFT,ALIGN.RIGHT,ALIGN.LEFT_EDGE,ALIGN.RIGHT_EDGE]),vertical:_propTypes2.default.oneOf([ALIGN.AUTO,ALIGN.BOTTOM,ALIGN.TOP,ALIGN.BOTTOM_EDGE,ALIGN.TOP_EDGE])}),getAlignStyle:_propTypes2.default.func,orientation:_propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT,ORIENTATION.BOTTOM_RIGHT,ORIENTATION.TOP_LEFT,ORIENTATION.TOP_RIGHT])}}}]);return Hint}(_react.PureComponent);Hint.displayName="Hint";Hint.ORIENTATION=ORIENTATION;Hint.ALIGN=ALIGN;exports.default=Hint},{"../utils/scales-utils":146,"prop-types":33,react:73}],99:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;iMAX_DRAWS){clearInterval(drawCycle)}drawIteration+=1},1)}function drawLayers(ctx,height,width,layers,drawIteration){ctx.clearRect(0,0,width,height);layers.forEach(function(layer){var interpolator=layer.interpolator,newProps=layer.newProps,animation=layer.animation;var interpolatedProps=animation?interpolator?interpolator(drawIteration/MAX_DRAWS):interpolator:function(){return{}};layer.renderLayer(_extends({},newProps,interpolatedProps),ctx)})}function buildLayers(newChildren,oldChildren){return newChildren.map(function(child,index){var oldProps=oldChildren[index]?oldChildren[index].props:{};var newProps=child.props;var oldAnimatedProps=(0,_animation.extractAnimatedPropValues)(_extends({},oldProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}));var newAnimatedProps=newProps?(0,_animation.extractAnimatedPropValues)(_extends({},newProps,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS})):null;var interpolator=(0,_d3Interpolate.interpolate)(oldAnimatedProps,newAnimatedProps);return{renderLayer:child.type.renderLayer,newProps:child.props,animation:child.props.animation,interpolator:interpolator}})}var CanvasWrapper=function(_Component){_inherits(CanvasWrapper,_Component);function CanvasWrapper(){_classCallCheck(this,CanvasWrapper);return _possibleConstructorReturn(this,(CanvasWrapper.__proto__||Object.getPrototypeOf(CanvasWrapper)).apply(this,arguments))}_createClass(CanvasWrapper,[{key:"componentDidMount",value:function componentDidMount(){var ctx=this.canvas.getContext("2d");if(!ctx){return}var pixelRatio=this.props.pixelRatio;if(!ctx){return}ctx.scale(pixelRatio,pixelRatio);this.drawChildren(null,this.props,ctx)}},{key:"componentDidUpdate",value:function componentDidUpdate(oldProps){this.drawChildren(oldProps,this.props,this.canvas.getContext("2d"))}},{key:"drawChildren",value:function drawChildren(oldProps,newProps,ctx){var children=newProps.children,innerHeight=newProps.innerHeight,innerWidth=newProps.innerWidth,marginBottom=newProps.marginBottom,marginLeft=newProps.marginLeft,marginRight=newProps.marginRight,marginTop=newProps.marginTop;if(!ctx){return}var childrenShouldAnimate=children.find(function(child){return child.props.animation});var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;var layers=buildLayers(newProps.children,oldProps?oldProps.children:[]);if(!childrenShouldAnimate){drawLayers(ctx,height,width,layers);return}engageDrawLoop(ctx,height,width,layers)}},{key:"render",value:function render(){var _this2=this;var _props=this.props,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginBottom=_props.marginBottom,marginLeft=_props.marginLeft,marginRight=_props.marginRight,marginTop=_props.marginTop,pixelRatio=_props.pixelRatio;var height=innerHeight+marginTop+marginBottom;var width=innerWidth+marginLeft+marginRight;return _react2.default.createElement("div",{style:{left:0,top:0},className:"rv-xy-canvas"},_react2.default.createElement("canvas",{className:"rv-xy-canvas-element",height:height*pixelRatio,width:width*pixelRatio,style:{height:height+"px",width:width+"px"},ref:function ref(_ref){return _this2.canvas=_ref}}),this.props.children)}}],[{key:"defaultProps",get:function get(){return{pixelRatio:window&&window.devicePixelRatio||1}}}]);return CanvasWrapper}(_react.Component);CanvasWrapper.displayName="CanvasWrapper";CanvasWrapper.propTypes={marginBottom:_propTypes2.default.number.isRequired,marginLeft:_propTypes2.default.number.isRequired,marginRight:_propTypes2.default.number.isRequired,marginTop:_propTypes2.default.number.isRequired,innerHeight:_propTypes2.default.number.isRequired,innerWidth:_propTypes2.default.number.isRequired,pixelRatio:_propTypes2.default.number.isRequired};exports.default=CanvasWrapper},{"../../animation":74,"../../utils/series-utils":147,"d3-interpolate":11,"prop-types":33,react:73}],106:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i1&&arguments[1]!==undefined?arguments[1]:2;var style=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_STYLE;switch(type){case"diamond":return _react2.default.createElement("polygon",{style:style,points:"0 0 "+size/2+" "+size/2+" 0 "+size+" "+-size/2+" "+size/2+" 0 0"});case"star":var starPoints=[].concat(_toConsumableArray(new Array(5))).map(function(c,index){var angle=index/5*Math.PI*2;var innerAngle=angle+Math.PI/10;var outerAngle=angle-Math.PI/10;var innerRadius=size/2.61;return"\n "+Math.cos(outerAngle)*size+" "+Math.sin(outerAngle)*size+"\n "+Math.cos(innerAngle)*innerRadius+" "+Math.sin(innerAngle)*innerRadius+"\n "}).join(" ");return _react2.default.createElement("polygon",{points:starPoints,x:"0",y:"0",height:size,width:size,style:style});case"square":return _react2.default.createElement("rect",{x:""+-size/2,y:""+-size/2,height:size,width:size,style:style});default:case"circle":return _react2.default.createElement("circle",{cx:"0",cy:"0",r:size/2,style:style})}}function getInnerComponent(_ref){var customComponent=_ref.customComponent,defaultType=_ref.defaultType,positionInPixels=_ref.positionInPixels,positionFunctions=_ref.positionFunctions,style=_ref.style,propsSize=_ref.propsSize;var size=customComponent.size;var aggStyle=_extends({},style,customComponent.style||{});var innerComponent=customComponent.customComponent;if(!innerComponent&&typeof defaultType==="string"){return predefinedComponents(defaultType,size||propsSize,aggStyle)}if(!innerComponent){return defaultType(customComponent,positionInPixels,aggStyle)}if(typeof innerComponent==="string"){return predefinedComponents(innerComponent||defaultType,size,aggStyle)}return innerComponent(customComponent,positionInPixels,aggStyle)}var CustomSVGSeries=function(_AbstractSeries){_inherits(CustomSVGSeries,_AbstractSeries);function CustomSVGSeries(){_classCallCheck(this,CustomSVGSeries);return _possibleConstructorReturn(this,(CustomSVGSeries.__proto__||Object.getPrototypeOf(CustomSVGSeries)).apply(this,arguments))}_createClass(CustomSVGSeries,[{key:"render",value:function render(){var _this2=this;var _props=this.props,animation=_props.animation,className=_props.className,customComponent=_props.customComponent,data=_props.data,innerHeight=_props.innerHeight,innerWidth=_props.innerWidth,marginLeft=_props.marginLeft,marginTop=_props.marginTop,style=_props.style,size=_props.size;if(!data||!innerWidth||!innerHeight){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(CustomSVGSeries,_extends({},this.props,{animation:false})))}var x=this._getAttributeFunctor("x");var y=this._getAttributeFunctor("y");var contents=data.map(function(seriesComponent,index){var positionInPixels={x:x({x:seriesComponent.x}),y:y({y:seriesComponent.y})};var innerComponent=getInnerComponent({customComponent:seriesComponent,positionInPixels:positionInPixels,defaultType:customComponent,positionFunctions:{x:x,y:y},style:style,propsSize:size});return _react2.default.createElement("g",{className:"rv-xy-plot__series--custom-svg",key:"rv-xy-plot__series--custom-svg-"+index,transform:"translate("+positionInPixels.x+","+positionInPixels.y+")",onMouseEnter:function onMouseEnter(e){return _this2._valueMouseOverHandler(seriesComponent,e)},onMouseLeave:function onMouseLeave(e){return _this2._valueMouseOutHandler(seriesComponent,e)}},innerComponent)});return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},contents)}}]);return CustomSVGSeries}(_abstractSeries2.default);CustomSVGSeries.propTypes={animation:_propTypes2.default.bool,className:_propTypes2.default.string,customComponent:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.func]),data:_propTypes2.default.arrayOf(_propTypes2.default.shape({x:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired,y:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired})).isRequired,marginLeft:_propTypes2.default.number,marginTop:_propTypes2.default.number,style:_propTypes2.default.object,size:_propTypes2.default.number,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func};CustomSVGSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{animation:false,customComponent:"circle",style:{},size:2});exports.default=CustomSVGSeries},{"../../animation":74,"../../utils/series-utils":147,"./abstract-series":100,"prop-types":33,react:73}],108:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;ipositiveYVariance;if(!hasXWhiskers&&!hasYWhiskers){return null}var styleAttr=_extends({opacity:opacityFunctor?opacityFunctor(d):_theme.DEFAULT_OPACITY,stroke:strokeFunctor&&strokeFunctor(d),strokeWidth:strokeWidth||DEFAULT_STROKE_WIDTH},style);var crossBarExtension=crossBarWidth/2;var rightLineAttrs={x1:cx+r,y1:cy,x2:positiveXVariance,y2:cy,style:styleAttr};var leftLineAttrs={x1:cx-r,y1:cy,x2:negativeXVariance,y2:cy,style:styleAttr};var rightCrossBarAttrs={x1:positiveXVariance,y1:cy-crossBarExtension,x2:positiveXVariance,y2:cy+crossBarExtension,style:styleAttr};var leftCrossBarAttrs={x1:negativeXVariance,y1:cy-crossBarExtension,x2:negativeXVariance,y2:cy+crossBarExtension,style:styleAttr};var upperLineAttrs={x1:cx,y1:cy-r,x2:cx,y2:positiveYVariance,style:styleAttr};var lowerLineAttrs={x1:cx,y1:cy+r,x2:cx,y2:negativeYVariance,style:styleAttr};var upperCrossBarAttrs={x1:cx-crossBarExtension,y1:positiveYVariance,x2:cx+crossBarExtension,y2:positiveYVariance,style:styleAttr};var lowerCrossBarAttrs={x1:cx-crossBarExtension,y1:negativeYVariance,x2:cx+crossBarExtension,y2:negativeYVariance,style:styleAttr};return _react2.default.createElement("g",{className:"mark-whiskers",key:i,onClick:function onClick(e){return valueClickHandler(d,e)},onContextMenu:function onContextMenu(e){return valueRightClickHandler(d,e)},onMouseOver:function onMouseOver(e){return valueMouseOverHandler(d,e)},onMouseOut:function onMouseOut(e){return valueMouseOutHandler(d,e)}},hasXWhiskers?_react2.default.createElement("g",{className:"x-whiskers"},_react2.default.createElement("line",rightLineAttrs),_react2.default.createElement("line",leftLineAttrs),_react2.default.createElement("line",rightCrossBarAttrs),_react2.default.createElement("line",leftCrossBarAttrs)):null,hasYWhiskers?_react2.default.createElement("g",{className:"y-whiskers"},_react2.default.createElement("line",upperLineAttrs),_react2.default.createElement("line",lowerLineAttrs),_react2.default.createElement("line",upperCrossBarAttrs),_react2.default.createElement("line",lowerCrossBarAttrs)):null)}};var WhiskerSeries=function(_AbstractSeries){_inherits(WhiskerSeries,_AbstractSeries);function WhiskerSeries(){_classCallCheck(this,WhiskerSeries);return _possibleConstructorReturn(this,(WhiskerSeries.__proto__||Object.getPrototypeOf(WhiskerSeries)).apply(this,arguments))}_createClass(WhiskerSeries,[{key:"render",value:function render(){var _props=this.props,animation=_props.animation,className=_props.className,crossBarWidth=_props.crossBarWidth,data=_props.data,marginLeft=_props.marginLeft,marginTop=_props.marginTop,strokeWidth=_props.strokeWidth,style=_props.style;if(!data){return null}if(animation){return _react2.default.createElement(_animation2.default,_extends({},this.props,{animatedProps:_seriesUtils.ANIMATED_SERIES_PROPS}),_react2.default.createElement(WhiskerSeries,_extends({},this.props,{animation:null})))}var whiskerMarkProps={crossBarWidth:crossBarWidth,opacityFunctor:this._getAttributeFunctor("opacity"),sizeFunctor:this._getAttributeFunctor("size"),strokeFunctor:this._getAttributeFunctor("stroke")||this._getAttributeFunctor("color"),strokeWidth:strokeWidth,style:style,xFunctor:this._getAttributeFunctor("x"),yFunctor:this._getAttributeFunctor("y"),valueClickHandler:this._valueClickHandler,valueRightClickHandler:this._valueRightClickHandler,valueMouseOverHandler:this._valueMouseOverHandler,valueMouseOutHandler:this._valueMouseOutHandler};return _react2.default.createElement("g",{className:predefinedClassName+" "+className,transform:"translate("+marginLeft+","+marginTop+")"},data.map(renderWhiskerMark(whiskerMarkProps)))}}]);return WhiskerSeries}(_abstractSeries2.default);WhiskerSeries.displayName="WhiskerSeries";WhiskerSeries.propTypes=_extends({},_abstractSeries2.default.propTypes,{strokeWidth:_propTypes2.default.number});WhiskerSeries.defaultProps=_extends({},_abstractSeries2.default.defaultProps,{crossBarWidth:DEFAULT_CROSS_BAR_WIDTH,size:0,strokeWidth:DEFAULT_STROKE_WIDTH});exports.default=WhiskerSeries},{"../../animation":74,"../../theme":137,"../../utils/series-utils":147,"./abstract-series":100,"prop-types":33,react:73}],129:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i-1&&index0){if(Math.abs(axisEndPoint-.5)<=epsilon){axisEndPoint=.5}}else if(axisEndPoint<0){if(Math.abs(axisEndPoint+.5)<=epsilon){axisEndPoint=-.5}}return axisEndPoint}function getLabels(props){var domains=props.domains,startingAngle=props.startingAngle,style=props.style;return domains.map(function(_ref,index){var name=_ref.name;var angle=index/domains.length*Math.PI*2+startingAngle;var radius=1.2;return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),label:name,style:style}})}function getPolygons(props){var animation=props.animation,colorRange=props.colorRange,domains=props.domains,data=props.data,style=props.style,startingAngle=props.startingAngle,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var scales=domains.reduce(function(acc,_ref2){var domain=_ref2.domain,name=_ref2.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref3,index){var name=_ref3.name,getValue=_ref3.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),name:row.name}});return _react2.default.createElement(_polygonSeries2.default,{animation:animation,className:predefinedClassName+"-polygon",key:rowIndex+"-polygon",data:mappedData,style:_extends({stroke:row.color||row.stroke||colorRange[rowIndex%colorRange.length],fill:row.color||row.fill||colorRange[rowIndex%colorRange.length]},style.polygons),onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut})})}function getPolygonPoints(props){var animation=props.animation,domains=props.domains,data=props.data,startingAngle=props.startingAngle,style=props.style,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut;if(!onValueMouseOver){return}var scales=domains.reduce(function(acc,_ref4){var domain=_ref4.domain,name=_ref4.name;acc[name]=(0,_d3Scale.scaleLinear)().domain(domain).range([0,1]);return acc},{});return data.map(function(row,rowIndex){var mappedData=domains.map(function(_ref5,index){var name=_ref5.name,getValue=_ref5.getValue;var dataPoint=getValue?getValue(row):row[name];var angle=index/domains.length*Math.PI*2+startingAngle;var radius=Math.max(scales[name](dataPoint),0);return{x:radius*Math.cos(angle),y:radius*Math.sin(angle),domain:name,value:dataPoint,dataName:row.name}});return _react2.default.createElement(_markSeries2.default,{animation:animation,className:predefinedClassName+"-polygonPoint",key:rowIndex+"-polygonPoint",data:mappedData,size:10,style:_extends({},style.polygons,{fill:"transparent",stroke:"transparent"}),onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut})})}function RadarChart(props){var animation=props.animation,className=props.className,children=props.children,colorRange=props.colorRange,data=props.data,domains=props.domains,height=props.height,hideInnerMostValues=props.hideInnerMostValues,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,startingAngle=props.startingAngle,style=props.style,tickFormat=props.tickFormat,width=props.width,renderAxesOverPolygons=props.renderAxesOverPolygons,onValueMouseOver=props.onValueMouseOver,onValueMouseOut=props.onValueMouseOut,onSeriesMouseOver=props.onSeriesMouseOver,onSeriesMouseOut=props.onSeriesMouseOut;var axes=getAxes({domains:domains,animation:animation,hideInnerMostValues:hideInnerMostValues,startingAngle:startingAngle,style:style,tickFormat:tickFormat});var polygons=getPolygons({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onSeriesMouseOver:onSeriesMouseOver,onSeriesMouseOut:onSeriesMouseOut});var polygonPoints=getPolygonPoints({animation:animation,colorRange:colorRange,domains:domains,data:data,startingAngle:startingAngle,style:style,onValueMouseOver:onValueMouseOver,onValueMouseOut:onValueMouseOut});var labelSeries=_react2.default.createElement(_labelSeries2.default,{animation:animation,key:className,className:predefinedClassName+"-label",data:getLabels({domains:domains,style:style.labels,startingAngle:startingAngle})});return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:margin,dontCheckIfEmpty:true,className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-1,1],yDomain:[-1,1]},children,!renderAxesOverPolygons&&axes.concat(polygons).concat(labelSeries).concat(polygonPoints),renderAxesOverPolygons&&polygons.concat(labelSeries).concat(axes).concat(polygonPoints))}RadarChart.displayName="RadarChart";RadarChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,colorRange:_propTypes2.default.arrayOf(_propTypes2.default.string),data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,domains:_propTypes2.default.arrayOf(_propTypes2.default.shape({name:_propTypes2.default.string.isRequired,domain:_propTypes2.default.arrayOf(_propTypes2.default.number).isRequired,tickFormat:_propTypes2.default.func})).isRequired,height:_propTypes2.default.number.isRequired,hideInnerMostValues:_propTypes2.default.bool,margin:_chartUtils.MarginPropType,startingAngle:_propTypes2.default.number,style:_propTypes2.default.shape({axes:_propTypes2.default.object,labels:_propTypes2.default.object,polygons:_propTypes2.default.object}),tickFormat:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,renderAxesOverPolygons:_propTypes2.default.bool,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,onSeriesMouseOver:_propTypes2.default.func,onSeriesMouseOut:_propTypes2.default.func};RadarChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,hideInnerMostValues:true,startingAngle:Math.PI/2,style:{axes:{line:{},ticks:{},text:{}},labels:{fontSize:10,textAnchor:"middle"},polygons:{strokeWidth:.5,strokeOpacity:1,fillOpacity:.1}},tickFormat:DEFAULT_FORMAT,renderAxesOverPolygons:false};exports.default=RadarChart},{"../animation":74,"../plot/axis/decorative-axis":88,"../plot/series/label-series":114,"../plot/series/mark-series":120,"../plot/series/polygon-series":121,"../plot/xy-plot":131,"../theme":137,"../utils/chart-utils":143,"d3-format":7,"d3-scale":14,"prop-types":33,react:73}],133:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i2&&arguments[2]!==undefined?arguments[2]:1.1;var getLabel=accessors.getLabel,getSubLabel=accessors.getSubLabel;return mappedData.reduce(function(res,row){var angle=row.angle,angle0=row.angle0,radius=row.radius;var centeredAngle=(angle+angle0)/2;var updatedAngle=-1*centeredAngle+Math.PI/2;var newLabels=[];if(getLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getLabel(row)})}if(getSubLabel(row)){newLabels.push({angle:updatedAngle,radius:radius*labelsRadiusMultiplier,label:getSubLabel(row),style:{fontSize:10},yOffset:12})}return res.concat(newLabels)},[])}function getMaxRadius(width,height){return Math.min(width,height)/2-DEFAULT_RADIUS_MARGIN}function RadialChart(props){var animation=props.animation,className=props.className,children=props.children,colorType=props.colorType,data=props.data,getAngle=props.getAngle,getLabel=props.getLabel,getSubLabel=props.getSubLabel,height=props.height,hideRootNode=props.hideRootNode,innerRadius=props.innerRadius,labelsAboveChildren=props.labelsAboveChildren,labelsRadiusMultiplier=props.labelsRadiusMultiplier,labelsStyle=props.labelsStyle,margin=props.margin,onMouseLeave=props.onMouseLeave,onMouseEnter=props.onMouseEnter,radius=props.radius,showLabels=props.showLabels,style=props.style,width=props.width;var mappedData=getWedgesToRender({data:data,height:height,hideRootNode:hideRootNode,width:width,getAngle:getAngle});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var arcProps=_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:mappedData,radiusNoFallBack:true,style:style,arcClassName:"rv-radial-chart__series--pie__slice"});if(radius){arcProps.radiusDomain=[0,1];arcProps.radiusRange=[innerRadius||0,radius];arcProps.radiusType="linear"}var maxRadius=radius?radius:getMaxRadius(width,height);var defaultMargin=(0,_chartUtils.getRadialLayoutMargin)(width,height,maxRadius);var labels=generateLabels(mappedData,{getLabel:getLabel,getSubLabel:getSubLabel},labelsRadiusMultiplier);return _react2.default.createElement(_xyPlot2.default,{height:height,width:width,margin:_extends({},margin,defaultMargin),className:className+" "+predefinedClassName,onMouseLeave:onMouseLeave,onMouseEnter:onMouseEnter,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({},arcProps,{getAngle:function getAngle(d){return d.angle}})),showLabels&&!labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}),children,showLabels&&labelsAboveChildren&&_react2.default.createElement(_labelSeries2.default,{data:labels,style:labelsStyle}))}RadialChart.displayName="RadialChart";RadialChart.propTypes={animation:_animation.AnimationPropType,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.arrayOf(_propTypes2.default.shape({angle:_propTypes2.default.number,className:_propTypes2.default.string,label:_propTypes2.default.string,radius:_propTypes2.default.number,style:_propTypes2.default.object})).isRequired,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number]),getRadius:_propTypes2.default.func,getRadius0:_propTypes2.default.func,getLabel:_propTypes2.default.func,height:_propTypes2.default.number.isRequired,labelsAboveChildren:_propTypes2.default.bool,labelsStyle:_propTypes2.default.object,margin:_chartUtils.MarginPropType,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,showLabels:_propTypes2.default.bool,style:_propTypes2.default.object,subLabel:_propTypes2.default.func,width:_propTypes2.default.number.isRequired};RadialChart.defaultProps={className:"",colorType:"category",colorRange:_theme.DISCRETE_COLOR_RANGE,padAngle:0,getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},getRadius:function getRadius(d){return d.radius},getRadius0:function getRadius0(d){return d.radius0},getLabel:function getLabel(d){return d.label},getSubLabel:function getSubLabel(d){return d.subLabel}};exports.default=RadialChart},{"../animation":74,"../plot/series/arc-series":101,"../plot/series/label-series":114,"../plot/xy-plot":131,"../theme":137,"../utils/chart-utils":143,"../utils/series-utils":147,"d3-shape":15,"prop-types":33,react:73}],134:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i90?"end":"start"},row.labelStyle),rotation:rotateLabels?rotAngle>90?rotAngle+180:rotAngle===90?90:rotAngle:null})})}var NOOP=function NOOP(){};function Sunburst(props){var getAngle=props.getAngle,getAngle0=props.getAngle0,animation=props.animation,className=props.className,children=props.children,data=props.data,height=props.height,hideRootNode=props.hideRootNode,getLabel=props.getLabel,width=props.width,getSize=props.getSize,colorType=props.colorType;var mappedData=getNodesToRender({data:data,height:height, -hideRootNode:hideRootNode,width:width,getSize:getSize});var radialDomain=(0,_seriesUtils.getRadialDomain)(mappedData);var margin=(0,_chartUtils.getRadialLayoutMargin)(width,height,radialDomain);var labelData=buildLabels(mappedData,{getAngle:getAngle,getAngle0:getAngle0,getLabel:getLabel,getRadius0:function getRadius0(d){return d.radius0}});var hofBuilder=function hofBuilder(f){return function(e,i){return f?f(mappedData[e.index],i):NOOP}};return _react2.default.createElement(_xyPlot2.default,{height:height,hasTreeStructure:true,width:width,className:predefinedClassName+" "+className,margin:margin,xDomain:[-radialDomain,radialDomain],yDomain:[-radialDomain,radialDomain]},_react2.default.createElement(_arcSeries2.default,_extends({colorType:colorType},props,{animation:animation,radiusDomain:[0,radialDomain],data:animation?mappedData.map(function(row,index){return _extends({},row,{parent:null,children:null,index:index})}):mappedData,_data:animation?mappedData:null,arcClassName:predefinedClassName+"__series--radial__arc"},LISTENERS_TO_OVERWRITE.reduce(function(acc,propName){var prop=props[propName];acc[propName]=animation?hofBuilder(prop):prop;return acc},{}))),labelData.length>0&&_react2.default.createElement(_labelSeries2.default,{data:labelData,getLabel:getLabel}),children)}Sunburst.displayName="Sunburst";Sunburst.propTypes={animation:_animation.AnimationPropType,getAngle:_propTypes2.default.func,getAngle0:_propTypes2.default.func,className:_propTypes2.default.string,colorType:_propTypes2.default.string,data:_propTypes2.default.object.isRequired,height:_propTypes2.default.number.isRequired,hideRootNode:_propTypes2.default.bool,getLabel:_propTypes2.default.func,onValueClick:_propTypes2.default.func,onValueMouseOver:_propTypes2.default.func,onValueMouseOut:_propTypes2.default.func,getSize:_propTypes2.default.func,width:_propTypes2.default.number.isRequired,padAngle:_propTypes2.default.oneOfType([_propTypes2.default.func,_propTypes2.default.number])};Sunburst.defaultProps={getAngle:function getAngle(d){return d.angle},getAngle0:function getAngle0(d){return d.angle0},className:"",colorType:"literal",getColor:function getColor(d){return d.color},hideRootNode:false,getLabel:function getLabel(d){return d.label},getSize:function getSize(d){return d.size},padAngle:0};exports.default=Sunburst},{"../animation":74,"../plot/series/arc-series":101,"../plot/series/label-series":114,"../plot/xy-plot":131,"../utils/chart-utils":143,"../utils/series-utils":147,"d3-hierarchy":10,"d3-scale":14,"prop-types":33,react:73}],137:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var DISCRETE_COLOR_RANGE=exports.DISCRETE_COLOR_RANGE=["#12939A","#79C7E3","#1A3177","#FF9833","#EF5D28"];var EXTENDED_DISCRETE_COLOR_RANGE=exports.EXTENDED_DISCRETE_COLOR_RANGE=["#19CDD7","#DDB27C","#88572C","#FF991F","#F15C17","#223F9A","#DA70BF","#125C77","#4DC19C","#776E57","#12939A","#17B8BE","#F6D18A","#B7885E","#FFCB99","#F89570","#829AE3","#E79FD5","#1E96BE","#89DAC1","#B3AD9E"];var CONTINUOUS_COLOR_RANGE=exports.CONTINUOUS_COLOR_RANGE=["#EF5D28","#FF9833"];var SIZE_RANGE=exports.SIZE_RANGE=[1,10];var OPACITY_RANGE=exports.OPACITY_RANGE=[.1,1];var OPACITY_TYPE=exports.OPACITY_TYPE="literal";var DEFAULT_OPACITY=exports.DEFAULT_OPACITY=1;var DEFAULT_SIZE=exports.DEFAULT_SIZE=5;var DEFAULT_COLOR=exports.DEFAULT_COLOR=DISCRETE_COLOR_RANGE[0];var DEFAULT_TICK_SIZE=exports.DEFAULT_TICK_SIZE=7},{}],138:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i300){return 10}return 5}return 20}function getTickValues(scale,tickTotal,tickValues){return!tickValues?scale.ticks?scale.ticks(tickTotal):scale.domain():tickValues}function generateFit(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return{left:axisStart.y,right:axisEnd.y,slope:0,offset:axisStart.x}}var slope=(axisStart.y-axisEnd.y)/(axisStart.x-axisEnd.x);return{left:axisStart.x,right:axisEnd.x,slope:slope,offset:axisStart.y-slope*axisStart.x}}function generatePoints(_ref){var axisStart=_ref.axisStart,axisEnd=_ref.axisEnd,numberOfTicks=_ref.numberOfTicks,axisDomain=_ref.axisDomain;var _generateFit=generateFit(axisStart,axisEnd),left=_generateFit.left,right=_generateFit.right,slope=_generateFit.slope,offset=_generateFit.offset;var pointSlope=(right-left)/numberOfTicks;var axisScale=(0,_d3Scale.scaleLinear)().domain([left,right]).range(axisDomain);var slopeVertical=axisStart.x===axisEnd.x;return{slope:slopeVertical?Infinity:slope,points:(0,_d3Array.range)(left,right+pointSlope,pointSlope).map(function(val){if(slopeVertical){return{y:val,x:slope*val+offset,text:axisScale(val)}}return{x:val,y:slope*val+offset,text:axisScale(val)}}).slice(0,numberOfTicks+1)}}function getAxisAngle(axisStart,axisEnd){if(axisStart.x===axisEnd.x){return axisEnd.y>axisStart.y?Math.PI/2:3*Math.PI/2}return Math.atan((axisEnd.y-axisStart.y)/(axisEnd.x-axisStart.x))}exports.default={DIRECTION:DIRECTION,ORIENTATION:ORIENTATION,getTicksTotalFromSize:getTicksTotalFromSize,getTickValues:getTickValues}},{"d3-array":3,"d3-scale":14}],143:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_MARGINS=exports.MarginPropType=undefined;var _extends=Object.assign||function(target){for(var i=1;ivalue){result[0]=value}if(result[result.length-1]13||Number(major)>13;var isReactDOMSupported=exports.isReactDOMSupported=function isReactDOMSupported(){return versionHigherThanThirteen};var getDOMNode=exports.getDOMNode=function getDOMNode(ref){if(!isReactDOMSupported()){return ref&&ref.getDOMNode()}return ref};var USED_MESSAGES={};var HIDDEN_PROCESSES={test:true,production:true};function warning(message){var onlyShowMessageOnce=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(global.process&&HIDDEN_PROCESSES[process.env.NODE_ENV]){return}if(!onlyShowMessageOnce||!USED_MESSAGES[message]){console.warn(message);USED_MESSAGES[message]=true}}function warnOnce(message){warning(message,true)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:1,react:73}],146:[function(require,module,exports){"use strict";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[Symbol.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(Symbol.iterator in Object(arr)){return sliceIterator(arr,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();var _extends=Object.assign||function(target){for(var i=1;istop-scale.padding()*scale.step())domainIndex=n-1;else domainIndex=Math.floor((value-start-scale.padding()*scale.step())/scale.step());return scale.domain()[domainIndex]}}function getScaleFnFromScaleObject(scaleObject){if(!scaleObject){return null}var type=scaleObject.type,domain=scaleObject.domain,range=scaleObject.range;var modDomain=domain[0]===domain[1]?domain[0]===0?[-1,0]:[-domain[0],domain[0]]:domain;if(type===LITERAL_SCALE_TYPE){return literalScale(range[0])}var scale=SCALE_FUNCTIONS[type]().domain(modDomain).range(range);if(type===ORDINAL_SCALE_TYPE){scale.padding(.5);addInvertFunctionToOrdinalScaleObject(scale)}return scale}function getDomainByAccessor(allData,accessor,accessor0,type){var domain=void 0;var values=allData.reduce(function(data,d){var value=accessor(d);var value0=accessor0(d);if(_isDefined(value)){data.push(value)}if(_isDefined(value0)){data.push(value0)}return data},[]);if(!values.length){return[]}if(type!==ORDINAL_SCALE_TYPE&&type!==CATEGORY_SCALE_TYPE){domain=(0,_d3Array.extent)(values)}else{domain=(0,_d3Collection.set)(values).values()}return domain}function _createScaleObjectForValue(attr,value,type,accessor,accessor0){if(type===LITERAL_SCALE_TYPE){return{type:LITERAL_SCALE_TYPE,domain:[],range:[value],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}if(typeof value==="undefined"){return null}return{type:CATEGORY_SCALE_TYPE,range:[value],domain:[],distance:0,attr:attr,baseValue:undefined,isValue:true,accessor:accessor,accessor0:accessor0}}function _createScaleObjectForFunction(_ref){var domain=_ref.domain,range=_ref.range,type=_ref.type,distance=_ref.distance,attr=_ref.attr,baseValue=_ref.baseValue,accessor=_ref.accessor,accessor0=_ref.accessor0;return{domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,isValue:false,accessor:accessor,accessor0:accessor0}}function _collectScaleObjectFromProps(props,attr){var value=props[attr],fallbackValue=props["_"+attr+"Value"],range=props[attr+"Range"],_props$=props[attr+"Distance"],distance=_props$===undefined?0:_props$,baseValue=props[attr+"BaseValue"],_props$2=props[attr+"Type"],type=_props$2===undefined?LINEAR_SCALE_TYPE:_props$2,noFallBack=props[attr+"NoFallBack"],_props$3=props["get"+toTitleCase(attr)],accessor=_props$3===undefined?function(d){return d[attr]}:_props$3,_props$4=props["get"+toTitleCase(attr)+"0"],accessor0=_props$4===undefined?function(d){return d[attr+"0"]}:_props$4;var domain=props[attr+"Domain"];if(!noFallBack&&typeof value!=="undefined"){return _createScaleObjectForValue(attr,value,props[attr+"Type"],accessor,accessor0)}if(typeof baseValue!=="undefined"){domain=(0,_dataUtils.addValueToArray)(domain,baseValue)}if(!range||!domain||!domain.length){return _createScaleObjectForValue(attr,fallbackValue,props[attr+"Type"],accessor,accessor0)}return _createScaleObjectForFunction({domain:domain,range:range,type:type,distance:distance,attr:attr,baseValue:baseValue,accessor:accessor,accessor0:accessor0})}function _computeLeftDomainAdjustment(values){if(values.length>1){return(values[1]-values[0])/2}if(values.length===1){return values[0]-.5}return 0}function _computeRightDomainAdjustment(values){if(values.length>1){return(values[values.length-1]-values[values.length-2])/2}if(values.length===1){return values[0]-.5}return 0}function _computeScaleDistance(values,domain,bestDistIndex,scaleFn){if(values.length>1){var i=Math.max(bestDistIndex,1);return Math.abs(scaleFn(values[i])-scaleFn(values[i-1]))}if(values.length===1){return Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}return 0}function _normalizeValues(data,values,accessor0,type){if(type===TIME_SCALE_TYPE&&values.length===1){var attr0=accessor0(data[0]);return[attr0].concat(_toConsumableArray(values))}return values}function _getScaleDistanceAndAdjustedDomain(data,scaleObject){var domain=scaleObject.domain,type=scaleObject.type,accessor=scaleObject.accessor,accessor0=scaleObject.accessor0;var uniqueValues=(0,_dataUtils.getUniquePropertyValues)(data,accessor);var values=_normalizeValues(data,uniqueValues,accessor0,type);var index=_getSmallestDistanceIndex(values,scaleObject);var adjustedDomain=[].concat(domain);adjustedDomain[0]-=_computeLeftDomainAdjustment(values);adjustedDomain[domain.length-1]+=_computeRightDomainAdjustment(values);if(type===LOG_SCALE_TYPE&&domain[0]<=0){adjustedDomain[0]=Math.min(domain[1]/10,1)}var adjustedScaleFn=getScaleFnFromScaleObject(_extends({},scaleObject,{domain:adjustedDomain}));var distance=_computeScaleDistance(values,adjustedDomain,index,adjustedScaleFn);return{domain0:adjustedDomain[0],domainN:adjustedDomain[adjustedDomain.length-1],distance:distance}}function _isScaleAdjustmentPossible(props,scaleObject){var attr=scaleObject.attr;var _props$_adjustBy=props._adjustBy,adjustBy=_props$_adjustBy===undefined?[]:_props$_adjustBy,_props$_adjustWhat=props._adjustWhat,adjustWhat=_props$_adjustWhat===undefined?[]:_props$_adjustWhat;return adjustWhat.length&&adjustBy.length&&adjustBy.indexOf(attr)!==-1}function _adjustContinuousScale(props,scaleObject){var allSeriesData=props._allData,_props$_adjustWhat2=props._adjustWhat,adjustWhat=_props$_adjustWhat2===undefined?[]:_props$_adjustWhat2;var domainLength=scaleObject.domain.length;var domain=scaleObject.domain;var scaleDomain0=domain[0];var scaleDomainN=domain[domainLength-1];var scaleDistance=scaleObject.distance;allSeriesData.forEach(function(data,index){if(adjustWhat.indexOf(index)===-1){return}if(data&&data.length){var _getScaleDistanceAndA=_getScaleDistanceAndAdjustedDomain(data,scaleObject),domain0=_getScaleDistanceAndA.domain0,domainN=_getScaleDistanceAndA.domainN,distance=_getScaleDistanceAndA.distance;scaleDomain0=Math.min(scaleDomain0,domain0);scaleDomainN=Math.max(scaleDomainN,domainN);scaleDistance=Math.max(scaleDistance,distance)}});scaleObject.domain=[scaleDomain0].concat(_toConsumableArray(domain.slice(1,-1)),[scaleDomainN]);scaleObject.distance=scaleDistance;return scaleObject}function _adjustCategoricalScale(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);var domain=scaleObject.domain,range=scaleObject.range;if(domain.length>1){scaleObject.distance=Math.abs(scaleFn(domain[1])-scaleFn(domain[0]))}else{scaleObject.distance=Math.abs(range[1]-range[0])}return scaleObject}function getScaleObjectFromProps(props,attr){var scaleObject=_collectScaleObjectFromProps(props,attr);if(!scaleObject){return null}if(!_isScaleAdjustmentPossible(props,scaleObject)){return scaleObject}var type=scaleObject.type;if(type===ORDINAL_SCALE_TYPE||type===CATEGORY_SCALE_TYPE){return _adjustCategoricalScale(scaleObject)}return _adjustContinuousScale(props,scaleObject)}function getAttributeScale(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);return getScaleFnFromScaleObject(scaleObject)}function _getAttrValue(d,accessor){return accessor(d.data?d.data:d)}function _isDefined(value){return typeof value!=="undefined"}function _padDomain(domain,padding){if(!domain){return domain}if(isNaN(parseFloat(domain[0]))||isNaN(parseFloat(domain[1]))){return domain}var _domain=_slicedToArray(domain,2),min=_domain[0],max=_domain[1];var domainPadding=(max-min)*(padding*.01);return[min-domainPadding,max+domainPadding]}function getAttributeFunctor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){return scaleFn(_getAttrValue(d,scaleObject.accessor))}}return null}function getAttr0Functor(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){var domain=scaleObject.domain;var _scaleObject$baseValu=scaleObject.baseValue,baseValue=_scaleObject$baseValu===undefined?domain[0]:_scaleObject$baseValu;var scaleFn=getScaleFnFromScaleObject(scaleObject);return function(d){var value=_getAttrValue(d,scaleObject.accessor0);return scaleFn(_isDefined(value)?value:baseValue)}}return null}function getAttributeValue(props,attr){var scaleObject=getScaleObjectFromProps(props,attr);if(scaleObject){if(!scaleObject.isValue&&props["_"+attr+"Value"]===undefined){(0,_reactUtils.warning)("[React-vis] Cannot use data defined "+attr+" for this "+"series type. Using fallback value instead.")}return props["_"+attr+"Value"]||scaleObject.range[0]}return null}function getScalePropTypesByAttribute(attr){var _ref2;return _ref2={},_defineProperty(_ref2,"_"+attr+"Value",_propTypes2.default.any),_defineProperty(_ref2,attr+"Domain",_propTypes2.default.array),_defineProperty(_ref2,"get"+toTitleCase(attr),_propTypes2.default.func),_defineProperty(_ref2,"get"+toTitleCase(attr)+"0",_propTypes2.default.func),_defineProperty(_ref2,attr+"Range",_propTypes2.default.array),_defineProperty(_ref2,attr+"Type",_propTypes2.default.oneOf(Object.keys(SCALE_FUNCTIONS))),_defineProperty(_ref2,attr+"Distance",_propTypes2.default.number),_defineProperty(_ref2,attr+"BaseValue",_propTypes2.default.any),_ref2}function extractScalePropsFromProps(props,attributes){var result={};Object.keys(props).forEach(function(key){var attr=attributes.find(function(a){var isPlainSet=key.indexOf(a)===0;var isUnderscoreSet=key.indexOf("_"+a)===0;var usesGet=key.indexOf("get"+toTitleCase(a))===0;return isPlainSet||isUnderscoreSet||usesGet});if(!attr){return}result[key]=props[key]});return result}function getMissingScaleProps(props,data,attributes){var result={};attributes.forEach(function(attr){if(!props["get"+toTitleCase(attr)]){result["get"+toTitleCase(attr)]=function(d){return d[attr]}}if(!props["get"+toTitleCase(attr)+"0"]){result["get"+toTitleCase(attr)+"0"]=function(d){return d[attr+"0"]}}if(!props[attr+"Domain"]){result[attr+"Domain"]=getDomainByAccessor(data,props["get"+toTitleCase(attr)]||result["get"+toTitleCase(attr)],props["get"+toTitleCase(attr)+"0"]||result["get"+toTitleCase(attr)+"0"],props[attr+"Type"]);if(props[attr+"Padding"]){result[attr+"Domain"]=_padDomain(result[attr+"Domain"],props[attr+"Padding"])}}});return result}function literalScale(defaultValue){function scale(d){if(d===undefined){return defaultValue}return d}function response(){return scale}scale.domain=response;scale.range=response;scale.unknown=response;scale.copy=response;return scale}function getFontColorFromBackground(background){if(background){return(0,_d3Color.hsl)(background).l>.57?"#222":"#fff"}return null}function getXYPlotValues(props,children){var XYPlotScales=XYPLOT_ATTR.reduce(function(prev,attr){var domain=props[attr+"Domain"],range=props[attr+"Range"],type=props[attr+"Type"];if(domain&&range&&type){return _extends({},prev,_defineProperty({},attr,SCALE_FUNCTIONS[type]().domain(domain).range(range)))}return prev},{});return children.map(function(child){return XYPLOT_ATTR.reduce(function(prev,attr){if(child.props&&child.props[attr]!==undefined){var scaleInput=child.props[attr];var scale=XYPlotScales[attr];var fallbackValue=scale?scale(scaleInput):scaleInput;return _extends({},prev,_defineProperty({},"_"+attr+"Value",fallbackValue))}return prev},{})})}var OPTIONAL_SCALE_PROPS=["Padding"];var OPTIONAL_SCALE_PROPS_REGS=OPTIONAL_SCALE_PROPS.map(function(str){return new RegExp(str+"$","i")});function getOptionalScaleProps(props){return Object.keys(props).reduce(function(acc,prop){var propIsNotOptional=OPTIONAL_SCALE_PROPS_REGS.every(function(reg){return!prop.match(reg)});if(propIsNotOptional){return acc}acc[prop]=props[prop];return acc},{})}exports.default={extractScalePropsFromProps:extractScalePropsFromProps,getAttributeScale:getAttributeScale,getAttributeFunctor:getAttributeFunctor,getAttr0Functor:getAttr0Functor,getAttributeValue:getAttributeValue,getDomainByAccessor:getDomainByAccessor,getFontColorFromBackground:getFontColorFromBackground,getMissingScaleProps:getMissingScaleProps,getOptionalScaleProps:getOptionalScaleProps,getScaleObjectFromProps:getScaleObjectFromProps,getScalePropTypesByAttribute:getScalePropTypesByAttribute,getXYPlotValues:getXYPlotValues,literalScale:literalScale}},{"./data-utils":144,"./react-utils":145,"d3-array":3,"d3-collection":4,"d3-color":5,"d3-scale":14,"prop-types":33}],147:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ANIMATED_SERIES_PROPS=undefined;var _extends=Object.assign||function(target){for(var i=1;i0&&arguments[0]!==undefined?arguments[0]:[];if(!data){return false}return data.some(function(row){return row.radius&&row.angle})}function prepareData(data){if(!seriesHasAngleRadius(data)){return data}return data.map(function(row){return _extends({},row,{x:row.radius*Math.cos(row.angle),y:row.radius*Math.sin(row.angle)})})}function getStackedData(children,attr){var areSomeSeriesStacked=children.some(function(series){return series&&series.props.stack});var latestAttrPositions={};return children.reduce(function(accumulator,series,seriesIndex){if(!series){accumulator.push(null);return accumulator}var _series$props=series.props,data=_series$props.data,_series$props$cluster=_series$props.cluster,cluster=_series$props$cluster===undefined?"default":_series$props$cluster,stack=_series$props.stack;var preppedData=prepareData(data,attr);if(!attr||!preppedData||!preppedData.length||areSomeSeriesStacked&&!stack){accumulator.push(preppedData);return accumulator}var attr0=attr+"0";var baseAttr=attr==="y"?"x":"y";accumulator.push(preppedData.map(function(d,dIndex){var _extends2,_latestAttrPositions$2;if(!latestAttrPositions[cluster]){latestAttrPositions[cluster]={}}var prevD=latestAttrPositions[cluster][d[baseAttr]];if(!prevD){var _latestAttrPositions$;latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$={},_defineProperty(_latestAttrPositions$,attr0,d[attr0]),_defineProperty(_latestAttrPositions$,attr,d[attr]),_latestAttrPositions$);return _extends({},d)}var nextD=_extends({},d,(_extends2={},_defineProperty(_extends2,attr0,prevD[attr]),_defineProperty(_extends2,attr,prevD[attr]+d[attr]-(d[attr0]||0)),_extends2));latestAttrPositions[cluster][d[baseAttr]]=(_latestAttrPositions$2={},_defineProperty(_latestAttrPositions$2,attr0,nextD[attr0]),_defineProperty(_latestAttrPositions$2,attr,nextD[attr]),_latestAttrPositions$2);return nextD}));return accumulator},[])}function getSeriesPropsFromChildren(children){var result=[];var seriesTypesInfo=collectSeriesTypesInfo(children);var seriesIndex=0;var _opacityValue=_theme.DEFAULT_OPACITY;children.forEach(function(child){var props=void 0;if(isSeriesChild(child)){var seriesTypeInfo=seriesTypesInfo[child.type.displayName];var _colorValue=_theme.DISCRETE_COLOR_RANGE[seriesIndex%_theme.DISCRETE_COLOR_RANGE.length];props=_extends({},seriesTypeInfo,{seriesIndex:seriesIndex,_colorValue:_colorValue,_opacityValue:_opacityValue});seriesTypeInfo.sameTypeIndex++;seriesIndex++;if(child.props.cluster){props.cluster=child.props.cluster;props.clusters=Array.from(seriesTypeInfo.clusters);props.sameTypeTotal=props.clusters.length;props.sameTypeIndex=props.clusters.indexOf(child.props.cluster)}}result.push(props)});return result}function getRadialDomain(data){return data.reduce(function(res,row){return Math.max(row.radius,res)},0)}var ANIMATED_SERIES_PROPS=exports.ANIMATED_SERIES_PROPS=["xRange","xDomain","x","yRange","yDomain","y","colorRange","colorDomain","color","opacityRange","opacityDomain","opacity","strokeRange","strokeDomain","stroke","fillRange","fillDomain","fill","width","height","marginLeft","marginTop","marginRight","marginBottom","data","angleDomain","angleRange","angle","radiusDomain","radiusRange","radius","innerRadiusDomain","innerRadiusRange","innerRadius"];function getStackParams(props){var _stackBy=props._stackBy,valuePosAttr=props.valuePosAttr,cluster=props.cluster;var _props$sameTypeTotal=props.sameTypeTotal,sameTypeTotal=_props$sameTypeTotal===undefined?1:_props$sameTypeTotal,_props$sameTypeIndex=props.sameTypeIndex,sameTypeIndex=_props$sameTypeIndex===undefined?0:_props$sameTypeIndex;if(_stackBy===valuePosAttr&&!cluster){sameTypeTotal=1;sameTypeIndex=0}return{sameTypeTotal:sameTypeTotal,sameTypeIndex:sameTypeIndex}}},{"../plot/series/abstract-series":100,"../theme":137,react:73}]},{},[75])(75)}); diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e5b37734c..000000000 --- a/dist/index.js +++ /dev/null @@ -1,340 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ScaleUtils = exports.AxisUtils = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = exports.FlexibleXYPlot = exports.makeWidthFlexible = exports.makeVisFlexible = exports.makeHeightFlexible = exports.Sunburst = exports.Sankey = exports.ParallelCoordinates = exports.RadarChart = exports.RadialChart = exports.Treemap = exports.ContinuousSizeLegend = exports.ContinuousColorLegend = exports.SearchableDiscreteColorLegend = exports.DiscreteColorLegend = exports.Highlight = exports.Voronoi = exports.HorizontalGridLines = exports.VerticalGridLines = exports.GradientDefs = exports.GridLines = exports.ChartLabel = exports.CircularGridLines = exports.YAxis = exports.XAxis = exports.DecorativeAxis = exports.XYPlot = exports.Crosshair = exports.Borders = exports.Hint = exports.LineMarkSeriesCanvas = exports.LineMarkSeries = exports.ArcSeries = exports.AreaSeries = exports.CustomSVGSeries = exports.ContourSeries = exports.HexbinSeries = exports.HeatmapSeries = exports.WhiskerSeries = exports.MarkSeriesCanvas = exports.MarkSeries = exports.RectSeriesCanvas = exports.RectSeries = exports.PolygonSeries = exports.LabelSeries = exports.HorizontalRectSeriesCanvas = exports.HorizontalRectSeries = exports.VerticalRectSeriesCanvas = exports.VerticalRectSeries = exports.VerticalBarSeriesCanvas = exports.VerticalBarSeries = exports.HorizontalBarSeriesCanvas = exports.HorizontalBarSeries = exports.LineSeriesCanvas = exports.LineSeries = exports.AbstractSeries = undefined; - -var _makeVisFlexible = require('./make-vis-flexible'); - -Object.defineProperty(exports, 'makeHeightFlexible', { - enumerable: true, - get: function get() { - return _makeVisFlexible.makeHeightFlexible; - } -}); -Object.defineProperty(exports, 'makeVisFlexible', { - enumerable: true, - get: function get() { - return _makeVisFlexible.makeVisFlexible; - } -}); -Object.defineProperty(exports, 'makeWidthFlexible', { - enumerable: true, - get: function get() { - return _makeVisFlexible.makeWidthFlexible; - } -}); -Object.defineProperty(exports, 'FlexibleXYPlot', { - enumerable: true, - get: function get() { - return _makeVisFlexible.FlexibleXYPlot; - } -}); -Object.defineProperty(exports, 'FlexibleWidthXYPlot', { - enumerable: true, - get: function get() { - return _makeVisFlexible.FlexibleWidthXYPlot; - } -}); -Object.defineProperty(exports, 'FlexibleHeightXYPlot', { - enumerable: true, - get: function get() { - return _makeVisFlexible.FlexibleHeightXYPlot; - } -}); - -var _abstractSeries = require('./plot/series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _lineSeries = require('./plot/series/line-series'); - -var _lineSeries2 = _interopRequireDefault(_lineSeries); - -var _lineSeriesCanvas = require('./plot/series/line-series-canvas'); - -var _lineSeriesCanvas2 = _interopRequireDefault(_lineSeriesCanvas); - -var _horizontalBarSeries = require('./plot/series/horizontal-bar-series'); - -var _horizontalBarSeries2 = _interopRequireDefault(_horizontalBarSeries); - -var _horizontalBarSeriesCanvas = require('./plot/series/horizontal-bar-series-canvas'); - -var _horizontalBarSeriesCanvas2 = _interopRequireDefault(_horizontalBarSeriesCanvas); - -var _verticalBarSeries = require('./plot/series/vertical-bar-series'); - -var _verticalBarSeries2 = _interopRequireDefault(_verticalBarSeries); - -var _verticalBarSeriesCanvas = require('./plot/series/vertical-bar-series-canvas'); - -var _verticalBarSeriesCanvas2 = _interopRequireDefault(_verticalBarSeriesCanvas); - -var _verticalRectSeries = require('./plot/series/vertical-rect-series'); - -var _verticalRectSeries2 = _interopRequireDefault(_verticalRectSeries); - -var _verticalRectSeriesCanvas = require('./plot/series/vertical-rect-series-canvas'); - -var _verticalRectSeriesCanvas2 = _interopRequireDefault(_verticalRectSeriesCanvas); - -var _horizontalRectSeries = require('./plot/series/horizontal-rect-series'); - -var _horizontalRectSeries2 = _interopRequireDefault(_horizontalRectSeries); - -var _horizontalRectSeriesCanvas = require('./plot/series/horizontal-rect-series-canvas'); - -var _horizontalRectSeriesCanvas2 = _interopRequireDefault(_horizontalRectSeriesCanvas); - -var _labelSeries = require('./plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _polygonSeries = require('./plot/series/polygon-series'); - -var _polygonSeries2 = _interopRequireDefault(_polygonSeries); - -var _rectSeries = require('./plot/series/rect-series'); - -var _rectSeries2 = _interopRequireDefault(_rectSeries); - -var _rectSeriesCanvas = require('./plot/series/rect-series-canvas'); - -var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); - -var _markSeries = require('./plot/series/mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -var _markSeriesCanvas = require('./plot/series/mark-series-canvas'); - -var _markSeriesCanvas2 = _interopRequireDefault(_markSeriesCanvas); - -var _whiskerSeries = require('./plot/series/whisker-series'); - -var _whiskerSeries2 = _interopRequireDefault(_whiskerSeries); - -var _heatmapSeries = require('./plot/series/heatmap-series'); - -var _heatmapSeries2 = _interopRequireDefault(_heatmapSeries); - -var _hexbinSeries = require('./plot/series/hexbin-series'); - -var _hexbinSeries2 = _interopRequireDefault(_hexbinSeries); - -var _contourSeries = require('./plot/series/contour-series'); - -var _contourSeries2 = _interopRequireDefault(_contourSeries); - -var _customSvgSeries = require('./plot/series/custom-svg-series'); - -var _customSvgSeries2 = _interopRequireDefault(_customSvgSeries); - -var _areaSeries = require('./plot/series/area-series'); - -var _areaSeries2 = _interopRequireDefault(_areaSeries); - -var _arcSeries = require('./plot/series/arc-series'); - -var _arcSeries2 = _interopRequireDefault(_arcSeries); - -var _lineMarkSeries = require('./plot/series/line-mark-series'); - -var _lineMarkSeries2 = _interopRequireDefault(_lineMarkSeries); - -var _lineMarkSeriesCanvas = require('./plot/series/line-mark-series-canvas'); - -var _lineMarkSeriesCanvas2 = _interopRequireDefault(_lineMarkSeriesCanvas); - -var _hint = require('./plot/hint'); - -var _hint2 = _interopRequireDefault(_hint); - -var _borders = require('./plot/borders'); - -var _borders2 = _interopRequireDefault(_borders); - -var _crosshair = require('./plot/crosshair'); - -var _crosshair2 = _interopRequireDefault(_crosshair); - -var _xyPlot = require('./plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _decorativeAxis = require('./plot/axis/decorative-axis'); - -var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); - -var _xAxis = require('./plot/axis/x-axis'); - -var _xAxis2 = _interopRequireDefault(_xAxis); - -var _yAxis = require('./plot/axis/y-axis'); - -var _yAxis2 = _interopRequireDefault(_yAxis); - -var _circularGridLines = require('./plot/circular-grid-lines'); - -var _circularGridLines2 = _interopRequireDefault(_circularGridLines); - -var _chartLabel = require('./plot/chart-label'); - -var _chartLabel2 = _interopRequireDefault(_chartLabel); - -var _gridLines = require('./plot/grid-lines'); - -var _gridLines2 = _interopRequireDefault(_gridLines); - -var _gradientDefs = require('./plot/gradient-defs'); - -var _gradientDefs2 = _interopRequireDefault(_gradientDefs); - -var _verticalGridLines = require('./plot/vertical-grid-lines'); - -var _verticalGridLines2 = _interopRequireDefault(_verticalGridLines); - -var _horizontalGridLines = require('./plot/horizontal-grid-lines'); - -var _horizontalGridLines2 = _interopRequireDefault(_horizontalGridLines); - -var _voronoi = require('./plot/voronoi'); - -var _voronoi2 = _interopRequireDefault(_voronoi); - -var _highlight = require('./plot/highlight'); - -var _highlight2 = _interopRequireDefault(_highlight); - -var _discreteColorLegend = require('./legends/discrete-color-legend'); - -var _discreteColorLegend2 = _interopRequireDefault(_discreteColorLegend); - -var _searchableDiscreteColorLegend = require('./legends/searchable-discrete-color-legend'); - -var _searchableDiscreteColorLegend2 = _interopRequireDefault(_searchableDiscreteColorLegend); - -var _continuousColorLegend = require('./legends/continuous-color-legend'); - -var _continuousColorLegend2 = _interopRequireDefault(_continuousColorLegend); - -var _continuousSizeLegend = require('./legends/continuous-size-legend'); - -var _continuousSizeLegend2 = _interopRequireDefault(_continuousSizeLegend); - -var _treemap = require('./treemap'); - -var _treemap2 = _interopRequireDefault(_treemap); - -var _radialChart = require('./radial-chart'); - -var _radialChart2 = _interopRequireDefault(_radialChart); - -var _radarChart = require('./radar-chart'); - -var _radarChart2 = _interopRequireDefault(_radarChart); - -var _parallelCoordinates = require('./parallel-coordinates'); - -var _parallelCoordinates2 = _interopRequireDefault(_parallelCoordinates); - -var _sankey = require('./sankey'); - -var _sankey2 = _interopRequireDefault(_sankey); - -var _sunburst = require('./sunburst'); - -var _sunburst2 = _interopRequireDefault(_sunburst); - -var _axisUtils = require('./utils/axis-utils'); - -var _axisUtils2 = _interopRequireDefault(_axisUtils); - -var _scalesUtils = require('./utils/scales-utils'); - -var _scalesUtils2 = _interopRequireDefault(_scalesUtils); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.AbstractSeries = _abstractSeries2.default; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// TODO alphabetize - -exports.LineSeries = _lineSeries2.default; -exports.LineSeriesCanvas = _lineSeriesCanvas2.default; -exports.HorizontalBarSeries = _horizontalBarSeries2.default; -exports.HorizontalBarSeriesCanvas = _horizontalBarSeriesCanvas2.default; -exports.VerticalBarSeries = _verticalBarSeries2.default; -exports.VerticalBarSeriesCanvas = _verticalBarSeriesCanvas2.default; -exports.VerticalRectSeries = _verticalRectSeries2.default; -exports.VerticalRectSeriesCanvas = _verticalRectSeriesCanvas2.default; -exports.HorizontalRectSeries = _horizontalRectSeries2.default; -exports.HorizontalRectSeriesCanvas = _horizontalRectSeriesCanvas2.default; -exports.LabelSeries = _labelSeries2.default; -exports.PolygonSeries = _polygonSeries2.default; -exports.RectSeries = _rectSeries2.default; -exports.RectSeriesCanvas = _rectSeriesCanvas2.default; -exports.MarkSeries = _markSeries2.default; -exports.MarkSeriesCanvas = _markSeriesCanvas2.default; -exports.WhiskerSeries = _whiskerSeries2.default; -exports.HeatmapSeries = _heatmapSeries2.default; -exports.HexbinSeries = _hexbinSeries2.default; -exports.ContourSeries = _contourSeries2.default; -exports.CustomSVGSeries = _customSvgSeries2.default; -exports.AreaSeries = _areaSeries2.default; -exports.ArcSeries = _arcSeries2.default; -exports.LineMarkSeries = _lineMarkSeries2.default; -exports.LineMarkSeriesCanvas = _lineMarkSeriesCanvas2.default; -exports.Hint = _hint2.default; -exports.Borders = _borders2.default; -exports.Crosshair = _crosshair2.default; -exports.XYPlot = _xyPlot2.default; -exports.DecorativeAxis = _decorativeAxis2.default; -exports.XAxis = _xAxis2.default; -exports.YAxis = _yAxis2.default; -exports.CircularGridLines = _circularGridLines2.default; -exports.ChartLabel = _chartLabel2.default; -exports.GridLines = _gridLines2.default; -exports.GradientDefs = _gradientDefs2.default; -exports.VerticalGridLines = _verticalGridLines2.default; -exports.HorizontalGridLines = _horizontalGridLines2.default; -exports.Voronoi = _voronoi2.default; -exports.Highlight = _highlight2.default; - -// TODO alphabetize - -exports.DiscreteColorLegend = _discreteColorLegend2.default; -exports.SearchableDiscreteColorLegend = _searchableDiscreteColorLegend2.default; -exports.ContinuousColorLegend = _continuousColorLegend2.default; -exports.ContinuousSizeLegend = _continuousSizeLegend2.default; - -// TODO alphabetize - -exports.Treemap = _treemap2.default; -exports.RadialChart = _radialChart2.default; -exports.RadarChart = _radarChart2.default; -exports.ParallelCoordinates = _parallelCoordinates2.default; -exports.Sankey = _sankey2.default; -exports.Sunburst = _sunburst2.default; -exports.AxisUtils = _axisUtils2.default; -exports.ScaleUtils = _scalesUtils2.default; \ No newline at end of file diff --git a/dist/legends/continuous-color-legend.js b/dist/legends/continuous-color-legend.js deleted file mode 100644 index 8784a3dcc..000000000 --- a/dist/legends/continuous-color-legend.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _theme = require('../theme'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var propTypes = { - className: _propTypes2.default.string, - height: _propTypes2.default.number, - endColor: _propTypes2.default.string, - endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - midColor: _propTypes2.default.string, - midTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - startColor: _propTypes2.default.string, - startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - width: _propTypes2.default.number -}; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var defaultProps = { - className: '', - startColor: _theme.CONTINUOUS_COLOR_RANGE[0], - endColor: _theme.CONTINUOUS_COLOR_RANGE[1] -}; - -function ContinuousColorLegend(_ref) { - var startColor = _ref.startColor, - midColor = _ref.midColor, - endColor = _ref.endColor, - startTitle = _ref.startTitle, - midTitle = _ref.midTitle, - endTitle = _ref.endTitle, - height = _ref.height, - width = _ref.width, - className = _ref.className; - - var colors = [startColor]; - if (midColor) { - colors.push(midColor); - } - colors.push(endColor); - return _react2.default.createElement( - 'div', - { - className: 'rv-continuous-color-legend ' + className, - style: { width: width, height: height } - }, - _react2.default.createElement('div', { - className: 'rv-gradient', - style: { background: 'linear-gradient(to right, ' + colors.join(',') + ')' } - }), - _react2.default.createElement( - 'div', - { className: 'rv-legend-titles' }, - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__left' }, - startTitle - ), - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__right' }, - endTitle - ), - midTitle ? _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__center' }, - midTitle - ) : null - ) - ); -} - -ContinuousColorLegend.displayName = 'ContinuousColorLegend'; -ContinuousColorLegend.propTypes = propTypes; -ContinuousColorLegend.defaultProps = defaultProps; - -exports.default = ContinuousColorLegend; \ No newline at end of file diff --git a/dist/legends/continuous-size-legend.js b/dist/legends/continuous-size-legend.js deleted file mode 100644 index 91f072d5e..000000000 --- a/dist/legends/continuous-size-legend.js +++ /dev/null @@ -1,116 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var propTypes = { - className: _propTypes2.default.string, - circlesTotal: _propTypes2.default.number, - endSize: _propTypes2.default.number, - endTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - height: _propTypes2.default.number, - startSize: _propTypes2.default.number, - startTitle: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]).isRequired, - width: _propTypes2.default.number -}; - -var defaultProps = { - circlesTotal: 10, - className: '', - endSize: 20, - startSize: 2 -}; - -function ContinuousSizeLegend(_ref) { - var startTitle = _ref.startTitle, - endTitle = _ref.endTitle, - startSize = _ref.startSize, - endSize = _ref.endSize, - circlesTotal = _ref.circlesTotal, - height = _ref.height, - width = _ref.width, - className = _ref.className; - - var circles = []; - var step = (endSize - startSize) / (circlesTotal - 1); - - for (var i = 0; i < circlesTotal; i++) { - var size = step * i + startSize; - circles.push(_react2.default.createElement('div', { - key: i, - className: 'rv-bubble', - style: { - width: size, - height: size, - borderRadius: size / 2 - } - })); - // Add the separator in order to justify the content (otherwise the tags - // will be stacked together without any margins around). - circles.push(' '); - } - return _react2.default.createElement( - 'div', - { - className: 'rv-continuous-size-legend ' + className, - style: { width: width, height: height } - }, - _react2.default.createElement( - 'div', - { className: 'rv-bubbles', style: { height: endSize } }, - circles, - _react2.default.createElement('div', { className: 'rv-spacer' }) - ), - _react2.default.createElement( - 'div', - { className: 'rv-legend-titles' }, - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__left' }, - startTitle - ), - _react2.default.createElement( - 'span', - { className: 'rv-legend-titles__right' }, - endTitle - ) - ) - ); -} - -ContinuousSizeLegend.displayName = 'ContinuousSizeLegend'; -ContinuousSizeLegend.propTypes = propTypes; -ContinuousSizeLegend.defaultProps = defaultProps; - -exports.default = ContinuousSizeLegend; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend-item.js b/dist/legends/discrete-color-legend-item.js deleted file mode 100644 index 4b12b4428..000000000 --- a/dist/legends/discrete-color-legend-item.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var STROKE_STYLES = { - dashed: '6, 2', - solid: null -}; - -function DiscreteColorLegendItem(_ref) { - var color = _ref.color, - strokeDasharray = _ref.strokeDasharray, - strokeStyle = _ref.strokeStyle, - strokeWidth = _ref.strokeWidth, - disabled = _ref.disabled, - onClick = _ref.onClick, - orientation = _ref.orientation, - onMouseEnter = _ref.onMouseEnter, - onMouseLeave = _ref.onMouseLeave, - title = _ref.title; - - var className = 'rv-discrete-color-legend-item ' + orientation; - if (disabled) { - className += ' disabled'; - } - if (onClick) { - className += ' clickable'; - } - var strokeDasharrayStyle = STROKE_STYLES[strokeStyle] || strokeDasharray; - return _react2.default.createElement( - 'div', - { className: className, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, - _react2.default.createElement( - 'svg', - { className: 'rv-discrete-color-legend-item__color', height: 2, width: 14 }, - _react2.default.createElement('path', { - className: 'rv-discrete-color-legend-item__color__path', - d: 'M 0, 1 L 14, 1', - style: _extends({}, strokeWidth ? { strokeWidth: strokeWidth } : {}, strokeDasharrayStyle ? { strokeDasharray: strokeDasharrayStyle } : {}, { - stroke: disabled ? null : color - }) - - }) - ), - _react2.default.createElement( - 'span', - { className: 'rv-discrete-color-legend-item__title' }, - title - ) - ); -} - -DiscreteColorLegendItem.propTypes = { - color: _propTypes2.default.string.isRequired, - disabled: _propTypes2.default.bool, - title: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]).isRequired, - onClick: _propTypes2.default.func, - onMouseEnter: _propTypes2.default.func, - onMouseLeave: _propTypes2.default.func, - orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']).isRequired, - strokeDasharray: _propTypes2.default.string, - strokeWidth: _propTypes2.default.number, - strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)) -}; -DiscreteColorLegendItem.defaultProps = { - disabled: false, - strokeStyle: 'solid' -}; -DiscreteColorLegendItem.displayName = 'DiscreteColorLegendItem'; - -exports.default = DiscreteColorLegendItem; \ No newline at end of file diff --git a/dist/legends/discrete-color-legend.js b/dist/legends/discrete-color-legend.js deleted file mode 100644 index 76424e745..000000000 --- a/dist/legends/discrete-color-legend.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _discreteColorLegendItem = require('./discrete-color-legend-item'); - -var _discreteColorLegendItem2 = _interopRequireDefault(_discreteColorLegendItem); - -var _theme = require('../theme'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function DiscreteColorLegend(_ref) { - var className = _ref.className, - colors = _ref.colors, - height = _ref.height, - items = _ref.items, - onItemClick = _ref.onItemClick, - onItemMouseEnter = _ref.onItemMouseEnter, - onItemMouseLeave = _ref.onItemMouseLeave, - orientation = _ref.orientation, - style = _ref.style, - width = _ref.width; - - return _react2.default.createElement( - 'div', - { - className: 'rv-discrete-color-legend ' + orientation + ' ' + className, - style: _extends({ width: width, height: height }, style) - }, - items.map(function (item, i) { - return _react2.default.createElement(_discreteColorLegendItem2.default, { - title: item.title ? item.title : item, - color: item.color ? item.color : colors[i % colors.length], - strokeDasharray: item.strokeDasharray, - strokeStyle: item.strokeStyle, - strokeWidth: item.strokeWidth, - disabled: Boolean(item.disabled), - orientation: orientation, - key: i, - onClick: onItemClick ? function (e) { - return onItemClick(item, i, e); - } : null, - onMouseEnter: onItemMouseEnter ? function (e) { - return onItemMouseEnter(item, i, e); - } : null, - onMouseLeave: onItemMouseEnter ? function (e) { - return onItemMouseLeave(item, i, e); - } : null - }); - }) - ); -} - -DiscreteColorLegend.displayName = 'DiscreteColorLegendItem'; -DiscreteColorLegend.propTypes = { - className: _propTypes2.default.string, - items: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.shape({ - title: _propTypes2.default.string.isRequired, - color: _propTypes2.default.string, - disabled: _propTypes2.default.bool - }), _propTypes2.default.string.isRequired, _propTypes2.default.element])).isRequired, - onItemClick: _propTypes2.default.func, - onItemMouseEnter: _propTypes2.default.func, - onItemMouseLeave: _propTypes2.default.func, - height: _propTypes2.default.number, - width: _propTypes2.default.number, - orientation: _propTypes2.default.oneOf(['vertical', 'horizontal']) -}; - -DiscreteColorLegend.defaultProps = { - className: '', - colors: _theme.DISCRETE_COLOR_RANGE, - orientation: 'vertical' -}; - -exports.default = DiscreteColorLegend; \ No newline at end of file diff --git a/dist/legends/searchable-discrete-color-legend.js b/dist/legends/searchable-discrete-color-legend.js deleted file mode 100644 index 49e081ef0..000000000 --- a/dist/legends/searchable-discrete-color-legend.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _discreteColorLegend = require('./discrete-color-legend'); - -var _discreteColorLegend2 = _interopRequireDefault(_discreteColorLegend); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var propTypes = _extends({}, _discreteColorLegend2.default.propTypes, { - searchText: _propTypes2.default.string, - onSearchChange: _propTypes2.default.func, - searchPlaceholder: _propTypes2.default.string, - searchFn: _propTypes2.default.func -}); - -var defaultProps = { - className: '', - searchText: '', - searchFn: function searchFn(items, s) { - return items.filter(function (item) { - return String(item.title || item).toLowerCase().indexOf(s) !== -1; - }); - } -}; - -function SearchableDiscreteColorLegend(props) { - var className = props.className, - colors = props.colors, - height = props.height, - items = props.items, - onItemClick = props.onItemClick, - onSearchChange = props.onSearchChange, - orientation = props.orientation, - searchFn = props.searchFn, - searchPlaceholder = props.searchPlaceholder, - searchText = props.searchText, - width = props.width; - - var onChange = onSearchChange ? function (_ref) { - var value = _ref.target.value; - return onSearchChange(value); - } : null; - var filteredItems = searchFn(items, searchText); - return _react2.default.createElement( - 'div', - { className: 'rv-search-wrapper ' + className, style: { width: width, height: height } }, - _react2.default.createElement( - 'form', - { className: 'rv-search-wrapper__form' }, - _react2.default.createElement('input', { - type: 'search', - placeholder: searchPlaceholder, - className: 'rv-search-wrapper__form__input', - value: searchText, - onChange: onChange - }) - ), - _react2.default.createElement( - 'div', - { className: 'rv-search-wrapper__contents' }, - _react2.default.createElement(_discreteColorLegend2.default, { - colors: colors, - items: filteredItems, - onItemClick: onItemClick, - orientation: orientation - }) - ) - ); -} - -SearchableDiscreteColorLegend.propTypes = propTypes; -SearchableDiscreteColorLegend.defaultProps = defaultProps; -SearchableDiscreteColorLegend.displayName = 'SearchableDiscreteColorLegend'; - -exports.default = SearchableDiscreteColorLegend; \ No newline at end of file diff --git a/dist/main.scss b/dist/main.scss deleted file mode 100644 index 30bac3dc2..000000000 --- a/dist/main.scss +++ /dev/null @@ -1,9 +0,0 @@ -// special tag for using to check if the style file has been imported -.react-vis-magic-css-import-rule { - display: inherit; -} - -@import 'styles/treemap'; -@import 'styles/plot'; -@import 'styles/legends'; -@import 'styles/radial-chart'; diff --git a/dist/make-vis-flexible.js b/dist/make-vis-flexible.js deleted file mode 100644 index c99808b61..000000000 --- a/dist/make-vis-flexible.js +++ /dev/null @@ -1,250 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.FlexibleXYPlot = exports.FlexibleHeightXYPlot = exports.FlexibleWidthXYPlot = undefined; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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; }; }(); - -exports.makeHeightFlexible = makeHeightFlexible; -exports.makeVisFlexible = makeVisFlexible; -exports.makeWidthFlexible = makeWidthFlexible; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _window = require('global/window'); - -var _window2 = _interopRequireDefault(_window); - -var _xyPlot = require('./plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _reactUtils = require('./utils/react-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var CONTAINER_REF = 'container'; - -// As a performance enhancement, we want to only listen once -var resizeSubscribers = []; -var DEBOUNCE_DURATION = 100; -var timeoutId = null; - -/** - * Calls each subscriber, debounced to the - */ -function debounceEmitResize() { - _window2.default.clearTimeout(timeoutId); - timeoutId = _window2.default.setTimeout(emitResize, DEBOUNCE_DURATION); -} - -/** - * Calls each subscriber once syncronously. - */ -function emitResize() { - resizeSubscribers.forEach(function (cb) { - return cb(); - }); -} - -/** - * Add the given callback to the list of subscribers to be caled when the - * window resizes. Returns a function that, when called, removes the given - * callback from the list of subscribers. This function is also resposible for - * adding and removing the resize listener on `window`. - * - * @param {Function} cb - Subscriber callback function - * @returns {Function} Unsubscribe function - */ -function subscribeToDebouncedResize(cb) { - resizeSubscribers.push(cb); - - // if we go from zero to one Flexible components instances, add the listener - if (resizeSubscribers.length === 1) { - _window2.default.addEventListener('resize', debounceEmitResize); - } - return function unsubscribe() { - removeSubscriber(cb); - - // if we have no Flexible components, remove the listener - if (resizeSubscribers.length === 0) { - _window2.default.clearTimeout(timeoutId); - _window2.default.removeEventListener('resize', debounceEmitResize); - } - }; -} - -/** - * Helper for removing the given callback from the list of subscribers. - * - * @param {Function} cb - Subscriber callback function - */ -function removeSubscriber(cb) { - var index = resizeSubscribers.indexOf(cb); - if (index > -1) { - resizeSubscribers.splice(index, 1); - } -} - -/** - * Helper for getting a display name for the child component - * @param {*} Component React class for the child component. - * @returns {String} The child components name - */ -function getDisplayName(Component) { - return Component.displayName || Component.name || 'Component'; -} - -/** - * Add the ability to stretch the visualization on window resize. - * @param {*} Component React class for the child component. - * @returns {*} Flexible component. - */ - -function makeFlexible(Component, isWidthFlexible, isHeightFlexible) { - var ResultClass = function (_React$Component) { - _inherits(ResultClass, _React$Component); - - _createClass(ResultClass, null, [{ - key: 'propTypes', - get: function get() { - var _Component$propTypes = Component.propTypes, - height = _Component$propTypes.height, - width = _Component$propTypes.width, - otherPropTypes = _objectWithoutProperties(_Component$propTypes, ['height', 'width']); // eslint-disable-line no-unused-vars - - - return otherPropTypes; - } - }]); - - function ResultClass(props) { - _classCallCheck(this, ResultClass); - - var _this = _possibleConstructorReturn(this, (ResultClass.__proto__ || Object.getPrototypeOf(ResultClass)).call(this, props)); - - _this._onResize = function () { - var containerElement = (0, _reactUtils.getDOMNode)(_this[CONTAINER_REF]); - var offsetHeight = containerElement.offsetHeight, - offsetWidth = containerElement.offsetWidth; - - - var newHeight = _this.state.height === offsetHeight ? {} : { height: offsetHeight }; - - var newWidth = _this.state.width === offsetWidth ? {} : { width: offsetWidth }; - - _this.setState(_extends({}, newHeight, newWidth)); - }; - - _this.state = { - height: 0, - width: 0 - }; - return _this; - } - - /** - * Get the width of the container and assign the width. - * @private - */ - - - _createClass(ResultClass, [{ - key: 'componentDidMount', - value: function componentDidMount() { - this._onResize(); - this.cancelSubscription = subscribeToDebouncedResize(this._onResize); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps() { - this._onResize(); - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.cancelSubscription(); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _state = this.state, - height = _state.height, - width = _state.width; - - var props = _extends({}, this.props, { - animation: height === 0 && width === 0 ? null : this.props.animation - }); - - var updatedDimensions = _extends({}, isHeightFlexible ? { height: height } : {}, isWidthFlexible ? { width: width } : {}); - - return _react2.default.createElement( - 'div', - { - ref: function ref(_ref) { - return _this2[CONTAINER_REF] = _ref; - }, - style: { width: '100%', height: '100%' } - }, - _react2.default.createElement(Component, _extends({}, updatedDimensions, props)) - ); - } - }]); - - return ResultClass; - }(_react2.default.Component); - - ResultClass.displayName = 'Flexible' + getDisplayName(Component); - - return ResultClass; -} - -function makeHeightFlexible(component) { - return makeFlexible(component, false, true); -} - -function makeVisFlexible(component) { - return makeFlexible(component, true, true); -} - -function makeWidthFlexible(component) { - return makeFlexible(component, true, false); -} - -var FlexibleWidthXYPlot = exports.FlexibleWidthXYPlot = makeWidthFlexible(_xyPlot2.default); -var FlexibleHeightXYPlot = exports.FlexibleHeightXYPlot = makeHeightFlexible(_xyPlot2.default); -var FlexibleXYPlot = exports.FlexibleXYPlot = makeVisFlexible(_xyPlot2.default); \ No newline at end of file diff --git a/dist/parallel-coordinates/index.js b/dist/parallel-coordinates/index.js deleted file mode 100644 index 6b39942e9..000000000 --- a/dist/parallel-coordinates/index.js +++ /dev/null @@ -1,360 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Scale = require('d3-scale'); - -var _d3Format = require('d3-format'); - -var _animation = require('../animation'); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _theme = require('../theme'); - -var _chartUtils = require('../utils/chart-utils'); - -var _lineSeries = require('../plot/series/line-series'); - -var _lineSeries2 = _interopRequireDefault(_lineSeries); - -var _lineMarkSeries = require('../plot/series/line-mark-series'); - -var _lineMarkSeries2 = _interopRequireDefault(_lineMarkSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _decorativeAxis = require('../plot/axis/decorative-axis'); - -var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); - -var _highlight = require('../plot/highlight'); - -var _highlight2 = _interopRequireDefault(_highlight); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } - -var predefinedClassName = 'rv-parallel-coordinates-chart'; -var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); -/** - * Generate axes for each of the domains - * @param {Object} props - - props.animation {Boolean} - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for the whole chart - - props.tickFormat {Function} formatting function for axes - * @return {Array} the plotted axis components - */ -function getAxes(props) { - var animation = props.animation, - domains = props.domains, - style = props.style, - tickFormat = props.tickFormat; - - return domains.map(function (domain, index) { - var sortedDomain = domain.domain; - - var domainTickFormat = function domainTickFormat(t) { - return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); - }; - - return _react2.default.createElement(_decorativeAxis2.default, { - animation: animation, - key: index + '-axis', - axisStart: { x: domain.name, y: 0 }, - axisEnd: { x: domain.name, y: 1 }, - axisDomain: sortedDomain, - numberOfTicks: 5, - tickValue: domainTickFormat, - style: style.axes - }); - }); -} - -/** - * Generate labels for the ends of the axes - * @param {Object} props - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for just the labels - * @return {Array} the prepped data for the labelSeries - */ -function getLabels(props) { - var domains = props.domains, - style = props.style; - - return domains.map(function (domain, index) { - return { - x: domain.name, - y: 1.1, - label: domain.name, - style: style - }; - }); -} - -/** - * Generate the actual lines to be plotted - * @param {Object} props - - props.animation {Boolean} - - props.data {Array} array of object specifying what values are to be plotted - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for the whole chart - - props.showMarks {Bool} whether or not to use the line mark series - * @return {Array} the plotted axis components - */ -function getLines(props) { - var animation = props.animation, - brushFilters = props.brushFilters, - colorRange = props.colorRange, - domains = props.domains, - data = props.data, - style = props.style, - showMarks = props.showMarks; - - var scales = domains.reduce(function (acc, _ref) { - var domain = _ref.domain, - name = _ref.name; - - acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); - return acc; - }, {}); - // const - - return data.map(function (row, rowIndex) { - var withinFilteredRange = true; - var mappedData = domains.map(function (domain, index) { - var getValue = domain.getValue, - name = domain.name; - - // watch out! Gotcha afoot - // yVal after being scale is in [0, 1] range - - var yVal = scales[name](getValue ? getValue(row) : row[name]); - var filter = brushFilters[name]; - // filter value after being scale back from pixel space is also in [0, 1] - if (filter && (yVal < filter.min || yVal > filter.max)) { - withinFilteredRange = false; - } - return { x: name, y: yVal }; - }); - var selectedName = predefinedClassName + '-line'; - var unselectedName = selectedName + ' ' + predefinedClassName + '-line-unselected'; - var lineProps = { - animation: animation, - className: withinFilteredRange ? selectedName : unselectedName, - key: rowIndex + '-polygon', - data: mappedData, - color: row.color || colorRange[rowIndex % colorRange.length], - style: _extends({}, style.lines, row.style || {}) - }; - if (!withinFilteredRange) { - lineProps.style = _extends({}, lineProps.style, style.deselectedLineStyle); - } - return showMarks ? _react2.default.createElement(_lineMarkSeries2.default, lineProps) : _react2.default.createElement(_lineSeries2.default, lineProps); - }); -} - -var ParallelCoordinates = function (_Component) { - _inherits(ParallelCoordinates, _Component); - - function ParallelCoordinates() { - var _ref2; - - var _temp, _this, _ret; - - _classCallCheck(this, ParallelCoordinates); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = ParallelCoordinates.__proto__ || Object.getPrototypeOf(ParallelCoordinates)).call.apply(_ref2, [this].concat(args))), _this), _this.state = { - brushFilters: {} - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(ParallelCoordinates, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var brushFilters = this.state.brushFilters; - var _props = this.props, - animation = _props.animation, - brushing = _props.brushing, - className = _props.className, - children = _props.children, - colorRange = _props.colorRange, - data = _props.data, - domains = _props.domains, - height = _props.height, - hideInnerMostValues = _props.hideInnerMostValues, - margin = _props.margin, - onMouseLeave = _props.onMouseLeave, - onMouseEnter = _props.onMouseEnter, - showMarks = _props.showMarks, - style = _props.style, - tickFormat = _props.tickFormat, - width = _props.width; - - - var axes = getAxes({ - domains: domains, - animation: animation, - hideInnerMostValues: hideInnerMostValues, - style: style, - tickFormat: tickFormat - }); - - var lines = getLines({ - animation: animation, - brushFilters: brushFilters, - colorRange: colorRange, - domains: domains, - data: data, - showMarks: showMarks, - style: style - }); - var labelSeries = _react2.default.createElement(_labelSeries2.default, { - animation: true, - key: className, - className: predefinedClassName + '-label', - data: getLabels({ domains: domains, style: style.labels }) - }); - - var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS), - marginLeft = _getInnerDimensions.marginLeft, - marginRight = _getInnerDimensions.marginRight; - - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - width: width, - margin: margin, - dontCheckIfEmpty: true, - className: className + ' ' + predefinedClassName, - onMouseLeave: onMouseLeave, - onMouseEnter: onMouseEnter, - xType: 'ordinal', - yDomain: [0, 1] - }, - children, - axes.concat(lines).concat(labelSeries), - brushing && domains.map(function (d) { - var trigger = function trigger(row) { - _this2.setState({ - brushFilters: _extends({}, brushFilters, _defineProperty({}, d.name, row ? { min: row.bottom, max: row.top } : null)) - }); - }; - return _react2.default.createElement(_highlight2.default, { - key: d.name, - drag: true, - highlightX: d.name, - onBrushEnd: trigger, - onDragEnd: trigger, - highlightWidth: (width - marginLeft - marginRight) / domains.length, - enableX: false - }); - }) - ); - } - }]); - - return ParallelCoordinates; -}(_react.Component); - -ParallelCoordinates.displayName = 'ParallelCoordinates'; -ParallelCoordinates.propTypes = { - animation: _animation.AnimationPropType, - brushing: _propTypes2.default.bool, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), - data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - name: _propTypes2.default.string.isRequired, - domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, - tickFormat: _propTypes2.default.func - })).isRequired, - height: _propTypes2.default.number.isRequired, - margin: _chartUtils.MarginPropType, - style: _propTypes2.default.shape({ - axes: _propTypes2.default.object, - labels: _propTypes2.default.object, - lines: _propTypes2.default.object - }), - showMarks: _propTypes2.default.bool, - tickFormat: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired -}; -ParallelCoordinates.defaultProps = { - className: '', - colorType: 'category', - colorRange: _theme.DISCRETE_COLOR_RANGE, - style: { - axes: { - line: {}, - ticks: {}, - text: {} - }, - labels: { - fontSize: 10, - textAnchor: 'middle' - }, - lines: { - strokeWidth: 1, - strokeOpacity: 1 - }, - deselectedLineStyle: { - strokeOpacity: 0.1 - } - }, - tickFormat: DEFAULT_FORMAT -}; - -exports.default = ParallelCoordinates; \ No newline at end of file diff --git a/dist/plot/axis/axis-line.js b/dist/plot/axis/axis-line.js deleted file mode 100644 index 23b8f0d9c..000000000 --- a/dist/plot/axis/axis-line.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = { - height: _propTypes2.default.number.isRequired, - style: _propTypes2.default.object, - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, - width: _propTypes2.default.number.isRequired -}; - -var defaultProps = { - style: {} -}; - -function AxisLine(_ref) { - var orientation = _ref.orientation, - width = _ref.width, - height = _ref.height, - style = _ref.style; - - var lineProps = void 0; - if (orientation === LEFT) { - lineProps = { - x1: width, - x2: width, - y1: 0, - y2: height - }; - } else if (orientation === RIGHT) { - lineProps = { - x1: 0, - x2: 0, - y1: 0, - y2: height - }; - } else if (orientation === TOP) { - lineProps = { - x1: 0, - x2: width, - y1: height, - y2: height - }; - } else { - lineProps = { - x1: 0, - x2: width, - y1: 0, - y2: 0 - }; - } - return _react2.default.createElement('line', _extends({}, lineProps, { className: 'rv-xy-plot__axis__line', style: style })); -} - -AxisLine.defaultProps = defaultProps; -AxisLine.displayName = 'AxisLine'; -AxisLine.propTypes = propTypes; - -exports.default = AxisLine; \ No newline at end of file diff --git a/dist/plot/axis/axis-ticks.js b/dist/plot/axis/axis-ticks.js deleted file mode 100644 index f0d0b8e91..000000000 --- a/dist/plot/axis/axis-ticks.js +++ /dev/null @@ -1,271 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -var _scalesUtils = require('../../utils/scales-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = { - height: _propTypes2.default.number.isRequired, - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, - style: _propTypes2.default.object, - width: _propTypes2.default.number.isRequired -}; - -var defaultProps = { - style: {} -}; - -function _getTickFormatFn(scale, tickTotal, tickFormat) { - return !tickFormat ? scale.tickFormat ? scale.tickFormat(tickTotal) : function (v) { - return v; - } : tickFormat; -} - -var AxisTicks = function (_React$Component) { - _inherits(AxisTicks, _React$Component); - - function AxisTicks() { - _classCallCheck(this, AxisTicks); - - return _possibleConstructorReturn(this, (AxisTicks.__proto__ || Object.getPrototypeOf(AxisTicks)).apply(this, arguments)); - } - - _createClass(AxisTicks, [{ - key: '_areTicksWrapped', - - /** - * Check if axis ticks should be mirrored (for the right and top positions. - * @returns {boolean} True if mirrored. - * @private - */ - value: function _areTicksWrapped() { - var orientation = this.props.orientation; - - return orientation === LEFT || orientation === TOP; - } - }, { - key: '_getTickContainerPropsGetterFn', - value: function _getTickContainerPropsGetterFn() { - if (this._isAxisVertical()) { - return function (pos) { - return { transform: 'translate(0, ' + pos + ')' }; - }; - } - return function (pos) { - return { transform: 'translate(' + pos + ', 0)' }; - }; - } - - /** - * Get attributes for the label of the tick. - * @returns {Object} Object with properties. - * @private - */ - - }, { - key: '_getTickLabelProps', - value: function _getTickLabelProps() { - var _props = this.props, - orientation = _props.orientation, - tickLabelAngle = _props.tickLabelAngle, - tickSize = _props.tickSize, - _props$tickSizeOuter = _props.tickSizeOuter, - tickSizeOuter = _props$tickSizeOuter === undefined ? tickSize : _props$tickSizeOuter, - _props$tickPadding = _props.tickPadding, - tickPadding = _props$tickPadding === undefined ? tickSize : _props$tickPadding; - - // Assign the text orientation inside the label of the tick mark. - - var textAnchor = void 0; - if (orientation === LEFT || orientation === BOTTOM && tickLabelAngle) { - textAnchor = 'end'; - } else if (orientation === RIGHT || orientation === TOP && tickLabelAngle) { - textAnchor = 'start'; - } else { - textAnchor = 'middle'; - } - - // The label's position is translated to the given padding and then the - // label is rotated to the given angle. - var isVertical = this._isAxisVertical(); - var wrap = this._areTicksWrapped() ? -1 : 1; - - var labelOffset = wrap * (tickSizeOuter + tickPadding); - var transform = (isVertical ? 'translate(' + labelOffset + ', 0)' : 'translate(0, ' + labelOffset + ')') + (tickLabelAngle ? ' rotate(' + tickLabelAngle + ')' : ''); - - // Set the vertical offset of the label according to the position of - // the axis. - var dy = orientation === TOP || tickLabelAngle ? '0' : orientation === BOTTOM ? '0.72em' : '0.32em'; - - return { - textAnchor: textAnchor, - dy: dy, - transform: transform - }; - } - - /** - * Get the props of the tick line. - * @returns {Object} Props. - * @private - */ - - }, { - key: '_getTickLineProps', - value: function _getTickLineProps() { - var _ref; - - var _props2 = this.props, - tickSize = _props2.tickSize, - _props2$tickSizeOuter = _props2.tickSizeOuter, - tickSizeOuter = _props2$tickSizeOuter === undefined ? tickSize : _props2$tickSizeOuter, - _props2$tickSizeInner = _props2.tickSizeInner, - tickSizeInner = _props2$tickSizeInner === undefined ? tickSize : _props2$tickSizeInner; - - var isVertical = this._isAxisVertical(); - var tickXAttr = isVertical ? 'y' : 'x'; - var tickYAttr = isVertical ? 'x' : 'y'; - var wrap = this._areTicksWrapped() ? -1 : 1; - return _ref = {}, _defineProperty(_ref, tickXAttr + '1', 0), _defineProperty(_ref, tickXAttr + '2', 0), _defineProperty(_ref, tickYAttr + '1', -wrap * tickSizeInner), _defineProperty(_ref, tickYAttr + '2', wrap * tickSizeOuter), _ref; - } - - /** - * Gets if the axis is vertical. - * @returns {boolean} True if vertical. - * @private - */ - - }, { - key: '_isAxisVertical', - value: function _isAxisVertical() { - var orientation = this.props.orientation; - - return orientation === LEFT || orientation === RIGHT; - } - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - attr = _props3.attr, - orientation = _props3.orientation, - width = _props3.width, - height = _props3.height, - style = _props3.style, - tickFormat = _props3.tickFormat, - tickTotal = _props3.tickTotal, - tickValues = _props3.tickValues; - - - var x = orientation === LEFT ? width : 0; - var y = orientation === TOP ? height : 0; - - var scale = (0, _scalesUtils.getAttributeScale)(this.props, attr); - - var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); - var tickFormatFn = _getTickFormatFn(scale, tickTotal, tickFormat); - - var translateFn = this._getTickContainerPropsGetterFn(); - var pathProps = this._getTickLineProps(); - var textProps = this._getTickLabelProps(); - - var ticks = values.map(function (v, i) { - var pos = scale(v); - var labelNode = tickFormatFn(v, i, scale, tickTotal); - var shouldRenderAsOwnNode = _react2.default.isValidElement(labelNode) && !['tspan', 'textPath'].includes(labelNode.type); - var shouldAddProps = labelNode && typeof labelNode.type !== 'string'; - return _react2.default.createElement( - 'g', - _extends({ - key: i - }, translateFn(pos, 0), { - className: 'rv-xy-plot__axis__tick', - style: style - }), - _react2.default.createElement('line', _extends({}, pathProps, { - className: 'rv-xy-plot__axis__tick__line', - style: _extends({}, style, style.line) - })), - shouldRenderAsOwnNode ? _react2.default.cloneElement(labelNode, shouldAddProps ? _extends({}, textProps, { - containerWidth: width, - tickCount: values.length - }) : undefined) : _react2.default.createElement( - 'text', - _extends({}, textProps, { - className: 'rv-xy-plot__axis__tick__text', - style: _extends({}, style, style.text) - }), - labelNode - ) - ); - }); - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + x + ', ' + y + ')', - className: 'rv-xy-plot__axis__ticks' - }, - ticks - ); - } - }]); - - return AxisTicks; -}(_react2.default.Component); - -AxisTicks.defaultProps = defaultProps; -AxisTicks.displayName = 'AxisTicks'; -AxisTicks.propTypes = propTypes; -AxisTicks.requiresSVG = true; - -exports.default = AxisTicks; \ No newline at end of file diff --git a/dist/plot/axis/axis-title.js b/dist/plot/axis/axis-title.js deleted file mode 100644 index 619a31ec1..000000000 --- a/dist/plot/axis/axis-title.js +++ /dev/null @@ -1,186 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// Assuming that 16px = 1em -var ADJUSTMENT_FOR_TEXT_SIZE = 16; -var MARGIN = 6; -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - -var defaultProps = { - position: 'end' -}; - -/** - * Compute transformations, keyed by orientation - * @param {number} width - width of axis - * @param {number} height - height of axis - * @returns {Object} Object of transformations, keyed by orientation - */ -var transformation = function transformation(width, height) { - var _ref; - - return _ref = {}, _defineProperty(_ref, LEFT, { - end: { - x: ADJUSTMENT_FOR_TEXT_SIZE, - y: MARGIN, - rotation: -90, - textAnchor: 'end' - }, - middle: { - x: ADJUSTMENT_FOR_TEXT_SIZE, - y: height / 2 - MARGIN, - rotation: -90, - textAnchor: 'middle' - }, - start: { - x: ADJUSTMENT_FOR_TEXT_SIZE, - y: height - MARGIN, - rotation: -90, - textAnchor: 'start' - } - }), _defineProperty(_ref, RIGHT, { - end: { - x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, - y: MARGIN, - rotation: -90, - textAnchor: 'end' - }, - middle: { - x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, - y: height / 2 - MARGIN, - rotation: -90, - textAnchor: 'middle' - }, - start: { - x: ADJUSTMENT_FOR_TEXT_SIZE * -0.5, - y: height - MARGIN, - rotation: -90, - textAnchor: 'start' - } - }), _defineProperty(_ref, TOP, { - start: { - x: MARGIN, - y: ADJUSTMENT_FOR_TEXT_SIZE, - rotation: 0, - textAnchor: 'start' - }, - middle: { - x: width / 2 - MARGIN, - y: ADJUSTMENT_FOR_TEXT_SIZE, - rotation: 0, - textAnchor: 'middle' - }, - end: { - x: width - MARGIN, - y: ADJUSTMENT_FOR_TEXT_SIZE, - rotation: 0, - textAnchor: 'end' - } - }), _defineProperty(_ref, BOTTOM, { - start: { - x: MARGIN, - y: -MARGIN, - rotation: 0, - textAnchor: 'start' - }, - middle: { - x: width / 2 - MARGIN, - y: -MARGIN, - rotation: 0, - textAnchor: 'middle' - }, - end: { - x: width - MARGIN, - y: -MARGIN, - rotation: 0, - textAnchor: 'end' - } - }), _ref; -}; - -var propTypes = { - width: _propTypes2.default.number.isRequired, - height: _propTypes2.default.number.isRequired, - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]).isRequired, - style: _propTypes2.default.object, - title: _propTypes2.default.string.isRequired -}; - -function AxisTitle(_ref2) { - var orientation = _ref2.orientation, - position = _ref2.position, - width = _ref2.width, - height = _ref2.height, - style = _ref2.style, - title = _ref2.title; - - var outerGroupTranslateX = orientation === LEFT ? width : 0; - var outerGroupTranslateY = orientation === TOP ? height : 0; - var outerGroupTransform = 'translate(' + outerGroupTranslateX + ', ' + outerGroupTranslateY + ')'; - var _transformation$orien = transformation(width, height)[orientation][position], - x = _transformation$orien.x, - y = _transformation$orien.y, - rotation = _transformation$orien.rotation, - textAnchor = _transformation$orien.textAnchor; - - var innerGroupTransform = 'translate(' + x + ', ' + y + ') rotate(' + rotation + ')'; - - return _react2.default.createElement( - 'g', - { transform: outerGroupTransform, className: 'rv-xy-plot__axis__title' }, - _react2.default.createElement( - 'g', - { style: _extends({ textAnchor: textAnchor }, style), transform: innerGroupTransform }, - _react2.default.createElement( - 'text', - { style: style }, - title - ) - ) - ); -} - -AxisTitle.displayName = 'AxisTitle'; -AxisTitle.propTypes = propTypes; -AxisTitle.defaultProps = defaultProps; -exports.default = AxisTitle; \ No newline at end of file diff --git a/dist/plot/axis/axis.js b/dist/plot/axis/axis.js deleted file mode 100644 index e41a8d82b..000000000 --- a/dist/plot/axis/axis.js +++ /dev/null @@ -1,264 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _axisUtils = require('../../utils/axis-utils'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _axisLine = require('./axis-line'); - -var _axisLine2 = _interopRequireDefault(_axisLine); - -var _axisTicks = require('./axis-ticks'); - -var _axisTicks2 = _interopRequireDefault(_axisTicks); - -var _axisTitle = require('./axis-title'); - -var _axisTitle2 = _interopRequireDefault(_axisTitle); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var defaultAnimatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT, - TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = { - orientation: _propTypes2.default.oneOf([LEFT, RIGHT, TOP, BOTTOM]), - attr: _propTypes2.default.string.isRequired, - attrAxis: _propTypes2.default.string, - width: _propTypes2.default.number, - height: _propTypes2.default.number, - top: _propTypes2.default.number, - left: _propTypes2.default.number, - title: _propTypes2.default.string, - - style: _propTypes2.default.object, - - className: _propTypes2.default.string, - hideTicks: _propTypes2.default.bool, - hideLine: _propTypes2.default.bool, - on0: _propTypes2.default.bool, - tickLabelAngle: _propTypes2.default.number, - tickSize: _propTypes2.default.number, - tickSizeInner: _propTypes2.default.number, - tickSizeOuter: _propTypes2.default.number, - tickPadding: _propTypes2.default.number, - tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), - tickFormat: _propTypes2.default.func, - tickTotal: _propTypes2.default.number, - - // Not expected to be used by the users. - // TODO: Add underscore to these properties later. - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; - -var defaultProps = { - className: '', - on0: false, - style: {}, - tickSize: 6, - tickPadding: 8, - orientation: BOTTOM -}; - -var predefinedClassName = 'rv-xy-plot__axis'; -var VERTICAL_CLASS_NAME = 'rv-xy-plot__axis--vertical'; -var HORIZONTAL_CLASS_NAME = 'rv-xy-plot__axis--horizontal'; - -var Axis = function (_PureComponent) { - _inherits(Axis, _PureComponent); - - function Axis() { - _classCallCheck(this, Axis); - - return _possibleConstructorReturn(this, (Axis.__proto__ || Object.getPrototypeOf(Axis)).apply(this, arguments)); - } - - _createClass(Axis, [{ - key: '_getDefaultAxisProps', - - /** - * Define the default values depending on the data passed from the outside. - * @returns {*} Object of default properties. - * @private - */ - value: function _getDefaultAxisProps() { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginTop = _props.marginTop, - marginBottom = _props.marginBottom, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - orientation = _props.orientation; - - if (orientation === BOTTOM) { - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), - top: innerHeight + marginTop, - left: marginLeft, - width: innerWidth, - height: marginBottom - }; - } else if (orientation === TOP) { - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerWidth), - top: 0, - left: marginLeft, - width: innerWidth, - height: marginTop - }; - } else if (orientation === LEFT) { - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), - top: marginTop, - left: 0, - width: marginLeft, - height: innerHeight - }; - } - return { - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(innerHeight), - top: marginTop, - left: marginLeft + innerWidth, - width: marginRight, - height: innerHeight - }; - } - }, { - key: 'render', - value: function render() { - var animation = this.props.animation; - - - if (animation) { - var animatedProps = animation.nonAnimatedProps ? defaultAnimatedProps.filter(function (prop) { - return animation.nonAnimatedProps.indexOf(prop) < 0; - }) : defaultAnimatedProps; - - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(Axis, _extends({}, this.props, { animation: null })) - ); - } - - var props = _extends({}, this._getDefaultAxisProps(), this.props); - - var attrAxis = props.attrAxis, - className = props.className, - height = props.height, - hideLine = props.hideLine, - hideTicks = props.hideTicks, - left = props.left, - marginTop = props.marginTop, - on0 = props.on0, - orientation = props.orientation, - position = props.position, - style = props.style, - title = props.title, - top = props.top, - width = props.width; - - var isVertical = [LEFT, RIGHT].indexOf(orientation) > -1; - var axisClassName = isVertical ? VERTICAL_CLASS_NAME : HORIZONTAL_CLASS_NAME; - - var leftPos = left; - var topPos = top; - if (on0) { - var scale = (0, _scalesUtils.getAttributeScale)(props, attrAxis); - if (isVertical) { - leftPos = scale(0); - } else { - topPos = marginTop + scale(0); - } - } - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + leftPos + ',' + topPos + ')', - className: predefinedClassName + ' ' + axisClassName + ' ' + className, - style: style - }, - !hideLine && _react2.default.createElement(_axisLine2.default, { - height: height, - width: width, - orientation: orientation, - style: _extends({}, style, style.line) - }), - !hideTicks && _react2.default.createElement(_axisTicks2.default, _extends({}, props, { style: _extends({}, style, style.ticks) })), - title ? _react2.default.createElement(_axisTitle2.default, { - position: position, - title: title, - height: height, - width: width, - style: _extends({}, style, style.title), - orientation: orientation - }) : null - ); - } - }]); - - return Axis; -}(_react.PureComponent); - -Axis.displayName = 'Axis'; -Axis.propTypes = propTypes; -Axis.defaultProps = defaultProps; -Axis.requiresSVG = true; - -exports.default = Axis; \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis-ticks.js b/dist/plot/axis/decorative-axis-ticks.js deleted file mode 100644 index f070bea88..000000000 --- a/dist/plot/axis/decorative-axis-ticks.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.default = decorativeAxisTick; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _axisUtils = require('../../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Generate the actual polygons to be plotted - * @param {Object} props - - props.animation {Boolean} - - props.axisDomain {Array} a pair of values specifying the domain of the axis - - props.numberOfTicks{Number} the number of ticks on the axis - - props.axisStart {Object} a object specify in cartesian space the start of the axis - example: {x: 0, y: 0} - - props.axisEnd {Object} a object specify in cartesian space the start of the axis - - props.tickValue {Func} a formatting function for the tick values - - props.tickSize {Number} a pixel size of the axis - - props.style {Object} The style object for the axis - * @return {Component} the plotted axis - */ -function decorativeAxisTick(props) { - var axisDomain = props.axisDomain, - numberOfTicks = props.numberOfTicks, - axisStart = props.axisStart, - axisEnd = props.axisEnd, - tickValue = props.tickValue, - tickSize = props.tickSize, - style = props.style; - - var _generatePoints = (0, _axisUtils.generatePoints)({ - axisStart: axisStart, - axisEnd: axisEnd, - numberOfTicks: numberOfTicks, - axisDomain: axisDomain - }), - points = _generatePoints.points; - // add a quarter rotation to make ticks orthogonal to axis - - - var tickAngle = (0, _axisUtils.getAxisAngle)(axisStart, axisEnd) + Math.PI / 2; - return points.map(function (point, index) { - var tickProps = _extends({ - x1: 0, - y1: 0, - x2: tickSize * Math.cos(tickAngle), - y2: tickSize * Math.sin(tickAngle) - }, style.ticks); - - var textProps = _extends({ - x: tickSize * Math.cos(tickAngle), - y: tickSize * Math.sin(tickAngle), - textAnchor: 'start' - }, style.text); - return _react2.default.createElement( - 'g', - { - key: index, - transform: 'translate(' + point.x + ', ' + point.y + ')', - className: 'rv-xy-plot__axis__tick' - }, - _react2.default.createElement('line', _extends({}, tickProps, { className: 'rv-xy-plot__axis__tick__line' })), - _react2.default.createElement( - 'text', - _extends({}, textProps, { className: 'rv-xy-plot__axis__tick__text' }), - tickValue(point.text) - ) - ); - }); -} \ No newline at end of file diff --git a/dist/plot/axis/decorative-axis.js b/dist/plot/axis/decorative-axis.js deleted file mode 100644 index 809b9dfec..000000000 --- a/dist/plot/axis/decorative-axis.js +++ /dev/null @@ -1,174 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _d3Format = require('d3-format'); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('../series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _decorativeAxisTicks = require('./decorative-axis-ticks'); - -var _decorativeAxisTicks2 = _interopRequireDefault(_decorativeAxisTicks); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-manipulable-axis rv-xy-plot__axis'; - -var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickSize', 'tickTotal', 'tickSizeInner', 'tickSizeOuter']; - -var DecorativeAxis = function (_AbstractSeries) { - _inherits(DecorativeAxis, _AbstractSeries); - - function DecorativeAxis() { - _classCallCheck(this, DecorativeAxis); - - return _possibleConstructorReturn(this, (DecorativeAxis.__proto__ || Object.getPrototypeOf(DecorativeAxis)).apply(this, arguments)); - } - - _createClass(DecorativeAxis, [{ - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - axisStart = _props.axisStart, - axisEnd = _props.axisEnd, - axisDomain = _props.axisDomain, - numberOfTicks = _props.numberOfTicks, - tickValue = _props.tickValue, - tickSize = _props.tickSize, - style = _props.style; - - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(DecorativeAxis, _extends({}, this.props, { animation: null })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - _react2.default.createElement('line', _extends({}, _extends({ - x1: x({ x: axisStart.x }), - x2: x({ x: axisEnd.x }), - y1: y({ y: axisStart.y }), - y2: y({ y: axisEnd.y }) - }, style.line), { - className: 'rv-xy-plot__axis__line' - })), - _react2.default.createElement( - 'g', - { className: 'rv-xy-manipulable-axis__ticks' }, - (0, _decorativeAxisTicks2.default)({ - axisDomain: axisDomain, - axisEnd: { x: x(axisEnd), y: y(axisEnd) }, - axisStart: { x: x(axisStart), y: y(axisStart) }, - numberOfTicks: numberOfTicks, - tickValue: tickValue, - tickSize: tickSize, - style: style - }) - ) - ); - } - }]); - - return DecorativeAxis; -}(_abstractSeries2.default); - -var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); - -DecorativeAxis.defaultProps = { - className: '', - numberOfTicks: 10, - tickValue: function tickValue(d) { - return DEFAULT_FORMAT(d); - }, - tickSize: 5, - style: { - line: { - strokeWidth: 1 - }, - ticks: { - strokeWidth: 2 - }, - text: {} - } -}; -DecorativeAxis.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - axisDomain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, - axisEnd: _propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) - }).isRequired, - axisStart: _propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]) - }).isRequired, - className: _propTypes2.default.string, - numberOfTicks: _propTypes2.default.number, - tickValue: _propTypes2.default.func, - tickSize: _propTypes2.default.number, - style: _propTypes2.default.shape({ - line: _propTypes2.default.object, - ticks: _propTypes2.default.object, - text: _propTypes2.default.object - }) -}); -DecorativeAxis.displayName = 'DecorativeAxis'; -exports.default = DecorativeAxis; \ No newline at end of file diff --git a/dist/plot/axis/x-axis.js b/dist/plot/axis/x-axis.js deleted file mode 100644 index 7ea59bbeb..000000000 --- a/dist/plot/axis/x-axis.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -var _axis = require('./axis'); - -var _axis2 = _interopRequireDefault(_axis); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var TOP = _axisUtils.ORIENTATION.TOP, - BOTTOM = _axisUtils.ORIENTATION.BOTTOM; - - -var propTypes = _extends({}, _axis2.default.propTypes, { - orientation: _propTypes2.default.oneOf([TOP, BOTTOM]) -}); - -var defaultProps = { - orientation: BOTTOM, - attr: 'x', - attrAxis: 'y' -}; - -function XAxis(props) { - return _react2.default.createElement(_axis2.default, props); -} - -XAxis.displayName = 'XAxis'; -XAxis.propTypes = propTypes; -XAxis.defaultProps = defaultProps; -XAxis.requiresSVG = true; - -exports.default = XAxis; \ No newline at end of file diff --git a/dist/plot/axis/y-axis.js b/dist/plot/axis/y-axis.js deleted file mode 100644 index a77570258..000000000 --- a/dist/plot/axis/y-axis.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../../utils/axis-utils'); - -var _axis = require('./axis'); - -var _axis2 = _interopRequireDefault(_axis); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var LEFT = _axisUtils.ORIENTATION.LEFT, - RIGHT = _axisUtils.ORIENTATION.RIGHT; - - -var propTypes = _extends({}, _axis2.default.propTypes, { - orientation: _propTypes2.default.oneOf([LEFT, RIGHT]) -}); - -var defaultProps = { - orientation: LEFT, - attr: 'y', - attrAxis: 'x' -}; - -function YAxis(props) { - return _react2.default.createElement(_axis2.default, props); -} - -YAxis.displayName = 'YAxis'; -YAxis.propTypes = propTypes; -YAxis.defaultProps = defaultProps; -YAxis.requiresSVG = true; - -exports.default = YAxis; \ No newline at end of file diff --git a/dist/plot/borders.js b/dist/plot/borders.js deleted file mode 100644 index fd83342f7..000000000 --- a/dist/plot/borders.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var propTypes = { - style: _propTypes2.default.shape({ - bottom: _propTypes2.default.object, - left: _propTypes2.default.object, - right: _propTypes2.default.object, - top: _propTypes2.default.object - }), - // supplied by xyplot - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; - -var CLASSES = { - bottom: 'rv-xy-plot__borders-bottom', - container: 'rv-xy-plot__borders', - left: 'rv-xy-plot__borders-left', - right: 'rv-xy-plot__borders-right', - top: 'rv-xy-plot__borders-top' -}; - -function Borders(props) { - var marginTop = props.marginTop, - marginBottom = props.marginBottom, - marginLeft = props.marginLeft, - marginRight = props.marginRight, - innerWidth = props.innerWidth, - innerHeight = props.innerHeight, - style = props.style, - className = props.className; - - var height = innerHeight + marginTop + marginBottom; - var width = innerWidth + marginLeft + marginRight; - return _react2.default.createElement( - 'g', - { className: CLASSES.container + ' ' + className }, - _react2.default.createElement('rect', { - className: CLASSES.bottom + ' ' + className + '-bottom', - style: _extends({}, style.all, style.bottom), - x: 0, - y: height - marginBottom, - width: width, - height: marginBottom - }), - _react2.default.createElement('rect', { - className: CLASSES.left + ' ' + className + '-left', - style: _extends({}, style.all, style.left), - x: 0, - y: 0, - width: marginLeft, - height: height - }), - _react2.default.createElement('rect', { - className: CLASSES.right + ' ' + className + '-right', - style: _extends({}, style.all, style.right), - x: width - marginRight, - y: 0, - width: marginRight, - height: height - }), - _react2.default.createElement('rect', { - className: CLASSES.top + ' ' + className + '-top', - style: _extends({}, style.all, style.top), - x: 0, - y: 0, - width: width, - height: marginTop - }) - ); -} - -Borders.displayName = 'Borders'; -Borders.defaultProps = { - className: '', - style: { - all: {}, - bottom: {}, - left: {}, - right: {}, - top: {} - } -}; -Borders.propTypes = propTypes; -Borders.requiresSVG = true; - -exports.default = Borders; \ No newline at end of file diff --git a/dist/plot/chart-label.js b/dist/plot/chart-label.js deleted file mode 100644 index cc614ad38..000000000 --- a/dist/plot/chart-label.js +++ /dev/null @@ -1,112 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -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; } // Copyright (c) 2018 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var ChartLabel = function (_React$PureComponent) { - _inherits(ChartLabel, _React$PureComponent); - - function ChartLabel() { - _classCallCheck(this, ChartLabel); - - return _possibleConstructorReturn(this, (ChartLabel.__proto__ || Object.getPrototypeOf(ChartLabel)).apply(this, arguments)); - } - - _createClass(ChartLabel, [{ - key: 'render', - value: function render() { - var _props = this.props, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginBottom = _props.marginBottom, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - marginTop = _props.marginTop, - className = _props.className, - includeMargin = _props.includeMargin, - style = _props.style, - text = _props.text, - xPercent = _props.xPercent, - yPercent = _props.yPercent; - - var width = innerWidth + (includeMargin ? marginLeft + marginRight : 0); - var height = innerHeight + (includeMargin ? marginTop + marginBottom : 0); - var xPos = width * xPercent + (includeMargin ? 0 : marginLeft); - var yPos = height * yPercent + (includeMargin ? marginLeft : 0); - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + xPos + ', ' + yPos + ')', - className: 'rv-xy-plot__axis__title ' + className }, - _react2.default.createElement( - 'text', - style, - text - ) - ); - } - }], [{ - key: 'requiresSVG', - get: function get() { - return true; - } - }]); - - return ChartLabel; -}(_react2.default.PureComponent); - -ChartLabel.displayName = 'ChartLabel'; -ChartLabel.propTypes = { - className: _propTypes2.default.string, - includeMargin: _propTypes2.default.bool, - style: _propTypes2.default.object, - text: _propTypes2.default.string.isRequired, - xPercent: _propTypes2.default.number.isRequired, - yPercent: _propTypes2.default.number.isRequired -}; -ChartLabel.defaultProps = { - className: '', - includeMargin: true, - text: '', - xPercent: 0, - yPercent: 0, - style: {} -}; -exports.default = ChartLabel; \ No newline at end of file diff --git a/dist/plot/circular-grid-lines.js b/dist/plot/circular-grid-lines.js deleted file mode 100644 index a8638ad64..000000000 --- a/dist/plot/circular-grid-lines.js +++ /dev/null @@ -1,165 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _axisUtils = require('../utils/axis-utils'); - -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; } // Copyright (c) 2016 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; - -var CircularGridLines = function (_PureComponent) { - _inherits(CircularGridLines, _PureComponent); - - function CircularGridLines() { - _classCallCheck(this, CircularGridLines); - - return _possibleConstructorReturn(this, (CircularGridLines.__proto__ || Object.getPrototypeOf(CircularGridLines)).apply(this, arguments)); - } - - _createClass(CircularGridLines, [{ - key: '_getDefaultProps', - value: function _getDefaultProps() { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginTop = _props.marginTop, - marginLeft = _props.marginLeft; - - return { - left: marginLeft, - top: marginTop, - width: innerWidth, - height: innerHeight, - style: {}, - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(Math.min(innerWidth, innerHeight)) - }; - } - }, { - key: 'render', - value: function render() { - var _props2 = this.props, - animation = _props2.animation, - centerX = _props2.centerX, - centerY = _props2.centerY; - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(CircularGridLines, _extends({}, this.props, { animation: null })) - ); - } - - var props = _extends({}, this._getDefaultProps(), this.props); - - var tickTotal = props.tickTotal, - tickValues = props.tickValues, - marginLeft = props.marginLeft, - marginTop = props.marginTop, - rRange = props.rRange, - style = props.style; - - - var xScale = (0, _scalesUtils.getAttributeScale)(props, 'x'); - var yScale = (0, _scalesUtils.getAttributeScale)(props, 'y'); - var values = (0, _axisUtils.getTickValues)(xScale, tickTotal, tickValues); - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + (xScale(centerX) + marginLeft) + ',' + (yScale(centerY) + marginTop) + ')', - className: 'rv-xy-plot__circular-grid-lines' - }, - values.reduce(function (res, value, index) { - var radius = xScale(value); - if (rRange && (radius < rRange[0] || radius > rRange[1])) { - return res; - } - return res.concat([_react2.default.createElement('circle', _extends({ cx: 0, cy: 0, r: radius }, { - key: index, - className: 'rv-xy-plot__circular-grid-lines__line', - style: style - }))]); - }, []) - ); - } - }]); - - return CircularGridLines; -}(_react.PureComponent); - -CircularGridLines.displayName = 'CircularGridLines'; -CircularGridLines.propTypes = { - centerX: _propTypes2.default.number, - centerY: _propTypes2.default.number, - width: _propTypes2.default.number, - height: _propTypes2.default.number, - top: _propTypes2.default.number, - left: _propTypes2.default.number, - rRange: _propTypes2.default.arrayOf(_propTypes2.default.number), - - style: _propTypes2.default.object, - - tickValues: _propTypes2.default.arrayOf(_propTypes2.default.number), - tickTotal: _propTypes2.default.number, - - animation: _animation.AnimationPropType, - // generally supplied by xyplot - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; -CircularGridLines.defaultProps = { - centerX: 0, - centerY: 0 -}; -CircularGridLines.requiresSVG = true; - -exports.default = CircularGridLines; \ No newline at end of file diff --git a/dist/plot/crosshair.js b/dist/plot/crosshair.js deleted file mode 100644 index b9c6edeb7..000000000 --- a/dist/plot/crosshair.js +++ /dev/null @@ -1,262 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/** - * Format title by detault. - * @param {Array} values List of values. - * @returns {*} Formatted value or undefined. - */ -function defaultTitleFormat(values) { - var value = getFirstNonEmptyValue(values); - if (value) { - return { - title: 'x', - value: value.x - }; - } -} - -/** - * Format items by default. - * @param {Array} values Array of values. - * @returns {*} Formatted list of items. - */ -function defaultItemsFormat(values) { - return values.map(function (v, i) { - if (v) { - return { value: v.y, title: i }; - } - }); -} - -/** - * Get the first non-empty item from an array. - * @param {Array} values Array of values. - * @returns {*} First non-empty value or undefined. - */ -function getFirstNonEmptyValue(values) { - return (values || []).find(function (v) { - return Boolean(v); - }); -} - -var Crosshair = function (_PureComponent) { - _inherits(Crosshair, _PureComponent); - - function Crosshair() { - _classCallCheck(this, Crosshair); - - return _possibleConstructorReturn(this, (Crosshair.__proto__ || Object.getPrototypeOf(Crosshair)).apply(this, arguments)); - } - - _createClass(Crosshair, [{ - key: '_renderCrosshairItems', - - - /** - * Render crosshair items (title + value for each series). - * @returns {*} Array of React classes with the crosshair values. - * @private - */ - value: function _renderCrosshairItems() { - var _props = this.props, - values = _props.values, - itemsFormat = _props.itemsFormat; - - var items = itemsFormat(values); - if (!items) { - return null; - } - return items.filter(function (i) { - return i; - }).map(function renderValue(item, i) { - return _react2.default.createElement( - 'div', - { className: 'rv-crosshair__item', key: 'item' + i }, - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__item__title' }, - item.title - ), - ': ', - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__item__value' }, - item.value - ) - ); - }); - } - - /** - * Render crosshair title. - * @returns {*} Container with the crosshair title. - * @private - */ - - }, { - key: '_renderCrosshairTitle', - value: function _renderCrosshairTitle() { - var _props2 = this.props, - values = _props2.values, - titleFormat = _props2.titleFormat, - style = _props2.style; - - var titleItem = titleFormat(values); - if (!titleItem) { - return null; - } - return _react2.default.createElement( - 'div', - { className: 'rv-crosshair__title', key: 'title', style: style.title }, - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__title__title' }, - titleItem.title - ), - ': ', - _react2.default.createElement( - 'span', - { className: 'rv-crosshair__title__value' }, - titleItem.value - ) - ); - } - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - children = _props3.children, - className = _props3.className, - values = _props3.values, - marginTop = _props3.marginTop, - marginLeft = _props3.marginLeft, - innerWidth = _props3.innerWidth, - innerHeight = _props3.innerHeight, - style = _props3.style; - - var value = getFirstNonEmptyValue(values); - if (!value) { - return null; - } - var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x'); - var innerLeft = x(value); - - var _props$orientation = this.props.orientation, - orientation = _props$orientation === undefined ? innerLeft > innerWidth / 2 ? 'left' : 'right' : _props$orientation; - - var left = marginLeft + innerLeft; - var top = marginTop; - var innerClassName = 'rv-crosshair__inner rv-crosshair__inner--' + orientation; - - return _react2.default.createElement( - 'div', - { - className: 'rv-crosshair ' + className, - style: { left: left + 'px', top: top + 'px' } - }, - _react2.default.createElement('div', { - className: 'rv-crosshair__line', - style: _extends({ height: innerHeight + 'px' }, style.line) - }), - _react2.default.createElement( - 'div', - { className: innerClassName }, - children ? children : _react2.default.createElement( - 'div', - { className: 'rv-crosshair__inner__content', style: style.box }, - _react2.default.createElement( - 'div', - null, - this._renderCrosshairTitle(), - this._renderCrosshairItems() - ) - ) - ) - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return { - titleFormat: defaultTitleFormat, - itemsFormat: defaultItemsFormat, - style: { - line: {}, - title: {}, - box: {} - } - }; - } - }, { - key: 'propTypes', - get: function get() { - return { - className: _propTypes2.default.string, - values: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string, _propTypes2.default.object])), - series: _propTypes2.default.object, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - orientation: _propTypes2.default.oneOf(['left', 'right']), - itemsFormat: _propTypes2.default.func, - titleFormat: _propTypes2.default.func, - style: _propTypes2.default.shape({ - line: _propTypes2.default.object, - title: _propTypes2.default.object, - box: _propTypes2.default.object - }) - }; - } - }]); - - return Crosshair; -}(_react.PureComponent); - -Crosshair.displayName = 'Crosshair'; - -exports.default = Crosshair; \ No newline at end of file diff --git a/dist/plot/gradient-defs.js b/dist/plot/gradient-defs.js deleted file mode 100644 index 2da31b486..000000000 --- a/dist/plot/gradient-defs.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-gradient-defs'; - -function GradientDefs(props) { - var className = props.className; - - return _react2.default.createElement( - 'defs', - { className: predefinedClassName + ' ' + className }, - props.children - ); -} - -GradientDefs.displayName = 'GradientDefs'; -GradientDefs.requiresSVG = true; -GradientDefs.propTypes = { - className: _propTypes2.default.string -}; -GradientDefs.defaultProps = { - className: '' -}; - -exports.default = GradientDefs; \ No newline at end of file diff --git a/dist/plot/grid-lines.js b/dist/plot/grid-lines.js deleted file mode 100644 index 1336d8718..000000000 --- a/dist/plot/grid-lines.js +++ /dev/null @@ -1,178 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _axisUtils = require('../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var VERTICAL = _axisUtils.DIRECTION.VERTICAL, - HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; - - -var propTypes = { - direction: _propTypes2.default.oneOf([VERTICAL, HORIZONTAL]), - attr: _propTypes2.default.string.isRequired, - width: _propTypes2.default.number, - height: _propTypes2.default.number, - top: _propTypes2.default.number, - left: _propTypes2.default.number, - - style: _propTypes2.default.object, - - tickValues: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string])), - tickTotal: _propTypes2.default.number, - - animation: _animation.AnimationPropType, - - // generally supplied by xyplot - marginTop: _propTypes2.default.number, - marginBottom: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - marginRight: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number -}; - -var defaultProps = { - direction: VERTICAL -}; - -var animatedProps = ['xRange', 'yRange', 'xDomain', 'yDomain', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'tickTotal']; - -var GridLines = function (_PureComponent) { - _inherits(GridLines, _PureComponent); - - function GridLines() { - _classCallCheck(this, GridLines); - - return _possibleConstructorReturn(this, (GridLines.__proto__ || Object.getPrototypeOf(GridLines)).apply(this, arguments)); - } - - _createClass(GridLines, [{ - key: '_getDefaultProps', - value: function _getDefaultProps() { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginTop = _props.marginTop, - marginLeft = _props.marginLeft, - direction = _props.direction; - - return { - left: marginLeft, - top: marginTop, - width: innerWidth, - height: innerHeight, - tickTotal: (0, _axisUtils.getTicksTotalFromSize)(direction === VERTICAL ? innerWidth : innerHeight) - }; - } - }, { - key: 'render', - value: function render() { - var animation = this.props.animation; - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: animatedProps }), - _react2.default.createElement(GridLines, _extends({}, this.props, { animation: null })) - ); - } - - var props = _extends({}, this._getDefaultProps(), this.props); - - var attr = props.attr, - direction = props.direction, - width = props.width, - height = props.height, - style = props.style, - tickTotal = props.tickTotal, - tickValues = props.tickValues, - top = props.top, - left = props.left; - - var isVertical = direction === VERTICAL; - var tickXAttr = isVertical ? 'y' : 'x'; - var tickYAttr = isVertical ? 'x' : 'y'; - var length = isVertical ? height : width; - - var scale = (0, _scalesUtils.getAttributeScale)(props, attr); - var values = (0, _axisUtils.getTickValues)(scale, tickTotal, tickValues); - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + left + ',' + top + ')', - className: 'rv-xy-plot__grid-lines' - }, - values.map(function (v, i) { - var _pathProps; - - var pos = scale(v); - var pathProps = (_pathProps = {}, _defineProperty(_pathProps, tickYAttr + '1', pos), _defineProperty(_pathProps, tickYAttr + '2', pos), _defineProperty(_pathProps, tickXAttr + '1', 0), _defineProperty(_pathProps, tickXAttr + '2', length), _pathProps); - return _react2.default.createElement('line', _extends({}, pathProps, { - key: i, - className: 'rv-xy-plot__grid-lines__line', - style: style - })); - }) - ); - } - }]); - - return GridLines; -}(_react.PureComponent); - -GridLines.displayName = 'GridLines'; -GridLines.defaultProps = defaultProps; -GridLines.propTypes = propTypes; -GridLines.requiresSVG = true; - -exports.default = GridLines; \ No newline at end of file diff --git a/dist/plot/highlight.js b/dist/plot/highlight.js deleted file mode 100644 index 63458b3e1..000000000 --- a/dist/plot/highlight.js +++ /dev/null @@ -1,426 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _scalesUtils = require('../utils/scales-utils'); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -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; } - -function getLocs(evt) { - var xLoc = evt.type === 'touchstart' ? evt.pageX : evt.offsetX; - var yLoc = evt.type === 'touchstart' ? evt.pageY : evt.offsetY; - return { xLoc: xLoc, yLoc: yLoc }; -} - -var Highlight = function (_AbstractSeries) { - _inherits(Highlight, _AbstractSeries); - - function Highlight() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, Highlight); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Highlight.__proto__ || Object.getPrototypeOf(Highlight)).call.apply(_ref, [this].concat(args))), _this), _this.state = { - dragging: false, - brushArea: { top: 0, right: 0, bottom: 0, left: 0 }, - brushing: false, - startLocX: 0, - startLocY: 0, - dragArea: null - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(Highlight, [{ - key: '_getDrawArea', - value: function _getDrawArea(xLoc, yLoc) { - var _state = this.state, - startLocX = _state.startLocX, - startLocY = _state.startLocY; - var _props = this.props, - enableX = _props.enableX, - enableY = _props.enableY, - highlightWidth = _props.highlightWidth, - highlightHeight = _props.highlightHeight, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - marginBottom = _props.marginBottom, - marginTop = _props.marginTop; - - var plotHeight = innerHeight + marginTop + marginBottom; - var plotWidth = innerWidth + marginLeft + marginRight; - var touchWidth = highlightWidth || plotWidth; - var touchHeight = highlightHeight || plotHeight; - - return { - bottom: enableY ? Math.max(startLocY, yLoc) : touchHeight, - right: enableX ? Math.max(startLocX, xLoc) : touchWidth, - left: enableX ? Math.min(xLoc, startLocX) : 0, - top: enableY ? Math.min(yLoc, startLocY) : 0 - }; - } - }, { - key: '_getDragArea', - value: function _getDragArea(xLoc, yLoc) { - var _props2 = this.props, - enableX = _props2.enableX, - enableY = _props2.enableY; - var _state2 = this.state, - startLocX = _state2.startLocX, - startLocY = _state2.startLocY, - dragArea = _state2.dragArea; - - - return { - bottom: dragArea.bottom + (enableY ? yLoc - startLocY : 0), - left: dragArea.left + (enableX ? xLoc - startLocX : 0), - right: dragArea.right + (enableX ? xLoc - startLocX : 0), - top: dragArea.top + (enableY ? yLoc - startLocY : 0) - }; - } - }, { - key: '_clickedOutsideDrag', - value: function _clickedOutsideDrag(xLoc, yLoc) { - var _props3 = this.props, - enableX = _props3.enableX, - enableY = _props3.enableY; - var _state3 = this.state, - dragArea = _state3.dragArea, - _state3$brushArea = _state3.brushArea, - left = _state3$brushArea.left, - right = _state3$brushArea.right, - top = _state3$brushArea.top, - bottom = _state3$brushArea.bottom; - - var clickedOutsideDragX = dragArea && (xLoc < left || xLoc > right); - var clickedOutsideDragY = dragArea && (yLoc < top || yLoc > bottom); - if (enableX && enableY) { - return clickedOutsideDragX || clickedOutsideDragY; - } - if (enableX) { - return clickedOutsideDragX; - } - if (enableY) { - return clickedOutsideDragY; - } - return true; - } - }, { - key: '_convertAreaToCoordinates', - value: function _convertAreaToCoordinates(brushArea) { - // NOTE only continuous scales are supported for brushing/getting coordinates back - var _props4 = this.props, - enableX = _props4.enableX, - enableY = _props4.enableY, - marginLeft = _props4.marginLeft, - marginTop = _props4.marginTop; - - var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); - var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); - - // Ensure that users wishes are being respected about which scales are evaluated - // this is specifically enabled to ensure brushing on mixed categorical and linear - // charts will run as expected - - if (enableX && enableY) { - return { - bottom: yScale.invert(brushArea.bottom), - left: xScale.invert(brushArea.left - marginLeft), - right: xScale.invert(brushArea.right - marginLeft), - top: yScale.invert(brushArea.top) - }; - } - - if (enableY) { - return { - bottom: yScale.invert(brushArea.bottom - marginTop), - top: yScale.invert(brushArea.top - marginTop) - }; - } - - if (enableX) { - return { - left: xScale.invert(brushArea.left - marginLeft), - right: xScale.invert(brushArea.right - marginLeft) - }; - } - - return {}; - } - }, { - key: 'startBrushing', - value: function startBrushing(e) { - var _this2 = this; - - var _props5 = this.props, - onBrushStart = _props5.onBrushStart, - onDragStart = _props5.onDragStart, - drag = _props5.drag; - var dragArea = this.state.dragArea; - - var _getLocs = getLocs(e.nativeEvent), - xLoc = _getLocs.xLoc, - yLoc = _getLocs.yLoc; - - var startArea = function startArea(dragging, resetDrag) { - var emptyBrush = { - bottom: yLoc, - left: xLoc, - right: xLoc, - top: yLoc - }; - _this2.setState({ - dragging: dragging, - brushArea: dragArea && !resetDrag ? dragArea : emptyBrush, - brushing: !dragging, - startLocX: xLoc, - startLocY: yLoc - }); - }; - - var clickedOutsideDrag = this._clickedOutsideDrag(xLoc, yLoc); - if (drag && !dragArea || !drag || clickedOutsideDrag) { - startArea(false, clickedOutsideDrag); - - if (onBrushStart) { - onBrushStart(e); - } - return; - } - - if (drag && dragArea) { - startArea(true, clickedOutsideDrag); - if (onDragStart) { - onDragStart(e); - } - } - } - }, { - key: 'stopBrushing', - value: function stopBrushing(e) { - var _state4 = this.state, - brushing = _state4.brushing, - dragging = _state4.dragging, - brushArea = _state4.brushArea; - // Quickly short-circuit if the user isn't brushing in our component - - if (!brushing && !dragging) { - return; - } - var _props6 = this.props, - onBrushEnd = _props6.onBrushEnd, - onDragEnd = _props6.onDragEnd, - drag = _props6.drag; - - var noHorizontal = Math.abs(brushArea.right - brushArea.left) < 5; - var noVertical = Math.abs(brushArea.top - brushArea.bottom) < 5; - // Invoke the callback with null if the selected area was < 5px - var isNulled = noVertical || noHorizontal; - // Clear the draw area - this.setState({ - brushing: false, - dragging: false, - brushArea: drag ? brushArea : { top: 0, right: 0, bottom: 0, left: 0 }, - startLocX: 0, - startLocY: 0, - dragArea: drag && !isNulled && brushArea - }); - - if (brushing && onBrushEnd) { - onBrushEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); - } - - if (drag && onDragEnd) { - onDragEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null); - } - } - }, { - key: 'onBrush', - value: function onBrush(e) { - var _props7 = this.props, - onBrush = _props7.onBrush, - onDrag = _props7.onDrag, - drag = _props7.drag; - var _state5 = this.state, - brushing = _state5.brushing, - dragging = _state5.dragging; - - var _getLocs2 = getLocs(e.nativeEvent), - xLoc = _getLocs2.xLoc, - yLoc = _getLocs2.yLoc; - - if (brushing) { - var brushArea = this._getDrawArea(xLoc, yLoc); - this.setState({ brushArea: brushArea }); - - if (onBrush) { - onBrush(this._convertAreaToCoordinates(brushArea)); - } - } - - if (drag && dragging) { - var _brushArea = this._getDragArea(xLoc, yLoc); - this.setState({ brushArea: _brushArea }); - if (onDrag) { - onDrag(this._convertAreaToCoordinates(_brushArea)); - } - } - } - }, { - key: 'render', - value: function render() { - var _this3 = this; - - var _props8 = this.props, - color = _props8.color, - className = _props8.className, - highlightHeight = _props8.highlightHeight, - highlightWidth = _props8.highlightWidth, - highlightX = _props8.highlightX, - highlightY = _props8.highlightY, - innerWidth = _props8.innerWidth, - innerHeight = _props8.innerHeight, - marginLeft = _props8.marginLeft, - marginRight = _props8.marginRight, - marginTop = _props8.marginTop, - marginBottom = _props8.marginBottom, - opacity = _props8.opacity; - var _state$brushArea = this.state.brushArea, - left = _state$brushArea.left, - right = _state$brushArea.right, - top = _state$brushArea.top, - bottom = _state$brushArea.bottom; - - - var leftPos = 0; - if (highlightX) { - var xScale = (0, _scalesUtils.getAttributeScale)(this.props, 'x'); - leftPos = xScale(highlightX); - } - - var topPos = 0; - if (highlightY) { - var yScale = (0, _scalesUtils.getAttributeScale)(this.props, 'y'); - topPos = yScale(highlightY); - } - - var plotWidth = marginLeft + marginRight + innerWidth; - var plotHeight = marginTop + marginBottom + innerHeight; - var touchWidth = highlightWidth || plotWidth; - var touchHeight = highlightHeight || plotHeight; - - return _react2.default.createElement( - 'g', - { - transform: 'translate(' + leftPos + ', ' + topPos + ')', - className: className + ' rv-highlight-container' - }, - _react2.default.createElement('rect', { - className: 'rv-mouse-target', - fill: 'black', - opacity: '0', - x: '0', - y: '0', - width: Math.max(touchWidth, 0), - height: Math.max(touchHeight, 0), - onMouseDown: function onMouseDown(e) { - return _this3.startBrushing(e); - }, - onMouseMove: function onMouseMove(e) { - return _this3.onBrush(e); - }, - onMouseUp: function onMouseUp(e) { - return _this3.stopBrushing(e); - }, - onMouseLeave: function onMouseLeave(e) { - return _this3.stopBrushing(e); - } - // preventDefault() so that mouse event emulation does not happen - , onTouchEnd: function onTouchEnd(e) { - e.preventDefault(); - _this3.stopBrushing(e); - }, - onTouchCancel: function onTouchCancel(e) { - e.preventDefault(); - _this3.stopBrushing(e); - }, - onContextMenu: function onContextMenu(e) { - return e.preventDefault(); - }, - onContextMenuCapture: function onContextMenuCapture(e) { - return e.preventDefault(); - } - }), - _react2.default.createElement('rect', { - className: 'rv-highlight', - pointerEvents: 'none', - opacity: opacity, - fill: color, - x: left, - y: top, - width: Math.min(Math.max(0, right - left), touchWidth), - height: Math.min(Math.max(0, bottom - top), touchHeight) - }) - ); - } - }]); - - return Highlight; -}(_abstractSeries2.default); - -Highlight.displayName = 'HighlightOverlay'; -Highlight.defaultProps = { - color: 'rgb(77, 182, 172)', - className: '', - enableX: true, - enableY: true, - opacity: 0.3 -}; - -Highlight.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - enableX: _propTypes2.default.bool, - enableY: _propTypes2.default.bool, - highlightHeight: _propTypes2.default.number, - highlightWidth: _propTypes2.default.number, - highlightX: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), - highlightY: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), - onBrushStart: _propTypes2.default.func, - onDragStart: _propTypes2.default.func, - onBrush: _propTypes2.default.func, - onDrag: _propTypes2.default.func, - onBrushEnd: _propTypes2.default.func, - onDragEnd: _propTypes2.default.func -}); - -exports.default = Highlight; \ No newline at end of file diff --git a/dist/plot/hint.js b/dist/plot/hint.js deleted file mode 100644 index 8e15b3cae..000000000 --- a/dist/plot/hint.js +++ /dev/null @@ -1,454 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _scalesUtils = require('../utils/scales-utils'); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/* - * Hint provides two options for placement of hint: - * a) around a data point in one of four quadrants (imagine the point bisected - * by two axes -vertical, horizontal- creating 4 quadrants around a data - * point). - * b) **New** pin to an edge of chart/plot area and position along that edge - * using data point's other dimension value. - * - * To support these two options, deprecate one Hint props (orientation) with two - * new Hint align prop object (horizontal, vertical) with following values: - * - * horizontal: auto, left, right, leftEdge, rightEdge - * vertical: auto, bottom, top, bottomEdge, topEdge - * - * Thus, the following ALIGN constants are the values for horizontal - * and vertical - */ -var ALIGN = { - AUTO: 'auto', - LEFT: 'left', - RIGHT: 'right', - LEFT_EDGE: 'leftEdge', - RIGHT_EDGE: 'rightEdge', - BOTTOM: 'bottom', - TOP: 'top', - BOTTOM_EDGE: 'bottomEdge', - TOP_EDGE: 'topEdge' -}; - -/** - * For backwards support, retain the ORIENTATION prop constants - */ -var ORIENTATION = { - BOTTOM_LEFT: 'bottomleft', - BOTTOM_RIGHT: 'bottomright', - TOP_LEFT: 'topleft', - TOP_RIGHT: 'topright' -}; - -/** - * Default format function for the value. - * @param {Object} value Value. - * @returns {Array} title-value pairs. - */ -function defaultFormat(value) { - return Object.keys(value).map(function getProp(key) { - return { title: key, value: value[key] }; - }); -} - -var Hint = function (_PureComponent) { - _inherits(Hint, _PureComponent); - - function Hint() { - _classCallCheck(this, Hint); - - return _possibleConstructorReturn(this, (Hint.__proto__ || Object.getPrototypeOf(Hint)).apply(this, arguments)); - } - - _createClass(Hint, [{ - key: '_getAlign', - - - /** - * Obtain align object with horizontal and vertical settings - * but convert any AUTO values to the non-auto ALIGN depending on the - * values of x and y. - * @param {number} x X value. - * @param {number} y Y value. - * @returns {Object} Align object w/ horizontal, vertical prop strings. - * @private - */ - value: function _getAlign(x, y) { - var _props = this.props, - innerWidth = _props.innerWidth, - innerHeight = _props.innerHeight, - orientation = _props.orientation, - _props$align = _props.align, - horizontal = _props$align.horizontal, - vertical = _props$align.vertical; - - var align = orientation ? this._mapOrientationToAlign(orientation) : { horizontal: horizontal, vertical: vertical }; - if (horizontal === ALIGN.AUTO) { - align.horizontal = x > innerWidth / 2 ? ALIGN.LEFT : ALIGN.RIGHT; - } - if (vertical === ALIGN.AUTO) { - align.vertical = y > innerHeight / 2 ? ALIGN.TOP : ALIGN.BOTTOM; - } - return align; - } - - /** - * Get the class names from align values. - * @param {Object} align object with horizontal and vertical prop strings. - * @returns {string} Class names. - * @private - */ - - }, { - key: '_getAlignClassNames', - value: function _getAlignClassNames(align) { - var orientation = this.props.orientation; - - var orientationClass = orientation ? 'rv-hint--orientation-' + orientation : ''; - return orientationClass + ' rv-hint--horizontalAlign-' + align.horizontal + '\n rv-hint--verticalAlign-' + align.vertical; - } - - /** - * Get a CSS mixin for a proper positioning of the element. - * @param {Object} align object with horizontal and vertical prop strings. - * @param {number} x X position. - * @param {number} y Y position. - * @returns {Object} Object, that may contain `left` or `right, `top` or - * `bottom` properties. - * @private - */ - - }, { - key: '_getAlignStyle', - value: function _getAlignStyle(align, x, y) { - return _extends({}, this._getXCSS(align.horizontal, x), this._getYCSS(align.vertical, y)); - } - - /** - * Get the bottom coordinate of the hint. - * When y undefined or null, edge case, pin bottom. - * @param {number} y Y. - * @returns {{bottom: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSBottom', - value: function _getCSSBottom(y) { - if (y === undefined || y === null) { - return { - bottom: 0 - }; - } - - var _props2 = this.props, - innerHeight = _props2.innerHeight, - marginBottom = _props2.marginBottom; - - return { - bottom: marginBottom + innerHeight - y - }; - } - - /** - * Get the left coordinate of the hint. - * When x undefined or null, edge case, pin left. - * @param {number} x X. - * @returns {{left: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSLeft', - value: function _getCSSLeft(x) { - if (x === undefined || x === null) { - return { - left: 0 - }; - } - - var marginLeft = this.props.marginLeft; - - return { - left: marginLeft + x - }; - } - - /** - * Get the right coordinate of the hint. - * When x undefined or null, edge case, pin right. - * @param {number} x X. - * @returns {{right: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSRight', - value: function _getCSSRight(x) { - if (x === undefined || x === null) { - return { - right: 0 - }; - } - - var _props3 = this.props, - innerWidth = _props3.innerWidth, - marginRight = _props3.marginRight; - - return { - right: marginRight + innerWidth - x - }; - } - - /** - * Get the top coordinate of the hint. - * When y undefined or null, edge case, pin top. - * @param {number} y Y. - * @returns {{top: *}} Mixin. - * @private - */ - - }, { - key: '_getCSSTop', - value: function _getCSSTop(y) { - if (y === undefined || y === null) { - return { - top: 0 - }; - } - - var marginTop = this.props.marginTop; - - return { - top: marginTop + y - }; - } - - /** - * Get the position for the hint and the appropriate class name. - * @returns {{style: Object, className: string}} Style and className for the - * hint. - * @private - */ - - }, { - key: '_getPositionInfo', - value: function _getPositionInfo() { - var _props4 = this.props, - value = _props4.value, - getAlignStyle = _props4.getAlignStyle; - - - var x = (0, _scalesUtils.getAttributeFunctor)(this.props, 'x')(value); - var y = (0, _scalesUtils.getAttributeFunctor)(this.props, 'y')(value); - - var align = this._getAlign(x, y); - - return { - position: getAlignStyle ? getAlignStyle(align, x, y) : this._getAlignStyle(align, x, y), - className: this._getAlignClassNames(align) - }; - } - }, { - key: '_getXCSS', - value: function _getXCSS(horizontal, x) { - // obtain xCSS - switch (horizontal) { - case ALIGN.LEFT_EDGE: - // this pins x to left edge - return this._getCSSLeft(null); - case ALIGN.RIGHT_EDGE: - // this pins x to left edge - return this._getCSSRight(null); - case ALIGN.LEFT: - // this places hint text to the left of center, so set its right edge - return this._getCSSRight(x); - case ALIGN.RIGHT: - default: - // this places hint text to the right of center, so set its left edge - // default case should not be possible but if it happens set to RIGHT - return this._getCSSLeft(x); - } - } - }, { - key: '_getYCSS', - value: function _getYCSS(verticalAlign, y) { - // obtain yCSS - switch (verticalAlign) { - case ALIGN.TOP_EDGE: - // this pins x to top edge - return this._getCSSTop(null); - case ALIGN.BOTTOM_EDGE: - // this pins x to bottom edge - return this._getCSSBottom(null); - case ALIGN.BOTTOM: - // this places hint text to the bottom of center, so set its top edge - return this._getCSSTop(y); - case ALIGN.TOP: - default: - // this places hint text to the top of center, so set its bottom edge - // default case should not be possible but if it happens set to BOTTOM - return this._getCSSBottom(y); - } - } - }, { - key: '_mapOrientationToAlign', - value: function _mapOrientationToAlign(orientation) { - // TODO: print warning that this feature is deprecated and support will be - // removed in next major release. - switch (orientation) { - case ORIENTATION.BOTTOM_LEFT: - return { - horizontal: ALIGN.LEFT, - vertical: ALIGN.BOTTOM - }; - case ORIENTATION.BOTTOM_RIGHT: - return { - horizontal: ALIGN.RIGHT, - vertical: ALIGN.BOTTOM - }; - case ORIENTATION.TOP_LEFT: - return { - horizontal: ALIGN.LEFT, - vertical: ALIGN.TOP - }; - case ORIENTATION.TOP_RIGHT: - return { - horizontal: ALIGN.RIGHT, - vertical: ALIGN.TOP - }; - default: - // fall back to horizontalAlign, verticalAlign that are either - // provided or defaulted to AUTO. So, don't change things - break; - } - } - }, { - key: 'render', - value: function render() { - var _props5 = this.props, - value = _props5.value, - format = _props5.format, - children = _props5.children, - style = _props5.style; - - var _getPositionInfo2 = this._getPositionInfo(), - position = _getPositionInfo2.position, - className = _getPositionInfo2.className; - - return _react2.default.createElement( - 'div', - { - className: 'rv-hint ' + className, - style: _extends({}, style, position, { - position: 'absolute' - }) - }, - children ? children : _react2.default.createElement( - 'div', - { className: 'rv-hint__content', style: style.content }, - format(value).map(function (formattedProp, i) { - return _react2.default.createElement( - 'div', - { key: 'rv-hint' + i, style: style.row }, - _react2.default.createElement( - 'span', - { className: 'rv-hint__title', style: style.title }, - formattedProp.title - ), - ': ', - _react2.default.createElement( - 'span', - { className: 'rv-hint__value', style: style.value }, - formattedProp.value - ) - ); - }) - ) - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return { - format: defaultFormat, - align: { - horizontal: ALIGN.AUTO, - vertical: ALIGN.AUTO - }, - style: {} - }; - } - }, { - key: 'propTypes', - get: function get() { - return { - marginTop: _propTypes2.default.number, - marginLeft: _propTypes2.default.number, - innerWidth: _propTypes2.default.number, - innerHeight: _propTypes2.default.number, - scales: _propTypes2.default.object, - value: _propTypes2.default.object, - format: _propTypes2.default.func, - style: _propTypes2.default.object, - align: _propTypes2.default.shape({ - horizontal: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.LEFT, ALIGN.RIGHT, ALIGN.LEFT_EDGE, ALIGN.RIGHT_EDGE]), - vertical: _propTypes2.default.oneOf([ALIGN.AUTO, ALIGN.BOTTOM, ALIGN.TOP, ALIGN.BOTTOM_EDGE, ALIGN.TOP_EDGE]) - }), - getAlignStyle: _propTypes2.default.func, - orientation: _propTypes2.default.oneOf([ORIENTATION.BOTTOM_LEFT, ORIENTATION.BOTTOM_RIGHT, ORIENTATION.TOP_LEFT, ORIENTATION.TOP_RIGHT]) - }; - } - }]); - - return Hint; -}(_react.PureComponent); - -Hint.displayName = 'Hint'; -Hint.ORIENTATION = ORIENTATION; -Hint.ALIGN = ALIGN; - -exports.default = Hint; \ No newline at end of file diff --git a/dist/plot/horizontal-grid-lines.js b/dist/plot/horizontal-grid-lines.js deleted file mode 100644 index 549b2d8b5..000000000 --- a/dist/plot/horizontal-grid-lines.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _axisUtils = require('../utils/axis-utils'); - -var _gridLines = require('./grid-lines'); - -var _gridLines2 = _interopRequireDefault(_gridLines); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var HORIZONTAL = _axisUtils.DIRECTION.HORIZONTAL; - - -var propTypes = _extends({}, _gridLines2.default.propTypes, { - direction: _propTypes2.default.oneOf([HORIZONTAL]) -}); - -var defaultProps = { - direction: HORIZONTAL, - attr: 'y' -}; - -function HorizontalGridLines(props) { - return _react2.default.createElement(_gridLines2.default, props); -} - -HorizontalGridLines.displayName = 'HorizontalGridLines'; -HorizontalGridLines.propTypes = propTypes; -HorizontalGridLines.defaultProps = defaultProps; -HorizontalGridLines.requiresSVG = true; - -exports.default = HorizontalGridLines; \ No newline at end of file diff --git a/dist/plot/series/abstract-series.js b/dist/plot/series/abstract-series.js deleted file mode 100644 index 7f86a482f..000000000 --- a/dist/plot/series/abstract-series.js +++ /dev/null @@ -1,415 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Voronoi = require('d3-voronoi'); - -var _react = require('react'); - -var _animation = require('../../animation'); - -var _scalesUtils = require('../../utils/scales-utils'); - -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; } - -var propTypes = _extends({}, (0, _scalesUtils.getScalePropTypesByAttribute)('x'), (0, _scalesUtils.getScalePropTypesByAttribute)('y'), (0, _scalesUtils.getScalePropTypesByAttribute)('size'), (0, _scalesUtils.getScalePropTypesByAttribute)('opacity'), (0, _scalesUtils.getScalePropTypesByAttribute)('color'), { - width: _propTypes2.default.number, - height: _propTypes2.default.number, - data: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.array])), - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - onValueClick: _propTypes2.default.func, - onValueRightClick: _propTypes2.default.func, - onSeriesMouseOver: _propTypes2.default.func, - onSeriesMouseOut: _propTypes2.default.func, - onSeriesClick: _propTypes2.default.func, - onSeriesRightClick: _propTypes2.default.func, - onNearestX: _propTypes2.default.func, - onNearestXY: _propTypes2.default.func, - style: _propTypes2.default.object, - animation: _animation.AnimationPropType, - stack: _propTypes2.default.bool -}); - -var defaultProps = { - className: '', - stack: false, - style: {} -}; - -var AbstractSeries = function (_PureComponent) { - _inherits(AbstractSeries, _PureComponent); - - function AbstractSeries() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, AbstractSeries); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AbstractSeries.__proto__ || Object.getPrototypeOf(AbstractSeries)).call.apply(_ref, [this].concat(args))), _this), _this._seriesClickHandler = function (event) { - var onSeriesClick = _this.props.onSeriesClick; - - if (onSeriesClick) { - onSeriesClick({ event: event }); - } - }, _this._seriesMouseOutHandler = function (event) { - var onSeriesMouseOut = _this.props.onSeriesMouseOut; - - if (onSeriesMouseOut) { - onSeriesMouseOut({ event: event }); - } - }, _this._seriesMouseOverHandler = function (event) { - var onSeriesMouseOver = _this.props.onSeriesMouseOver; - - if (onSeriesMouseOver) { - onSeriesMouseOver({ event: event }); - } - }, _this._seriesRightClickHandler = function (event) { - var onSeriesRightClick = _this.props.onSeriesRightClick; - - if (onSeriesRightClick) { - onSeriesRightClick({ event: event }); - } - }, _this._valueClickHandler = function (d, event) { - var _this$props = _this.props, - onValueClick = _this$props.onValueClick, - onSeriesClick = _this$props.onSeriesClick; - - if (onValueClick) { - onValueClick(d, { event: event }); - } - if (onSeriesClick) { - onSeriesClick({ event: event }); - } - }, _this._valueMouseOutHandler = function (d, event) { - var _this$props2 = _this.props, - onValueMouseOut = _this$props2.onValueMouseOut, - onSeriesMouseOut = _this$props2.onSeriesMouseOut; - - if (onValueMouseOut) { - onValueMouseOut(d, { event: event }); - } - if (onSeriesMouseOut) { - onSeriesMouseOut({ event: event }); - } - }, _this._valueMouseOverHandler = function (d, event) { - var _this$props3 = _this.props, - onValueMouseOver = _this$props3.onValueMouseOver, - onSeriesMouseOver = _this$props3.onSeriesMouseOver; - - if (onValueMouseOver) { - onValueMouseOver(d, { event: event }); - } - if (onSeriesMouseOver) { - onSeriesMouseOver({ event: event }); - } - }, _this._valueRightClickHandler = function (d, event) { - var _this$props4 = _this.props, - onValueRightClick = _this$props4.onValueRightClick, - onSeriesRightClick = _this$props4.onSeriesRightClick; - - if (onValueRightClick) { - onValueRightClick(d, { event: event }); - } - if (onSeriesRightClick) { - onSeriesRightClick({ event: event }); - } - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(AbstractSeries, [{ - key: 'onParentMouseMove', - value: function onParentMouseMove(event) { - var _props = this.props, - onNearestX = _props.onNearestX, - onNearestXY = _props.onNearestXY, - data = _props.data; - - if (!onNearestX && !onNearestXY || !data) { - return; - } - if (onNearestXY) { - this._handleNearestXY(event); - } else { - this._handleNearestX(event); - } - } - }, { - key: 'onParentTouchMove', - value: function onParentTouchMove(e) { - e.preventDefault(); - this.onParentMouseMove(e); - } - }, { - key: 'onParentTouchStart', - value: function onParentTouchStart(e) { - // prevent mouse event emulation - e.preventDefault(); - } - - /** - * Get the attr0 functor. - * @param {string} attr Attribute name. - * @returns {*} Functor. - * @private - */ - - }, { - key: '_getAttr0Functor', - value: function _getAttr0Functor(attr) { - return (0, _scalesUtils.getAttr0Functor)(this.props, attr); - } - - /** - * Get attribute functor. - * @param {string} attr Attribute name - * @returns {*} Functor. - * @protected - */ - - }, { - key: '_getAttributeFunctor', - value: function _getAttributeFunctor(attr) { - return (0, _scalesUtils.getAttributeFunctor)(this.props, attr); - } - - /** - * Get the attribute value if it is available. - * @param {string} attr Attribute name. - * @returns {*} Attribute value if available, fallback value or undefined - * otherwise. - * @protected - */ - - }, { - key: '_getAttributeValue', - value: function _getAttributeValue(attr) { - return (0, _scalesUtils.getAttributeValue)(this.props, attr); - } - - /** - * Get the scale object distance by the attribute from the list of properties. - * @param {string} attr Attribute name. - * @returns {number} Scale distance. - * @protected - */ - - }, { - key: '_getScaleDistance', - value: function _getScaleDistance(attr) { - var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(this.props, attr); - return scaleObject ? scaleObject.distance : 0; - } - }, { - key: '_getXYCoordinateInContainer', - value: function _getXYCoordinateInContainer(event) { - var _props2 = this.props, - _props2$marginTop = _props2.marginTop, - marginTop = _props2$marginTop === undefined ? 0 : _props2$marginTop, - _props2$marginLeft = _props2.marginLeft, - marginLeft = _props2$marginLeft === undefined ? 0 : _props2$marginLeft; - var evt = event.nativeEvent, - currentTarget = event.currentTarget; - - var rect = currentTarget.getBoundingClientRect(); - var x = evt.clientX; - var y = evt.clientY; - if (evt.type === 'touchmove') { - x = evt.touches[0].pageX; - y = evt.touches[0].pageY; - } - return { - x: x - rect.left - currentTarget.clientLeft - marginLeft, - y: y - rect.top - currentTarget.clientTop - marginTop - }; - } - }, { - key: '_handleNearestX', - value: function _handleNearestX(event) { - var _props3 = this.props, - onNearestX = _props3.onNearestX, - data = _props3.data; - - var minDistance = Number.POSITIVE_INFINITY; - var value = null; - var valueIndex = null; - - var coordinate = this._getXYCoordinateInContainer(event); - var xScaleFn = this._getAttributeFunctor('x'); - - data.forEach(function (item, i) { - var currentCoordinate = xScaleFn(item); - var newDistance = Math.abs(coordinate.x - currentCoordinate); - if (newDistance < minDistance) { - minDistance = newDistance; - value = item; - valueIndex = i; - } - }); - if (!value) { - return; - } - onNearestX(value, { - innerX: xScaleFn(value), - index: valueIndex, - event: event.nativeEvent - }); - } - }, { - key: '_handleNearestXY', - value: function _handleNearestXY(event) { - var _props4 = this.props, - onNearestXY = _props4.onNearestXY, - data = _props4.data; - - - var coordinate = this._getXYCoordinateInContainer(event); - var xScaleFn = this._getAttributeFunctor('x'); - var yScaleFn = this._getAttributeFunctor('y'); - - // Create a voronoi with each node center points - var voronoiInstance = (0, _d3Voronoi.voronoi)().x(xScaleFn).y(yScaleFn); - - var foundPoint = voronoiInstance(data).find(coordinate.x, coordinate.y); - var value = foundPoint.data; - - if (!value) { - return; - } - onNearestXY(value, { - innerX: foundPoint.x, - innerY: foundPoint.y, - index: foundPoint.index, - event: event.nativeEvent - }); - } - - /** - * Click handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse out handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse over handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Right Click handler for the entire series. - * @param {Object} event Event. - * @protected - */ - - - /** - * Click handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse out handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - - /** - * Mouse over handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - - /** - * Right Click handler for the specific series' value. - * @param {Object} d Value object - * @param {Object} event Event. - * @protected - */ - - }], [{ - key: 'getParentConfig', - - /** - * Get a default config for the parent. - * @returns {Object} Empty config. - */ - value: function getParentConfig() { - return {}; - } - - /** - * Tells the rest of the world that it requires SVG to work. - * @returns {boolean} Result. - */ - - }, { - key: 'requiresSVG', - get: function get() { - return true; - } - }]); - - return AbstractSeries; -}(_react.PureComponent); - -AbstractSeries.displayName = 'AbstractSeries'; -AbstractSeries.propTypes = propTypes; -AbstractSeries.defaultProps = defaultProps; - -exports.default = AbstractSeries; \ No newline at end of file diff --git a/dist/plot/series/arc-series.js b/dist/plot/series/arc-series.js deleted file mode 100644 index 465cf5a91..000000000 --- a/dist/plot/series/arc-series.js +++ /dev/null @@ -1,279 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _d3Shape = require('d3-shape'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _scalesUtils = require('../../utils/scales-utils'); - -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; } - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--arc'; -var ATTRIBUTES = ['radius', 'angle']; - -var defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - center: { x: 0, y: 0 }, - arcClassName: '', - className: '', - style: {}, - padAngle: 0 -}); - -/** - * Prepare the internal representation of row for real use. - * This is necessary because d3 insists on starting at 12 oclock and moving - * clockwise, rather than starting at 3 oclock and moving counter clockwise - * as one might expect from polar - * @param {Object} row - coordinate object to be modifed - * @return {Object} angle corrected object - */ -function modifyRow(row) { - var radius = row.radius, - angle = row.angle, - angle0 = row.angle0; - - var truedAngle = -1 * angle + Math.PI / 2; - var truedAngle0 = -1 * angle0 + Math.PI / 2; - return _extends({}, row, { - x: radius * Math.cos(truedAngle), - y: radius * Math.sin(truedAngle), - angle: truedAngle, - angle0: truedAngle0 - }); -} - -var ArcSeries = function (_AbstractSeries) { - _inherits(ArcSeries, _AbstractSeries); - - function ArcSeries(props) { - _classCallCheck(this, ArcSeries); - - var _this = _possibleConstructorReturn(this, (ArcSeries.__proto__ || Object.getPrototypeOf(ArcSeries)).call(this, props)); - - var scaleProps = _this._getAllScaleProps(props); - _this.state = { scaleProps: scaleProps }; - return _this; - } - - _createClass(ArcSeries, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - this.setState({ scaleProps: this._getAllScaleProps(nextProps) }); - } - - /** - * Get the map of scales from the props. - * @param {Object} props Props. - * @param {Array} data Array of all data. - * @returns {Object} Map of scales. - * @private - */ - - }, { - key: '_getAllScaleProps', - value: function _getAllScaleProps(props) { - var defaultScaleProps = this._getDefaultScaleProps(props); - var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); - var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, userScaleProps), props.data, ATTRIBUTES); - - return _extends({}, defaultScaleProps, userScaleProps, missingScaleProps); - } - - /** - * Get the list of scale-related settings that should be applied by default. - * @param {Object} props Object of props. - * @returns {Object} Defaults. - * @private - */ - - }, { - key: '_getDefaultScaleProps', - value: function _getDefaultScaleProps(props) { - var innerWidth = props.innerWidth, - innerHeight = props.innerHeight; - - var radius = Math.min(innerWidth / 2, innerHeight / 2); - return { - radiusRange: [0, radius], - _radiusValue: radius, - angleType: 'literal' - }; - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - arcClassName = _props.arcClassName, - animation = _props.animation, - className = _props.className, - center = _props.center, - data = _props.data, - disableSeries = _props.disableSeries, - hideSeries = _props.hideSeries, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - padAngle = _props.padAngle, - style = _props.style; - - - if (!data) { - return null; - } - - if (animation) { - var cloneData = data.map(function (d) { - return _extends({}, d); - }); - return _react2.default.createElement( - 'g', - { className: 'rv-xy-plot__series--arc__animation-wrapper' }, - _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { - animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS, - data: cloneData - }), - _react2.default.createElement(ArcSeries, _extends({}, this.props, { - animation: null, - disableSeries: true, - data: cloneData - })) - ), - _react2.default.createElement(ArcSeries, _extends({}, this.props, { - animation: null, - hideSeries: true, - style: { stroke: 'red' } - })) - ); - } - - var scaleProps = this.state.scaleProps; - var radiusDomain = scaleProps.radiusDomain; - // need to generate our own functors as abstract series doesnt have anythign for us - - var radius = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'radius'); - var radius0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'radius'); - var angle = (0, _scalesUtils.getAttributeFunctor)(scaleProps, 'angle'); - var angle0 = (0, _scalesUtils.getAttr0Functor)(scaleProps, 'angle'); - // but it does have good color support! - var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var opacity = this._getAttributeFunctor('opacity'); - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - onMouseOver: this._seriesMouseOverHandler, - onMouseOut: this._seriesMouseOutHandler, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - opacity: hideSeries ? 0 : 1, - pointerEvents: disableSeries ? 'none' : 'all', - transform: 'translate(' + (marginLeft + x(center)) + ',' + (marginTop + y(center)) + ')' - }, - data.map(function (row, i) { - var noRadius = radiusDomain[1] === radiusDomain[0]; - var arcArg = { - innerRadius: noRadius ? 0 : radius0(row), - outerRadius: radius(row), - startAngle: angle0(row) || 0, - endAngle: angle(row) - }; - var arcedData = (0, _d3Shape.arc)().padAngle(padAngle); - var rowStyle = row.style || {}; - var rowClassName = row.className || ''; - return _react2.default.createElement('path', { - style: _extends({ - opacity: opacity && opacity(row), - stroke: stroke && stroke(row), - fill: fill && fill(row) - }, style, rowStyle), - onClick: function onClick(e) { - return _this2._valueClickHandler(modifyRow(row), e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(modifyRow(row), e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(modifyRow(row), e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(modifyRow(row), e); - }, - key: i, - className: predefinedClassName + '-path ' + arcClassName + ' ' + rowClassName, - d: arcedData(arcArg) - }); - }) - ); - } - }]); - - return ArcSeries; -}(_abstractSeries2.default); - -ArcSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, (0, _scalesUtils.getScalePropTypesByAttribute)('radius'), (0, _scalesUtils.getScalePropTypesByAttribute)('angle'), { - center: _propTypes2.default.shape({ - x: _propTypes2.default.number, - y: _propTypes2.default.number - }), - arcClassName: _propTypes2.default.string, - padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) -}); -ArcSeries.defaultProps = defaultProps; -ArcSeries.displayName = 'ArcSeries'; - -exports.default = ArcSeries; \ No newline at end of file diff --git a/dist/plot/series/area-series.js b/dist/plot/series/area-series.js deleted file mode 100644 index 10b6f12b0..000000000 --- a/dist/plot/series/area-series.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Shape = require('d3-shape'); - -var d3Shape = _interopRequireWildcard(_d3Shape); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _theme = require('../../theme'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _reactUtils = require('../../utils/react-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; - -var AreaSeries = function (_AbstractSeries) { - _inherits(AreaSeries, _AbstractSeries); - - function AreaSeries() { - _classCallCheck(this, AreaSeries); - - return _possibleConstructorReturn(this, (AreaSeries.__proto__ || Object.getPrototypeOf(AreaSeries)).apply(this, arguments)); - } - - _createClass(AreaSeries, [{ - key: '_renderArea', - value: function _renderArea(data, x, y0, y, curve, getNull) { - var area = d3Shape.area(); - if (curve !== null) { - if (typeof curve === 'string' && d3Shape[curve]) { - area = area.curve(d3Shape[curve]); - } else if (typeof curve === 'function') { - area = area.curve(curve); - } - } - area = area.defined(getNull); - area = area.x(x).y0(y0).y1(y); - return area(data); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - curve = _props.curve, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - - if (this.props.nullAccessor) { - (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); - } - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(AreaSeries, _extends({}, this.props, { animation: null })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var y0 = this._getAttr0Functor('y'); - var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); - var fill = this._getAttributeValue('fill') || this._getAttributeValue('color'); - var newOpacity = this._getAttributeValue('opacity'); - var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; - var getNull = this.props.nullAccessor || this.props.getNull; - var d = this._renderArea(data, x, y0, y, curve, getNull); - - return _react2.default.createElement('path', { - d: d, - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')', - onMouseOver: this._seriesMouseOverHandler, - onMouseOut: this._seriesMouseOutHandler, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - style: _extends({ - opacity: opacity, - stroke: stroke, - fill: fill - }, style) - }); - } - }]); - - return AreaSeries; -}(_abstractSeries2.default); - -AreaSeries.displayName = 'AreaSeries'; -AreaSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - getNull: _propTypes2.default.func -}); -AreaSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - getNull: function getNull() { - return true; - } -}); - -exports.default = AreaSeries; \ No newline at end of file diff --git a/dist/plot/series/bar-series-canvas.js b/dist/plot/series/bar-series-canvas.js deleted file mode 100644 index 3ede5b8fe..000000000 --- a/dist/plot/series/bar-series-canvas.js +++ /dev/null @@ -1,161 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Color = require('d3-color'); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -function getScaleDistance(props, attr) { - var scaleObject = (0, _scalesUtils.getScaleObjectFromProps)(props, attr); - return scaleObject ? scaleObject.distance : 0; -} - -var BarSeriesCanvas = function (_AbstractSeries) { - _inherits(BarSeriesCanvas, _AbstractSeries); - - function BarSeriesCanvas() { - _classCallCheck(this, BarSeriesCanvas); - - return _possibleConstructorReturn(this, (BarSeriesCanvas.__proto__ || Object.getPrototypeOf(BarSeriesCanvas)).apply(this, arguments)); - } - - _createClass(BarSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var data = props.data, - linePosAttr = props.linePosAttr, - lineSizeAttr = props.lineSizeAttr, - valuePosAttr = props.valuePosAttr, - marginTop = props.marginTop, - marginBottom = props.marginBottom; - - if (!data || data.length === 0) { - return; - } - - var distance = getScaleDistance(props, linePosAttr); - var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); - var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); - var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); - var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); - - var halfSpace = distance / 2 * 0.85; - // totalSpaceAvailable is the space we have available to draw all the - // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) - var totalSpaceAvailable = halfSpace * 2; - - var _getStackParams = (0, _seriesUtils.getStackParams)(props), - sameTypeTotal = _getStackParams.sameTypeTotal, - sameTypeIndex = _getStackParams.sameTypeIndex; - - data.forEach(function (row) { - var totalSpaceCenter = line(row); - // totalSpaceStartingPoint is the first pixel were we can start drawing - var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; - - // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal - var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; - // lineSize is the space we have available to draw sameTypeIndex bar - var lineSize = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; - - var fillColor = (0, _d3Color.rgb)(fill(row)); - var strokeColor = (0, _d3Color.rgb)(stroke(row)); - var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; - - // linePos is the first pixel were we can start drawing sameTypeIndex bar - var linePos = totalSpaceStartingPoint + lineSize * sameTypeIndex + sameTypeIndex; - var valuePos = Math.min(value0(row), value(row)); - var x = valuePosAttr === 'x' ? valuePos : linePos; - var y = valuePosAttr === 'y' ? valuePos : linePos; - - var valueSize = Math.abs(-value0(row) + value(row)); - var height = lineSizeAttr === 'height' ? lineSize : valueSize; - var width = lineSizeAttr === 'width' ? lineSize : valueSize; - - ctx.beginPath(); - ctx.rect(x + marginBottom, y + marginTop, width, height); - ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; - ctx.fill(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; - ctx.stroke(); - }); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return BarSeriesCanvas; -}(_abstractSeries2.default); - -BarSeriesCanvas.displayName = 'BarSeriesCanvas'; -BarSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - linePosAttr: _propTypes2.default.string.isRequired, - valuePosAttr: _propTypes2.default.string.isRequired, - lineSizeAttr: _propTypes2.default.string.isRequired, - valueSizeAttr: _propTypes2.default.string.isRequired -}); - -BarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = BarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/bar-series.js b/dist/plot/series/bar-series.js deleted file mode 100644 index 2c38ee25f..000000000 --- a/dist/plot/series/bar-series.js +++ /dev/null @@ -1,180 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--bar'; - -var BarSeries = function (_AbstractSeries) { - _inherits(BarSeries, _AbstractSeries); - - function BarSeries() { - _classCallCheck(this, BarSeries); - - return _possibleConstructorReturn(this, (BarSeries.__proto__ || Object.getPrototypeOf(BarSeries)).apply(this, arguments)); - } - - _createClass(BarSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - linePosAttr = _props.linePosAttr, - lineSizeAttr = _props.lineSizeAttr, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style, - valuePosAttr = _props.valuePosAttr, - valueSizeAttr = _props.valueSizeAttr, - barWidth = _props.barWidth; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(BarSeries, _extends({}, this.props, { animation: null })) - ); - } - - var _getStackParams = (0, _seriesUtils.getStackParams)(this.props), - sameTypeTotal = _getStackParams.sameTypeTotal, - sameTypeIndex = _getStackParams.sameTypeIndex; - - var distance = this._getScaleDistance(linePosAttr); - var lineFunctor = this._getAttributeFunctor(linePosAttr); - var valueFunctor = this._getAttributeFunctor(valuePosAttr); - var value0Functor = this._getAttr0Functor(valuePosAttr); - var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var opacityFunctor = this._getAttributeFunctor('opacity'); - - var halfSpace = distance / 2 * barWidth; - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - var _attrs; - - // totalSpaceAvailable is the space we have available to draw all the - // bars of a same 'linePosAttr' value (a.k.a. sameTypeTotal) - var totalSpaceAvailable = halfSpace * 2; - var totalSpaceCenter = lineFunctor(d); - // totalSpaceStartingPoint is the first pixel were we can start drawing - var totalSpaceStartingPoint = totalSpaceCenter - halfSpace; - // spaceTakenByInterBarsPixels has the overhead space consumed by each bar of sameTypeTotal - var spaceTakenByInterBarsPixels = (sameTypeTotal - 1) / sameTypeTotal; - // spacePerBar is the space we have available to draw sameTypeIndex bar - var spacePerBar = totalSpaceAvailable / sameTypeTotal - spaceTakenByInterBarsPixels; - // barStartingPoint is the first pixel were we can start drawing sameTypeIndex bar - var barStartingPoint = totalSpaceStartingPoint + spacePerBar * sameTypeIndex + sameTypeIndex; - - var attrs = (_attrs = { - style: _extends({ - opacity: opacityFunctor && opacityFunctor(d), - stroke: strokeFunctor && strokeFunctor(d), - fill: fillFunctor && fillFunctor(d) - }, style) - }, _defineProperty(_attrs, linePosAttr, barStartingPoint), _defineProperty(_attrs, lineSizeAttr, spacePerBar), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { - return _this2._valueClickHandler(d, e); - }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - }), _defineProperty(_attrs, 'key', i), _attrs); - return _react2.default.createElement('rect', attrs); - }) - ); - } - }], [{ - key: 'propTypes', - get: function get() { - return _extends({}, _abstractSeries2.default.propTypes, { - linePosAttr: _propTypes2.default.string, - valuePosAttr: _propTypes2.default.string, - lineSizeAttr: _propTypes2.default.string, - valueSizeAttr: _propTypes2.default.string, - cluster: _propTypes2.default.string, - barWidth: _propTypes2.default.number - }); - } - }, { - key: 'defaultProps', - get: function get() { - return { - barWidth: 0.85 - }; - } - }]); - - return BarSeries; -}(_abstractSeries2.default); - -BarSeries.displayName = 'BarSeries'; - -exports.default = BarSeries; \ No newline at end of file diff --git a/dist/plot/series/canvas-wrapper.js b/dist/plot/series/canvas-wrapper.js deleted file mode 100644 index 5211e2bd7..000000000 --- a/dist/plot/series/canvas-wrapper.js +++ /dev/null @@ -1,256 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Interpolate = require('d3-interpolate'); - -var _animation = require('../../animation'); - -var _seriesUtils = require('../../utils/series-utils'); - -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; } - -var MAX_DRAWS = 30; - -/** - * Draw loop draws each of the layers until it should draw more - * @param {CanvasContext} ctx - the context where the drawing will take place - * @param {Number} height - height of the canvas - * @param {Number} width - width of the canvas - * @param {Array} layers - the layer objects to render - */ -function engageDrawLoop(ctx, height, width, layers) { - var drawIteration = 0; - // using setInterval because request animation frame goes too fast - var drawCycle = setInterval(function () { - if (!ctx) { - clearInterval(drawCycle); - return; - } - drawLayers(ctx, height, width, layers, drawIteration); - if (drawIteration > MAX_DRAWS) { - clearInterval(drawCycle); - } - drawIteration += 1; - }, 1); -} - -/** - * Loops across each of the layers to be drawn and draws them - * @param {CanvasContext} ctx - the context where the drawing will take place - * @param {Number} height - height of the canvas - * @param {Number} width - width of the canvas - * @param {Array} layers - the layer objects to render - * @param {Number} drawIteration - width of the canvas - */ -function drawLayers(ctx, height, width, layers, drawIteration) { - ctx.clearRect(0, 0, width, height); - layers.forEach(function (layer) { - var interpolator = layer.interpolator, - newProps = layer.newProps, - animation = layer.animation; - // return an empty object if dont need to be animating - - var interpolatedProps = animation ? interpolator ? interpolator(drawIteration / MAX_DRAWS) : interpolator : function () { - return {}; - }; - layer.renderLayer(_extends({}, newProps, interpolatedProps), ctx); - }); -} - -/** - * Build an array of layer of objects the contain the method for drawing each series - * as well as an interpolar (specifically a d3-interpolate interpolator) - * @param {Object} newChildren the new children to be rendered. - * @param {Object} oldChildren the old children to be rendered. - * @returns {Array} Object for rendering - */ -function buildLayers(newChildren, oldChildren) { - return newChildren.map(function (child, index) { - var oldProps = oldChildren[index] ? oldChildren[index].props : {}; - var newProps = child.props; - - var oldAnimatedProps = (0, _animation.extractAnimatedPropValues)(_extends({}, oldProps, { - animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS - })); - var newAnimatedProps = newProps ? (0, _animation.extractAnimatedPropValues)(_extends({}, newProps, { - animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS - })) : null; - var interpolator = (0, _d3Interpolate.interpolate)(oldAnimatedProps, newAnimatedProps); - - return { - renderLayer: child.type.renderLayer, - newProps: child.props, - animation: child.props.animation, - interpolator: interpolator - }; - }); -} - -var CanvasWrapper = function (_Component) { - _inherits(CanvasWrapper, _Component); - - function CanvasWrapper() { - _classCallCheck(this, CanvasWrapper); - - return _possibleConstructorReturn(this, (CanvasWrapper.__proto__ || Object.getPrototypeOf(CanvasWrapper)).apply(this, arguments)); - } - - _createClass(CanvasWrapper, [{ - key: 'componentDidMount', - value: function componentDidMount() { - var ctx = this.canvas.getContext('2d'); - if (!ctx) { - return; - } - var pixelRatio = this.props.pixelRatio; - - if (!ctx) { - return; - } - ctx.scale(pixelRatio, pixelRatio); - - this.drawChildren(null, this.props, ctx); - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate(oldProps) { - this.drawChildren(oldProps, this.props, this.canvas.getContext('2d')); - } - - /** - * Check that we can and should be animating, then kick off animations as apporpriate - * @param {Object} newProps the new props to be interpolated to - * @param {Object} oldProps the old props to be interpolated against - * @param {DomRef} ctx the canvas context to be drawn on. - * @returns {Array} Object for rendering - */ - - }, { - key: 'drawChildren', - value: function drawChildren(oldProps, newProps, ctx) { - var children = newProps.children, - innerHeight = newProps.innerHeight, - innerWidth = newProps.innerWidth, - marginBottom = newProps.marginBottom, - marginLeft = newProps.marginLeft, - marginRight = newProps.marginRight, - marginTop = newProps.marginTop; - - if (!ctx) { - return; - } - - var childrenShouldAnimate = children.find(function (child) { - return child.props.animation; - }); - - var height = innerHeight + marginTop + marginBottom; - var width = innerWidth + marginLeft + marginRight; - var layers = buildLayers(newProps.children, oldProps ? oldProps.children : []); - // if we don't need to be animating, dont! cut short - if (!childrenShouldAnimate) { - drawLayers(ctx, height, width, layers); - return; - } - - engageDrawLoop(ctx, height, width, layers); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginBottom = _props.marginBottom, - marginLeft = _props.marginLeft, - marginRight = _props.marginRight, - marginTop = _props.marginTop, - pixelRatio = _props.pixelRatio; - - - var height = innerHeight + marginTop + marginBottom; - var width = innerWidth + marginLeft + marginRight; - - return _react2.default.createElement( - 'div', - { style: { left: 0, top: 0 }, className: 'rv-xy-canvas' }, - _react2.default.createElement('canvas', { - className: 'rv-xy-canvas-element', - height: height * pixelRatio, - width: width * pixelRatio, - style: { - height: height + 'px', - width: width + 'px' - }, - ref: function ref(_ref) { - return _this2.canvas = _ref; - } - }), - this.props.children - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return { - pixelRatio: window && window.devicePixelRatio || 1 - }; - } - }]); - - return CanvasWrapper; -}(_react.Component); - -CanvasWrapper.displayName = 'CanvasWrapper'; -CanvasWrapper.propTypes = { - marginBottom: _propTypes2.default.number.isRequired, - marginLeft: _propTypes2.default.number.isRequired, - marginRight: _propTypes2.default.number.isRequired, - marginTop: _propTypes2.default.number.isRequired, - innerHeight: _propTypes2.default.number.isRequired, - innerWidth: _propTypes2.default.number.isRequired, - pixelRatio: _propTypes2.default.number.isRequired -}; - -exports.default = CanvasWrapper; \ No newline at end of file diff --git a/dist/plot/series/contour-series.js b/dist/plot/series/contour-series.js deleted file mode 100644 index 030567d86..000000000 --- a/dist/plot/series/contour-series.js +++ /dev/null @@ -1,164 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Contour = require('d3-contour'); - -var _d3Geo = require('d3-geo'); - -var _d3Scale = require('d3-scale'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _theme = require('../../theme'); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--contour'; - -function getDomain(data) { - return data.reduce(function (acc, row) { - return { - min: Math.min(acc.min, row.value), - max: Math.max(acc.max, row.value) - }; - }, { min: Infinity, max: -Infinity }); -} - -var ContourSeries = function (_AbstractSeries) { - _inherits(ContourSeries, _AbstractSeries); - - function ContourSeries() { - _classCallCheck(this, ContourSeries); - - return _possibleConstructorReturn(this, (ContourSeries.__proto__ || Object.getPrototypeOf(ContourSeries)).apply(this, arguments)); - } - - _createClass(ContourSeries, [{ - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - bandwidth = _props.bandwidth, - className = _props.className, - colorRange = _props.colorRange, - data = _props.data, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - - if (!data || !innerWidth || !innerHeight) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(ContourSeries, _extends({}, this.props, { animation: null })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - var contouredData = (0, _d3Contour.contourDensity)().x(function (d) { - return x(d); - }).y(function (d) { - return y(d); - }).size([innerWidth, innerHeight]).bandwidth(bandwidth)(data); - - var geo = (0, _d3Geo.geoPath)(); - - var _getDomain = getDomain(contouredData), - min = _getDomain.min, - max = _getDomain.max; - - var colorScale = (0, _d3Scale.scaleLinear)().domain([min, max]).range(colorRange || _theme.CONTINUOUS_COLOR_RANGE); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - contouredData.map(function (polygon, index) { - return _react2.default.createElement('path', { - className: 'rv-xy-plot__series--contour-line', - key: 'rv-xy-plot__series--contour-line-' + index, - d: geo(polygon), - style: _extends({ - fill: colorScale(polygon.value) - }, style) - }); - }) - ); - } - }]); - - return ContourSeries; -}(_abstractSeries2.default); - -ContourSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - animation: _propTypes2.default.bool, - bandwidth: _propTypes2.default.number, - className: _propTypes2.default.string, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - style: _propTypes2.default.object -}); - -ContourSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - bandwidth: 40, - style: {} -}); - -exports.default = ContourSeries; \ No newline at end of file diff --git a/dist/plot/series/custom-svg-series.js b/dist/plot/series/custom-svg-series.js deleted file mode 100644 index 1dfedfcb2..000000000 --- a/dist/plot/series/custom-svg-series.js +++ /dev/null @@ -1,237 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -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; } - -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); } } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--custom-svg-wrapper'; - -var DEFAULT_STYLE = { - stroke: 'blue', - fill: 'blue' -}; - -function predefinedComponents(type) { - var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; - var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_STYLE; - - switch (type) { - case 'diamond': - return _react2.default.createElement('polygon', { - style: style, - points: '0 0 ' + size / 2 + ' ' + size / 2 + ' 0 ' + size + ' ' + -size / 2 + ' ' + size / 2 + ' 0 0' - }); - case 'star': - var starPoints = [].concat(_toConsumableArray(new Array(5))).map(function (c, index) { - var angle = index / 5 * Math.PI * 2; - var innerAngle = angle + Math.PI / 10; - var outerAngle = angle - Math.PI / 10; - // ratio of inner polygon to outer polgyon - var innerRadius = size / 2.61; - return '\n ' + Math.cos(outerAngle) * size + ' ' + Math.sin(outerAngle) * size + '\n ' + Math.cos(innerAngle) * innerRadius + ' ' + Math.sin(innerAngle) * innerRadius + '\n '; - }).join(' '); - return _react2.default.createElement('polygon', { - points: starPoints, - x: '0', - y: '0', - height: size, - width: size, - style: style - }); - case 'square': - return _react2.default.createElement('rect', { - x: '' + -size / 2, - y: '' + -size / 2, - height: size, - width: size, - style: style - }); - default: - case 'circle': - return _react2.default.createElement('circle', { cx: '0', cy: '0', r: size / 2, style: style }); - } -} - -function getInnerComponent(_ref) { - var customComponent = _ref.customComponent, - defaultType = _ref.defaultType, - positionInPixels = _ref.positionInPixels, - positionFunctions = _ref.positionFunctions, - style = _ref.style, - propsSize = _ref.propsSize; - var size = customComponent.size; - - var aggStyle = _extends({}, style, customComponent.style || {}); - var innerComponent = customComponent.customComponent; - if (!innerComponent && typeof defaultType === 'string') { - return predefinedComponents(defaultType, size || propsSize, aggStyle); - } - // if default component is a function - if (!innerComponent) { - return defaultType(customComponent, positionInPixels, aggStyle); - } - if (typeof innerComponent === 'string') { - return predefinedComponents(innerComponent || defaultType, size, aggStyle); - } - // if inner component is a function - return innerComponent(customComponent, positionInPixels, aggStyle); -} - -var CustomSVGSeries = function (_AbstractSeries) { - _inherits(CustomSVGSeries, _AbstractSeries); - - function CustomSVGSeries() { - _classCallCheck(this, CustomSVGSeries); - - return _possibleConstructorReturn(this, (CustomSVGSeries.__proto__ || Object.getPrototypeOf(CustomSVGSeries)).apply(this, arguments)); - } - - _createClass(CustomSVGSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - customComponent = _props.customComponent, - data = _props.data, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style, - size = _props.size; - - - if (!data || !innerWidth || !innerHeight) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(CustomSVGSeries, _extends({}, this.props, { animation: false })) - ); - } - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var contents = data.map(function (seriesComponent, index) { - var positionInPixels = { - x: x({ x: seriesComponent.x }), - y: y({ y: seriesComponent.y }) - }; - var innerComponent = getInnerComponent({ - customComponent: seriesComponent, - positionInPixels: positionInPixels, - defaultType: customComponent, - positionFunctions: { x: x, y: y }, - style: style, - propsSize: size - }); - return _react2.default.createElement( - 'g', - { - className: 'rv-xy-plot__series--custom-svg', - key: 'rv-xy-plot__series--custom-svg-' + index, - transform: 'translate(' + positionInPixels.x + ',' + positionInPixels.y + ')', - onMouseEnter: function onMouseEnter(e) { - return _this2._valueMouseOverHandler(seriesComponent, e); - }, - onMouseLeave: function onMouseLeave(e) { - return _this2._valueMouseOutHandler(seriesComponent, e); - } - }, - innerComponent - ); - }); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - contents - ); - } - }]); - - return CustomSVGSeries; -}(_abstractSeries2.default); - -CustomSVGSeries.propTypes = { - animation: _propTypes2.default.bool, - className: _propTypes2.default.string, - customComponent: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), - data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired, - y: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired - })).isRequired, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - style: _propTypes2.default.object, - size: _propTypes2.default.number, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func -}; - -CustomSVGSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - animation: false, - customComponent: 'circle', - style: {}, - size: 2 -}); - -exports.default = CustomSVGSeries; \ No newline at end of file diff --git a/dist/plot/series/heatmap-series.js b/dist/plot/series/heatmap-series.js deleted file mode 100644 index 69c142265..000000000 --- a/dist/plot/series/heatmap-series.js +++ /dev/null @@ -1,147 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--heatmap'; - -var HeatmapSeries = function (_AbstractSeries) { - _inherits(HeatmapSeries, _AbstractSeries); - - function HeatmapSeries() { - _classCallCheck(this, HeatmapSeries); - - return _possibleConstructorReturn(this, (HeatmapSeries.__proto__ || Object.getPrototypeOf(HeatmapSeries)).apply(this, arguments)); - } - - _createClass(HeatmapSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - if (!data) { - return null; - } - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(HeatmapSeries, _extends({}, this.props, { animation: null })) - ); - } - - var _rectStyle$style = _extends({ rectStyle: {} }, style), - rectStyle = _rectStyle$style.rectStyle; - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var opacity = this._getAttributeFunctor('opacity'); - var fill = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var stroke = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var xDistance = this._getScaleDistance('x'); - var yDistance = this._getScaleDistance('y'); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - var attrs = _extends({ - style: _extends({ - stroke: stroke && stroke(d), - fill: fill && fill(d), - opacity: opacity && opacity(d) - }, style) - }, rectStyle, { - x: x(d) - xDistance / 2, - y: y(d) - yDistance / 2, - width: xDistance, - height: yDistance, - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - } - }); - return _react2.default.createElement('rect', attrs); - }) - ); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'x' || attr === 'y'; - return { isDomainAdjustmentNeeded: isDomainAdjustmentNeeded }; - } - }]); - - return HeatmapSeries; -}(_abstractSeries2.default); - -HeatmapSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -HeatmapSeries.displayName = 'HeatmapSeries'; - -exports.default = HeatmapSeries; \ No newline at end of file diff --git a/dist/plot/series/hexbin-series.js b/dist/plot/series/hexbin-series.js deleted file mode 100644 index 2f2cadcf9..000000000 --- a/dist/plot/series/hexbin-series.js +++ /dev/null @@ -1,180 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _d3Hexbin = require('d3-hexbin'); - -var _d3Scale = require('d3-scale'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _theme = require('../../theme'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } - -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); } } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--hexbin'; - -function getColorDomain(_ref, hexes) { - var countDomain = _ref.countDomain; - - if (countDomain) { - return countDomain; - } - return [0, Math.max.apply(Math, _toConsumableArray(hexes.map(function (row) { - return row.length; - })))]; -} - -var HexbinSeries = function (_AbstractSeries) { - _inherits(HexbinSeries, _AbstractSeries); - - function HexbinSeries() { - _classCallCheck(this, HexbinSeries); - - return _possibleConstructorReturn(this, (HexbinSeries.__proto__ || Object.getPrototypeOf(HexbinSeries)).apply(this, arguments)); - } - - _createClass(HexbinSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - colorRange = _props.colorRange, - data = _props.data, - innerHeight = _props.innerHeight, - innerWidth = _props.innerWidth, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - radius = _props.radius, - sizeHexagonsWithCount = _props.sizeHexagonsWithCount, - style = _props.style, - xOffset = _props.xOffset, - yOffset = _props.yOffset; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(HexbinSeries, _extends({}, this.props, { animation: null })) - ); - } - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - - var hex = (0, _d3Hexbin.hexbin)().x(function (d) { - return x(d) + xOffset; - }).y(function (d) { - return y(d) + yOffset; - }).radius(radius).size([innerWidth, innerHeight]); - - var hexagonPath = hex.hexagon(); - var hexes = hex(data); - - var countDomain = getColorDomain(this.props, hexes); - var color = (0, _d3Scale.scaleLinear)().domain(countDomain).range(colorRange); - var size = (0, _d3Scale.scaleLinear)().domain(countDomain).range([0, radius]); - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - hexes.map(function (d, i) { - var attrs = { - style: style, - d: sizeHexagonsWithCount ? hex.hexagon(size(d.length)) : hexagonPath, - fill: color(d.length), - transform: 'translate(' + d.x + ', ' + d.y + ')', - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - } - }; - return _react2.default.createElement('path', attrs); - }) - ); - } - }]); - - return HexbinSeries; -}(_abstractSeries2.default); - -HexbinSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - radius: _propTypes2.default.number -}); - -HexbinSeries.defaultProps = { - radius: 20, - colorRange: _theme.CONTINUOUS_COLOR_RANGE, - xOffset: 0, - yOffset: 0 -}; - -HexbinSeries.displayName = 'HexbinSeries'; - -exports.default = HexbinSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series-canvas.js b/dist/plot/series/horizontal-bar-series-canvas.js deleted file mode 100644 index fa817cc24..000000000 --- a/dist/plot/series/horizontal-bar-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeriesCanvas = require('./bar-series-canvas'); - -var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalBarSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); - - function HorizontalBarSeriesCanvas() { - _classCallCheck(this, HorizontalBarSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalBarSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'y'; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _barSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalBarSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; -HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-bar-series.js b/dist/plot/series/horizontal-bar-series.js deleted file mode 100644 index ef65b02da..000000000 --- a/dist/plot/series/horizontal-bar-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeries = require('./bar-series'); - -var _barSeries2 = _interopRequireDefault(_barSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalBarSeries = function (_AbstractSeries) { - _inherits(HorizontalBarSeries, _AbstractSeries); - - function HorizontalBarSeries() { - _classCallCheck(this, HorizontalBarSeries); - - return _possibleConstructorReturn(this, (HorizontalBarSeries.__proto__ || Object.getPrototypeOf(HorizontalBarSeries)).apply(this, arguments)); - } - - _createClass(HorizontalBarSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'y'; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return HorizontalBarSeries; -}(_abstractSeries2.default); - -HorizontalBarSeries.displayName = 'HorizontalBarSeries'; - -exports.default = HorizontalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series-canvas.js b/dist/plot/series/horizontal-rect-series-canvas.js deleted file mode 100644 index c275a349d..000000000 --- a/dist/plot/series/horizontal-rect-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeriesCanvas = require('./rect-series-canvas'); - -var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalRectSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); - - function HorizontalRectSeriesCanvas() { - _classCallCheck(this, HorizontalRectSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalRectSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalRectSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; -HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/horizontal-rect-series.js b/dist/plot/series/horizontal-rect-series.js deleted file mode 100644 index 014390674..000000000 --- a/dist/plot/series/horizontal-rect-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeries = require('./rect-series'); - -var _rectSeries2 = _interopRequireDefault(_rectSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalRectSeries = function (_AbstractSeries) { - _inherits(HorizontalRectSeries, _AbstractSeries); - - function HorizontalRectSeries() { - _classCallCheck(this, HorizontalRectSeries); - - return _possibleConstructorReturn(this, (HorizontalRectSeries.__proto__ || Object.getPrototypeOf(HorizontalRectSeries)).apply(this, arguments)); - } - - _createClass(HorizontalRectSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { - linePosAttr: 'y', - valuePosAttr: 'x', - lineSizeAttr: 'height', - valueSizeAttr: 'width' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'x'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return HorizontalRectSeries; -}(_abstractSeries2.default); - -HorizontalRectSeries.displayName = 'HorizontalRectSeries'; - -exports.default = HorizontalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/label-series.js b/dist/plot/series/label-series.js deleted file mode 100644 index 5b2da150d..000000000 --- a/dist/plot/series/label-series.js +++ /dev/null @@ -1,200 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--label'; - -var getTextAnchor = function getTextAnchor(labelAnchorX, leftOfMiddle) { - return labelAnchorX ? labelAnchorX : leftOfMiddle ? 'start' : 'end'; -}; -var getDominantBaseline = function getDominantBaseline(labelAnchorY, aboveMiddle) { - return labelAnchorY ? labelAnchorY : aboveMiddle ? 'text-before-edge' : 'text-after-edge'; -}; - -var LabelSeries = function (_AbstractSeries) { - _inherits(LabelSeries, _AbstractSeries); - - function LabelSeries() { - _classCallCheck(this, LabelSeries); - - return _possibleConstructorReturn(this, (LabelSeries.__proto__ || Object.getPrototypeOf(LabelSeries)).apply(this, arguments)); - } - - _createClass(LabelSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - allowOffsetToBeReversed = _props.allowOffsetToBeReversed, - className = _props.className, - data = _props.data, - _data = _props._data, - getLabel = _props.getLabel, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - rotation = _props.rotation, - style = _props.style, - xRange = _props.xRange, - yRange = _props.yRange, - labelAnchorX = _props.labelAnchorX, - labelAnchorY = _props.labelAnchorY; - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(LabelSeries, _extends({}, this.props, { animation: null, _data: data })) - ); - } - - var xFunctor = this._getAttributeFunctor('x'); - var yFunctor = this._getAttributeFunctor('y'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')', - style: style - }, - data.reduce(function (res, d, i) { - var markStyle = d.style, - xOffset = d.xOffset, - yOffset = d.yOffset; - - if (!getLabel(d)) { - return res; - } - var xVal = xFunctor(d); - var yVal = yFunctor(d); - var leftOfMiddle = xVal < (xRange[1] - xRange[0]) / 2; - var aboveMiddle = yVal < Math.abs(yRange[1] - yRange[0]) / 2; - - var x = xVal + (allowOffsetToBeReversed && leftOfMiddle ? -1 : 1) * (xOffset || 0); - var y = yVal + (allowOffsetToBeReversed && aboveMiddle ? -1 : 1) * (yOffset || 0); - - var hasRotationValueSet = d.rotation === 0 || d.rotation; - var labelRotation = hasRotationValueSet ? d.rotation : rotation; - var attrs = _extends({ - dominantBaseline: getDominantBaseline(labelAnchorY, aboveMiddle), - className: 'rv-xy-plot__series--label-text', - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - }, - textAnchor: getTextAnchor(labelAnchorX, leftOfMiddle), - x: x, - y: y, - transform: 'rotate(' + labelRotation + ',' + x + ',' + y + ')' - }, markStyle); - var textContent = getLabel(_data ? _data[i] : d); - return res.concat([_react2.default.createElement( - 'text', - attrs, - textContent - )]); - }, []) - ); - } - }]); - - return LabelSeries; -}(_abstractSeries2.default); - -LabelSeries.propTypes = { - animation: _propTypes2.default.bool, - allowOffsetToBeReversed: _propTypes2.default.bool, - className: _propTypes2.default.string, - data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - x: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - y: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), - angle: _propTypes2.default.number, - radius: _propTypes2.default.number, - label: _propTypes2.default.string, - xOffset: _propTypes2.default.number, - yOffset: _propTypes2.default.number, - style: _propTypes2.default.object - })).isRequired, - marginLeft: _propTypes2.default.number, - marginTop: _propTypes2.default.number, - rotation: _propTypes2.default.number, - style: _propTypes2.default.object, - xRange: _propTypes2.default.arrayOf(_propTypes2.default.number), - yRange: _propTypes2.default.arrayOf(_propTypes2.default.number), - labelAnchorX: _propTypes2.default.string, - labelAnchorY: _propTypes2.default.string -}; -LabelSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - animation: false, - rotation: 0, - getLabel: function getLabel(d) { - return d.label; - } -}); -LabelSeries.displayName = 'LabelSeries'; -exports.default = LabelSeries; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series-canvas.js b/dist/plot/series/line-mark-series-canvas.js deleted file mode 100644 index 501c2745a..000000000 --- a/dist/plot/series/line-mark-series-canvas.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _markSeriesCanvas = require('./mark-series-canvas'); - -var _markSeriesCanvas2 = _interopRequireDefault(_markSeriesCanvas); - -var _lineSeriesCanvas = require('./line-series-canvas'); - -var _lineSeriesCanvas2 = _interopRequireDefault(_lineSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var LineMarkSeriesCanvas = function (_AbstractSeries) { - _inherits(LineMarkSeriesCanvas, _AbstractSeries); - - function LineMarkSeriesCanvas() { - _classCallCheck(this, LineMarkSeriesCanvas); - - return _possibleConstructorReturn(this, (LineMarkSeriesCanvas.__proto__ || Object.getPrototypeOf(LineMarkSeriesCanvas)).apply(this, arguments)); - } - - _createClass(LineMarkSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _lineSeriesCanvas2.default.renderLayer(props, ctx); - _markSeriesCanvas2.default.renderLayer(props, ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return LineMarkSeriesCanvas; -}(_abstractSeries2.default); - -LineMarkSeriesCanvas.displayName = 'LineMarkSeriesCanvas'; -LineMarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = LineMarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-mark-series.js b/dist/plot/series/line-mark-series.js deleted file mode 100644 index 7c3c876cf..000000000 --- a/dist/plot/series/line-mark-series.js +++ /dev/null @@ -1,102 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _lineSeries = require('./line-series'); - -var _lineSeries2 = _interopRequireDefault(_lineSeries); - -var _markSeries = require('./mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -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; } - -var propTypes = _extends({}, _lineSeries2.default.propTypes, { - lineStyle: _propTypes2.default.object, - markStyle: _propTypes2.default.object -}); - -var LineMarkSeries = function (_AbstractSeries) { - _inherits(LineMarkSeries, _AbstractSeries); - - function LineMarkSeries() { - _classCallCheck(this, LineMarkSeries); - - return _possibleConstructorReturn(this, (LineMarkSeries.__proto__ || Object.getPrototypeOf(LineMarkSeries)).apply(this, arguments)); - } - - _createClass(LineMarkSeries, [{ - key: 'render', - value: function render() { - var _props = this.props, - lineStyle = _props.lineStyle, - markStyle = _props.markStyle, - style = _props.style; - - return _react2.default.createElement( - 'g', - { className: 'rv-xy-plot__series rv-xy-plot__series--linemark' }, - _react2.default.createElement(_lineSeries2.default, _extends({}, this.props, { style: _extends({}, style, lineStyle) })), - _react2.default.createElement(_markSeries2.default, _extends({}, this.props, { style: _extends({}, style, markStyle) })) - ); - } - }], [{ - key: 'defaultProps', - get: function get() { - return _extends({}, _lineSeries2.default.defaultProps, { - lineStyle: {}, - markStyle: {} - }); - } - }]); - - return LineMarkSeries; -}(_abstractSeries2.default); - -LineMarkSeries.displayName = 'LineMarkSeries'; -LineMarkSeries.propTypes = propTypes; - -exports.default = LineMarkSeries; \ No newline at end of file diff --git a/dist/plot/series/line-series-canvas.js b/dist/plot/series/line-series-canvas.js deleted file mode 100644 index 9694a334d..000000000 --- a/dist/plot/series/line-series-canvas.js +++ /dev/null @@ -1,146 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Color = require('d3-color'); - -var _d3Shape = require('d3-shape'); - -var d3Shape = _interopRequireWildcard(_d3Shape); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -var LineSeriesCanvas = function (_AbstractSeries) { - _inherits(LineSeriesCanvas, _AbstractSeries); - - function LineSeriesCanvas() { - _classCallCheck(this, LineSeriesCanvas); - - return _possibleConstructorReturn(this, (LineSeriesCanvas.__proto__ || Object.getPrototypeOf(LineSeriesCanvas)).apply(this, arguments)); - } - - _createClass(LineSeriesCanvas, [{ - key: 'render', - value: function render() { - return _react2.default.createElement('div', null); - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var curve = props.curve, - data = props.data, - marginLeft = props.marginLeft, - marginTop = props.marginTop, - strokeWidth = props.strokeWidth, - strokeDasharray = props.strokeDasharray; - - if (!data || data.length === 0) { - return; - } - - var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); - var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); - var stroke = (0, _scalesUtils.getAttributeValue)(props, 'stroke') || (0, _scalesUtils.getAttributeValue)(props, 'color'); - var strokeColor = (0, _d3Color.rgb)(stroke); - var newOpacity = (0, _scalesUtils.getAttributeValue)(props, 'opacity'); - var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; - var line = d3Shape.line().x(function (row) { - return x(row) + marginLeft; - }).y(function (row) { - return y(row) + marginTop; - }); - if (typeof curve === 'string' && d3Shape[curve]) { - line = line.curve(d3Shape[curve]); - } else if (typeof curve === 'function') { - line = line.curve(curve); - } - - ctx.beginPath(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + opacity + ')'; - ctx.lineWidth = strokeWidth; - - if (strokeDasharray) { - ctx.setLineDash(strokeDasharray); - } - - line.context(ctx)(data); - ctx.stroke(); - ctx.closePath(); - // set back to default - ctx.lineWidth = 1; - ctx.setLineDash([]); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return LineSeriesCanvas; -}(_abstractSeries2.default); - -LineSeriesCanvas.displayName = 'LineSeriesCanvas'; -LineSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - strokeWidth: 2 -}); - -LineSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - strokeWidth: _propTypes2.default.number -}); - -exports.default = LineSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/line-series.js b/dist/plot/series/line-series.js deleted file mode 100644 index d643b3b7f..000000000 --- a/dist/plot/series/line-series.js +++ /dev/null @@ -1,177 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Shape = require('d3-shape'); - -var d3Shape = _interopRequireWildcard(_d3Shape); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _theme = require('../../theme'); - -var _seriesUtils = require('../../utils/series-utils'); - -var _reactUtils = require('../../utils/react-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--line'; - -var STROKE_STYLES = { - dashed: '6, 2', - solid: null -}; - -var LineSeries = function (_AbstractSeries) { - _inherits(LineSeries, _AbstractSeries); - - function LineSeries() { - _classCallCheck(this, LineSeries); - - return _possibleConstructorReturn(this, (LineSeries.__proto__ || Object.getPrototypeOf(LineSeries)).apply(this, arguments)); - } - - _createClass(LineSeries, [{ - key: '_renderLine', - value: function _renderLine(data, x, y, curve, getNull) { - var line = d3Shape.line(); - if (curve !== null) { - if (typeof curve === 'string' && d3Shape[curve]) { - line = line.curve(d3Shape[curve]); - } else if (typeof curve === 'function') { - line = line.curve(curve); - } - } - line = line.defined(getNull); - line = line.x(x).y(y); - return line(data); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data; - - - if (this.props.nullAccessor) { - (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); - } - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(LineSeries, _extends({}, this.props, { animation: null })) - ); - } - - var _props2 = this.props, - curve = _props2.curve, - marginLeft = _props2.marginLeft, - marginTop = _props2.marginTop, - strokeDasharray = _props2.strokeDasharray, - strokeStyle = _props2.strokeStyle, - strokeWidth = _props2.strokeWidth, - style = _props2.style; - - - var x = this._getAttributeFunctor('x'); - var y = this._getAttributeFunctor('y'); - var stroke = this._getAttributeValue('stroke') || this._getAttributeValue('color'); - var newOpacity = this._getAttributeValue('opacity'); - var opacity = Number.isFinite(newOpacity) ? newOpacity : _theme.DEFAULT_OPACITY; - var getNull = this.props.nullAccessor || this.props.getNull; - var d = this._renderLine(data, x, y, curve, getNull); - - return _react2.default.createElement('path', { - d: d, - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')', - onMouseOver: this._seriesMouseOverHandler, - onMouseOut: this._seriesMouseOutHandler, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - style: _extends({ - opacity: opacity, - strokeDasharray: STROKE_STYLES[strokeStyle] || strokeDasharray, - strokeWidth: strokeWidth, - stroke: stroke - }, style) - }); - } - }]); - - return LineSeries; -}(_abstractSeries2.default); - -LineSeries.displayName = 'LineSeries'; -LineSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - strokeStyle: _propTypes2.default.oneOf(Object.keys(STROKE_STYLES)), - curve: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]), - getNull: _propTypes2.default.func -}); -LineSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - strokeStyle: 'solid', - style: {}, - opacity: 1, - curve: null, - className: '', - getNull: function getNull() { - return true; - } -}); - -exports.default = LineSeries; \ No newline at end of file diff --git a/dist/plot/series/mark-series-canvas.js b/dist/plot/series/mark-series-canvas.js deleted file mode 100644 index de7f2e814..000000000 --- a/dist/plot/series/mark-series-canvas.js +++ /dev/null @@ -1,109 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _d3Color = require('d3-color'); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var MarkSeriesCanvas = function (_AbstractSeries) { - _inherits(MarkSeriesCanvas, _AbstractSeries); - - function MarkSeriesCanvas() { - _classCallCheck(this, MarkSeriesCanvas); - - return _possibleConstructorReturn(this, (MarkSeriesCanvas.__proto__ || Object.getPrototypeOf(MarkSeriesCanvas)).apply(this, arguments)); - } - - _createClass(MarkSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var data = props.data, - marginLeft = props.marginLeft, - marginTop = props.marginTop; - - - var x = (0, _scalesUtils.getAttributeFunctor)(props, 'x'); - var y = (0, _scalesUtils.getAttributeFunctor)(props, 'y'); - var size = (0, _scalesUtils.getAttributeFunctor)(props, 'size') || function (p) { - return _theme.DEFAULT_SIZE; - }; - var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); - - data.forEach(function (row) { - var fillColor = (0, _d3Color.rgb)(fill(row)); - var strokeColor = (0, _d3Color.rgb)(stroke(row)); - var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; - ctx.beginPath(); - ctx.arc(x(row) + marginLeft, y(row) + marginTop, size(row), 0, 2 * Math.PI); - ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; - ctx.fill(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; - ctx.stroke(); - }); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return MarkSeriesCanvas; -}(_abstractSeries2.default); - -MarkSeriesCanvas.displayName = 'MarkSeriesCanvas'; - -MarkSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = MarkSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/mark-series.js b/dist/plot/series/mark-series.js deleted file mode 100644 index 9ba9a0e8a..000000000 --- a/dist/plot/series/mark-series.js +++ /dev/null @@ -1,179 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _reactUtils = require('../../utils/react-utils'); - -var _theme = require('../../theme'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--mark'; -var DEFAULT_STROKE_WIDTH = 1; - -var MarkSeries = function (_AbstractSeries) { - _inherits(MarkSeries, _AbstractSeries); - - function MarkSeries() { - _classCallCheck(this, MarkSeries); - - return _possibleConstructorReturn(this, (MarkSeries.__proto__ || Object.getPrototypeOf(MarkSeries)).apply(this, arguments)); - } - - _createClass(MarkSeries, [{ - key: '_renderCircle', - value: function _renderCircle(d, i, strokeWidth, style, scalingFunctions) { - var _this2 = this; - - var fill = scalingFunctions.fill, - opacity = scalingFunctions.opacity, - size = scalingFunctions.size, - stroke = scalingFunctions.stroke, - x = scalingFunctions.x, - y = scalingFunctions.y; - - - var attrs = { - r: size ? size(d) : _theme.DEFAULT_SIZE, - cx: x(d), - cy: y(d), - style: _extends({ - opacity: opacity ? opacity(d) : _theme.DEFAULT_OPACITY, - stroke: stroke && stroke(d), - fill: fill && fill(d), - strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH - }, style), - key: i, - onClick: function onClick(e) { - return _this2._valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - } - }; - return _react2.default.createElement('circle', attrs); - } - }, { - key: 'render', - value: function render() { - var _this3 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - strokeWidth = _props.strokeWidth, - style = _props.style; - - - if (this.props.nullAccessor) { - (0, _reactUtils.warning)('nullAccessor has been renamed to getNull', true); - } - - var getNull = this.props.nullAccessor || this.props.getNull; - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(MarkSeries, _extends({}, this.props, { animation: null })) - ); - } - - var scalingFunctions = { - fill: this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'), - opacity: this._getAttributeFunctor('opacity'), - size: this._getAttributeFunctor('size'), - stroke: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), - x: this._getAttributeFunctor('x'), - y: this._getAttributeFunctor('y') - }; - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - return getNull(d) && _this3._renderCircle(d, i, strokeWidth, style, scalingFunctions); - }) - ); - } - }]); - - return MarkSeries; -}(_abstractSeries2.default); - -MarkSeries.displayName = 'MarkSeries'; -MarkSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - getNull: _propTypes2.default.func, - strokeWidth: _propTypes2.default.number -}); -MarkSeries.defaultProps = { - getNull: function getNull() { - return true; - } -}; - -exports.default = MarkSeries; \ No newline at end of file diff --git a/dist/plot/series/polygon-series.js b/dist/plot/series/polygon-series.js deleted file mode 100644 index d922d284b..000000000 --- a/dist/plot/series/polygon-series.js +++ /dev/null @@ -1,126 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--polygon'; -var DEFAULT_COLOR = '#12939A'; - -var generatePath = function generatePath(data, xFunctor, yFunctor) { - return data.reduce(function (res, row, i) { - return res + ' ' + (i ? 'L' : 'M') + xFunctor(row) + ' ' + yFunctor(row); - }, '') + ' Z'; -}; - -var PolygonSeries = function (_AbstractSeries) { - _inherits(PolygonSeries, _AbstractSeries); - - function PolygonSeries() { - _classCallCheck(this, PolygonSeries); - - return _possibleConstructorReturn(this, (PolygonSeries.__proto__ || Object.getPrototypeOf(PolygonSeries)).apply(this, arguments)); - } - - _createClass(PolygonSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - color = _props.color, - className = _props.className, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(PolygonSeries, _extends({}, this.props, { animation: null })) - ); - } - var xFunctor = this._getAttributeFunctor('x'); - var yFunctor = this._getAttributeFunctor('y'); - - return _react2.default.createElement('path', { - className: predefinedClassName + ' ' + className, - onMouseOver: function onMouseOver(e) { - return _this2._seriesMouseOverHandler(data, e); - }, - onMouseOut: function onMouseOut(e) { - return _this2._seriesMouseOutHandler(data, e); - }, - onClick: this._seriesClickHandler, - onContextMenu: this._seriesRightClickHandler, - fill: color || DEFAULT_COLOR, - style: style, - d: generatePath(data, xFunctor, yFunctor), - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }); - } - }], [{ - key: 'propTypes', - get: function get() { - return _extends({}, _abstractSeries2.default.propTypes); - } - }]); - - return PolygonSeries; -}(_abstractSeries2.default); - -PolygonSeries.displayName = 'PolygonSeries'; - -exports.default = PolygonSeries; \ No newline at end of file diff --git a/dist/plot/series/rect-series-canvas.js b/dist/plot/series/rect-series-canvas.js deleted file mode 100644 index 727596c9b..000000000 --- a/dist/plot/series/rect-series-canvas.js +++ /dev/null @@ -1,136 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Color = require('d3-color'); - -var _theme = require('../../theme'); - -var _scalesUtils = require('../../utils/scales-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -var RectSeriesCanvas = function (_AbstractSeries) { - _inherits(RectSeriesCanvas, _AbstractSeries); - - function RectSeriesCanvas() { - _classCallCheck(this, RectSeriesCanvas); - - return _possibleConstructorReturn(this, (RectSeriesCanvas.__proto__ || Object.getPrototypeOf(RectSeriesCanvas)).apply(this, arguments)); - } - - _createClass(RectSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'renderLayer', - value: function renderLayer(props, ctx) { - var data = props.data, - linePosAttr = props.linePosAttr, - lineSizeAttr = props.lineSizeAttr, - marginLeft = props.marginLeft, - marginTop = props.marginTop, - valuePosAttr = props.valuePosAttr; - - if (!data || data.length === 0) { - return; - } - - var line = (0, _scalesUtils.getAttributeFunctor)(props, linePosAttr); - var line0 = (0, _scalesUtils.getAttr0Functor)(props, linePosAttr); - var value = (0, _scalesUtils.getAttributeFunctor)(props, valuePosAttr); - var value0 = (0, _scalesUtils.getAttr0Functor)(props, valuePosAttr); - var fill = (0, _scalesUtils.getAttributeFunctor)(props, 'fill') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var stroke = (0, _scalesUtils.getAttributeFunctor)(props, 'stroke') || (0, _scalesUtils.getAttributeFunctor)(props, 'color'); - var opacity = (0, _scalesUtils.getAttributeFunctor)(props, 'opacity'); - - data.forEach(function (row) { - var fillColor = (0, _d3Color.rgb)(fill(row)); - var strokeColor = (0, _d3Color.rgb)(stroke(row)); - var rowOpacity = opacity(row) || _theme.DEFAULT_OPACITY; - - var linePos = line0(row); - var valuePos = Math.min(value0(row), value(row)); - var x = valuePosAttr === 'x' ? valuePos : linePos; - var y = valuePosAttr === 'y' ? valuePos : linePos; - - var lineSize = Math.abs(line(row) - line0(row)); - var valueSize = Math.abs(-value0(row) + value(row)); - var height = lineSizeAttr === 'height' ? lineSize : valueSize; - var width = lineSizeAttr === 'width' ? lineSize : valueSize; - - ctx.beginPath(); - ctx.rect(x + marginLeft, y + marginTop, width, height); - ctx.fillStyle = 'rgba(' + fillColor.r + ', ' + fillColor.g + ', ' + fillColor.b + ', ' + rowOpacity + ')'; - ctx.fill(); - ctx.strokeStyle = 'rgba(' + strokeColor.r + ', ' + strokeColor.g + ', ' + strokeColor.b + ', ' + rowOpacity + ')'; - ctx.stroke(); - }); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return RectSeriesCanvas; -}(_abstractSeries2.default); - -RectSeriesCanvas.displayName = 'RectSeriesCanvas'; -RectSeriesCanvas.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - linePosAttr: _propTypes2.default.string.isRequired, - valuePosAttr: _propTypes2.default.string.isRequired, - lineSizeAttr: _propTypes2.default.string.isRequired, - valueSizeAttr: _propTypes2.default.string.isRequired -}); - -RectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = RectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/rect-series.js b/dist/plot/series/rect-series.js deleted file mode 100644 index 75bbd5f46..000000000 --- a/dist/plot/series/rect-series.js +++ /dev/null @@ -1,151 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--rect'; - -var RectSeries = function (_AbstractSeries) { - _inherits(RectSeries, _AbstractSeries); - - function RectSeries() { - _classCallCheck(this, RectSeries); - - return _possibleConstructorReturn(this, (RectSeries.__proto__ || Object.getPrototypeOf(RectSeries)).apply(this, arguments)); - } - - _createClass(RectSeries, [{ - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - animation = _props.animation, - className = _props.className, - data = _props.data, - linePosAttr = _props.linePosAttr, - lineSizeAttr = _props.lineSizeAttr, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - style = _props.style, - valuePosAttr = _props.valuePosAttr, - valueSizeAttr = _props.valueSizeAttr; - - - if (!data) { - return null; - } - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(RectSeries, _extends({}, this.props, { animation: null })) - ); - } - - var lineFunctor = this._getAttributeFunctor(linePosAttr); - var line0Functor = this._getAttr0Functor(linePosAttr); - var valueFunctor = this._getAttributeFunctor(valuePosAttr); - var value0Functor = this._getAttr0Functor(valuePosAttr); - var fillFunctor = this._getAttributeFunctor('fill') || this._getAttributeFunctor('color'); - var strokeFunctor = this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'); - var opacityFunctor = this._getAttributeFunctor('opacity'); - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(function (d, i) { - var _attrs; - - var attrs = (_attrs = { - style: _extends({ - opacity: opacityFunctor && opacityFunctor(d), - stroke: strokeFunctor && strokeFunctor(d), - fill: fillFunctor && fillFunctor(d) - }, style) - }, _defineProperty(_attrs, linePosAttr, line0Functor(d)), _defineProperty(_attrs, lineSizeAttr, Math.abs(lineFunctor(d) - line0Functor(d))), _defineProperty(_attrs, valuePosAttr, Math.min(value0Functor(d), valueFunctor(d))), _defineProperty(_attrs, valueSizeAttr, Math.abs(-value0Functor(d) + valueFunctor(d))), _defineProperty(_attrs, 'onClick', function onClick(e) { - return _this2._valueClickHandler(d, e); - }), _defineProperty(_attrs, 'onContextMenu', function onContextMenu(e) { - return _this2._valueRightClickHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOver', function onMouseOver(e) { - return _this2._valueMouseOverHandler(d, e); - }), _defineProperty(_attrs, 'onMouseOut', function onMouseOut(e) { - return _this2._valueMouseOutHandler(d, e); - }), _defineProperty(_attrs, 'key', i), _attrs); - return _react2.default.createElement('rect', attrs); - }) - ); - } - }], [{ - key: 'propTypes', - get: function get() { - return _extends({}, _abstractSeries2.default.propTypes, { - linePosAttr: _propTypes2.default.string, - valuePosAttr: _propTypes2.default.string, - lineSizeAttr: _propTypes2.default.string, - valueSizeAttr: _propTypes2.default.string - }); - } - }]); - - return RectSeries; -}(_abstractSeries2.default); - -RectSeries.displayName = 'RectSeries'; - -exports.default = RectSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series-canvas.js b/dist/plot/series/vertical-bar-series-canvas.js deleted file mode 100644 index c07d69f63..000000000 --- a/dist/plot/series/vertical-bar-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeriesCanvas = require('./bar-series-canvas'); - -var _barSeriesCanvas2 = _interopRequireDefault(_barSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalBarSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalBarSeriesCanvas, _AbstractSeries); - - function HorizontalBarSeriesCanvas() { - _classCallCheck(this, HorizontalBarSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalBarSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalBarSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalBarSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'x'; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _barSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalBarSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalBarSeriesCanvas.displayName = 'HorizontalBarSeriesCanvas'; -HorizontalBarSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalBarSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-bar-series.js b/dist/plot/series/vertical-bar-series.js deleted file mode 100644 index 0a0e1de82..000000000 --- a/dist/plot/series/vertical-bar-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _barSeries = require('./bar-series'); - -var _barSeries2 = _interopRequireDefault(_barSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var VerticalBarSeries = function (_AbstractSeries) { - _inherits(VerticalBarSeries, _AbstractSeries); - - function VerticalBarSeries() { - _classCallCheck(this, VerticalBarSeries); - - return _possibleConstructorReturn(this, (VerticalBarSeries.__proto__ || Object.getPrototypeOf(VerticalBarSeries)).apply(this, arguments)); - } - - _createClass(VerticalBarSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_barSeries2.default, _extends({}, this.props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = attr === 'x'; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return VerticalBarSeries; -}(_abstractSeries2.default); - -VerticalBarSeries.displayName = 'VerticalBarSeries'; - -exports.default = VerticalBarSeries; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series-canvas.js b/dist/plot/series/vertical-rect-series-canvas.js deleted file mode 100644 index a45961e48..000000000 --- a/dist/plot/series/vertical-rect-series-canvas.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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 _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeriesCanvas = require('./rect-series-canvas'); - -var _rectSeriesCanvas2 = _interopRequireDefault(_rectSeriesCanvas); - -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; } // Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var HorizontalRectSeriesCanvas = function (_AbstractSeries) { - _inherits(HorizontalRectSeriesCanvas, _AbstractSeries); - - function HorizontalRectSeriesCanvas() { - _classCallCheck(this, HorizontalRectSeriesCanvas); - - return _possibleConstructorReturn(this, (HorizontalRectSeriesCanvas.__proto__ || Object.getPrototypeOf(HorizontalRectSeriesCanvas)).apply(this, arguments)); - } - - _createClass(HorizontalRectSeriesCanvas, [{ - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }, { - key: 'renderLayer', - value: function renderLayer(props, ctx) { - _rectSeriesCanvas2.default.renderLayer(_extends({}, props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - }), ctx); - } - }, { - key: 'requiresSVG', - get: function get() { - return false; - } - }, { - key: 'isCanvas', - get: function get() { - return true; - } - }]); - - return HorizontalRectSeriesCanvas; -}(_abstractSeries2.default); - -HorizontalRectSeriesCanvas.displayName = 'HorizontalRectSeriesCanvas'; -HorizontalRectSeriesCanvas.propTypes = _extends({}, _abstractSeries2.default.propTypes); - -exports.default = HorizontalRectSeriesCanvas; \ No newline at end of file diff --git a/dist/plot/series/vertical-rect-series.js b/dist/plot/series/vertical-rect-series.js deleted file mode 100644 index e4b09a340..000000000 --- a/dist/plot/series/vertical-rect-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _rectSeries = require('./rect-series'); - -var _rectSeries2 = _interopRequireDefault(_rectSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var VerticalRectSeries = function (_AbstractSeries) { - _inherits(VerticalRectSeries, _AbstractSeries); - - function VerticalRectSeries() { - _classCallCheck(this, VerticalRectSeries); - - return _possibleConstructorReturn(this, (VerticalRectSeries.__proto__ || Object.getPrototypeOf(VerticalRectSeries)).apply(this, arguments)); - } - - _createClass(VerticalRectSeries, [{ - key: 'render', - value: function render() { - return _react2.default.createElement(_rectSeries2.default, _extends({}, this.props, { - linePosAttr: 'x', - valuePosAttr: 'y', - lineSizeAttr: 'width', - valueSizeAttr: 'height' - })); - } - }], [{ - key: 'getParentConfig', - value: function getParentConfig(attr) { - var isDomainAdjustmentNeeded = false; - var zeroBaseValue = attr === 'y'; - return { - isDomainAdjustmentNeeded: isDomainAdjustmentNeeded, - zeroBaseValue: zeroBaseValue - }; - } - }]); - - return VerticalRectSeries; -}(_abstractSeries2.default); - -VerticalRectSeries.displayName = 'VerticalRectSeries'; - -exports.default = VerticalRectSeries; \ No newline at end of file diff --git a/dist/plot/series/whisker-series.js b/dist/plot/series/whisker-series.js deleted file mode 100644 index b2c479d8c..000000000 --- a/dist/plot/series/whisker-series.js +++ /dev/null @@ -1,274 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../../utils/series-utils'); - -var _theme = require('../../theme'); - -var _abstractSeries = require('./abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -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; } - -var predefinedClassName = 'rv-xy-plot__series rv-xy-plot__series--whisker'; -var DEFAULT_STROKE_WIDTH = 1; -var DEFAULT_CROSS_BAR_WIDTH = 6; - -/** - * Render whisker lines for a data point. - * @param {Object} whiskerMarkProps All the properties of the whisker mark. - * @private - */ -var renderWhiskerMark = function renderWhiskerMark(whiskerMarkProps) { - return function (d, i) { - var crossBarWidth = whiskerMarkProps.crossBarWidth, - opacityFunctor = whiskerMarkProps.opacityFunctor, - sizeFunctor = whiskerMarkProps.sizeFunctor, - strokeFunctor = whiskerMarkProps.strokeFunctor, - strokeWidth = whiskerMarkProps.strokeWidth, - style = whiskerMarkProps.style, - valueClickHandler = whiskerMarkProps.valueClickHandler, - valueMouseOutHandler = whiskerMarkProps.valueMouseOutHandler, - valueMouseOverHandler = whiskerMarkProps.valueMouseOverHandler, - valueRightClickHandler = whiskerMarkProps.valueRightClickHandler, - xFunctor = whiskerMarkProps.xFunctor, - yFunctor = whiskerMarkProps.yFunctor; - - - var r = sizeFunctor ? sizeFunctor(d) : 0; - var cx = xFunctor(d); - var cy = yFunctor(d); - var positiveXVariance = xFunctor({ x: d.x + d.xVariance / 2 }); - var negativeXVariance = xFunctor({ x: d.x - d.xVariance / 2 }); - var positiveYVariance = yFunctor({ y: d.y + d.yVariance / 2 }); - var negativeYVariance = yFunctor({ y: d.y - d.yVariance / 2 }); - /** - * Determine whether on not we should draw whiskers in each direction. - * We need to see an actual variance value, and also have that value extend past the - * radius "buffer" region in which we won't be drawing (if any). - */ - var hasXWhiskers = positiveXVariance && cx + r < positiveXVariance; - var hasYWhiskers = positiveYVariance && cy - r > positiveYVariance; - if (!hasXWhiskers && !hasYWhiskers) { - return null; - } - - var styleAttr = _extends({ - opacity: opacityFunctor ? opacityFunctor(d) : _theme.DEFAULT_OPACITY, - stroke: strokeFunctor && strokeFunctor(d), - strokeWidth: strokeWidth || DEFAULT_STROKE_WIDTH - }, style); - var crossBarExtension = crossBarWidth / 2; - - var rightLineAttrs = { - x1: cx + r, - y1: cy, - x2: positiveXVariance, - y2: cy, - style: styleAttr - }; - var leftLineAttrs = { - x1: cx - r, - y1: cy, - x2: negativeXVariance, - y2: cy, - style: styleAttr - }; - var rightCrossBarAttrs = { - x1: positiveXVariance, - y1: cy - crossBarExtension, - x2: positiveXVariance, - y2: cy + crossBarExtension, - style: styleAttr - }; - var leftCrossBarAttrs = { - x1: negativeXVariance, - y1: cy - crossBarExtension, - x2: negativeXVariance, - y2: cy + crossBarExtension, - style: styleAttr - }; - - var upperLineAttrs = { - x1: cx, - y1: cy - r, - x2: cx, - y2: positiveYVariance, - style: styleAttr - }; - var lowerLineAttrs = { - x1: cx, - y1: cy + r, - x2: cx, - y2: negativeYVariance, - style: styleAttr - }; - var upperCrossBarAttrs = { - x1: cx - crossBarExtension, - y1: positiveYVariance, - x2: cx + crossBarExtension, - y2: positiveYVariance, - style: styleAttr - }; - var lowerCrossBarAttrs = { - x1: cx - crossBarExtension, - y1: negativeYVariance, - x2: cx + crossBarExtension, - y2: negativeYVariance, - style: styleAttr - }; - - return _react2.default.createElement( - 'g', - { - className: 'mark-whiskers', - key: i, - onClick: function onClick(e) { - return valueClickHandler(d, e); - }, - onContextMenu: function onContextMenu(e) { - return valueRightClickHandler(d, e); - }, - onMouseOver: function onMouseOver(e) { - return valueMouseOverHandler(d, e); - }, - onMouseOut: function onMouseOut(e) { - return valueMouseOutHandler(d, e); - } - }, - hasXWhiskers ? _react2.default.createElement( - 'g', - { className: 'x-whiskers' }, - _react2.default.createElement('line', rightLineAttrs), - _react2.default.createElement('line', leftLineAttrs), - _react2.default.createElement('line', rightCrossBarAttrs), - _react2.default.createElement('line', leftCrossBarAttrs) - ) : null, - hasYWhiskers ? _react2.default.createElement( - 'g', - { className: 'y-whiskers' }, - _react2.default.createElement('line', upperLineAttrs), - _react2.default.createElement('line', lowerLineAttrs), - _react2.default.createElement('line', upperCrossBarAttrs), - _react2.default.createElement('line', lowerCrossBarAttrs) - ) : null - ); - }; -}; - -var WhiskerSeries = function (_AbstractSeries) { - _inherits(WhiskerSeries, _AbstractSeries); - - function WhiskerSeries() { - _classCallCheck(this, WhiskerSeries); - - return _possibleConstructorReturn(this, (WhiskerSeries.__proto__ || Object.getPrototypeOf(WhiskerSeries)).apply(this, arguments)); - } - - _createClass(WhiskerSeries, [{ - key: 'render', - value: function render() { - var _props = this.props, - animation = _props.animation, - className = _props.className, - crossBarWidth = _props.crossBarWidth, - data = _props.data, - marginLeft = _props.marginLeft, - marginTop = _props.marginTop, - strokeWidth = _props.strokeWidth, - style = _props.style; - - if (!data) { - return null; - } - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, this.props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(WhiskerSeries, _extends({}, this.props, { animation: null })) - ); - } - - var whiskerMarkProps = { - crossBarWidth: crossBarWidth, - opacityFunctor: this._getAttributeFunctor('opacity'), - sizeFunctor: this._getAttributeFunctor('size'), - strokeFunctor: this._getAttributeFunctor('stroke') || this._getAttributeFunctor('color'), - strokeWidth: strokeWidth, - style: style, - xFunctor: this._getAttributeFunctor('x'), - yFunctor: this._getAttributeFunctor('y'), - valueClickHandler: this._valueClickHandler, - valueRightClickHandler: this._valueRightClickHandler, - valueMouseOverHandler: this._valueMouseOverHandler, - valueMouseOutHandler: this._valueMouseOutHandler - }; - - return _react2.default.createElement( - 'g', - { - className: predefinedClassName + ' ' + className, - transform: 'translate(' + marginLeft + ',' + marginTop + ')' - }, - data.map(renderWhiskerMark(whiskerMarkProps)) - ); - } - }]); - - return WhiskerSeries; -}(_abstractSeries2.default); - -WhiskerSeries.displayName = 'WhiskerSeries'; -WhiskerSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes, { - strokeWidth: _propTypes2.default.number -}); -WhiskerSeries.defaultProps = _extends({}, _abstractSeries2.default.defaultProps, { - crossBarWidth: DEFAULT_CROSS_BAR_WIDTH, - size: 0, - strokeWidth: DEFAULT_STROKE_WIDTH -}); -exports.default = WhiskerSeries; \ No newline at end of file diff --git a/dist/plot/vertical-grid-lines.js b/dist/plot/vertical-grid-lines.js deleted file mode 100644 index 220165193..000000000 --- a/dist/plot/vertical-grid-lines.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _gridLines = require('./grid-lines'); - -var _gridLines2 = _interopRequireDefault(_gridLines); - -var _axisUtils = require('../utils/axis-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var VERTICAL = _axisUtils.DIRECTION.VERTICAL; - - -var propTypes = _extends({}, _gridLines2.default.propTypes, { - direction: _propTypes2.default.oneOf([VERTICAL]) -}); - -var defaultProps = { - direction: VERTICAL, - attr: 'x' -}; - -function VerticalGridLines(props) { - return _react2.default.createElement(_gridLines2.default, props); -} - -VerticalGridLines.displayName = 'VerticalGridLines'; -VerticalGridLines.propTypes = propTypes; -VerticalGridLines.defaultProps = defaultProps; -VerticalGridLines.requiresSVG = true; - -exports.default = VerticalGridLines; \ No newline at end of file diff --git a/dist/plot/voronoi.js b/dist/plot/voronoi.js deleted file mode 100644 index 45517bb4f..000000000 --- a/dist/plot/voronoi.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Voronoi = require('d3-voronoi'); - -var _scalesUtils = require('../utils/scales-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var NOOP = function NOOP(f) { - return f; -}; - -// Find the index of the node at coordinates of a touch point -function getNodeIndex(evt) { - var _evt$nativeEvent = evt.nativeEvent, - pageX = _evt$nativeEvent.pageX, - pageY = _evt$nativeEvent.pageY; - - var target = document.elementFromPoint(pageX, pageY); - if (!target) { - return -1; - } - var parentNode = target.parentNode; - - return Array.prototype.indexOf.call(parentNode.childNodes, target); -} - -function getExtent(_ref) { - var innerWidth = _ref.innerWidth, - innerHeight = _ref.innerHeight, - marginLeft = _ref.marginLeft, - marginTop = _ref.marginTop; - - return [[marginLeft, marginTop], [innerWidth + marginLeft, innerHeight + marginTop]]; -} - -function Voronoi(props) { - var className = props.className, - extent = props.extent, - nodes = props.nodes, - onBlur = props.onBlur, - _onClick = props.onClick, - _onMouseUp = props.onMouseUp, - _onMouseDown = props.onMouseDown, - onHover = props.onHover, - polygonStyle = props.polygonStyle, - style = props.style, - x = props.x, - y = props.y; - // Create a voronoi with each node center points - - var voronoiInstance = (0, _d3Voronoi.voronoi)().x(x || (0, _scalesUtils.getAttributeFunctor)(props, 'x')).y(y || (0, _scalesUtils.getAttributeFunctor)(props, 'y')).extent(extent || getExtent(props)); - - // Create an array of polygons corresponding to the cells in voronoi - var polygons = voronoiInstance.polygons(nodes); - - // Create helper function to handle special logic for touch events - var handleTouchEvent = function handleTouchEvent(handler) { - return function (evt) { - evt.preventDefault(); - var index = getNodeIndex(evt); - if (index > -1 && index < polygons.length) { - var d = polygons[index]; - handler(d.data); - } - }; - }; - - return _react2.default.createElement( - 'g', - { - className: className + ' rv-voronoi', - style: style - // Because of the nature of how touch events, and more specifically touchmove - // and how it differs from mouseover, we must manage touch events on the parent - , onTouchEnd: handleTouchEvent(_onMouseUp), - onTouchStart: handleTouchEvent(_onMouseDown), - onTouchMove: handleTouchEvent(onHover), - onTouchCancel: handleTouchEvent(onBlur) - }, - polygons.map(function (d, i) { - return _react2.default.createElement('path', { - className: 'rv-voronoi__cell ' + (d.data && d.data.className || ''), - d: 'M' + d.join('L') + 'Z', - onClick: function onClick() { - return _onClick(d.data); - }, - onMouseUp: function onMouseUp() { - return _onMouseUp(d.data); - }, - onMouseDown: function onMouseDown() { - return _onMouseDown(d.data); - }, - onMouseOver: function onMouseOver() { - return onHover(d.data); - }, - onMouseOut: function onMouseOut() { - return onBlur(d.data); - }, - fill: 'none', - style: _extends({ - pointerEvents: 'all' - }, polygonStyle, d.data && d.data.style), - key: i - }); - }) - ); -} - -Voronoi.requiresSVG = true; -Voronoi.displayName = 'Voronoi'; -Voronoi.defaultProps = { - className: '', - onBlur: NOOP, - onClick: NOOP, - onHover: NOOP, - onMouseDown: NOOP, - onMouseUp: NOOP -}; - -Voronoi.propTypes = { - className: _propTypes2.default.string, - extent: _propTypes2.default.arrayOf(_propTypes2.default.arrayOf(_propTypes2.default.number)), - nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - onBlur: _propTypes2.default.func, - onClick: _propTypes2.default.func, - onHover: _propTypes2.default.func, - onMouseDown: _propTypes2.default.func, - onMouseUp: _propTypes2.default.func, - x: _propTypes2.default.func, - y: _propTypes2.default.func -}; - -exports.default = Voronoi; \ No newline at end of file diff --git a/dist/plot/xy-plot.js b/dist/plot/xy-plot.js deleted file mode 100644 index 5d5eec470..000000000 --- a/dist/plot/xy-plot.js +++ /dev/null @@ -1,660 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _deepEqual = require('deep-equal'); - -var _deepEqual2 = _interopRequireDefault(_deepEqual); - -var _scalesUtils = require('../utils/scales-utils'); - -var _seriesUtils = require('../utils/series-utils'); - -var _chartUtils = require('../utils/chart-utils'); - -var _animation = require('../animation'); - -var _theme = require('../theme'); - -var _canvasWrapper = require('./series/canvas-wrapper'); - -var _canvasWrapper2 = _interopRequireDefault(_canvasWrapper); - -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 _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; } - -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; } - -var ATTRIBUTES = ['x', 'y', 'radius', 'angle', 'color', 'fill', 'stroke', 'opacity', 'size']; - -/** - * Remove parents from tree formatted data. deep-equal doesnt play nice with data - * that has circular structures, so we make every node single directional by pruning the parents. - * @param {Array} data - the data object to have circular deps resolved in - * @returns {Array} the sanitized data - */ -function cleanseData(data) { - return data.map(function (series) { - if (!Array.isArray(series)) { - return series; - } - return series.map(function (row) { - return _extends({}, row, { parent: null }); - }); - }); -} - -/** - * Wrapper on the deep-equal method for checking equality of next props vs current props - * @param {Object} scaleMixins - Scale object. - * @param {Object} nextScaleMixins - Scale object. - * @param {Boolean} hasTreeStructure - Whether or not to cleanse the data of possible cyclic structures - * @returns {Boolean} whether or not the two mixins objects are equal - */ -function checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, hasTreeStructure) { - var newMixins = _extends({}, nextScaleMixins, { - _allData: hasTreeStructure ? cleanseData(nextScaleMixins._allData) : nextScaleMixins._allData - }); - var oldMixins = _extends({}, scaleMixins, { - _allData: hasTreeStructure ? cleanseData(scaleMixins._allData) : scaleMixins._allData - }); - // it's hard to say if this function is reasonable? - return (0, _deepEqual2.default)(newMixins, oldMixins); -} - -var XYPlot = function (_React$Component) { - _inherits(XYPlot, _React$Component); - - _createClass(XYPlot, null, [{ - key: 'defaultProps', - get: function get() { - return { - className: '' - }; - } - }, { - key: 'propTypes', - get: function get() { - return { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - dontCheckIfEmpty: _propTypes2.default.bool, - height: _propTypes2.default.number.isRequired, - margin: _chartUtils.MarginPropType, - onClick: _propTypes2.default.func, - onDoubleClick: _propTypes2.default.func, - onMouseDown: _propTypes2.default.func, - onMouseUp: _propTypes2.default.func, - onMouseEnter: _propTypes2.default.func, - onMouseLeave: _propTypes2.default.func, - onMouseMove: _propTypes2.default.func, - onTouchStart: _propTypes2.default.func, - onTouchMove: _propTypes2.default.func, - onTouchEnd: _propTypes2.default.func, - onTouchCancel: _propTypes2.default.func, - onWheel: _propTypes2.default.func, - stackBy: _propTypes2.default.oneOf(ATTRIBUTES), - style: _propTypes2.default.object, - width: _propTypes2.default.number.isRequired - }; - } - }]); - - function XYPlot(props) { - _classCallCheck(this, XYPlot); - - var _this = _possibleConstructorReturn(this, (XYPlot.__proto__ || Object.getPrototypeOf(XYPlot)).call(this, props)); - - _initialiseProps.call(_this); - - var stackBy = props.stackBy; - - var children = (0, _seriesUtils.getSeriesChildren)(props.children); - var data = (0, _seriesUtils.getStackedData)(children, stackBy); - _this.state = { - scaleMixins: _this._getScaleMixins(data, props), - data: data - }; - return _this; - } - - _createClass(XYPlot, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - var children = (0, _seriesUtils.getSeriesChildren)(nextProps.children); - var nextData = (0, _seriesUtils.getStackedData)(children, nextProps.stackBy); - var scaleMixins = this.state.scaleMixins; - - var nextScaleMixins = this._getScaleMixins(nextData, nextProps); - if (!checkIfMixinsAreEqual(nextScaleMixins, scaleMixins, nextProps.hasTreeStructure)) { - this.setState({ - scaleMixins: nextScaleMixins, - data: nextData - }); - } - } - - /** - * Trigger click related callbacks if they are available. - * @param {React.SyntheticEvent} event Click event. - * @private - */ - - - /** - * Trigger doule-click related callbacks if they are available. - * @param {React.SyntheticEvent} event Double-click event. - * @private - */ - - }, { - key: '_getClonedChildComponents', - - - /** - * Prepare the child components (including series) for rendering. - * @returns {Array} Array of child components. - * @private - */ - value: function _getClonedChildComponents() { - var _this2 = this; - - var props = this.props; - var animation = this.props.animation; - var _state = this.state, - scaleMixins = _state.scaleMixins, - data = _state.data; - - var dimensions = (0, _chartUtils.getInnerDimensions)(this.props, _chartUtils.DEFAULT_MARGINS); - var children = _react2.default.Children.toArray(this.props.children); - var seriesProps = (0, _seriesUtils.getSeriesPropsFromChildren)(children); - var XYPlotValues = (0, _scalesUtils.getXYPlotValues)(props, children); - return children.map(function (child, index) { - var dataProps = null; - if (seriesProps[index]) { - // Get the index of the series in the list of props and retrieve - // the data property from it. - var seriesIndex = seriesProps[index].seriesIndex; - - dataProps = { data: data[seriesIndex] }; - } - return _react2.default.cloneElement(child, _extends({}, dimensions, { - animation: animation - }, dataProps && child.type.prototype && child.type.prototype.render ? { - ref: function ref(_ref) { - return _this2['series' + seriesProps[index].seriesIndex] = _ref; - } - } : {}, seriesProps[index], scaleMixins, child.props, XYPlotValues[index], dataProps)); - }); - } - /** - * Get the list of scale-related settings that should be applied by default. - * @param {Object} props Object of props. - * @returns {Object} Defaults. - * @private - */ - - }, { - key: '_getDefaultScaleProps', - value: function _getDefaultScaleProps(props) { - var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)(props, _chartUtils.DEFAULT_MARGINS), - innerWidth = _getInnerDimensions.innerWidth, - innerHeight = _getInnerDimensions.innerHeight; - - var colorRanges = ['color', 'fill', 'stroke'].reduce(function (acc, attr) { - var range = props[attr + 'Type'] === 'category' ? _theme.EXTENDED_DISCRETE_COLOR_RANGE : _theme.CONTINUOUS_COLOR_RANGE; - return _extends({}, acc, _defineProperty({}, attr + 'Range', range)); - }, {}); - - return _extends({ - xRange: [0, innerWidth], - yRange: [innerHeight, 0] - }, colorRanges, { - opacityType: _theme.OPACITY_TYPE, - sizeRange: _theme.SIZE_RANGE - }); - } - - /** - * Get the map of scales from the props, apply defaults to them and then pass - * them further. - * @param {Object} data Array of all data. - * @param {Object} props Props of the component. - * @returns {Object} Map of scale-related props. - * @private - */ - - }, { - key: '_getScaleMixins', - value: function _getScaleMixins(data, props) { - var _ref2; - - var filteredData = data.filter(function (d) { - return d; - }); - var allData = (_ref2 = []).concat.apply(_ref2, _toConsumableArray(filteredData)); - - var defaultScaleProps = this._getDefaultScaleProps(props); - var optionalScaleProps = (0, _scalesUtils.getOptionalScaleProps)(props); - var userScaleProps = (0, _scalesUtils.extractScalePropsFromProps)(props, ATTRIBUTES); - var missingScaleProps = (0, _scalesUtils.getMissingScaleProps)(_extends({}, defaultScaleProps, optionalScaleProps, userScaleProps), allData, ATTRIBUTES); - var children = (0, _seriesUtils.getSeriesChildren)(props.children); - var zeroBaseProps = {}; - var adjustBy = new Set(); - var adjustWhat = new Set(); - children.forEach(function (child, index) { - if (!child || !data[index]) { - return; - } - ATTRIBUTES.forEach(function (attr) { - var _child$type$getParent = child.type.getParentConfig(attr, child.props), - isDomainAdjustmentNeeded = _child$type$getParent.isDomainAdjustmentNeeded, - zeroBaseValue = _child$type$getParent.zeroBaseValue; - - if (isDomainAdjustmentNeeded) { - adjustBy.add(attr); - adjustWhat.add(index); - } - if (zeroBaseValue) { - var specifiedDomain = props[attr + 'Domain']; - zeroBaseProps[attr + 'BaseValue'] = specifiedDomain ? specifiedDomain[0] : 0; - } - }); - }); - return _extends({}, defaultScaleProps, zeroBaseProps, userScaleProps, missingScaleProps, { - _allData: data, - _adjustBy: Array.from(adjustBy), - _adjustWhat: Array.from(adjustWhat), - _stackBy: props.stackBy - }); - } - - /** - * Checks if the plot is empty or not. - * Currently checks the data only. - * @returns {boolean} True for empty. - * @private - */ - - }, { - key: '_isPlotEmpty', - value: function _isPlotEmpty() { - var data = this.state.data; - - return !data || !data.length || !data.some(function (series) { - return series && series.some(function (d) { - return d; - }); - }); - } - - /** - * Trigger mouse-down related callbacks if they are available. - * @param {React.SyntheticEvent} event Mouse down event. - * @private - */ - - - /** - * Trigger onMouseEnter handler if it was passed in props. - * @param {React.SyntheticEvent} event Mouse enter event. - * @private - */ - - - /** - * Trigger onMouseLeave handler if it was passed in props. - * @param {React.SyntheticEvent} event Mouse leave event. - * @private - */ - - - /** - * Trigger movement-related callbacks if they are available. - * @param {React.SyntheticEvent} event Mouse move event. - * @private - */ - - - /** - * Trigger mouse-up related callbacks if they are available. - * @param {React.SyntheticEvent} event Mouse up event. - * @private - */ - - - /** - * Trigger onTouchCancel handler if it was passed in props. - * @param {React.SyntheticEvent} event Touch Cancel event. - * @private - */ - - - /** - * Trigger onTouchEnd handler if it was passed in props. - * @param {React.SyntheticEvent} event Touch End event. - * @private - */ - - - /** - * Trigger touch movement-related callbacks if they are available. - * @param {React.SyntheticEvent} event Touch move event. - * @private - */ - - - /** - * Trigger touch-start related callbacks if they are available. - * @param {React.SyntheticEvent} event Touch start event. - * @private - */ - - - /** - * Trigger doule-click related callbacks if they are available. - * @param {React.SyntheticEvent} event Double-click event. - * @private - */ - - }, { - key: 'renderCanvasComponents', - value: function renderCanvasComponents(components, props) { - var componentsToRender = components.filter(function (c) { - return c && !c.type.requiresSVG && c.type.isCanvas; - }); - - if (componentsToRender.length === 0) { - return null; - } - var _componentsToRender$ = componentsToRender[0].props, - marginLeft = _componentsToRender$.marginLeft, - marginTop = _componentsToRender$.marginTop, - marginBottom = _componentsToRender$.marginBottom, - marginRight = _componentsToRender$.marginRight, - innerHeight = _componentsToRender$.innerHeight, - innerWidth = _componentsToRender$.innerWidth; - - return _react2.default.createElement( - _canvasWrapper2.default, - { - innerHeight: innerHeight, - innerWidth: innerWidth, - marginLeft: marginLeft, - marginTop: marginTop, - marginBottom: marginBottom, - marginRight: marginRight - }, - componentsToRender - ); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - className = _props.className, - dontCheckIfEmpty = _props.dontCheckIfEmpty, - style = _props.style, - width = _props.width, - height = _props.height; - - - if (!dontCheckIfEmpty && this._isPlotEmpty()) { - return _react2.default.createElement('div', { - className: 'rv-xy-plot ' + className, - style: _extends({ - width: width + 'px', - height: height + 'px' - }, this.props.style) - }); - } - var components = this._getClonedChildComponents(); - return _react2.default.createElement( - 'div', - { - style: { - width: width + 'px', - height: height + 'px' - }, - className: 'rv-xy-plot ' + className - }, - _react2.default.createElement( - 'svg', - { - className: 'rv-xy-plot__inner', - width: width, - height: height, - style: style, - onClick: this._clickHandler, - onDoubleClick: this._doubleClickHandler, - onMouseDown: this._mouseDownHandler, - onMouseUp: this._mouseUpHandler, - onMouseMove: this._mouseMoveHandler, - onMouseLeave: this._mouseLeaveHandler, - onMouseEnter: this._mouseEnterHandler, - onTouchStart: this._mouseDownHandler, - onTouchMove: this._touchMoveHandler, - onTouchEnd: this._touchEndHandler, - onTouchCancel: this._touchCancelHandler, - onWheel: this._wheelHandler - }, - components.filter(function (c) { - return c && c.type.requiresSVG; - }) - ), - this.renderCanvasComponents(components, this.props), - components.filter(function (c) { - return c && !c.type.requiresSVG && !c.type.isCanvas; - }) - ); - } - }]); - - return XYPlot; -}(_react2.default.Component); - -var _initialiseProps = function _initialiseProps() { - var _this3 = this; - - this._clickHandler = function (event) { - var onClick = _this3.props.onClick; - - if (onClick) { - onClick(event); - } - }; - - this._doubleClickHandler = function (event) { - var onDoubleClick = _this3.props.onDoubleClick; - - if (onDoubleClick) { - onDoubleClick(event); - } - }; - - this._mouseDownHandler = function (event) { - var _props2 = _this3.props, - onMouseDown = _props2.onMouseDown, - children = _props2.children; - - if (onMouseDown) { - onMouseDown(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseDown) { - component.onParentMouseDown(event); - } - }); - }; - - this._mouseEnterHandler = function (event) { - var _props3 = _this3.props, - onMouseEnter = _props3.onMouseEnter, - children = _props3.children; - - if (onMouseEnter) { - onMouseEnter(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseEnter) { - component.onParentMouseEnter(event); - } - }); - }; - - this._mouseLeaveHandler = function (event) { - var _props4 = _this3.props, - onMouseLeave = _props4.onMouseLeave, - children = _props4.children; - - if (onMouseLeave) { - onMouseLeave(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseLeave) { - component.onParentMouseLeave(event); - } - }); - }; - - this._mouseMoveHandler = function (event) { - var _props5 = _this3.props, - onMouseMove = _props5.onMouseMove, - children = _props5.children; - - if (onMouseMove) { - onMouseMove(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseMove) { - component.onParentMouseMove(event); - } - }); - }; - - this._mouseUpHandler = function (event) { - var _props6 = _this3.props, - onMouseUp = _props6.onMouseUp, - children = _props6.children; - - if (onMouseUp) { - onMouseUp(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentMouseUp) { - component.onParentMouseUp(event); - } - }); - }; - - this._touchCancelHandler = function (event) { - var onTouchCancel = _this3.props.onTouchCancel; - - if (onTouchCancel) { - onTouchCancel(event); - } - }; - - this._touchEndHandler = function (event) { - var onTouchEnd = _this3.props.onTouchEnd; - - if (onTouchEnd) { - onTouchEnd(event); - } - }; - - this._touchMoveHandler = function (event) { - var _props7 = _this3.props, - onTouchMove = _props7.onTouchMove, - children = _props7.children; - - if (onTouchMove) { - onTouchMove(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentTouchMove) { - component.onParentTouchMove(event); - } - }); - }; - - this._touchStartHandler = function (event) { - var _props8 = _this3.props, - onTouchStart = _props8.onTouchStart, - children = _props8.children; - - if (onTouchStart) { - onTouchStart(event); - } - var seriesChildren = (0, _seriesUtils.getSeriesChildren)(children); - seriesChildren.forEach(function (child, index) { - var component = _this3['series' + index]; - if (component && component.onParentTouchStart) { - component.onParentTouchStart(event); - } - }); - }; - - this._wheelHandler = function (event) { - var onWheel = _this3.props.onWheel; - - if (onWheel) { - onWheel(event); - } - }; -}; - -XYPlot.displayName = 'XYPlot'; - -exports.default = XYPlot; \ No newline at end of file diff --git a/dist/radar-chart/index.js b/dist/radar-chart/index.js deleted file mode 100644 index b1f659dfd..000000000 --- a/dist/radar-chart/index.js +++ /dev/null @@ -1,418 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Scale = require('d3-scale'); - -var _d3Format = require('d3-format'); - -var _animation = require('../animation'); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _theme = require('../theme'); - -var _chartUtils = require('../utils/chart-utils'); - -var _markSeries = require('../plot/series/mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -var _polygonSeries = require('../plot/series/polygon-series'); - -var _polygonSeries2 = _interopRequireDefault(_polygonSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _decorativeAxis = require('../plot/axis/decorative-axis'); - -var _decorativeAxis2 = _interopRequireDefault(_decorativeAxis); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var predefinedClassName = 'rv-radar-chart'; -var DEFAULT_FORMAT = (0, _d3Format.format)('.2r'); -/** - * Generate axes for each of the domains - * @param {Object} props - - props.animation {Boolean} - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.style {object} style object for the whole chart - - props.tickFormat {Function} formatting function for axes - - props.startingAngle {number} the initial angle offset - * @return {Array} the plotted axis components - */ -function getAxes(props) { - var animation = props.animation, - domains = props.domains, - startingAngle = props.startingAngle, - style = props.style, - tickFormat = props.tickFormat, - hideInnerMostValues = props.hideInnerMostValues; - - return domains.map(function (domain, index) { - var angle = index / domains.length * Math.PI * 2 + startingAngle; - var sortedDomain = domain.domain; - - var domainTickFormat = function domainTickFormat(t) { - if (hideInnerMostValues && t === sortedDomain[0]) { - return ''; - } - return domain.tickFormat ? domain.tickFormat(t) : tickFormat(t); - }; - - return _react2.default.createElement(_decorativeAxis2.default, { - animation: animation, - key: index + '-axis', - axisStart: { x: 0, y: 0 }, - axisEnd: { - x: getCoordinate(Math.cos(angle)), - y: getCoordinate(Math.sin(angle)) - }, - axisDomain: sortedDomain, - numberOfTicks: 5, - tickValue: domainTickFormat, - style: style.axes - }); - }); -} - -/** - * Generate x or y coordinate for axisEnd - * @param {Number} axisEndPoint - - epsilon is an arbitrarily chosen small number to approximate axisEndPoints - - to true values resulting from trigonometry functions (sin, cos) on angles - * @return {Number} the x or y coordinate accounting for exact trig values - */ -function getCoordinate(axisEndPoint) { - var epsilon = 10e-13; - if (Math.abs(axisEndPoint) <= epsilon) { - axisEndPoint = 0; - } else if (axisEndPoint > 0) { - if (Math.abs(axisEndPoint - 0.5) <= epsilon) { - axisEndPoint = 0.5; - } - } else if (axisEndPoint < 0) { - if (Math.abs(axisEndPoint + 0.5) <= epsilon) { - axisEndPoint = -0.5; - } - } - return axisEndPoint; -} - -/** - * Generate labels for the ends of the axes - * @param {Object} props - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.startingAngle {number} the initial angle offset - - props.style {object} style object for just the labels - * @return {Array} the prepped data for the labelSeries - */ -function getLabels(props) { - var domains = props.domains, - startingAngle = props.startingAngle, - style = props.style; - - return domains.map(function (_ref, index) { - var name = _ref.name; - - var angle = index / domains.length * Math.PI * 2 + startingAngle; - var radius = 1.2; - return { - x: radius * Math.cos(angle), - y: radius * Math.sin(angle), - label: name, - style: style - }; - }); -} - -/** - * Generate the actual polygons to be plotted - * @param {Object} props - - props.animation {Boolean} - - props.data {Array} array of object specifying what values are to be plotted - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.startingAngle {number} the initial angle offset - - props.style {object} style object for the whole chart - * @return {Array} the plotted axis components - */ -function getPolygons(props) { - var animation = props.animation, - colorRange = props.colorRange, - domains = props.domains, - data = props.data, - style = props.style, - startingAngle = props.startingAngle, - onSeriesMouseOver = props.onSeriesMouseOver, - onSeriesMouseOut = props.onSeriesMouseOut; - - var scales = domains.reduce(function (acc, _ref2) { - var domain = _ref2.domain, - name = _ref2.name; - - acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); - return acc; - }, {}); - - return data.map(function (row, rowIndex) { - var mappedData = domains.map(function (_ref3, index) { - var name = _ref3.name, - getValue = _ref3.getValue; - - var dataPoint = getValue ? getValue(row) : row[name]; - // error handling if point doesn't exist - var angle = index / domains.length * Math.PI * 2 + startingAngle; - // dont let the radius become negative - var radius = Math.max(scales[name](dataPoint), 0); - return { x: radius * Math.cos(angle), y: radius * Math.sin(angle), name: row.name }; - }); - - return _react2.default.createElement(_polygonSeries2.default, { - animation: animation, - className: predefinedClassName + '-polygon', - key: rowIndex + '-polygon', - data: mappedData, - style: _extends({ - stroke: row.color || row.stroke || colorRange[rowIndex % colorRange.length], - fill: row.color || row.fill || colorRange[rowIndex % colorRange.length] - }, style.polygons), - onSeriesMouseOver: onSeriesMouseOver, - onSeriesMouseOut: onSeriesMouseOut - }); - }); -} - -/** - * Generate circles at the polygon points for Hover functionality - * @param {Object} props - - props.animation {Boolean} - - props.data {Array} array of object specifying what values are to be plotted - - props.domains {Array} array of object specifying the way each axis is to be plotted - - props.startingAngle {number} the initial angle offset - - props.style {object} style object for the whole chart - - props.onValueMouseOver {function} function to call on mouse over a polygon point - - props.onValueMouseOver {function} function to call when mouse leaves a polygon point - * @return {Array} the plotted axis components - */ -function getPolygonPoints(props) { - var animation = props.animation, - domains = props.domains, - data = props.data, - startingAngle = props.startingAngle, - style = props.style, - onValueMouseOver = props.onValueMouseOver, - onValueMouseOut = props.onValueMouseOut; - - if (!onValueMouseOver) { - return; - } - var scales = domains.reduce(function (acc, _ref4) { - var domain = _ref4.domain, - name = _ref4.name; - - acc[name] = (0, _d3Scale.scaleLinear)().domain(domain).range([0, 1]); - return acc; - }, {}); - return data.map(function (row, rowIndex) { - var mappedData = domains.map(function (_ref5, index) { - var name = _ref5.name, - getValue = _ref5.getValue; - - var dataPoint = getValue ? getValue(row) : row[name]; - // error handling if point doesn't exist - var angle = index / domains.length * Math.PI * 2 + startingAngle; - // dont let the radius become negative - var radius = Math.max(scales[name](dataPoint), 0); - return { - x: radius * Math.cos(angle), - y: radius * Math.sin(angle), - domain: name, - value: dataPoint, - dataName: row.name - }; - }); - - return _react2.default.createElement(_markSeries2.default, { - animation: animation, - className: predefinedClassName + '-polygonPoint', - key: rowIndex + '-polygonPoint', - data: mappedData, - size: 10, - style: _extends({}, style.polygons, { - fill: 'transparent', - stroke: 'transparent' - }), - onValueMouseOver: onValueMouseOver, - onValueMouseOut: onValueMouseOut - }); - }); -} - -function RadarChart(props) { - var animation = props.animation, - className = props.className, - children = props.children, - colorRange = props.colorRange, - data = props.data, - domains = props.domains, - height = props.height, - hideInnerMostValues = props.hideInnerMostValues, - margin = props.margin, - onMouseLeave = props.onMouseLeave, - onMouseEnter = props.onMouseEnter, - startingAngle = props.startingAngle, - style = props.style, - tickFormat = props.tickFormat, - width = props.width, - renderAxesOverPolygons = props.renderAxesOverPolygons, - onValueMouseOver = props.onValueMouseOver, - onValueMouseOut = props.onValueMouseOut, - onSeriesMouseOver = props.onSeriesMouseOver, - onSeriesMouseOut = props.onSeriesMouseOut; - - - var axes = getAxes({ - domains: domains, - animation: animation, - hideInnerMostValues: hideInnerMostValues, - startingAngle: startingAngle, - style: style, - tickFormat: tickFormat - }); - - var polygons = getPolygons({ - animation: animation, - colorRange: colorRange, - domains: domains, - data: data, - startingAngle: startingAngle, - style: style, - onSeriesMouseOver: onSeriesMouseOver, - onSeriesMouseOut: onSeriesMouseOut - }); - - var polygonPoints = getPolygonPoints({ - animation: animation, - colorRange: colorRange, - domains: domains, - data: data, - startingAngle: startingAngle, - style: style, - onValueMouseOver: onValueMouseOver, - onValueMouseOut: onValueMouseOut - }); - - var labelSeries = _react2.default.createElement(_labelSeries2.default, { - animation: animation, - key: className, - className: predefinedClassName + '-label', - data: getLabels({ domains: domains, style: style.labels, startingAngle: startingAngle }) }); - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - width: width, - margin: margin, - dontCheckIfEmpty: true, - className: className + ' ' + predefinedClassName, - onMouseLeave: onMouseLeave, - onMouseEnter: onMouseEnter, - xDomain: [-1, 1], - yDomain: [-1, 1] }, - children, - !renderAxesOverPolygons && axes.concat(polygons).concat(labelSeries).concat(polygonPoints), - renderAxesOverPolygons && polygons.concat(labelSeries).concat(axes).concat(polygonPoints) - ); -} - -RadarChart.displayName = 'RadarChart'; -RadarChart.propTypes = { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - colorRange: _propTypes2.default.arrayOf(_propTypes2.default.string), - data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - domains: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - name: _propTypes2.default.string.isRequired, - domain: _propTypes2.default.arrayOf(_propTypes2.default.number).isRequired, - tickFormat: _propTypes2.default.func - })).isRequired, - height: _propTypes2.default.number.isRequired, - hideInnerMostValues: _propTypes2.default.bool, - margin: _chartUtils.MarginPropType, - startingAngle: _propTypes2.default.number, - style: _propTypes2.default.shape({ - axes: _propTypes2.default.object, - labels: _propTypes2.default.object, - polygons: _propTypes2.default.object - }), - tickFormat: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired, - renderAxesOverPolygons: _propTypes2.default.bool, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - onSeriesMouseOver: _propTypes2.default.func, - onSeriesMouseOut: _propTypes2.default.func -}; -RadarChart.defaultProps = { - className: '', - colorType: 'category', - colorRange: _theme.DISCRETE_COLOR_RANGE, - hideInnerMostValues: true, - startingAngle: Math.PI / 2, - style: { - axes: { - line: {}, - ticks: {}, - text: {} - }, - labels: { - fontSize: 10, - textAnchor: 'middle' - }, - polygons: { - strokeWidth: 0.5, - strokeOpacity: 1, - fillOpacity: 0.1 - } - }, - tickFormat: DEFAULT_FORMAT, - renderAxesOverPolygons: false -}; - -exports.default = RadarChart; \ No newline at end of file diff --git a/dist/radial-chart/index.js b/dist/radial-chart/index.js deleted file mode 100644 index a43e58552..000000000 --- a/dist/radial-chart/index.js +++ /dev/null @@ -1,263 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Shape = require('d3-shape'); - -var _animation = require('../animation'); - -var _arcSeries = require('../plot/series/arc-series'); - -var _arcSeries2 = _interopRequireDefault(_arcSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _theme = require('../theme'); - -var _chartUtils = require('../utils/chart-utils'); - -var _seriesUtils = require('../utils/series-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var predefinedClassName = 'rv-radial-chart'; - -var DEFAULT_RADIUS_MARGIN = 15; - -/** - * Create the list of wedges to render. - * @param {Object} props - props.data {Object} - tree structured data (each node has a name anc an array of children) - * @returns {Array} Array of nodes. - */ -function getWedgesToRender(_ref) { - var data = _ref.data, - getAngle = _ref.getAngle; - - var pie = (0, _d3Shape.pie)().sort(null).value(getAngle); - var pieData = pie(data).reverse(); - return pieData.map(function (row, index) { - return _extends({}, row.data, { - angle0: row.startAngle, - angle: row.endAngle, - radius0: row.data.innerRadius || 0, - radius: row.data.radius || 1, - color: row.data.color || index - }); - }); -} - -function generateLabels(mappedData, accessors) { - var labelsRadiusMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.1; - var getLabel = accessors.getLabel, - getSubLabel = accessors.getSubLabel; - - return mappedData.reduce(function (res, row) { - var angle = row.angle, - angle0 = row.angle0, - radius = row.radius; - - var centeredAngle = (angle + angle0) / 2; - - // unfortunate, but true fact: d3 starts its radians at 12 oclock rather than 3 - // and move clockwise rather than counter clockwise. why why why! - var updatedAngle = -1 * centeredAngle + Math.PI / 2; - var newLabels = []; - if (getLabel(row)) { - newLabels.push({ - angle: updatedAngle, - radius: radius * labelsRadiusMultiplier, - label: getLabel(row) - }); - } - - if (getSubLabel(row)) { - newLabels.push({ - angle: updatedAngle, - radius: radius * labelsRadiusMultiplier, - label: getSubLabel(row), - style: { fontSize: 10 }, - yOffset: 12 - }); - } - return res.concat(newLabels); - }, []); - // could add force direction here to make sure the labels dont overlap -} - -/** - * Get the max radius so the chart can extend to the margin. - * @param {Number} width - container width - * @param {Number} height - container height - * @return {Number} radius - */ -function getMaxRadius(width, height) { - return Math.min(width, height) / 2 - DEFAULT_RADIUS_MARGIN; -} - -function RadialChart(props) { - var animation = props.animation, - className = props.className, - children = props.children, - colorType = props.colorType, - data = props.data, - getAngle = props.getAngle, - getLabel = props.getLabel, - getSubLabel = props.getSubLabel, - height = props.height, - hideRootNode = props.hideRootNode, - innerRadius = props.innerRadius, - labelsAboveChildren = props.labelsAboveChildren, - labelsRadiusMultiplier = props.labelsRadiusMultiplier, - labelsStyle = props.labelsStyle, - margin = props.margin, - onMouseLeave = props.onMouseLeave, - onMouseEnter = props.onMouseEnter, - radius = props.radius, - showLabels = props.showLabels, - style = props.style, - width = props.width; - - var mappedData = getWedgesToRender({ - data: data, - height: height, - hideRootNode: hideRootNode, - width: width, - getAngle: getAngle - }); - var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); - var arcProps = _extends({ - colorType: colorType - }, props, { - animation: animation, - radiusDomain: [0, radialDomain], - data: mappedData, - radiusNoFallBack: true, - style: style, - arcClassName: 'rv-radial-chart__series--pie__slice' - }); - if (radius) { - arcProps.radiusDomain = [0, 1]; - arcProps.radiusRange = [innerRadius || 0, radius]; - arcProps.radiusType = 'linear'; - } - var maxRadius = radius ? radius : getMaxRadius(width, height); - var defaultMargin = (0, _chartUtils.getRadialLayoutMargin)(width, height, maxRadius); - - var labels = generateLabels(mappedData, { - getLabel: getLabel, - getSubLabel: getSubLabel - }, labelsRadiusMultiplier); - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - width: width, - margin: _extends({}, margin, defaultMargin), - className: className + ' ' + predefinedClassName, - onMouseLeave: onMouseLeave, - onMouseEnter: onMouseEnter, - xDomain: [-radialDomain, radialDomain], - yDomain: [-radialDomain, radialDomain] - }, - _react2.default.createElement(_arcSeries2.default, _extends({}, arcProps, { getAngle: function getAngle(d) { - return d.angle; - } })), - showLabels && !labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }), - children, - showLabels && labelsAboveChildren && _react2.default.createElement(_labelSeries2.default, { data: labels, style: labelsStyle }) - ); -} - -RadialChart.displayName = 'RadialChart'; -RadialChart.propTypes = { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - angle: _propTypes2.default.number, - className: _propTypes2.default.string, - label: _propTypes2.default.string, - radius: _propTypes2.default.number, - style: _propTypes2.default.object - })).isRequired, - getAngle: _propTypes2.default.func, - getAngle0: _propTypes2.default.func, - padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]), - getRadius: _propTypes2.default.func, - getRadius0: _propTypes2.default.func, - getLabel: _propTypes2.default.func, - height: _propTypes2.default.number.isRequired, - labelsAboveChildren: _propTypes2.default.bool, - labelsStyle: _propTypes2.default.object, - margin: _chartUtils.MarginPropType, - onValueClick: _propTypes2.default.func, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - showLabels: _propTypes2.default.bool, - style: _propTypes2.default.object, - subLabel: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired -}; -RadialChart.defaultProps = { - className: '', - colorType: 'category', - colorRange: _theme.DISCRETE_COLOR_RANGE, - padAngle: 0, - getAngle: function getAngle(d) { - return d.angle; - }, - getAngle0: function getAngle0(d) { - return d.angle0; - }, - getRadius: function getRadius(d) { - return d.radius; - }, - getRadius0: function getRadius0(d) { - return d.radius0; - }, - getLabel: function getLabel(d) { - return d.label; - }, - getSubLabel: function getSubLabel(d) { - return d.subLabel; - } -}; - -exports.default = RadialChart; \ No newline at end of file diff --git a/dist/sankey/index.js b/dist/sankey/index.js deleted file mode 100644 index 55b694d88..000000000 --- a/dist/sankey/index.js +++ /dev/null @@ -1,238 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Sankey = require('d3-sankey'); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _chartUtils = require('../utils/chart-utils'); - -var _verticalRectSeries = require('../plot/series/vertical-rect-series'); - -var _verticalRectSeries2 = _interopRequireDefault(_verticalRectSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _voronoi = require('../plot/voronoi'); - -var _voronoi2 = _interopRequireDefault(_voronoi); - -var _theme = require('../theme'); - -var _sankeyLink = require('./sankey-link'); - -var _sankeyLink2 = _interopRequireDefault(_sankeyLink); - -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); } } - -var NOOP = function NOOP(f) { - return f; -}; - -var ALIGNMENTS = { - justify: _d3Sankey.sankeyJustify, - center: _d3Sankey.sankeyCenter, - left: _d3Sankey.sankeyLeft, - right: _d3Sankey.sankeyRight -}; - -var DEFAULT_MARGINS = { - top: 20, - left: 20, - right: 20, - bottom: 20 -}; - -function Sankey(props) { - var align = props.align, - animation = props.animation, - children = props.children, - className = props.className, - hasVoronoi = props.hasVoronoi, - height = props.height, - hideLabels = props.hideLabels, - labelRotation = props.labelRotation, - layout = props.layout, - links = props.links, - linkOpacity = props.linkOpacity, - margin = props.margin, - nodePadding = props.nodePadding, - nodes = props.nodes, - nodeWidth = props.nodeWidth, - onValueClick = props.onValueClick, - onValueMouseOver = props.onValueMouseOver, - onValueMouseOut = props.onValueMouseOut, - onLinkClick = props.onLinkClick, - onLinkMouseOver = props.onLinkMouseOver, - onLinkMouseOut = props.onLinkMouseOut, - style = props.style, - width = props.width; - - var nodesCopy = [].concat(_toConsumableArray(new Array(nodes.length))).map(function (e, i) { - return _extends({}, nodes[i]); - }); - var linksCopy = [].concat(_toConsumableArray(new Array(links.length))).map(function (e, i) { - return _extends({}, links[i]); - }); - - var _getInnerDimensions = (0, _chartUtils.getInnerDimensions)({ - margin: margin, - height: height, - width: width - }, DEFAULT_MARGINS), - marginLeft = _getInnerDimensions.marginLeft, - marginTop = _getInnerDimensions.marginTop, - marginRight = _getInnerDimensions.marginRight, - marginBottom = _getInnerDimensions.marginBottom; - - var sankeyInstance = (0, _d3Sankey.sankey)().extent([[marginLeft, marginTop], [width - marginRight, height - marginBottom - marginTop]]).nodeWidth(nodeWidth).nodePadding(nodePadding).nodes(nodesCopy).links(linksCopy).nodeAlign(ALIGNMENTS[align]).iterations(layout); - sankeyInstance(nodesCopy); - - var nWidth = sankeyInstance.nodeWidth(); - var path = (0, _d3Sankey.sankeyLinkHorizontal)(); - - return _react2.default.createElement( - _xyPlot2.default, - _extends({}, props, { yType: 'literal', className: 'rv-sankey ' + className }), - linksCopy.map(function (link, i) { - return _react2.default.createElement(_sankeyLink2.default, { - style: style.links, - data: path(link), - opacity: link.opacity || linkOpacity, - color: link.color, - onLinkClick: onLinkClick, - onLinkMouseOver: onLinkMouseOver, - onLinkMouseOut: onLinkMouseOut, - strokeWidth: Math.max(link.width, 1), - node: link, - nWidth: nWidth, - key: 'link-' + i - }); - }), - _react2.default.createElement(_verticalRectSeries2.default, { - animation: animation, - className: className + ' rv-sankey__node', - data: nodesCopy.map(function (node) { - return _extends({}, node, { - y: node.y1 - marginTop, - y0: node.y0 - marginTop, - x: node.x1, - x0: node.x0, - color: node.color || _theme.DISCRETE_COLOR_RANGE[0], - sourceLinks: null, - targetLinks: null - }); - }), - style: style.rects, - onValueClick: onValueClick, - onValueMouseOver: onValueMouseOver, - onValueMouseOut: onValueMouseOut, - colorType: 'literal' - }), - !hideLabels && _react2.default.createElement(_labelSeries2.default, { - animation: animation, - className: className, - rotation: labelRotation, - labelAnchorY: 'text-before-edge', - data: nodesCopy.map(function (node, i) { - return _extends({ - x: node.x0 + (node.x0 < width / 2 ? nWidth + 10 : -10), - y: (node.y0 + node.y1) / 2 - marginTop, - label: node.name, - style: _extends({ - textAnchor: node.x0 < width / 2 ? 'start' : 'end', - dy: '-.5em' - }, style.labels) - }, nodes[i]); - }) - }), - hasVoronoi && _react2.default.createElement(_voronoi2.default, { - className: 'rv-sankey__voronoi', - extent: [[-marginLeft, -marginTop], [width + marginRight, height + marginBottom]], - nodes: nodesCopy, - onClick: onValueClick, - onHover: onValueMouseOver, - onBlur: onValueMouseOut, - x: function x(d) { - return d.x0 + (d.x1 - d.x0) / 2; - }, - y: function y(d) { - return d.y0 + (d.y1 - d.y0) / 2; - } - }), - children - ); -} - -Sankey.defaultProps = { - align: 'justify', - className: '', - hasVoronoi: false, - hideLabels: false, - labelRotation: 0, - layout: 50, - margin: DEFAULT_MARGINS, - nodePadding: 10, - nodeWidth: 10, - onValueMouseOver: NOOP, - onValueClick: NOOP, - onValueMouseOut: NOOP, - onLinkClick: NOOP, - onLinkMouseOver: NOOP, - onLinkMouseOut: NOOP, - style: { - links: {}, - rects: {}, - labels: {} - } -}; - -Sankey.propTypes = { - align: _propTypes2.default.oneOf(['justify', 'left', 'right', 'center']), - className: _propTypes2.default.string, - hasVoronoi: _propTypes2.default.bool, - height: _propTypes2.default.number.isRequired, - hideLabels: _propTypes2.default.bool, - labelRotation: _propTypes2.default.number, - layout: _propTypes2.default.number, - links: _propTypes2.default.arrayOf(_propTypes2.default.shape({ - source: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired, - target: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.object]).isRequired - })).isRequired, - margin: _chartUtils.MarginPropType, - nodePadding: _propTypes2.default.number, - nodes: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, - nodeWidth: _propTypes2.default.number, - onValueMouseOver: _propTypes2.default.func, - onValueClick: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - onLinkClick: _propTypes2.default.func, - onLinkMouseOver: _propTypes2.default.func, - onLinkMouseOut: _propTypes2.default.func, - style: _propTypes2.default.shape({ - links: _propTypes2.default.object, - rects: _propTypes2.default.object, - labels: _propTypes2.default.object - }), - width: _propTypes2.default.number.isRequired -}; -exports.default = Sankey; \ No newline at end of file diff --git a/dist/sankey/sankey-link.js b/dist/sankey/sankey-link.js deleted file mode 100644 index d664e22d6..000000000 --- a/dist/sankey/sankey-link.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _theme = require('../theme'); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _seriesUtils = require('../utils/series-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var DEFAULT_LINK_COLOR = _theme.DISCRETE_COLOR_RANGE[1]; -var DEFAULT_LINK_OPACITY = 0.7; - -function SankeyLink(props) { - var animation = props.animation, - data = props.data, - node = props.node, - opacity = props.opacity, - color = props.color, - strokeWidth = props.strokeWidth, - style = props.style, - onLinkClick = props.onLinkClick, - onLinkMouseOver = props.onLinkMouseOver, - onLinkMouseOut = props.onLinkMouseOut; - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }), - _react2.default.createElement(SankeyLink, _extends({}, props, { animation: null })) - ); - } - return _react2.default.createElement('path', _extends({ - d: data - }, style, { - className: 'rv-sankey__link', - opacity: Number.isFinite(opacity) ? opacity : DEFAULT_LINK_OPACITY, - stroke: color || DEFAULT_LINK_COLOR, - onClick: function onClick(e) { - return onLinkClick(node, e); - }, - onMouseOver: function onMouseOver(e) { - return onLinkMouseOver(node, e); - }, - onMouseOut: function onMouseOut(e) { - return onLinkMouseOut(node, e); - }, - strokeWidth: strokeWidth, - fill: 'none' - })); -} - -SankeyLink.displayName = 'SankeyLink'; -SankeyLink.requiresSVG = true; -exports.default = SankeyLink; \ No newline at end of file diff --git a/dist/style.css b/dist/style.css deleted file mode 100644 index 42d247c14..000000000 --- a/dist/style.css +++ /dev/null @@ -1 +0,0 @@ -.react-vis-magic-css-import-rule{display:inherit}.rv-treemap{font-size:12px;position:relative}.rv-treemap__leaf{overflow:hidden;position:absolute}.rv-treemap__leaf--circle{align-items:center;border-radius:100%;display:flex;justify-content:center}.rv-treemap__leaf__content{overflow:hidden;padding:10px;text-overflow:ellipsis}.rv-xy-plot{color:#c3c3c3;position:relative}.rv-xy-plot canvas{pointer-events:none}.rv-xy-plot .rv-xy-canvas{pointer-events:none;position:absolute}.rv-xy-plot__inner{display:block}.rv-xy-plot__axis__line{fill:none;stroke-width:2px;stroke:#e6e6e9}.rv-xy-plot__axis__tick__line{stroke:#e6e6e9}.rv-xy-plot__axis__tick__text{fill:#6b6b76;font-size:11px}.rv-xy-plot__axis__title text{fill:#6b6b76;font-size:11px}.rv-xy-plot__grid-lines__line{stroke:#e6e6e9}.rv-xy-plot__circular-grid-lines__line{fill-opacity:0;stroke:#e6e6e9}.rv-xy-plot__series,.rv-xy-plot__series path{pointer-events:all}.rv-xy-plot__series--line{fill:none;stroke:#000;stroke-width:2px}.rv-crosshair{position:absolute;font-size:11px;pointer-events:none}.rv-crosshair__line{background:#47d3d9;width:1px}.rv-crosshair__inner{position:absolute;text-align:left;top:0}.rv-crosshair__inner__content{border-radius:4px;background:#3a3a48;color:#fff;font-size:12px;padding:7px 10px;box-shadow:0 2px 4px rgba(0,0,0,0.5)}.rv-crosshair__inner--left{right:4px}.rv-crosshair__inner--right{left:4px}.rv-crosshair__title{font-weight:bold;white-space:nowrap}.rv-crosshair__item{white-space:nowrap}.rv-hint{position:absolute;pointer-events:none}.rv-hint__content{border-radius:4px;padding:7px 10px;font-size:12px;background:#3a3a48;box-shadow:0 2px 4px rgba(0,0,0,0.5);color:#fff;text-align:left;white-space:nowrap}.rv-discrete-color-legend{box-sizing:border-box;overflow-y:auto;font-size:12px}.rv-discrete-color-legend.horizontal{white-space:nowrap}.rv-discrete-color-legend-item{color:#3a3a48;border-radius:1px;padding:9px 10px}.rv-discrete-color-legend-item.horizontal{display:inline-block}.rv-discrete-color-legend-item.horizontal .rv-discrete-color-legend-item__title{margin-left:0;display:block}.rv-discrete-color-legend-item__color{display:inline-block;vertical-align:middle;overflow:visible}.rv-discrete-color-legend-item__color__path{stroke:#dcdcdc;stroke-width:2px}.rv-discrete-color-legend-item__title{margin-left:10px}.rv-discrete-color-legend-item.disabled{color:#b8b8b8}.rv-discrete-color-legend-item.clickable{cursor:pointer}.rv-discrete-color-legend-item.clickable:hover{background:#f9f9f9}.rv-search-wrapper{display:flex;flex-direction:column}.rv-search-wrapper__form{flex:0}.rv-search-wrapper__form__input{width:100%;color:#a6a6a5;border:1px solid #e5e5e4;padding:7px 10px;font-size:12px;box-sizing:border-box;border-radius:2px;margin:0 0 9px;outline:0}.rv-search-wrapper__contents{flex:1;overflow:auto}.rv-continuous-color-legend{font-size:12px}.rv-continuous-color-legend .rv-gradient{height:4px;border-radius:2px;margin-bottom:5px}.rv-continuous-size-legend{font-size:12px}.rv-continuous-size-legend .rv-bubbles{text-align:justify;overflow:hidden;margin-bottom:5px;width:100%}.rv-continuous-size-legend .rv-bubble{background:#d8d9dc;display:inline-block;vertical-align:bottom}.rv-continuous-size-legend .rv-spacer{display:inline-block;font-size:0;line-height:0;width:100%}.rv-legend-titles{height:16px;position:relative}.rv-legend-titles__left,.rv-legend-titles__right,.rv-legend-titles__center{position:absolute;white-space:nowrap;overflow:hidden}.rv-legend-titles__center{display:block;text-align:center;width:100%}.rv-legend-titles__right{right:0}.rv-radial-chart .rv-xy-plot__series--label{pointer-events:none} diff --git a/dist/styles/examples.scss b/dist/styles/examples.scss deleted file mode 100644 index 420cb2eb1..000000000 --- a/dist/styles/examples.scss +++ /dev/null @@ -1,461 +0,0 @@ -@import '../main.scss'; - -$black: #000; -$white: #fff; - -body { - font-family: Sintony, Helvetica, sans-serif; - font-size: 14px; - margin: 0; - padding: 0; -} - -h1, -h2, -h3, -h4, -h5 { - font-weight: normal; -} - -h1 { - font-size: 36px; - margin: 20px 0; -} - -h2 { - font-size: 24px; - margin: 15px 0; -} - -main { - padding: 40px 0; -} - -header { - background: #f0f0f0; - line-height: 40px; - position: fixed; - top: 0; - width: 100%; - z-index: 1000; -} - -.flex { - display: flex; -} - -.docs-link { - font-weight: 500; - font-size: 11px; - margin-right: 5px; - text-transform: uppercase; - border-left: 1px solid #c0c0c0; - padding-left: 5px; - line-height: 1; -} - -.docs-link:first-child { - border-left: 0px; - padding-left: 0px; -} - -.docs-comment { - display: flex; - max-width: 300px; -} - -.header-contents { - align-items: center; - display: flex; - justify-content: space-between; - padding: 0 20px; -} - -.header-logo { - color: $black; - float: left; - font-size: 20px; - text-decoration: none; -} - -.background-overlay { - bottom: 0; - left: 0; - position: fixed; - right: 0; - top: 0; - z-index: 1; -} - -.dropdown-button { - cursor: pointer; - z-index: 10; -} - -.dropdown-wrapper { - display: flex; - position: relative; - - .dropdown-inner-wrapper { - background: $white; - border: 2px solid $black; - display: flex; - flex-direction: column; - font-size: 11px; - height: auto; - list-style: none; - padding: 10px; - position: absolute; - right: -5px; - top: 25px; - width: 150px; - z-index: 10; - } - - a { - display: flex; - height: auto; - line-height: 15px; - text-decoration: none; - } - - li { - display: flex; - height: 100%; - } - - .subsection-label { - font-weight: 600; - line-height: 15px; - } -} - - -article { - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: flex-start; - margin: 0 auto; - max-width: 1200px; - min-width: 650px; - padding: 30px 20px 0; - - h1, - h2 { - flex: 1 100%; - - small { - color: #6b6b76; - font-size: 50%; - } - } - - section { - flex-basis: 400px; - flex-grow: 1; - margin: 0 0 40px; - } - - .section-title { - margin-bottom: 5px; - } - - .section-header { - margin-bottom: 1em; - } -} - -.click-me { - border: 0; - background: #ef5d28; - color: $white; - cursor: pointer; - font-family: Sintony, Helvetica, sans-serif; - font-size: 14px; - outline: none; - padding: 11px 20px; - text-transform: uppercase; - - &:hover { - background: #ff9833; - } - - animation: shake 5s 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite; - transform: translate3d(0, 0, 0); -} - -@keyframes shake { - 1%, - 9% { - transform: translate3d(-1px, 0, 0); - } - - 2%, - 8% { - transform: translate3d(2px, 0, 0); - } - - 3%, - 5%, - 7% { - transform: translate3d(-4px, 0, 0); - } - - 4%, - 6% { - transform: translate3d(4px, 0, 0); - } -} - -.example-with-click-me { - position: relative; - text-align: center; - width: 100%; - - &:hover { - .click-me { - animation: none; - } - } - - .chart { - margin-right: 200px; - .rv-xy-plot__axis__tick__line { - stroke: $rv-xy-plot-axis-font-color; - } - } - - .legend { - position: absolute; - text-align: left; - right: 0; - } -} - -.custom-hint { - background: #f9e7bb; - border-radius: 3px; - border: 1px solid #edaf00; - padding: 10px; - color: #333; - font-size: 10px; - position: relative; - margin: 12px 0 0 -10px; - - &::after { - border-radius: 5px; - border: 2px solid #edaf00; - background: $white; - display: block; - content: ' '; - height: 6px; - width: 6px; - top: -17px; - left: 5px; - position: absolute; - } -} - -.complex-hint { - margin-top: 40px; - - .rv-hint { - /* must be positioned in a parent with relative positioning */ - position: absolute; - width: 0; - height: 100%; - $hint-color: black; - $margin-left: 30px; - $margin-right: 10px; - $margin-top: 10px; - $margin-bottom: 25px; - - & .hint--text-container { - position: absolute; - - /* - * set to 0,0 so that its content (including children) - * can overflow out in vertical and horizontal - */ - width: 0; - height: 0; - - /* - * use flex to place its children (centered) and aligned (bottom). - * As its height is 0, align-items flex-end paints its items from cross-axis - * up. flex-start, its items would paint from cross-axis down. - */ - display: flex; - justify-content: center; - - &.rightEdge-top { - flex-direction: column-reverse; - align-items: flex-start; - } - - &.left-topEdge { - flex-direction: row; - align-items: flex-end; - } - - &.left-bottomEdge { - flex-direction: row; - align-items: flex-start; - } - - &.leftEdge-top { - flex-direction: column; - align-items: flex-end; - } - - & .hint--text { - /* text content uses -micro padding */ - padding: 4px; - border: 2px solid $hint-color; - color: $hint-color; - white-space: nowrap; - } - } - - & .hint--pole { - position: absolute; - - &.rightEdge-top { - top: -1px; - left: -$margin-right; - border-top: 2px solid $hint-color; - width: $margin-right; - height: 0; - } - - &.left-topEdge { - border-left: 2px solid $hint-color; - left: -1px; - height: $margin-top; - width: 0; - top: 0; - } - - &.left-bottomEdge { - border-left: 2px solid $hint-color; - left: -1px; - height: $margin-bottom; - width: 0; - top: -$margin-bottom; - } - - &.leftEdge-top { - top: -1px; - border-top: 2px solid $hint-color; - width: $margin-left; - height: 0; - } - } - } - - .rv-hint--horizontalAlign-rightEdge.rv-hint--verticalAlign-top { - width: 0; - height: 0; - } - - .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-topEdge { - width: 0; - height: 100%; - } - - .rv-hint--horizontalAlign-left.rv-hint--verticalAlign-bottomEdge { - width: 0; - height: 0; - } - - .rv-hint--horizontalAlign-leftEdge.rv-hint--verticalAlign-top { - width: 100%; - height: 0; - } -} - -.centered-and-flexed { - align-items: center; - display: flex; - flex-direction: column; - justify-content: center; - padding: 0 10px; - - .centered-and-flexed-controls { - align-items: center; - display: flex; - justify-content: space-between; - padding: 10px 0; - width: 75%; - } -} - -.dynamic-treemap-example { - .rv-treemap__leaf--circle { - border: thin solid white; - } -} - -.clustered-stacked-bar-chart-example { - .rv-discrete-color-legend { - left: 40px; - position: absolute; - top: 0; - } -} - -.basic-sunburst-example-path-name { - height: 20px; -} - -.showcase-button { - background: $white; - border: thin solid #333; - border-radius: 5px; - cursor: pointer; - font-size: 10px; - font-weight: 600; - padding: 5px 10px; -} - -.donut-chart-example { - .rv-radial-chart__series--pie__slice:hover { - stroke: $black !important; - stroke-width: 2px !important; - } -} - -.parallel-coordinates-example { - .rv-xy-plot__series--line { - stroke: #12939A !important; - - &:hover { - stroke: #F15C17 !important; - } - } -} - - -.canvas-example-controls { - display: flex; -} - -.canvas-wrapper { - align-items: center; - display: flex; - flex-direction: column; - width: 100%; -} - -.highlight-container { - cursor: crosshair; -} - -.no-select { - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} diff --git a/dist/styles/legends.scss b/dist/styles/legends.scss deleted file mode 100644 index f79e9c850..000000000 --- a/dist/styles/legends.scss +++ /dev/null @@ -1,137 +0,0 @@ -$rv-legend-enabled-color: #3a3a48; -$rv-legend-disabled-color: #b8b8b8; - -.rv-discrete-color-legend { - box-sizing: border-box; - overflow-y: auto; - font-size: 12px; - - &.horizontal { - white-space: nowrap; - } -} - -.rv-discrete-color-legend-item { - color: $rv-legend-enabled-color; - border-radius: 1px; - padding: 9px 10px; - - &.horizontal { - display: inline-block; - - .rv-discrete-color-legend-item__title { - margin-left: 0; - display: block; - } - } -} - -.rv-discrete-color-legend-item__color { - display: inline-block; - vertical-align: middle; - overflow: visible; -} - -.rv-discrete-color-legend-item__color__path { - stroke: #dcdcdc; - stroke-width: 2px; -} - -.rv-discrete-color-legend-item__title { - margin-left: 10px; -} - -.rv-discrete-color-legend-item.disabled { - color: $rv-legend-disabled-color; -} - -.rv-discrete-color-legend-item.clickable { - cursor: pointer; - - &:hover { - background: #f9f9f9; - } -} - -.rv-search-wrapper { - display: flex; - flex-direction: column; -} - -.rv-search-wrapper__form { - flex: 0; -} - -.rv-search-wrapper__form__input { - width: 100%; - color: #a6a6a5; - border: 1px solid #e5e5e4; - padding: 7px 10px; - font-size: 12px; - box-sizing: border-box; - border-radius: 2px; - margin: 0 0 9px; - outline: 0; -} - -.rv-search-wrapper__contents { - flex: 1; - overflow: auto; -} - -.rv-continuous-color-legend { - font-size: 12px; - - .rv-gradient { - height: 4px; - border-radius: 2px; - margin-bottom: 5px; - } -} - -.rv-continuous-size-legend { - font-size: 12px; - - .rv-bubbles { - text-align: justify; - overflow: hidden; - margin-bottom: 5px; - width: 100%; - } - - .rv-bubble { - background: #d8d9dc; - display: inline-block; - vertical-align: bottom; - } - - .rv-spacer { - display: inline-block; - font-size: 0; - line-height: 0; - width: 100%; - } -} - -.rv-legend-titles { - height: 16px; - position: relative; -} - -.rv-legend-titles__left, -.rv-legend-titles__right, -.rv-legend-titles__center { - position: absolute; - white-space: nowrap; - overflow: hidden; -} - -.rv-legend-titles__center { - display: block; - text-align: center; - width: 100%; -} - -.rv-legend-titles__right { - right: 0; -} diff --git a/dist/styles/plot.scss b/dist/styles/plot.scss deleted file mode 100644 index 8d1f75ca2..000000000 --- a/dist/styles/plot.scss +++ /dev/null @@ -1,128 +0,0 @@ -$rv-xy-plot-axis-font-color: #6b6b76; -$rv-xy-plot-axis-line-color: #e6e6e9; -$rv-xy-plot-axis-font-size: 11px; -$rv-xy-plot-tooltip-background: #3a3a48; -$rv-xy-plot-tooltip-color: #fff; -$rv-xy-plot-tooltip-font-size: 12px; -$rv-xy-plot-tooltip-border-radius: 4px; -$rv-xy-plot-tooltip-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); -$rv-xy-plot-tooltip-padding: 7px 10px; - -.rv-xy-plot { - color: #c3c3c3; - position: relative; - - canvas { - pointer-events: none; - } - - .rv-xy-canvas { - pointer-events: none; - position: absolute; - } -} - -.rv-xy-plot__inner { - display: block; -} - -.rv-xy-plot__axis__line { - fill: none; - stroke-width: 2px; - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__axis__tick__line { - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__axis__tick__text { - fill: $rv-xy-plot-axis-font-color; - font-size: $rv-xy-plot-axis-font-size; -} - -.rv-xy-plot__axis__title { - text { - fill: $rv-xy-plot-axis-font-color; - font-size: $rv-xy-plot-axis-font-size; - } -} - -.rv-xy-plot__grid-lines__line { - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__circular-grid-lines__line { - fill-opacity: 0; - stroke: $rv-xy-plot-axis-line-color; -} - -.rv-xy-plot__series, -.rv-xy-plot__series path { - pointer-events: all; -} - -.rv-xy-plot__series--line { - fill: none; - stroke: #000; - stroke-width: 2px; -} - -.rv-crosshair { - position: absolute; - font-size: 11px; - pointer-events: none; -} - -.rv-crosshair__line { - background: #47d3d9; - width: 1px; -} - -.rv-crosshair__inner { - position: absolute; - text-align: left; - top: 0; -} - -.rv-crosshair__inner__content { - border-radius: $rv-xy-plot-tooltip-border-radius; - background: $rv-xy-plot-tooltip-background; - color: $rv-xy-plot-tooltip-color; - font-size: $rv-xy-plot-tooltip-font-size; - padding: $rv-xy-plot-tooltip-padding; - box-shadow: $rv-xy-plot-tooltip-shadow; -} - -.rv-crosshair__inner--left { - right: 4px; -} - -.rv-crosshair__inner--right { - left: 4px; -} - -.rv-crosshair__title { - font-weight: bold; - white-space: nowrap; -} - -.rv-crosshair__item { - white-space: nowrap; -} - -.rv-hint { - position: absolute; - pointer-events: none; -} - -.rv-hint__content { - border-radius: $rv-xy-plot-tooltip-border-radius; - padding: $rv-xy-plot-tooltip-padding; - font-size: $rv-xy-plot-tooltip-font-size; - background: $rv-xy-plot-tooltip-background; - box-shadow: $rv-xy-plot-tooltip-shadow; - color: $rv-xy-plot-tooltip-color; - text-align: left; - white-space: nowrap; -} diff --git a/dist/styles/radial-chart.scss b/dist/styles/radial-chart.scss deleted file mode 100644 index 854a57d4b..000000000 --- a/dist/styles/radial-chart.scss +++ /dev/null @@ -1,6 +0,0 @@ -.rv-radial-chart { - - .rv-xy-plot__series--label { - pointer-events: none; - } -} diff --git a/dist/styles/treemap.scss b/dist/styles/treemap.scss deleted file mode 100644 index 4626d66ea..000000000 --- a/dist/styles/treemap.scss +++ /dev/null @@ -1,22 +0,0 @@ -.rv-treemap { - font-size: 12px; - position: relative; -} - -.rv-treemap__leaf { - overflow: hidden; - position: absolute; -} - -.rv-treemap__leaf--circle { - align-items: center; - border-radius: 100%; - display: flex; - justify-content: center; -} - -.rv-treemap__leaf__content { - overflow: hidden; - padding: 10px; - text-overflow: ellipsis; -} diff --git a/dist/sunburst/index.js b/dist/sunburst/index.js deleted file mode 100644 index a9c12d6c2..000000000 --- a/dist/sunburst/index.js +++ /dev/null @@ -1,253 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Hierarchy = require('d3-hierarchy'); - -var _d3Scale = require('d3-scale'); - -var _animation = require('../animation'); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -var _arcSeries = require('../plot/series/arc-series'); - -var _arcSeries2 = _interopRequireDefault(_arcSeries); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _seriesUtils = require('../utils/series-utils'); - -var _chartUtils = require('../utils/chart-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var predefinedClassName = 'rv-sunburst'; - -var LISTENERS_TO_OVERWRITE = ['onValueMouseOver', 'onValueMouseOut', 'onValueClick', 'onValueRightClick', 'onSeriesMouseOver', 'onSeriesMouseOut', 'onSeriesClick', 'onSeriesRightClick']; - -/** - * Create the list of nodes to render. - * @param {Object} props - props.data {Object} - tree structured data (each node has a name anc an array of children) - props.height {number} - the height of the graphic to be rendered - props.hideRootNode {boolean} - whether or not to hide the root node - props.width {number} - the width of the graphic to be rendered - props.getSize {function} - accessor for the size - * @returns {Array} Array of nodes. - */ -function getNodesToRender(_ref) { - var data = _ref.data, - height = _ref.height, - hideRootNode = _ref.hideRootNode, - width = _ref.width, - getSize = _ref.getSize; - - var partitionFunction = (0, _d3Hierarchy.partition)(); - var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize); - var radius = Math.min(width, height) / 2 - 10; - var x = (0, _d3Scale.scaleLinear)().range([0, 2 * Math.PI]); - var y = (0, _d3Scale.scaleSqrt)().range([0, radius]); - - return partitionFunction(structuredInput).descendants().reduce(function (res, cell, index) { - if (hideRootNode && index === 0) { - return res; - } - - return res.concat([_extends({ - angle0: Math.max(0, Math.min(2 * Math.PI, x(cell.x0))), - angle: Math.max(0, Math.min(2 * Math.PI, x(cell.x1))), - radius0: Math.max(0, y(cell.y0)), - radius: Math.max(0, y(cell.y1)), - depth: cell.depth, - parent: cell.parent - }, cell.data)]); - }, []); -} - -/** - * Convert arc nodes into label rows. - * Important to use mappedData rather than regular data, bc it is already unrolled - * @param {Array} mappedData - Array of nodes. - * @param {Object} accessors - object of accessors - * @returns {Array} array of node for rendering as labels - */ -function buildLabels(mappedData, accessors) { - var getAngle = accessors.getAngle, - getAngle0 = accessors.getAngle0, - getLabel = accessors.getLabel, - getRadius0 = accessors.getRadius0; - - - return mappedData.filter(getLabel).map(function (row) { - var truedAngle = -1 * getAngle(row) + Math.PI / 2; - var truedAngle0 = -1 * getAngle0(row) + Math.PI / 2; - var angle = (truedAngle0 + truedAngle) / 2; - var rotateLabels = !row.dontRotateLabel; - var rotAngle = -angle / (2 * Math.PI) * 360; - - return _extends({}, row, { - children: null, - angle: null, - radius: null, - x: getRadius0(row) * Math.cos(angle), - y: getRadius0(row) * Math.sin(angle), - style: _extends({ - textAnchor: rotAngle > 90 ? 'end' : 'start' - }, row.labelStyle), - rotation: rotateLabels ? rotAngle > 90 ? rotAngle + 180 : rotAngle === 90 ? 90 : rotAngle : null - }); - }); -} - -var NOOP = function NOOP() {}; - -function Sunburst(props) { - var getAngle = props.getAngle, - getAngle0 = props.getAngle0, - animation = props.animation, - className = props.className, - children = props.children, - data = props.data, - height = props.height, - hideRootNode = props.hideRootNode, - getLabel = props.getLabel, - width = props.width, - getSize = props.getSize, - colorType = props.colorType; - - var mappedData = getNodesToRender({ - data: data, - height: height, - hideRootNode: hideRootNode, - width: width, - getSize: getSize - }); - var radialDomain = (0, _seriesUtils.getRadialDomain)(mappedData); - var margin = (0, _chartUtils.getRadialLayoutMargin)(width, height, radialDomain); - - var labelData = buildLabels(mappedData, { - getAngle: getAngle, - getAngle0: getAngle0, - getLabel: getLabel, - getRadius0: function getRadius0(d) { - return d.radius0; - } - }); - - var hofBuilder = function hofBuilder(f) { - return function (e, i) { - return f ? f(mappedData[e.index], i) : NOOP; - }; - }; - return _react2.default.createElement( - _xyPlot2.default, - { - height: height, - hasTreeStructure: true, - width: width, - className: predefinedClassName + ' ' + className, - margin: margin, - xDomain: [-radialDomain, radialDomain], - yDomain: [-radialDomain, radialDomain] - }, - _react2.default.createElement(_arcSeries2.default, _extends({ - colorType: colorType - }, props, { - animation: animation, - radiusDomain: [0, radialDomain], - // need to present a stripped down version for interpolation - data: animation ? mappedData.map(function (row, index) { - return _extends({}, row, { - parent: null, - children: null, - index: index - }); - }) : mappedData, - _data: animation ? mappedData : null, - arcClassName: predefinedClassName + '__series--radial__arc' - }, LISTENERS_TO_OVERWRITE.reduce(function (acc, propName) { - var prop = props[propName]; - acc[propName] = animation ? hofBuilder(prop) : prop; - return acc; - }, {}))), - labelData.length > 0 && _react2.default.createElement(_labelSeries2.default, { data: labelData, getLabel: getLabel }), - children - ); -} - -Sunburst.displayName = 'Sunburst'; -Sunburst.propTypes = { - animation: _animation.AnimationPropType, - getAngle: _propTypes2.default.func, - getAngle0: _propTypes2.default.func, - className: _propTypes2.default.string, - colorType: _propTypes2.default.string, - data: _propTypes2.default.object.isRequired, - height: _propTypes2.default.number.isRequired, - hideRootNode: _propTypes2.default.bool, - getLabel: _propTypes2.default.func, - onValueClick: _propTypes2.default.func, - onValueMouseOver: _propTypes2.default.func, - onValueMouseOut: _propTypes2.default.func, - getSize: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired, - padAngle: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.number]) -}; -Sunburst.defaultProps = { - getAngle: function getAngle(d) { - return d.angle; - }, - getAngle0: function getAngle0(d) { - return d.angle0; - }, - className: '', - colorType: 'literal', - getColor: function getColor(d) { - return d.color; - }, - hideRootNode: false, - getLabel: function getLabel(d) { - return d.label; - }, - getSize: function getSize(d) { - return d.size; - }, - padAngle: 0 -}; - -exports.default = Sunburst; \ No newline at end of file diff --git a/dist/theme.js b/dist/theme.js deleted file mode 100644 index 3807452c3..000000000 --- a/dist/theme.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var DISCRETE_COLOR_RANGE = exports.DISCRETE_COLOR_RANGE = ['#12939A', '#79C7E3', '#1A3177', '#FF9833', '#EF5D28']; - -var EXTENDED_DISCRETE_COLOR_RANGE = exports.EXTENDED_DISCRETE_COLOR_RANGE = ['#19CDD7', '#DDB27C', '#88572C', '#FF991F', '#F15C17', '#223F9A', '#DA70BF', '#125C77', '#4DC19C', '#776E57', '#12939A', '#17B8BE', '#F6D18A', '#B7885E', '#FFCB99', '#F89570', '#829AE3', '#E79FD5', '#1E96BE', '#89DAC1', '#B3AD9E']; - -var CONTINUOUS_COLOR_RANGE = exports.CONTINUOUS_COLOR_RANGE = ['#EF5D28', '#FF9833']; - -var SIZE_RANGE = exports.SIZE_RANGE = [1, 10]; - -var OPACITY_RANGE = exports.OPACITY_RANGE = [0.1, 1]; -var OPACITY_TYPE = exports.OPACITY_TYPE = 'literal'; -var DEFAULT_OPACITY = exports.DEFAULT_OPACITY = 1; - -var DEFAULT_SIZE = exports.DEFAULT_SIZE = 5; - -var DEFAULT_COLOR = exports.DEFAULT_COLOR = DISCRETE_COLOR_RANGE[0]; - -var DEFAULT_TICK_SIZE = exports.DEFAULT_TICK_SIZE = 7; \ No newline at end of file diff --git a/dist/treemap/index.js b/dist/treemap/index.js deleted file mode 100644 index 27244fe2d..000000000 --- a/dist/treemap/index.js +++ /dev/null @@ -1,254 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -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 _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _d3Hierarchy = require('d3-hierarchy'); - -var _theme = require('../theme'); - -var _animation = require('../animation'); - -var _scalesUtils = require('../utils/scales-utils'); - -var _chartUtils = require('../utils/chart-utils'); - -var _treemapDom = require('./treemap-dom'); - -var _treemapDom2 = _interopRequireDefault(_treemapDom); - -var _treemapSvg = require('./treemap-svg'); - -var _treemapSvg2 = _interopRequireDefault(_treemapSvg); - -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; } - -var TREEMAP_TILE_MODES = { - squarify: _d3Hierarchy.treemapSquarify, - resquarify: _d3Hierarchy.treemapResquarify, - slice: _d3Hierarchy.treemapSlice, - dice: _d3Hierarchy.treemapDice, - slicedice: _d3Hierarchy.treemapSliceDice, - binary: _d3Hierarchy.treemapBinary -}; - -var TREEMAP_LAYOUT_MODES = ['circlePack', 'partition', 'partition-pivot']; - -var NOOP = function NOOP(d) { - return d; -}; - -var ATTRIBUTES = ['opacity', 'color']; - -var DEFAULT_MARGINS = { - left: 40, - right: 10, - top: 10, - bottom: 40 -}; - -/** - * Get the map of scale functions from the given props. - * @param {Object} props Props for the component. - * @returns {Object} Map of scale functions. - * @private - */ -function _getScaleFns(props) { - var data = props.data; - - var allData = data.children || []; - - // Adding _allData property to the object to reuse the existing - // getAttributeFunctor function. - var compatibleProps = _extends({}, props, (0, _scalesUtils.getMissingScaleProps)(props, allData, ATTRIBUTES), { - _allData: allData - }); - return { - opacity: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'opacity'), - color: (0, _scalesUtils.getAttributeFunctor)(compatibleProps, 'color') - }; -} - -var Treemap = function (_React$Component) { - _inherits(Treemap, _React$Component); - - function Treemap(props) { - _classCallCheck(this, Treemap); - - var _this = _possibleConstructorReturn(this, (Treemap.__proto__ || Object.getPrototypeOf(Treemap)).call(this, props)); - - _this.state = _extends({ - scales: _getScaleFns(props) - }, (0, _chartUtils.getInnerDimensions)(props, props.margin)); - return _this; - } - - _createClass(Treemap, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { - this.setState(_extends({ - scales: _getScaleFns(props) - }, (0, _chartUtils.getInnerDimensions)(props, props.margin))); - } - - /** - * Create the list of nodes to render. - * @returns {Array} Array of nodes. - * @private - */ - - }, { - key: '_getNodesToRender', - value: function _getNodesToRender() { - var _state = this.state, - innerWidth = _state.innerWidth, - innerHeight = _state.innerHeight; - var _props = this.props, - data = _props.data, - mode = _props.mode, - padding = _props.padding, - sortFunction = _props.sortFunction, - getSize = _props.getSize; - - if (!data) { - return []; - } - - if (mode === 'partition' || mode === 'partition-pivot') { - var partitionFunction = (0, _d3Hierarchy.partition)().size(mode === 'partition-pivot' ? [innerHeight, innerWidth] : [innerWidth, innerHeight]).padding(padding); - var _structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { - return sortFunction(a, b, getSize); - }); - var mappedNodes = partitionFunction(_structuredInput).descendants(); - if (mode === 'partition-pivot') { - return mappedNodes.map(function (node) { - return _extends({}, node, { - x0: node.y0, - x1: node.y1, - y0: node.x0, - y1: node.x1 - }); - }); - } - return mappedNodes; - } - if (mode === 'circlePack') { - var packingFunction = (0, _d3Hierarchy.pack)().size([innerWidth, innerHeight]).padding(padding); - var _structuredInput2 = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { - return sortFunction(a, b, getSize); - }); - return packingFunction(_structuredInput2).descendants(); - } - - var tileFn = TREEMAP_TILE_MODES[mode]; - var treemapingFunction = (0, _d3Hierarchy.treemap)(tileFn).tile(tileFn).size([innerWidth, innerHeight]).padding(padding); - var structuredInput = (0, _d3Hierarchy.hierarchy)(data).sum(getSize).sort(function (a, b) { - return sortFunction(a, b, getSize); - }); - return treemapingFunction(structuredInput).descendants(); - } - }, { - key: 'render', - value: function render() { - var renderMode = this.props.renderMode; - var scales = this.state.scales; - - var nodes = this._getNodesToRender(); - var TreemapElement = renderMode === 'SVG' ? _treemapSvg2.default : _treemapDom2.default; - return _react2.default.createElement(TreemapElement, _extends({}, this.props, { nodes: nodes, scales: scales })); - } - }]); - - return Treemap; -}(_react2.default.Component); - -Treemap.displayName = 'Treemap'; -Treemap.propTypes = { - animation: _animation.AnimationPropType, - className: _propTypes2.default.string, - data: _propTypes2.default.object.isRequired, - height: _propTypes2.default.number.isRequired, - hideRootNode: _propTypes2.default.bool, - margin: _chartUtils.MarginPropType, - mode: _propTypes2.default.oneOf(Object.keys(TREEMAP_TILE_MODES).concat(TREEMAP_LAYOUT_MODES)), - onLeafClick: _propTypes2.default.func, - onLeafMouseOver: _propTypes2.default.func, - onLeafMouseOut: _propTypes2.default.func, - useCirclePacking: _propTypes2.default.bool, - padding: _propTypes2.default.number.isRequired, - sortFunction: _propTypes2.default.func, - width: _propTypes2.default.number.isRequired, - getSize: _propTypes2.default.func, - getColor: _propTypes2.default.func -}; - -Treemap.defaultProps = { - className: '', - colorRange: _theme.CONTINUOUS_COLOR_RANGE, - _colorValue: _theme.DEFAULT_COLOR, - data: { - children: [] - }, - hideRootNode: false, - margin: DEFAULT_MARGINS, - mode: 'squarify', - onLeafClick: NOOP, - onLeafMouseOver: NOOP, - onLeafMouseOut: NOOP, - opacityType: _theme.OPACITY_TYPE, - _opacityValue: _theme.DEFAULT_OPACITY, - padding: 1, - sortFunction: function sortFunction(a, b, accessor) { - if (!accessor) { - return 0; - } - return accessor(a) - accessor(b); - }, - getSize: function getSize(d) { - return d.size; - }, - getColor: function getColor(d) { - return d.color; - }, - getLabel: function getLabel(d) { - return d.title; - } -}; -exports.default = Treemap; \ No newline at end of file diff --git a/dist/treemap/treemap-dom.js b/dist/treemap/treemap-dom.js deleted file mode 100644 index b8112f0a9..000000000 --- a/dist/treemap/treemap-dom.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _treemapLeaf = require('./treemap-leaf'); - -var _treemapLeaf2 = _interopRequireDefault(_treemapLeaf); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function TreemapDOM(props) { - var animation = props.animation, - className = props.className, - height = props.height, - hideRootNode = props.hideRootNode, - getLabel = props.getLabel, - mode = props.mode, - nodes = props.nodes, - width = props.width, - scales = props.scales, - style = props.style; - - var useCirclePacking = mode === 'circlePack'; - return _react2.default.createElement( - 'div', - { - className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, - style: { height: height, width: width } - }, - nodes.map(function (node, index) { - // throw out the rootest node - if (hideRootNode && !index) { - return null; - } - - var nodeProps = _extends({ - animation: animation, - node: node, - getLabel: getLabel - }, props, { - x0: useCirclePacking ? node.x : node.x0, - x1: useCirclePacking ? node.x : node.x1, - y0: useCirclePacking ? node.y : node.y0, - y1: useCirclePacking ? node.y : node.y1, - r: useCirclePacking ? node.r : 1, - scales: scales, - style: style - }); - return _react2.default.createElement(_treemapLeaf2.default, _extends({}, nodeProps, { key: 'leaf-' + index })); - }) - ); -} - -TreemapDOM.displayName = 'TreemapDOM'; -exports.default = TreemapDOM; \ No newline at end of file diff --git a/dist/treemap/treemap-leaf.js b/dist/treemap/treemap-leaf.js deleted file mode 100644 index d0a67615f..000000000 --- a/dist/treemap/treemap-leaf.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _animation = require('../animation'); - -var _animation2 = _interopRequireDefault(_animation); - -var _scalesUtils = require('../utils/scales-utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var ANIMATED_PROPS = ['colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'x0', 'x1', 'y0', 'y1', 'r']; - -function TreemapLeaf(props) { - var animation = props.animation, - getLabel = props.getLabel, - mode = props.mode, - node = props.node, - onLeafClick = props.onLeafClick, - onLeafMouseOver = props.onLeafMouseOver, - onLeafMouseOut = props.onLeafMouseOut, - r = props.r, - scales = props.scales, - x0 = props.x0, - x1 = props.x1, - y0 = props.y0, - y1 = props.y1, - style = props.style; - - - if (animation) { - return _react2.default.createElement( - _animation2.default, - _extends({}, props, { animatedProps: ANIMATED_PROPS }), - _react2.default.createElement(TreemapLeaf, _extends({}, props, { animation: null })) - ); - } - var useCirclePacking = mode === 'circlePack'; - var background = scales.color(node); - var opacity = scales.opacity(node); - var color = (0, _scalesUtils.getFontColorFromBackground)(background); - var data = node.data; - - var title = getLabel(data); - var leafStyle = _extends({ - top: useCirclePacking ? y0 - r : y0, - left: useCirclePacking ? x0 - r : x0, - width: useCirclePacking ? r * 2 : x1 - x0, - height: useCirclePacking ? r * 2 : y1 - y0, - background: background, - opacity: opacity, - color: color - }, style, node.data.style); - - return _react2.default.createElement( - 'div', - { - className: 'rv-treemap__leaf ' + (useCirclePacking ? 'rv-treemap__leaf--circle' : ''), - onMouseEnter: function onMouseEnter(event) { - return onLeafMouseOver(node, event); - }, - onMouseLeave: function onMouseLeave(event) { - return onLeafMouseOut(node, event); - }, - onClick: function onClick(event) { - return onLeafClick(node, event); - }, - style: leafStyle - }, - _react2.default.createElement( - 'div', - { className: 'rv-treemap__leaf__content' }, - title - ) - ); -} - -TreemapLeaf.propTypes = { - animation: _animation.AnimationPropType, - height: _propTypes2.default.number.isRequired, - mode: _propTypes2.default.string, - node: _propTypes2.default.object.isRequired, - onLeafClick: _propTypes2.default.func, - onLeafMouseOver: _propTypes2.default.func, - onLeafMouseOut: _propTypes2.default.func, - scales: _propTypes2.default.object.isRequired, - width: _propTypes2.default.number.isRequired, - r: _propTypes2.default.number.isRequired, - x0: _propTypes2.default.number.isRequired, - x1: _propTypes2.default.number.isRequired, - y0: _propTypes2.default.number.isRequired, - y1: _propTypes2.default.number.isRequired -}; -exports.default = TreemapLeaf; \ No newline at end of file diff --git a/dist/treemap/treemap-svg.js b/dist/treemap/treemap-svg.js deleted file mode 100644 index 6255dafbc..000000000 --- a/dist/treemap/treemap-svg.js +++ /dev/null @@ -1,246 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -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); - -var _xyPlot = require('../plot/xy-plot'); - -var _xyPlot2 = _interopRequireDefault(_xyPlot); - -var _polygonSeries = require('../plot/series/polygon-series'); - -var _polygonSeries2 = _interopRequireDefault(_polygonSeries); - -var _markSeries = require('../plot/series/mark-series'); - -var _markSeries2 = _interopRequireDefault(_markSeries); - -var _labelSeries = require('../plot/series/label-series'); - -var _labelSeries2 = _interopRequireDefault(_labelSeries); - -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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var MARGIN_ADJUST = 1.2; - -var TreemapSVG = function (_React$Component) { - _inherits(TreemapSVG, _React$Component); - - function TreemapSVG() { - _classCallCheck(this, TreemapSVG); - - return _possibleConstructorReturn(this, (TreemapSVG.__proto__ || Object.getPrototypeOf(TreemapSVG)).apply(this, arguments)); - } - - _createClass(TreemapSVG, [{ - key: 'getCircularNodes', - value: function getCircularNodes() { - var _props = this.props, - animation = _props.animation, - hideRootNode = _props.hideRootNode, - nodes = _props.nodes, - onLeafMouseOver = _props.onLeafMouseOver, - onLeafMouseOut = _props.onLeafMouseOut, - onLeafClick = _props.onLeafClick, - scales = _props.scales, - style = _props.style; - - var _nodes$reduce = nodes.reduce(function (acc, node, index) { - if (!index && hideRootNode) { - return acc; - } - var x = node.x, - y = node.y, - r = node.r; - - return { - maxY: Math.max(y + r, acc.maxY), - minY: Math.min(y - r, acc.minY), - maxX: Math.max(x + MARGIN_ADJUST * r, acc.maxX), - minX: Math.min(x - MARGIN_ADJUST * r, acc.minX), - rows: acc.rows.concat([{ - x: x, - y: y, - size: r, - color: scales.color(node) - }]) - }; - }, { - rows: [], - maxY: -Infinity, - minY: Infinity, - maxX: -Infinity, - minX: Infinity - }), - rows = _nodes$reduce.rows, - minY = _nodes$reduce.minY, - maxY = _nodes$reduce.maxY, - minX = _nodes$reduce.minX, - maxX = _nodes$reduce.maxX; - - return { - updatedNodes: _react2.default.createElement(_markSeries2.default, { - animation: animation, - className: 'rv-treemap__leaf rv-treemap__leaf--circle', - onSeriesMouseEnter: onLeafMouseOver, - onSeriesMouseLeave: onLeafMouseOut, - onSeriesClick: onLeafClick, - data: rows, - colorType: 'literal', - getColor: function getColor(d) { - return d.color; - }, - sizeType: 'literal', - getSize: function getSize(d) { - return d.size; - }, - style: style - }), - minY: minY, - maxY: maxY, - minX: minX, - maxX: maxX - }; - } - }, { - key: 'getNonCircularNodes', - value: function getNonCircularNodes() { - var _props2 = this.props, - animation = _props2.animation, - hideRootNode = _props2.hideRootNode, - nodes = _props2.nodes, - onLeafMouseOver = _props2.onLeafMouseOver, - onLeafMouseOut = _props2.onLeafMouseOut, - onLeafClick = _props2.onLeafClick, - scales = _props2.scales, - style = _props2.style; - var color = scales.color; - - return nodes.reduce(function (acc, node, index) { - if (!index && hideRootNode) { - return acc; - } - var x0 = node.x0, - x1 = node.x1, - y1 = node.y1, - y0 = node.y0; - - var x = x0; - var y = y0; - var nodeHeight = y1 - y0; - var nodeWidth = x1 - x0; - - acc.maxY = Math.max(y + nodeHeight, acc.maxY); - acc.minY = Math.min(y, acc.minY); - acc.maxX = Math.max(x + nodeWidth, acc.maxX); - acc.minX = Math.min(x, acc.minX); - - var data = [{ x: x, y: y }, { x: x, y: y + nodeHeight }, { x: x + nodeWidth, y: y + nodeHeight }, { x: x + nodeWidth, y: y }]; - - acc.updatedNodes = acc.updatedNodes.concat([_react2.default.createElement(_polygonSeries2.default, { - animation: animation, - className: 'rv-treemap__leaf', - key: index, - color: color(node), - type: 'literal', - onSeriesMouseEnter: onLeafMouseOver, - onSeriesMouseLeave: onLeafMouseOut, - onSeriesClick: onLeafClick, - data: data, - style: _extends({}, style, node.style) - })]); - return acc; - }, { - updatedNodes: [], - maxY: -Infinity, - minY: Infinity, - maxX: -Infinity, - minX: Infinity - }); - } - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - className = _props3.className, - height = _props3.height, - mode = _props3.mode, - nodes = _props3.nodes, - width = _props3.width; - - var useCirclePacking = mode === 'circlePack'; - - var _ref = useCirclePacking ? this.getCircularNodes() : this.getNonCircularNodes(), - minY = _ref.minY, - maxY = _ref.maxY, - minX = _ref.minX, - maxX = _ref.maxX, - updatedNodes = _ref.updatedNodes; - - var labels = nodes.reduce(function (acc, node) { - if (!node.data.title) { - return acc; - } - return acc.concat(_extends({}, node.data, { - x: node.x0 || node.x, - y: node.y0 || node.y, - label: '' + node.data.title - })); - }, []); - - return _react2.default.createElement( - _xyPlot2.default, - _extends({ - className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className, - width: width, - height: height, - yDomain: [maxY, minY], - xDomain: [minX, maxX], - colorType: 'literal', - hasTreeStructure: true - }, this.props), - updatedNodes, - _react2.default.createElement(_labelSeries2.default, { data: labels }) - ); - } - }]); - - return TreemapSVG; -}(_react2.default.Component); - -TreemapSVG.displayName = 'TreemapSVG'; - -exports.default = TreemapSVG; \ No newline at end of file diff --git a/dist/utils/axis-utils.js b/dist/utils/axis-utils.js deleted file mode 100644 index db9f09fa9..000000000 --- a/dist/utils/axis-utils.js +++ /dev/null @@ -1,167 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DIRECTION = exports.ORIENTATION = undefined; -exports.getTicksTotalFromSize = getTicksTotalFromSize; -exports.getTickValues = getTickValues; -exports.generateFit = generateFit; -exports.generatePoints = generatePoints; -exports.getAxisAngle = getAxisAngle; - -var _d3Array = require('d3-array'); - -var _d3Scale = require('d3-scale'); - -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -var ORIENTATION = exports.ORIENTATION = { - TOP: 'top', - LEFT: 'left', - RIGHT: 'right', - BOTTOM: 'bottom', - VERTICAL: 'vertical', - HORIZONTAL: 'horizontal' -}; - -var DIRECTION = exports.DIRECTION = { - VERTICAL: 'vertical', - HORIZONTAL: 'horizontal' -}; - -/** - * Get total amount of ticks from a given size in pixels. - * @param {number} size Size of the axis in pixels. - * @returns {number} Total amount of ticks. - */ -function getTicksTotalFromSize(size) { - if (size < 700) { - if (size > 300) { - return 10; - } - return 5; - } - return 20; -} - -/** - * Get the tick values from a given d3 scale. - * @param {d3.scale} scale Scale function. - * @param {number} tickTotal Total number of ticks - * @param {Array} tickValues Array of tick values if they exist. - * @returns {Array} Array of tick values. - */ -function getTickValues(scale, tickTotal, tickValues) { - return !tickValues ? scale.ticks ? scale.ticks(tickTotal) : scale.domain() : tickValues; -} - -/** - * Generate a description of a decorative axis in terms of a linear equation - * y = slope * x + offset in coordinates - * @param {Object} axisStart Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @param {Object} axisEnd Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @returns {Number} Object describing each the line in coordinates - */ -function generateFit(axisStart, axisEnd) { - // address the special case when the slope is infinite - if (axisStart.x === axisEnd.x) { - return { - left: axisStart.y, - right: axisEnd.y, - slope: 0, - offset: axisStart.x - }; - } - var slope = (axisStart.y - axisEnd.y) / (axisStart.x - axisEnd.x); - return { - left: axisStart.x, - right: axisEnd.x, - // generate the linear projection of the axis direction - slope: slope, - offset: axisStart.y - slope * axisStart.x - }; -} - -/** - * Generate a description of a decorative axis in terms of a linear equation - * y = slope * x + offset in coordinates - * @param props - * props.@param {Object} axisStart Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * props.@param {Object} axisEnd Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * props.@param {Number} numberOfTicks The number of ticks on the axis - * props.@param {Array.Numbers} axisDomain The values to be interpolated across for the axis - * @returns {Number} Object describing the slope and the specific coordinates of the points - */ -function generatePoints(_ref) { - var axisStart = _ref.axisStart, - axisEnd = _ref.axisEnd, - numberOfTicks = _ref.numberOfTicks, - axisDomain = _ref.axisDomain; - - var _generateFit = generateFit(axisStart, axisEnd), - left = _generateFit.left, - right = _generateFit.right, - slope = _generateFit.slope, - offset = _generateFit.offset; - // construct a linear band of points, then map them - - - var pointSlope = (right - left) / numberOfTicks; - var axisScale = (0, _d3Scale.scaleLinear)().domain([left, right]).range(axisDomain); - - var slopeVertical = axisStart.x === axisEnd.x; - return { - slope: slopeVertical ? Infinity : slope, - points: (0, _d3Array.range)(left, right + pointSlope, pointSlope).map(function (val) { - if (slopeVertical) { - return { y: val, x: slope * val + offset, text: axisScale(val) }; - } - return { x: val, y: slope * val + offset, text: axisScale(val) }; - }).slice(0, numberOfTicks + 1) - }; -} - -/** - * Compute the angle (in radians) of a decorative axis - * @param {Object} axisStart Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @param {Object} axisEnd Object of format {x, y} describing in coordinates - * the start position of the decorative axis - * @returns {Number} Angle in radials - */ -function getAxisAngle(axisStart, axisEnd) { - if (axisStart.x === axisEnd.x) { - return axisEnd.y > axisStart.y ? Math.PI / 2 : 3 * Math.PI / 2; - } - return Math.atan((axisEnd.y - axisStart.y) / (axisEnd.x - axisStart.x)); -} - -exports.default = { - DIRECTION: DIRECTION, - ORIENTATION: ORIENTATION, - getTicksTotalFromSize: getTicksTotalFromSize, - getTickValues: getTickValues -}; \ No newline at end of file diff --git a/dist/utils/chart-utils.js b/dist/utils/chart-utils.js deleted file mode 100644 index 296899ae8..000000000 --- a/dist/utils/chart-utils.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DEFAULT_MARGINS = exports.MarginPropType = undefined; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.getInnerDimensions = getInnerDimensions; -exports.getRadialLayoutMargin = getRadialLayoutMargin; - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Get the dimensions of the component for the future use. - * @param {Object} props Props. - * @param {Object} defaultMargins Object with default margins. - * @returns {Object} Dimensions of the component. - */ -function getInnerDimensions(props, defaultMargins) { - var margin = props.margin, - width = props.width, - height = props.height; - - var marginProps = _extends({}, defaultMargins, typeof margin === 'number' ? { - left: margin, - right: margin, - top: margin, - bottom: margin - } : margin); - var _marginProps$left = marginProps.left, - marginLeft = _marginProps$left === undefined ? 0 : _marginProps$left, - _marginProps$top = marginProps.top, - marginTop = _marginProps$top === undefined ? 0 : _marginProps$top, - _marginProps$right = marginProps.right, - marginRight = _marginProps$right === undefined ? 0 : _marginProps$right, - _marginProps$bottom = marginProps.bottom, - marginBottom = _marginProps$bottom === undefined ? 0 : _marginProps$bottom; - - return { - marginLeft: marginLeft, - marginTop: marginTop, - marginRight: marginRight, - marginBottom: marginBottom, - innerHeight: height - marginBottom - marginTop, - innerWidth: width - marginLeft - marginRight - }; -} - -/** - * Calculate the margin of the sunburst, - * so it can be at the center of the container - * @param {Number} width - the width of the container - * @param {Number} height - the height of the container - * @param {Number} radius - the max radius of the sunburst - * @return {Object} an object includes {bottom, left, right, top} - */ -function getRadialLayoutMargin(width, height, radius) { - var marginX = width / 2 - radius; - var marginY = height / 2 - radius; - return { - bottom: marginY, - left: marginX, - right: marginX, - top: marginY - }; -} - -var MarginPropType = exports.MarginPropType = _propTypes2.default.oneOfType([_propTypes2.default.shape({ - left: _propTypes2.default.number, - top: _propTypes2.default.number, - right: _propTypes2.default.number, - bottom: _propTypes2.default.number -}), _propTypes2.default.number]); - -var DEFAULT_MARGINS = exports.DEFAULT_MARGINS = { - left: 40, - right: 10, - top: 10, - bottom: 40 -}; \ No newline at end of file diff --git a/dist/utils/data-utils.js b/dist/utils/data-utils.js deleted file mode 100644 index af24379d4..000000000 --- a/dist/utils/data-utils.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getUniquePropertyValues = getUniquePropertyValues; -exports.addValueToArray = addValueToArray; -// Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/** - * Get unique property values from an array. - * @param {Array} arr Array of data. - * @param {string} propertyName Prop name. - * @returns {Array} Array of unique values. - */ -function getUniquePropertyValues(arr, accessor) { - var setOfValues = new Set(arr.map(accessor)); - return Array.from(setOfValues); -} - -/** - * Add zero to the domain. - * @param {Array} arr Add zero to the domain. - * @param {Number} value Add zero to domain. - * @returns {Array} Adjusted domain. - */ -function addValueToArray(arr, value) { - var result = [].concat(arr); - if (result[0] > value) { - result[0] = value; - } - if (result[result.length - 1] < value) { - result[result.length - 1] = value; - } - return result; -} \ No newline at end of file diff --git a/dist/utils/react-utils.js b/dist/utils/react-utils.js deleted file mode 100644 index 7bc856814..000000000 --- a/dist/utils/react-utils.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getDOMNode = exports.isReactDOMSupported = undefined; - -var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.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 (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.warning = warning; -exports.warnOnce = warnOnce; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _React$version$split = _react2.default.version.split('.'), - _React$version$split2 = _slicedToArray(_React$version$split, 2), - major = _React$version$split2[0], - minor = _React$version$split2[1]; - -var versionHigherThanThirteen = Number(minor) > 13 || Number(major) > 13; - -var isReactDOMSupported = exports.isReactDOMSupported = function isReactDOMSupported() { - return versionHigherThanThirteen; -}; - -/** - * Support React 0.13 and greater where refs are React components, not DOM - * nodes. - * @param {*} ref React's ref. - * @returns {Element} DOM element. - */ -var getDOMNode = exports.getDOMNode = function getDOMNode(ref) { - if (!isReactDOMSupported()) { - return ref && ref.getDOMNode(); - } - return ref; -}; - -var USED_MESSAGES = {}; -var HIDDEN_PROCESSES = { - test: true, - production: true -}; - -/** - * Warn the user about something - * @param {String} message - the message to be shown - * @param {Boolean} onlyShowMessageOnce - whether or not we allow the - - message to be show multiple times - */ -function warning(message) { - var onlyShowMessageOnce = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - /* eslint-disable no-undef, no-process-env */ - if (global.process && HIDDEN_PROCESSES[process.env.NODE_ENV]) { - return; - } - /* eslint-enable no-undef, no-process-env */ - if (!onlyShowMessageOnce || !USED_MESSAGES[message]) { - /* eslint-disable no-console */ - console.warn(message); - /* eslint-enable no-console */ - USED_MESSAGES[message] = true; - } -} - -/** - * Convience wrapper for warning - * @param {String} message - the message to be shown - */ -function warnOnce(message) { - warning(message, true); -} \ No newline at end of file diff --git a/dist/utils/scales-utils.js b/dist/utils/scales-utils.js deleted file mode 100644 index 1af42b6cc..000000000 --- a/dist/utils/scales-utils.js +++ /dev/null @@ -1,916 +0,0 @@ -'use strict'; - -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[Symbol.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 (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _SCALE_FUNCTIONS; - -exports._getSmallestDistanceIndex = _getSmallestDistanceIndex; -exports.getScaleFnFromScaleObject = getScaleFnFromScaleObject; -exports.getDomainByAccessor = getDomainByAccessor; -exports._getScaleDistanceAndAdjustedDomain = _getScaleDistanceAndAdjustedDomain; -exports._adjustCategoricalScale = _adjustCategoricalScale; -exports.getScaleObjectFromProps = getScaleObjectFromProps; -exports.getAttributeScale = getAttributeScale; -exports.getAttributeFunctor = getAttributeFunctor; -exports.getAttr0Functor = getAttr0Functor; -exports.getAttributeValue = getAttributeValue; -exports.getScalePropTypesByAttribute = getScalePropTypesByAttribute; -exports.extractScalePropsFromProps = extractScalePropsFromProps; -exports.getMissingScaleProps = getMissingScaleProps; -exports.literalScale = literalScale; -exports.getFontColorFromBackground = getFontColorFromBackground; -exports.getXYPlotValues = getXYPlotValues; -exports.getOptionalScaleProps = getOptionalScaleProps; - -var _d3Scale = require('d3-scale'); - -var _d3Array = require('d3-array'); - -var _d3Collection = require('d3-collection'); - -var _d3Color = require('d3-color'); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -var _reactUtils = require('./react-utils'); - -var _dataUtils = require('./data-utils'); - -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 _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; } // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -/** - * Linear scale name. - * @type {string} - * @const - */ -var LINEAR_SCALE_TYPE = 'linear'; - -/** - * Ordinal scale name. - * @type {string} - * @const - */ -var ORDINAL_SCALE_TYPE = 'ordinal'; - -/** - * Category scale. - * @type {string} - * @const - */ -var CATEGORY_SCALE_TYPE = 'category'; - -/** - * Literal scale. - * Differs slightly from d3's identity scale in that it does not coerce value - * into numbers, it simply returns exactly what you give it - * @type {string} - * @const - */ -var LITERAL_SCALE_TYPE = 'literal'; - -/** - * Log scale name. - * @type {string} - * @const - */ -var LOG_SCALE_TYPE = 'log'; - -/** - * Time scale name. - * @type {string} - * @const - */ -var TIME_SCALE_TYPE = 'time'; - -/** - * Time UTC scale name. - * @type {string} - * @const - */ -var TIME_UTC_SCALE_TYPE = 'time-utc'; - -/** - * Scale functions that are supported in the library. - * @type {Object} - * @const - */ -var SCALE_FUNCTIONS = (_SCALE_FUNCTIONS = {}, _defineProperty(_SCALE_FUNCTIONS, LINEAR_SCALE_TYPE, _d3Scale.scaleLinear), _defineProperty(_SCALE_FUNCTIONS, ORDINAL_SCALE_TYPE, _d3Scale.scalePoint), _defineProperty(_SCALE_FUNCTIONS, CATEGORY_SCALE_TYPE, _d3Scale.scaleOrdinal), _defineProperty(_SCALE_FUNCTIONS, LITERAL_SCALE_TYPE, literalScale), _defineProperty(_SCALE_FUNCTIONS, LOG_SCALE_TYPE, _d3Scale.scaleLog), _defineProperty(_SCALE_FUNCTIONS, TIME_SCALE_TYPE, _d3Scale.scaleTime), _defineProperty(_SCALE_FUNCTIONS, TIME_UTC_SCALE_TYPE, _d3Scale.scaleUtc), _SCALE_FUNCTIONS); - -/** - * Attrs for which a scale can be set up at XYPlot level - * @type {Array} - * @const - */ - -var XYPLOT_ATTR = ['color', 'fill', 'opacity', 'stroke']; - -/** - * Title case a given string - * @param {String} str Array of values. - * @returns {String} titlecased string - */ -function toTitleCase(str) { - return '' + str[0].toUpperCase() + str.slice(1); -} - -/** - * Find the smallest distance between the values on a given scale and return - * the index of the element, where the smallest distance was found. - * It returns the first occurrence of i where - * `scale(value[i]) - scale(value[i - 1])` is minimal - * @param {Array} values Array of values. - * @param {Object} scaleObject Scale object. - * @returns {number} Index of an element where the smallest distance was found. - * @private - */ -function _getSmallestDistanceIndex(values, scaleObject) { - var scaleFn = getScaleFnFromScaleObject(scaleObject); - var result = 0; - if (scaleFn) { - var nextValue = void 0; - var currentValue = scaleFn(values[0]); - var distance = Infinity; - var nextDistance = void 0; - - for (var i = 1; i < values.length; i++) { - nextValue = scaleFn(values[i]); - nextDistance = Math.abs(nextValue - currentValue); - if (nextDistance < distance) { - distance = nextDistance; - result = i; - } - currentValue = nextValue; - } - } - return result; -} - -/** - * This is a workaround for issue that ordinal scale - * does not have invert method implemented in d3-scale. - * @param {Object} Ordinal d3-scale object. - * @returns {void} - * @private - */ - -function addInvertFunctionToOrdinalScaleObject(scale) { - if (scale.invert) return; - - scale.invert = function invert(value) { - var domainIndex = 0; - var n = scale.domain().length; - var reverse = scale.range()[1] < scale.range()[0]; - var start = scale.range()[reverse - 0]; - var stop = scale.range()[1 - reverse]; - - if (value < start + scale.padding() * scale.step()) domainIndex = 0;else if (value > stop - scale.padding() * scale.step()) domainIndex = n - 1;else domainIndex = Math.floor((value - start - scale.padding() * scale.step()) / scale.step()); - - return scale.domain()[domainIndex]; - }; -} - -/** - * Crate a scale function from the scale object. - * @param {Object} scaleObject Scale object. - - scaleObject.domain {Array} - - scaleObject.range {Array} - - scaleObject.type {string} - - scaleObject.attr {string} - * @returns {*} Scale function. - * @private - */ -function getScaleFnFromScaleObject(scaleObject) { - if (!scaleObject) { - return null; - } - var type = scaleObject.type, - domain = scaleObject.domain, - range = scaleObject.range; - - var modDomain = domain[0] === domain[1] ? domain[0] === 0 ? [-1, 0] : [-domain[0], domain[0]] : domain; - if (type === LITERAL_SCALE_TYPE) { - return literalScale(range[0]); - } - var scale = SCALE_FUNCTIONS[type]().domain(modDomain).range(range); - if (type === ORDINAL_SCALE_TYPE) { - scale.padding(0.5); - addInvertFunctionToOrdinalScaleObject(scale); - } - return scale; -} - -/** - * Get the domain from the array of data. - * @param {Array} allData All data. - * @param {function} accessor - accessor for main value. - * @param {function} accessor0 - accessor for the naught value. - * @param {string} type Scale type. - * @returns {Array} Domain. - * @private - */ -function getDomainByAccessor(allData, accessor, accessor0, type) { - var domain = void 0; - - // Collect both attr and available attr0 values from the array of data. - var values = allData.reduce(function (data, d) { - var value = accessor(d); - var value0 = accessor0(d); - if (_isDefined(value)) { - data.push(value); - } - if (_isDefined(value0)) { - data.push(value0); - } - return data; - }, []); - - if (!values.length) { - return []; - } - - // Create proper domain depending on the type of the scale. - if (type !== ORDINAL_SCALE_TYPE && type !== CATEGORY_SCALE_TYPE) { - domain = (0, _d3Array.extent)(values); - } else { - domain = (0, _d3Collection.set)(values).values(); - } - return domain; -} - -/** - * Create custom scale object from the value. When the scale is created from - * this object, it should return the same value all time. - * @param {string} attr Attribute. - * @param {*} value Value. - * @param {string} type - the type of scale being used - * @param {function} accessor - the accessor function - * @param {function} accessor0 - the accessor function for the potential naught value - * @returns {Object} Custom scale object. - * @private - */ -function _createScaleObjectForValue(attr, value, type, accessor, accessor0) { - if (type === LITERAL_SCALE_TYPE) { - return { - type: LITERAL_SCALE_TYPE, - domain: [], - range: [value], - distance: 0, - attr: attr, - baseValue: undefined, - isValue: true, - accessor: accessor, - accessor0: accessor0 - }; - } - if (typeof value === 'undefined') { - return null; - } - return { - type: CATEGORY_SCALE_TYPE, - range: [value], - domain: [], - distance: 0, - attr: attr, - baseValue: undefined, - isValue: true, - accessor: accessor, - accessor0: accessor0 - }; -} - -/** - * Create a regular scale object for a further use from the existing parameters. - * @param {Array} domain - Domain. - * @param {Array} range - Range. - * @param {string} type - Type. - * @param {number} distance - Distance. - * @param {string} attr - Attribute. - * @param {number} baseValue - Base value. - * @param {function} accessor - Attribute accesor - * @param {function} accessor0 - Attribute accesor for potential naught value - * @returns {Object} Scale object. - * @private - */ -function _createScaleObjectForFunction(_ref) { - var domain = _ref.domain, - range = _ref.range, - type = _ref.type, - distance = _ref.distance, - attr = _ref.attr, - baseValue = _ref.baseValue, - accessor = _ref.accessor, - accessor0 = _ref.accessor0; - - return { - domain: domain, - range: range, - type: type, - distance: distance, - attr: attr, - baseValue: baseValue, - isValue: false, - accessor: accessor, - accessor0: accessor0 - }; -} - -/** - * Get scale object from props. E. g. object like {xRange, xDomain, xDistance, - * xType} is transformed into {range, domain, distance, type}. - * @param {Object} props Props. - * @param {string} attr Attribute. - * @returns {*} Null or an object with the scale. - * @private - */ -function _collectScaleObjectFromProps(props, attr) { - var value = props[attr], - fallbackValue = props['_' + attr + 'Value'], - range = props[attr + 'Range'], - _props$ = props[attr + 'Distance'], - distance = _props$ === undefined ? 0 : _props$, - baseValue = props[attr + 'BaseValue'], - _props$2 = props[attr + 'Type'], - type = _props$2 === undefined ? LINEAR_SCALE_TYPE : _props$2, - noFallBack = props[attr + 'NoFallBack'], - _props$3 = props['get' + toTitleCase(attr)], - accessor = _props$3 === undefined ? function (d) { - return d[attr]; - } : _props$3, - _props$4 = props['get' + toTitleCase(attr) + '0'], - accessor0 = _props$4 === undefined ? function (d) { - return d[attr + '0']; - } : _props$4; - var domain = props[attr + 'Domain']; - // Return value-based scale if the value is assigned. - - if (!noFallBack && typeof value !== 'undefined') { - return _createScaleObjectForValue(attr, value, props[attr + 'Type'], accessor, accessor0); - } - // Pick up the domain from the properties and create a new one if it's not - // available. - if (typeof baseValue !== 'undefined') { - domain = (0, _dataUtils.addValueToArray)(domain, baseValue); - } - - // Make sure that the minimum necessary properties exist. - if (!range || !domain || !domain.length) { - // Try to use the fallback value if it is available. - return _createScaleObjectForValue(attr, fallbackValue, props[attr + 'Type'], accessor, accessor0); - } - - return _createScaleObjectForFunction({ - domain: domain, - range: range, - type: type, - distance: distance, - attr: attr, - baseValue: baseValue, - accessor: accessor, - accessor0: accessor0 - }); -} - -/** - * Compute left domain adjustment for the given values. - * @param {Array} values Array of values. - * @returns {number} Domain adjustment. - * @private - */ -function _computeLeftDomainAdjustment(values) { - if (values.length > 1) { - return (values[1] - values[0]) / 2; - } - if (values.length === 1) { - return values[0] - 0.5; - } - return 0; -} - -/** - * Compute right domain adjustment for the given values. - * @param {Array} values Array of values. - * @returns {number} Domain adjustment. - * @private - */ -function _computeRightDomainAdjustment(values) { - if (values.length > 1) { - return (values[values.length - 1] - values[values.length - 2]) / 2; - } - if (values.length === 1) { - return values[0] - 0.5; - } - return 0; -} - -/** - * Compute distance for the given values. - * @param {Array} values Array of values. - * @param {Array} domain Domain. - * @param {number} bestDistIndex Index of a best distance found. - * @param {function} scaleFn Scale function. - * @returns {number} Domain adjustment. - * @private - */ -function _computeScaleDistance(values, domain, bestDistIndex, scaleFn) { - if (values.length > 1) { - // Avoid zero indexes. - var i = Math.max(bestDistIndex, 1); - return Math.abs(scaleFn(values[i]) - scaleFn(values[i - 1])); - } - if (values.length === 1) { - return Math.abs(scaleFn(domain[1]) - scaleFn(domain[0])); - } - return 0; -} - -/** - * Normilize array of values with a single value. - * @param {Array} arr Array of data. - * @param {Array} values Array of values. - * @param {string} attr Attribute. - * @param {string} type Type. - * @private - */ -function _normalizeValues(data, values, accessor0, type) { - if (type === TIME_SCALE_TYPE && values.length === 1) { - var attr0 = accessor0(data[0]); - - return [attr0].concat(_toConsumableArray(values)); - } - - return values; -} - -/** - * Get the distance, the smallest and the largest value of the domain. - * @param {Array} data Array of data for the single series. - * @param {Object} scaleObject Scale object. - * @returns {{domain0: number, domainN: number, distance: number}} Result. - * @private - */ -function _getScaleDistanceAndAdjustedDomain(data, scaleObject) { - var domain = scaleObject.domain, - type = scaleObject.type, - accessor = scaleObject.accessor, - accessor0 = scaleObject.accessor0; - - - var uniqueValues = (0, _dataUtils.getUniquePropertyValues)(data, accessor); - - // Fix time scale if a data has only one value. - var values = _normalizeValues(data, uniqueValues, accessor0, type); - var index = _getSmallestDistanceIndex(values, scaleObject); - - var adjustedDomain = [].concat(domain); - - adjustedDomain[0] -= _computeLeftDomainAdjustment(values); - adjustedDomain[domain.length - 1] += _computeRightDomainAdjustment(values); - // Fix log scale if it's too small. - if (type === LOG_SCALE_TYPE && domain[0] <= 0) { - adjustedDomain[0] = Math.min(domain[1] / 10, 1); - } - - var adjustedScaleFn = getScaleFnFromScaleObject(_extends({}, scaleObject, { - domain: adjustedDomain - })); - - var distance = _computeScaleDistance(values, adjustedDomain, index, adjustedScaleFn); - - return { - domain0: adjustedDomain[0], - domainN: adjustedDomain[adjustedDomain.length - 1], - distance: distance - }; -} - -/** - * Returns true if scale adjustments are possible for a given scale. - * @param {Object} props Props. - * @param {Object} scaleObject Scale object. - * @returns {boolean} True if scale adjustments possible. - * @private - */ -function _isScaleAdjustmentPossible(props, scaleObject) { - var attr = scaleObject.attr; - var _props$_adjustBy = props._adjustBy, - adjustBy = _props$_adjustBy === undefined ? [] : _props$_adjustBy, - _props$_adjustWhat = props._adjustWhat, - adjustWhat = _props$_adjustWhat === undefined ? [] : _props$_adjustWhat; - - // The scale cannot be adjusted if there's no attributes to adjust, no - // suitable values - - return adjustWhat.length && adjustBy.length && adjustBy.indexOf(attr) !== -1; -} - -/** - * Adjust continuous scales (e.g. 'linear', 'log' and 'time') by adding the - * space from the left and right of them and by computing the best distance. - * @param {Object} props Props. - * @param {Object} scaleObject Scale object. - * @returns {*} Scale object with adjustments. - * @private - */ -function _adjustContinuousScale(props, scaleObject) { - var allSeriesData = props._allData, - _props$_adjustWhat2 = props._adjustWhat, - adjustWhat = _props$_adjustWhat2 === undefined ? [] : _props$_adjustWhat2; - - // Assign the initial values. - - var domainLength = scaleObject.domain.length; - var domain = scaleObject.domain; - - var scaleDomain0 = domain[0]; - var scaleDomainN = domain[domainLength - 1]; - var scaleDistance = scaleObject.distance; - - // Find the smallest left position of the domain, the largest right position - // of the domain and the best distance for them. - allSeriesData.forEach(function (data, index) { - if (adjustWhat.indexOf(index) === -1) { - return; - } - if (data && data.length) { - var _getScaleDistanceAndA = _getScaleDistanceAndAdjustedDomain(data, scaleObject), - domain0 = _getScaleDistanceAndA.domain0, - domainN = _getScaleDistanceAndA.domainN, - distance = _getScaleDistanceAndA.distance; - - scaleDomain0 = Math.min(scaleDomain0, domain0); - scaleDomainN = Math.max(scaleDomainN, domainN); - scaleDistance = Math.max(scaleDistance, distance); - } - }); - - scaleObject.domain = [scaleDomain0].concat(_toConsumableArray(domain.slice(1, -1)), [scaleDomainN]); - - scaleObject.distance = scaleDistance; - - return scaleObject; -} - -/** - * Get an adjusted scale. Suitable for 'category' and 'ordinal' scales. - * @param {Object} scaleObject Scale object. - * @returns {*} Scale object with adjustments. - * @private - */ -function _adjustCategoricalScale(scaleObject) { - var scaleFn = getScaleFnFromScaleObject(scaleObject); - var domain = scaleObject.domain, - range = scaleObject.range; - - if (domain.length > 1) { - scaleObject.distance = Math.abs(scaleFn(domain[1]) - scaleFn(domain[0])); - } else { - scaleObject.distance = Math.abs(range[1] - range[0]); - } - - return scaleObject; -} - -/** - * Retrieve a scale object or a value from the properties passed. - * @param {Object} props Object of props. - * @param {string} attr Attribute. - * @returns {*} Scale object, value or null. - */ -function getScaleObjectFromProps(props, attr) { - // Create the initial scale object. - var scaleObject = _collectScaleObjectFromProps(props, attr); - if (!scaleObject) { - return null; - } - - // Make sure if it's possible to add space to the scale object. If not, - // return the object immediately. - if (!_isScaleAdjustmentPossible(props, scaleObject)) { - return scaleObject; - } - - var type = scaleObject.type; - // Depending on what type the scale is, apply different adjustments. Distances - // for the ordinal and category scales are even, equal domains cannot be - // adjusted. - - if (type === ORDINAL_SCALE_TYPE || type === CATEGORY_SCALE_TYPE) { - return _adjustCategoricalScale(scaleObject); - } - return _adjustContinuousScale(props, scaleObject); -} - -/** - * Get d3 scale for a given prop. - * @param {Object} props Props. - * @param {string} attr Attribute. - * @returns {function} d3 scale function. - */ -function getAttributeScale(props, attr) { - var scaleObject = getScaleObjectFromProps(props, attr); - return getScaleFnFromScaleObject(scaleObject); -} - -/** - * Get the value of `attr` from the object. - * @param {Object} d - data Object. - * @param {Function} accessor - accessor function. - * @returns {*} Value of the point. - * @private - */ -function _getAttrValue(d, accessor) { - return accessor(d.data ? d.data : d); -} - -function _isDefined(value) { - return typeof value !== 'undefined'; -} - -/* - * Adds a percentage of padding to a given domain - * @param {Array} domain X or Y domain to pad. - * @param {Number} padding Percentage of padding to add to domain - * @returns {Array} Padded Domain - */ -function _padDomain(domain, padding) { - if (!domain) { - return domain; - } - if (isNaN(parseFloat(domain[0])) || isNaN(parseFloat(domain[1]))) { - return domain; - } - - var _domain = _slicedToArray(domain, 2), - min = _domain[0], - max = _domain[1]; - - var domainPadding = (max - min) * (padding * 0.01); - return [min - domainPadding, max + domainPadding]; -} - -/** - * Get prop functor (either a value or a function) for a given attribute. - * @param {Object} props Series props. - * @param {Function} accessor - Property accessor. - * @returns {*} Function or value. - */ -function getAttributeFunctor(props, attr) { - var scaleObject = getScaleObjectFromProps(props, attr); - if (scaleObject) { - var scaleFn = getScaleFnFromScaleObject(scaleObject); - return function (d) { - return scaleFn(_getAttrValue(d, scaleObject.accessor)); - }; - } - return null; -} - -/** - * Get the functor which extracts value form [attr]0 property. Use baseValue if - * no attr0 property for a given object is defined. Fall back to domain[0] if no - * base value is available. - * @param {Object} props Object of props. - * @param {string} attr Attribute name. - * @returns {*} Function which returns value or null if no values available. - */ -function getAttr0Functor(props, attr) { - var scaleObject = getScaleObjectFromProps(props, attr); - if (scaleObject) { - var domain = scaleObject.domain; - var _scaleObject$baseValu = scaleObject.baseValue, - baseValue = _scaleObject$baseValu === undefined ? domain[0] : _scaleObject$baseValu; - - var scaleFn = getScaleFnFromScaleObject(scaleObject); - return function (d) { - var value = _getAttrValue(d, scaleObject.accessor0); - return scaleFn(_isDefined(value) ? value : baseValue); - }; - } - return null; -} - -/** - * Tries to get the string|number value of the attr and falls back to - * a fallback property in case if the value is a scale. - * @param {Object} props Series props. - * @param {string} attr Property name. - * @returns {*} Function or value. - */ -function getAttributeValue(props, attr) { - var scaleObject = getScaleObjectFromProps(props, attr); - if (scaleObject) { - if (!scaleObject.isValue && props['_' + attr + 'Value'] === undefined) { - (0, _reactUtils.warning)('[React-vis] Cannot use data defined ' + attr + ' for this ' + 'series type. Using fallback value instead.'); - } - return props['_' + attr + 'Value'] || scaleObject.range[0]; - } - return null; -} - -/** - * Get prop types by the attribute. - * @param {string} attr Attribute. - * @returns {Object} Object of xDomain, xRange, xType, xDistance and _xValue, - * where x is an attribute passed to the function. - */ -function getScalePropTypesByAttribute(attr) { - var _ref2; - - return _ref2 = {}, _defineProperty(_ref2, '_' + attr + 'Value', _propTypes2.default.any), _defineProperty(_ref2, attr + 'Domain', _propTypes2.default.array), _defineProperty(_ref2, 'get' + toTitleCase(attr), _propTypes2.default.func), _defineProperty(_ref2, 'get' + toTitleCase(attr) + '0', _propTypes2.default.func), _defineProperty(_ref2, attr + 'Range', _propTypes2.default.array), _defineProperty(_ref2, attr + 'Type', _propTypes2.default.oneOf(Object.keys(SCALE_FUNCTIONS))), _defineProperty(_ref2, attr + 'Distance', _propTypes2.default.number), _defineProperty(_ref2, attr + 'BaseValue', _propTypes2.default.any), _ref2; -} - -/** - * Extract the list of scale properties from the entire props object. - * @param {Object} props Props. - * @param {Array} attributes Array of attributes for the given - * components (for instance, `['x', 'y', 'color']`). - * @returns {Object} Collected props. - */ -function extractScalePropsFromProps(props, attributes) { - var result = {}; - Object.keys(props).forEach(function (key) { - // this filtering is critical for extracting the correct accessors! - var attr = attributes.find(function (a) { - // width - var isPlainSet = key.indexOf(a) === 0; - // Ex: _data - var isUnderscoreSet = key.indexOf('_' + a) === 0; - // EX: getX - var usesGet = key.indexOf('get' + toTitleCase(a)) === 0; - return isPlainSet || isUnderscoreSet || usesGet; - }); - if (!attr) { - return; - } - result[key] = props[key]; - }); - return result; -} - -/** - * Extract the missing scale props from the given data and return them as - * an object. - * @param {Object} props Props. - * @param {Array} data Array of all data. - * @param {Array} attributes Array of attributes for the given - * components (for instance, `['x', 'y', 'color']`). - * @returns {Object} Collected props. - */ -function getMissingScaleProps(props, data, attributes) { - var result = {}; - // Make sure that the domain is set pad it if specified - attributes.forEach(function (attr) { - if (!props['get' + toTitleCase(attr)]) { - result['get' + toTitleCase(attr)] = function (d) { - return d[attr]; - }; - } - if (!props['get' + toTitleCase(attr) + '0']) { - result['get' + toTitleCase(attr) + '0'] = function (d) { - return d[attr + '0']; - }; - } - if (!props[attr + 'Domain']) { - result[attr + 'Domain'] = getDomainByAccessor(data, props['get' + toTitleCase(attr)] || result['get' + toTitleCase(attr)], props['get' + toTitleCase(attr) + '0'] || result['get' + toTitleCase(attr) + '0'], props[attr + 'Type']); - if (props[attr + 'Padding']) { - result[attr + 'Domain'] = _padDomain(result[attr + 'Domain'], props[attr + 'Padding']); - } - } - }); - - return result; -} - -/** - * Return a d3 scale that returns the literal value that was given to it - * @returns {function} literal scale. - */ -function literalScale(defaultValue) { - function scale(d) { - if (d === undefined) { - return defaultValue; - } - return d; - } - - function response() { - return scale; - } - - scale.domain = response; - scale.range = response; - scale.unknown = response; - scale.copy = response; - - return scale; -} - -function getFontColorFromBackground(background) { - if (background) { - return (0, _d3Color.hsl)(background).l > 0.57 ? '#222' : '#fff'; - } - return null; -} - -/** - * Creates fallback values for series from scales defined at XYPlot level. - * @param {Object} props Props of the XYPlot object. - * @param {Array} children Array of components, children of XYPlot - * @returns {Array} Collected props. - */ - -function getXYPlotValues(props, children) { - var XYPlotScales = XYPLOT_ATTR.reduce(function (prev, attr) { - var domain = props[attr + 'Domain'], - range = props[attr + 'Range'], - type = props[attr + 'Type']; - - - if (domain && range && type) { - return _extends({}, prev, _defineProperty({}, attr, SCALE_FUNCTIONS[type]().domain(domain).range(range))); - } - return prev; - }, {}); - - return children.map(function (child) { - return XYPLOT_ATTR.reduce(function (prev, attr) { - if (child.props && child.props[attr] !== undefined) { - var scaleInput = child.props[attr]; - var scale = XYPlotScales[attr]; - var fallbackValue = scale ? scale(scaleInput) : scaleInput; - return _extends({}, prev, _defineProperty({}, '_' + attr + 'Value', fallbackValue)); - } - return prev; - }, {}); - }); -} - -var OPTIONAL_SCALE_PROPS = ['Padding']; -var OPTIONAL_SCALE_PROPS_REGS = OPTIONAL_SCALE_PROPS.map(function (str) { - return new RegExp(str + '$', 'i'); -}); -/** - * Get the list of optional scale-related settings for XYPlot - * mostly just used to find padding properties - * @param {Object} props Object of props. - * @returns {Object} Optional Props. - * @private - */ -function getOptionalScaleProps(props) { - return Object.keys(props).reduce(function (acc, prop) { - var propIsNotOptional = OPTIONAL_SCALE_PROPS_REGS.every(function (reg) { - return !prop.match(reg); - }); - if (propIsNotOptional) { - return acc; - } - acc[prop] = props[prop]; - return acc; - }, {}); -} - -exports.default = { - extractScalePropsFromProps: extractScalePropsFromProps, - getAttributeScale: getAttributeScale, - getAttributeFunctor: getAttributeFunctor, - getAttr0Functor: getAttr0Functor, - getAttributeValue: getAttributeValue, - getDomainByAccessor: getDomainByAccessor, - getFontColorFromBackground: getFontColorFromBackground, - getMissingScaleProps: getMissingScaleProps, - getOptionalScaleProps: getOptionalScaleProps, - getScaleObjectFromProps: getScaleObjectFromProps, - getScalePropTypesByAttribute: getScalePropTypesByAttribute, - getXYPlotValues: getXYPlotValues, - literalScale: literalScale -}; \ No newline at end of file diff --git a/dist/utils/series-utils.js b/dist/utils/series-utils.js deleted file mode 100644 index 7e1796dbe..000000000 --- a/dist/utils/series-utils.js +++ /dev/null @@ -1,268 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ANIMATED_SERIES_PROPS = undefined; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.isSeriesChild = isSeriesChild; -exports.getSeriesChildren = getSeriesChildren; -exports.getStackedData = getStackedData; -exports.getSeriesPropsFromChildren = getSeriesPropsFromChildren; -exports.getRadialDomain = getRadialDomain; -exports.getStackParams = getStackParams; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _abstractSeries = require('../plot/series/abstract-series'); - -var _abstractSeries2 = _interopRequireDefault(_abstractSeries); - -var _theme = require('../theme'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -/** - * Check if the component is series or not. - * @param {React.Component} child Component. - * @returns {boolean} True if the child is series, false otherwise. - */ -function isSeriesChild(child) { - var prototype = child.type.prototype; - - return prototype instanceof _abstractSeries2.default; -} - -/** - * Get all series from the 'children' object of the component. - * @param {Object} children Children. - * @returns {Array} Array of children. - */ -function getSeriesChildren(children) { - return _react2.default.Children.toArray(children).filter(function (child) { - return child && isSeriesChild(child); - }); -} - -/** - * Collect the map of repetitions of the series type for all children. - * @param {Array} children Array of children. - * @returns {{}} Map of repetitions where sameTypeTotal is the total amount and - * sameTypeIndex is always 0. - */ -function collectSeriesTypesInfo(children) { - var result = {}; - children.filter(isSeriesChild).forEach(function (child) { - var displayName = child.type.displayName; - var cluster = child.props.cluster; - - if (!result[displayName]) { - result[displayName] = { - sameTypeTotal: 0, - sameTypeIndex: 0, - clusters: new Set() - }; - } - result[displayName].clusters.add(cluster); - result[displayName].sameTypeTotal++; - }); - return result; -} - -/** - * Check series to see if it has angular data that needs to be converted - * @param {Array} data - an array of objects to check - * @returns {Boolean} whether or not this series contains polar configuration - */ -function seriesHasAngleRadius() { - var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - if (!data) { - return false; - } - return data.some(function (row) { - return row.radius && row.angle; - }); -} - -/** - * Possibly convert polar coordinates to x/y for computing domain - * @param {Array} data - an array of objects to check - * @param {String} attr - the property being checked - * @returns {Boolean} whether or not this series contains polar configuration - */ -function prepareData(data) { - if (!seriesHasAngleRadius(data)) { - return data; - } - - return data.map(function (row) { - return _extends({}, row, { - x: row.radius * Math.cos(row.angle), - y: row.radius * Math.sin(row.angle) - }); - }); -} - -/** - * Collect the stacked data for all children in use. If the children don't have - * the data (e.g. the child is invalid series or something else), then the child - * is skipped. - * Each next value of attr is equal to the previous value plus the difference - * between attr0 and attr. - * @param {Array} children Array of children. - * @param {string} attr Attribute to stack by. - * @returns {Array} New array of children for the series. - */ -function getStackedData(children, attr) { - var areSomeSeriesStacked = children.some(function (series) { - return series && series.props.stack; - }); - // It stores the last segment position added to each bar, separated by cluster. - var latestAttrPositions = {}; - - return children.reduce(function (accumulator, series, seriesIndex) { - // Skip the children that are not series (e.g. don't have any data). - if (!series) { - accumulator.push(null); - return accumulator; - } - - var _series$props = series.props, - data = _series$props.data, - _series$props$cluster = _series$props.cluster, - cluster = _series$props$cluster === undefined ? 'default' : _series$props$cluster, - stack = _series$props.stack; - - var preppedData = prepareData(data, attr); - - if (!attr || !preppedData || !preppedData.length || areSomeSeriesStacked && !stack) { - accumulator.push(preppedData); - return accumulator; - } - - var attr0 = attr + '0'; - var baseAttr = attr === 'y' ? 'x' : 'y'; - - accumulator.push(preppedData.map(function (d, dIndex) { - var _extends2, _latestAttrPositions$2; - - if (!latestAttrPositions[cluster]) { - latestAttrPositions[cluster] = {}; - } - - var prevD = latestAttrPositions[cluster][d[baseAttr]]; - // It is the first segment of a bar. - if (!prevD) { - var _latestAttrPositions$; - - latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$ = {}, _defineProperty(_latestAttrPositions$, attr0, d[attr0]), _defineProperty(_latestAttrPositions$, attr, d[attr]), _latestAttrPositions$); - - return _extends({}, d); - } - - // Calculate the position of the next segment in a bar. - var nextD = _extends({}, d, (_extends2 = {}, _defineProperty(_extends2, attr0, prevD[attr]), _defineProperty(_extends2, attr, prevD[attr] + d[attr] - (d[attr0] || 0)), _extends2)); - - latestAttrPositions[cluster][d[baseAttr]] = (_latestAttrPositions$2 = {}, _defineProperty(_latestAttrPositions$2, attr0, nextD[attr0]), _defineProperty(_latestAttrPositions$2, attr, nextD[attr]), _latestAttrPositions$2); - - return nextD; - })); - - return accumulator; - }, []); -} - -/** - * Get the list of series props for a child. - * @param {Array} children Array of all children. - * @returns {Array} Array of series props for each child. If a child is not a - * series, than it's undefined. - */ -function getSeriesPropsFromChildren(children) { - var result = []; - var seriesTypesInfo = collectSeriesTypesInfo(children); - var seriesIndex = 0; - var _opacityValue = _theme.DEFAULT_OPACITY; - children.forEach(function (child) { - var props = void 0; - if (isSeriesChild(child)) { - var seriesTypeInfo = seriesTypesInfo[child.type.displayName]; - var _colorValue = _theme.DISCRETE_COLOR_RANGE[seriesIndex % _theme.DISCRETE_COLOR_RANGE.length]; - props = _extends({}, seriesTypeInfo, { - seriesIndex: seriesIndex, - _colorValue: _colorValue, - _opacityValue: _opacityValue - }); - seriesTypeInfo.sameTypeIndex++; - seriesIndex++; - if (child.props.cluster) { - props.cluster = child.props.cluster; - // Using Array.from() so we can use .indexOf - props.clusters = Array.from(seriesTypeInfo.clusters); - props.sameTypeTotal = props.clusters.length; - props.sameTypeIndex = props.clusters.indexOf(child.props.cluster); - } - } - result.push(props); - }); - return result; -} - -/** - * Find the max radius value from the nodes to be rendered after they have been - * transformed into an array - * @param {Array} data - the tree data after it has been broken into a iterable - * it is an array of objects! - * @returns {number} the maximum value in coordinates for the radial variable - */ -function getRadialDomain(data) { - return data.reduce(function (res, row) { - return Math.max(row.radius, res); - }, 0); -} - -var ANIMATED_SERIES_PROPS = exports.ANIMATED_SERIES_PROPS = ['xRange', 'xDomain', 'x', 'yRange', 'yDomain', 'y', 'colorRange', 'colorDomain', 'color', 'opacityRange', 'opacityDomain', 'opacity', 'strokeRange', 'strokeDomain', 'stroke', 'fillRange', 'fillDomain', 'fill', 'width', 'height', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'data', 'angleDomain', 'angleRange', 'angle', 'radiusDomain', 'radiusRange', 'radius', 'innerRadiusDomain', 'innerRadiusRange', 'innerRadius']; - -function getStackParams(props) { - var _stackBy = props._stackBy, - valuePosAttr = props.valuePosAttr, - cluster = props.cluster; - var _props$sameTypeTotal = props.sameTypeTotal, - sameTypeTotal = _props$sameTypeTotal === undefined ? 1 : _props$sameTypeTotal, - _props$sameTypeIndex = props.sameTypeIndex, - sameTypeIndex = _props$sameTypeIndex === undefined ? 0 : _props$sameTypeIndex; - - // If bars are stacked, but not clustering, override `sameTypeTotal` and - // `sameTypeIndex` such that bars are stacked and not staggered. - - if (_stackBy === valuePosAttr && !cluster) { - sameTypeTotal = 1; - sameTypeIndex = 0; - } - return { sameTypeTotal: sameTypeTotal, sameTypeIndex: sameTypeIndex }; -} \ No newline at end of file From 7f888edcca3a7ba0c3e2ada87dcbb1a68db5f658 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Wed, 21 Nov 2018 16:43:22 +0100 Subject: [PATCH 09/10] Improving addInvertFunctionToOrdinalScaleObject function. --- src/utils/scales-utils.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils/scales-utils.js b/src/utils/scales-utils.js index 6d4cbc887..d2e4b507e 100644 --- a/src/utils/scales-utils.js +++ b/src/utils/scales-utils.js @@ -162,17 +162,20 @@ function addInvertFunctionToOrdinalScaleObject(scale) { if (scale.invert) return; scale.invert = function invert(value) { - let domainIndex = 0; - const n = scale.domain().length; const reverse = scale.range()[1] < scale.range()[0]; const start = scale.range()[reverse - 0]; const stop = scale.range()[1 - reverse]; - if (value < start + scale.padding() * scale.step()) domainIndex = 0; - else if (value > stop - scale.padding() * scale.step()) domainIndex = n - 1; - else domainIndex = Math.floor((value - start - scale.padding() * scale.step()) / scale.step()); + if (value < start + scale.padding() * scale.step()) { + return scale.domain()[0]; + } + + if (value > stop - scale.padding() * scale.step()) { + return scale.domain()[scale.domain().length - 1]; + } - return scale.domain()[domainIndex]; + const index = Math.floor((value - start - scale.padding() * scale.step()) / scale.step()); + return scale.domain()[index]; } } From 21696f61486e2a161c38bb559bada65c55d6d903 Mon Sep 17 00:00:00 2001 From: Bogdan Nikolic Date: Wed, 21 Nov 2018 22:26:36 +0100 Subject: [PATCH 10/10] Updating style in addInvertFunctionToOrdinalScaleObject function --- src/utils/scales-utils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/scales-utils.js b/src/utils/scales-utils.js index d2e4b507e..5ca122e11 100644 --- a/src/utils/scales-utils.js +++ b/src/utils/scales-utils.js @@ -159,12 +159,14 @@ export function _getSmallestDistanceIndex(values, scaleObject) { */ function addInvertFunctionToOrdinalScaleObject(scale) { - if (scale.invert) return; + if (scale.invert) { + return; + } scale.invert = function invert(value) { - const reverse = scale.range()[1] < scale.range()[0]; - const start = scale.range()[reverse - 0]; - const stop = scale.range()[1 - reverse]; + const [lower, upper] = scale.range(); + const start = Math.min(lower, upper); + const stop = Math.max(lower, upper); if (value < start + scale.padding() * scale.step()) { return scale.domain()[0];