Extract anyclip
This commit is contained in:
543
vendor/node_modules/recharts/es6/cartesian/Area.js
generated
vendored
Normal file
543
vendor/node_modules/recharts/es6/cartesian/Area.js
generated
vendored
Normal file
@@ -0,0 +1,543 @@
|
||||
var _excluded = ["layout", "type", "stroke", "connectNulls", "isRange", "ref"],
|
||||
_excluded2 = ["key"];
|
||||
var _Area;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Area
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import Animate from 'react-smooth';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import max from 'lodash/max';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isNan from 'lodash/isNaN';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { Dot } from '../shape/Dot';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { Global } from '../util/Global';
|
||||
import { isNumber, uniqueId, interpolateNumber } from '../util/DataUtils';
|
||||
import { getCateCoordinateOfLine, getValueByDataKey } from '../util/ChartUtils';
|
||||
import { filterProps, hasClipDot } from '../util/ReactUtils';
|
||||
export var Area = /*#__PURE__*/function (_PureComponent) {
|
||||
function Area() {
|
||||
var _this;
|
||||
_classCallCheck(this, Area);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, Area, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
isAnimationFinished: true
|
||||
});
|
||||
_defineProperty(_this, "id", uniqueId('recharts-area-'));
|
||||
_defineProperty(_this, "handleAnimationEnd", function () {
|
||||
var onAnimationEnd = _this.props.onAnimationEnd;
|
||||
_this.setState({
|
||||
isAnimationFinished: true
|
||||
});
|
||||
if (isFunction(onAnimationEnd)) {
|
||||
onAnimationEnd();
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationStart", function () {
|
||||
var onAnimationStart = _this.props.onAnimationStart;
|
||||
_this.setState({
|
||||
isAnimationFinished: false
|
||||
});
|
||||
if (isFunction(onAnimationStart)) {
|
||||
onAnimationStart();
|
||||
}
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_inherits(Area, _PureComponent);
|
||||
return _createClass(Area, [{
|
||||
key: "renderDots",
|
||||
value: function renderDots(needClip, clipDot, clipPathId) {
|
||||
var isAnimationActive = this.props.isAnimationActive;
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
if (isAnimationActive && !isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props = this.props,
|
||||
dot = _this$props.dot,
|
||||
points = _this$props.points,
|
||||
dataKey = _this$props.dataKey;
|
||||
var areaProps = filterProps(this.props, false);
|
||||
var customDotProps = filterProps(dot, true);
|
||||
var dots = points.map(function (entry, i) {
|
||||
var dotProps = _objectSpread(_objectSpread(_objectSpread({
|
||||
key: "dot-".concat(i),
|
||||
r: 3
|
||||
}, areaProps), customDotProps), {}, {
|
||||
index: i,
|
||||
cx: entry.x,
|
||||
cy: entry.y,
|
||||
dataKey: dataKey,
|
||||
value: entry.value,
|
||||
payload: entry.payload,
|
||||
points: points
|
||||
});
|
||||
return Area.renderDotItem(dot, dotProps);
|
||||
});
|
||||
var dotsProps = {
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipDot ? '' : 'dots-').concat(clipPathId, ")") : null
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: "recharts-area-dots"
|
||||
}, dotsProps), dots);
|
||||
}
|
||||
}, {
|
||||
key: "renderHorizontalRect",
|
||||
value: function renderHorizontalRect(alpha) {
|
||||
var _this$props2 = this.props,
|
||||
baseLine = _this$props2.baseLine,
|
||||
points = _this$props2.points,
|
||||
strokeWidth = _this$props2.strokeWidth;
|
||||
var startX = points[0].x;
|
||||
var endX = points[points.length - 1].x;
|
||||
var width = alpha * Math.abs(startX - endX);
|
||||
var maxY = max(points.map(function (entry) {
|
||||
return entry.y || 0;
|
||||
}));
|
||||
if (isNumber(baseLine) && typeof baseLine === 'number') {
|
||||
maxY = Math.max(baseLine, maxY);
|
||||
} else if (baseLine && Array.isArray(baseLine) && baseLine.length) {
|
||||
maxY = Math.max(max(baseLine.map(function (entry) {
|
||||
return entry.y || 0;
|
||||
})), maxY);
|
||||
}
|
||||
if (isNumber(maxY)) {
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
x: startX < endX ? startX : startX - width,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: Math.floor(maxY + (strokeWidth ? parseInt("".concat(strokeWidth), 10) : 1))
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "renderVerticalRect",
|
||||
value: function renderVerticalRect(alpha) {
|
||||
var _this$props3 = this.props,
|
||||
baseLine = _this$props3.baseLine,
|
||||
points = _this$props3.points,
|
||||
strokeWidth = _this$props3.strokeWidth;
|
||||
var startY = points[0].y;
|
||||
var endY = points[points.length - 1].y;
|
||||
var height = alpha * Math.abs(startY - endY);
|
||||
var maxX = max(points.map(function (entry) {
|
||||
return entry.x || 0;
|
||||
}));
|
||||
if (isNumber(baseLine) && typeof baseLine === 'number') {
|
||||
maxX = Math.max(baseLine, maxX);
|
||||
} else if (baseLine && Array.isArray(baseLine) && baseLine.length) {
|
||||
maxX = Math.max(max(baseLine.map(function (entry) {
|
||||
return entry.x || 0;
|
||||
})), maxX);
|
||||
}
|
||||
if (isNumber(maxX)) {
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
x: 0,
|
||||
y: startY < endY ? startY : startY - height,
|
||||
width: maxX + (strokeWidth ? parseInt("".concat(strokeWidth), 10) : 1),
|
||||
height: Math.floor(height)
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "renderClipRect",
|
||||
value: function renderClipRect(alpha) {
|
||||
var layout = this.props.layout;
|
||||
if (layout === 'vertical') {
|
||||
return this.renderVerticalRect(alpha);
|
||||
}
|
||||
return this.renderHorizontalRect(alpha);
|
||||
}
|
||||
}, {
|
||||
key: "renderAreaStatically",
|
||||
value: function renderAreaStatically(points, baseLine, needClip, clipPathId) {
|
||||
var _this$props4 = this.props,
|
||||
layout = _this$props4.layout,
|
||||
type = _this$props4.type,
|
||||
stroke = _this$props4.stroke,
|
||||
connectNulls = _this$props4.connectNulls,
|
||||
isRange = _this$props4.isRange,
|
||||
ref = _this$props4.ref,
|
||||
others = _objectWithoutProperties(_this$props4, _excluded);
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : null
|
||||
}, /*#__PURE__*/React.createElement(Curve, _extends({}, filterProps(others, true), {
|
||||
points: points,
|
||||
connectNulls: connectNulls,
|
||||
type: type,
|
||||
baseLine: baseLine,
|
||||
layout: layout,
|
||||
stroke: "none",
|
||||
className: "recharts-area-area"
|
||||
})), stroke !== 'none' && /*#__PURE__*/React.createElement(Curve, _extends({}, filterProps(this.props, false), {
|
||||
className: "recharts-area-curve",
|
||||
layout: layout,
|
||||
type: type,
|
||||
connectNulls: connectNulls,
|
||||
fill: "none",
|
||||
points: points
|
||||
})), stroke !== 'none' && isRange && /*#__PURE__*/React.createElement(Curve, _extends({}, filterProps(this.props, false), {
|
||||
className: "recharts-area-curve",
|
||||
layout: layout,
|
||||
type: type,
|
||||
connectNulls: connectNulls,
|
||||
fill: "none",
|
||||
points: baseLine
|
||||
})));
|
||||
}
|
||||
}, {
|
||||
key: "renderAreaWithAnimation",
|
||||
value: function renderAreaWithAnimation(needClip, clipPathId) {
|
||||
var _this2 = this;
|
||||
var _this$props5 = this.props,
|
||||
points = _this$props5.points,
|
||||
baseLine = _this$props5.baseLine,
|
||||
isAnimationActive = _this$props5.isAnimationActive,
|
||||
animationBegin = _this$props5.animationBegin,
|
||||
animationDuration = _this$props5.animationDuration,
|
||||
animationEasing = _this$props5.animationEasing,
|
||||
animationId = _this$props5.animationId;
|
||||
var _this$state = this.state,
|
||||
prevPoints = _this$state.prevPoints,
|
||||
prevBaseLine = _this$state.prevBaseLine;
|
||||
// const clipPathId = isNil(id) ? this.id : id;
|
||||
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing,
|
||||
from: {
|
||||
t: 0
|
||||
},
|
||||
to: {
|
||||
t: 1
|
||||
},
|
||||
key: "area-".concat(animationId),
|
||||
onAnimationEnd: this.handleAnimationEnd,
|
||||
onAnimationStart: this.handleAnimationStart
|
||||
}, function (_ref) {
|
||||
var t = _ref.t;
|
||||
if (prevPoints) {
|
||||
var prevPointsDiffFactor = prevPoints.length / points.length;
|
||||
// update animtaion
|
||||
var stepPoints = points.map(function (entry, index) {
|
||||
var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
|
||||
if (prevPoints[prevPointIndex]) {
|
||||
var prev = prevPoints[prevPointIndex];
|
||||
var interpolatorX = interpolateNumber(prev.x, entry.x);
|
||||
var interpolatorY = interpolateNumber(prev.y, entry.y);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: interpolatorX(t),
|
||||
y: interpolatorY(t)
|
||||
});
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
var stepBaseLine;
|
||||
if (isNumber(baseLine) && typeof baseLine === 'number') {
|
||||
var interpolator = interpolateNumber(prevBaseLine, baseLine);
|
||||
stepBaseLine = interpolator(t);
|
||||
} else if (isNil(baseLine) || isNan(baseLine)) {
|
||||
var _interpolator = interpolateNumber(prevBaseLine, 0);
|
||||
stepBaseLine = _interpolator(t);
|
||||
} else {
|
||||
stepBaseLine = baseLine.map(function (entry, index) {
|
||||
var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
|
||||
if (prevBaseLine[prevPointIndex]) {
|
||||
var prev = prevBaseLine[prevPointIndex];
|
||||
var interpolatorX = interpolateNumber(prev.x, entry.x);
|
||||
var interpolatorY = interpolateNumber(prev.y, entry.y);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: interpolatorX(t),
|
||||
y: interpolatorY(t)
|
||||
});
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
return _this2.renderAreaStatically(stepPoints, stepBaseLine, needClip, clipPathId);
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "animationClipPath-".concat(clipPathId)
|
||||
}, _this2.renderClipRect(t))), /*#__PURE__*/React.createElement(Layer, {
|
||||
clipPath: "url(#animationClipPath-".concat(clipPathId, ")")
|
||||
}, _this2.renderAreaStatically(points, baseLine, needClip, clipPathId)));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderArea",
|
||||
value: function renderArea(needClip, clipPathId) {
|
||||
var _this$props6 = this.props,
|
||||
points = _this$props6.points,
|
||||
baseLine = _this$props6.baseLine,
|
||||
isAnimationActive = _this$props6.isAnimationActive;
|
||||
var _this$state2 = this.state,
|
||||
prevPoints = _this$state2.prevPoints,
|
||||
prevBaseLine = _this$state2.prevBaseLine,
|
||||
totalLength = _this$state2.totalLength;
|
||||
if (isAnimationActive && points && points.length && (!prevPoints && totalLength > 0 || !isEqual(prevPoints, points) || !isEqual(prevBaseLine, baseLine))) {
|
||||
return this.renderAreaWithAnimation(needClip, clipPathId);
|
||||
}
|
||||
return this.renderAreaStatically(points, baseLine, needClip, clipPathId);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _filterProps;
|
||||
var _this$props7 = this.props,
|
||||
hide = _this$props7.hide,
|
||||
dot = _this$props7.dot,
|
||||
points = _this$props7.points,
|
||||
className = _this$props7.className,
|
||||
top = _this$props7.top,
|
||||
left = _this$props7.left,
|
||||
xAxis = _this$props7.xAxis,
|
||||
yAxis = _this$props7.yAxis,
|
||||
width = _this$props7.width,
|
||||
height = _this$props7.height,
|
||||
isAnimationActive = _this$props7.isAnimationActive,
|
||||
id = _this$props7.id;
|
||||
if (hide || !points || !points.length) {
|
||||
return null;
|
||||
}
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
var hasSinglePoint = points.length === 1;
|
||||
var layerClass = clsx('recharts-area', className);
|
||||
var needClipX = xAxis && xAxis.allowDataOverflow;
|
||||
var needClipY = yAxis && yAxis.allowDataOverflow;
|
||||
var needClip = needClipX || needClipY;
|
||||
var clipPathId = isNil(id) ? this.id : id;
|
||||
var _ref2 = (_filterProps = filterProps(dot, false)) !== null && _filterProps !== void 0 ? _filterProps : {
|
||||
r: 3,
|
||||
strokeWidth: 2
|
||||
},
|
||||
_ref2$r = _ref2.r,
|
||||
r = _ref2$r === void 0 ? 3 : _ref2$r,
|
||||
_ref2$strokeWidth = _ref2.strokeWidth,
|
||||
strokeWidth = _ref2$strokeWidth === void 0 ? 2 : _ref2$strokeWidth;
|
||||
var _ref3 = hasClipDot(dot) ? dot : {},
|
||||
_ref3$clipDot = _ref3.clipDot,
|
||||
clipDot = _ref3$clipDot === void 0 ? true : _ref3$clipDot;
|
||||
var dotSize = r * 2 + strokeWidth;
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, needClipX || needClipY ? /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "clipPath-".concat(clipPathId)
|
||||
}, /*#__PURE__*/React.createElement("rect", {
|
||||
x: needClipX ? left : left - width / 2,
|
||||
y: needClipY ? top : top - height / 2,
|
||||
width: needClipX ? width : width * 2,
|
||||
height: needClipY ? height : height * 2
|
||||
})), !clipDot && /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "clipPath-dots-".concat(clipPathId)
|
||||
}, /*#__PURE__*/React.createElement("rect", {
|
||||
x: left - dotSize / 2,
|
||||
y: top - dotSize / 2,
|
||||
width: width + dotSize,
|
||||
height: height + dotSize
|
||||
}))) : null, !hasSinglePoint ? this.renderArea(needClip, clipPathId) : null, (dot || hasSinglePoint) && this.renderDots(needClip, clipDot, clipPathId), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, points));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (nextProps.animationId !== prevState.prevAnimationId) {
|
||||
return {
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curPoints: nextProps.points,
|
||||
curBaseLine: nextProps.baseLine,
|
||||
prevPoints: prevState.curPoints,
|
||||
prevBaseLine: prevState.curBaseLine
|
||||
};
|
||||
}
|
||||
if (nextProps.points !== prevState.curPoints || nextProps.baseLine !== prevState.curBaseLine) {
|
||||
return {
|
||||
curPoints: nextProps.points,
|
||||
curBaseLine: nextProps.baseLine
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_Area = Area;
|
||||
_defineProperty(Area, "displayName", 'Area');
|
||||
_defineProperty(Area, "defaultProps", {
|
||||
stroke: '#3182bd',
|
||||
fill: '#3182bd',
|
||||
fillOpacity: 0.6,
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
legendType: 'line',
|
||||
connectNulls: false,
|
||||
// points of area
|
||||
points: [],
|
||||
dot: false,
|
||||
activeDot: true,
|
||||
hide: false,
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease'
|
||||
});
|
||||
_defineProperty(Area, "getBaseValue", function (props, item, xAxis, yAxis) {
|
||||
var layout = props.layout,
|
||||
chartBaseValue = props.baseValue;
|
||||
var itemBaseValue = item.props.baseValue;
|
||||
|
||||
// The baseValue can be defined both on the AreaChart as well as on the Area.
|
||||
// The value for the item takes precedence.
|
||||
var baseValue = itemBaseValue !== null && itemBaseValue !== void 0 ? itemBaseValue : chartBaseValue;
|
||||
if (isNumber(baseValue) && typeof baseValue === 'number') {
|
||||
return baseValue;
|
||||
}
|
||||
var numericAxis = layout === 'horizontal' ? yAxis : xAxis;
|
||||
var domain = numericAxis.scale.domain();
|
||||
if (numericAxis.type === 'number') {
|
||||
var domainMax = Math.max(domain[0], domain[1]);
|
||||
var domainMin = Math.min(domain[0], domain[1]);
|
||||
if (baseValue === 'dataMin') {
|
||||
return domainMin;
|
||||
}
|
||||
if (baseValue === 'dataMax') {
|
||||
return domainMax;
|
||||
}
|
||||
return domainMax < 0 ? domainMax : Math.max(Math.min(domain[0], domain[1]), 0);
|
||||
}
|
||||
if (baseValue === 'dataMin') {
|
||||
return domain[0];
|
||||
}
|
||||
if (baseValue === 'dataMax') {
|
||||
return domain[1];
|
||||
}
|
||||
return domain[0];
|
||||
});
|
||||
_defineProperty(Area, "getComposedData", function (_ref4) {
|
||||
var props = _ref4.props,
|
||||
item = _ref4.item,
|
||||
xAxis = _ref4.xAxis,
|
||||
yAxis = _ref4.yAxis,
|
||||
xAxisTicks = _ref4.xAxisTicks,
|
||||
yAxisTicks = _ref4.yAxisTicks,
|
||||
bandSize = _ref4.bandSize,
|
||||
dataKey = _ref4.dataKey,
|
||||
stackedData = _ref4.stackedData,
|
||||
dataStartIndex = _ref4.dataStartIndex,
|
||||
displayedData = _ref4.displayedData,
|
||||
offset = _ref4.offset;
|
||||
var layout = props.layout;
|
||||
var hasStack = stackedData && stackedData.length;
|
||||
var baseValue = _Area.getBaseValue(props, item, xAxis, yAxis);
|
||||
var isHorizontalLayout = layout === 'horizontal';
|
||||
var isRange = false;
|
||||
var points = displayedData.map(function (entry, index) {
|
||||
var value;
|
||||
if (hasStack) {
|
||||
value = stackedData[dataStartIndex + index];
|
||||
} else {
|
||||
value = getValueByDataKey(entry, dataKey);
|
||||
if (!Array.isArray(value)) {
|
||||
value = [baseValue, value];
|
||||
} else {
|
||||
isRange = true;
|
||||
}
|
||||
}
|
||||
var isBreakPoint = value[1] == null || hasStack && getValueByDataKey(entry, dataKey) == null;
|
||||
if (isHorizontalLayout) {
|
||||
return {
|
||||
x: getCateCoordinateOfLine({
|
||||
axis: xAxis,
|
||||
ticks: xAxisTicks,
|
||||
bandSize: bandSize,
|
||||
entry: entry,
|
||||
index: index
|
||||
}),
|
||||
y: isBreakPoint ? null : yAxis.scale(value[1]),
|
||||
value: value,
|
||||
payload: entry
|
||||
};
|
||||
}
|
||||
return {
|
||||
x: isBreakPoint ? null : xAxis.scale(value[1]),
|
||||
y: getCateCoordinateOfLine({
|
||||
axis: yAxis,
|
||||
ticks: yAxisTicks,
|
||||
bandSize: bandSize,
|
||||
entry: entry,
|
||||
index: index
|
||||
}),
|
||||
value: value,
|
||||
payload: entry
|
||||
};
|
||||
});
|
||||
var baseLine;
|
||||
if (hasStack || isRange) {
|
||||
baseLine = points.map(function (entry) {
|
||||
var x = Array.isArray(entry.value) ? entry.value[0] : null;
|
||||
if (isHorizontalLayout) {
|
||||
return {
|
||||
x: entry.x,
|
||||
y: x != null && entry.y != null ? yAxis.scale(x) : null
|
||||
};
|
||||
}
|
||||
return {
|
||||
x: x != null ? xAxis.scale(x) : null,
|
||||
y: entry.y
|
||||
};
|
||||
});
|
||||
} else {
|
||||
baseLine = isHorizontalLayout ? yAxis.scale(baseValue) : xAxis.scale(baseValue);
|
||||
}
|
||||
return _objectSpread({
|
||||
points: points,
|
||||
baseLine: baseLine,
|
||||
layout: layout,
|
||||
isRange: isRange
|
||||
}, offset);
|
||||
});
|
||||
_defineProperty(Area, "renderDotItem", function (option, props) {
|
||||
var dotItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
dotItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
dotItem = option(props);
|
||||
} else {
|
||||
var className = clsx('recharts-area-dot', typeof option !== 'boolean' ? option.className : '');
|
||||
var key = props.key,
|
||||
rest = _objectWithoutProperties(props, _excluded2);
|
||||
dotItem = /*#__PURE__*/React.createElement(Dot, _extends({}, rest, {
|
||||
key: key,
|
||||
className: className
|
||||
}));
|
||||
}
|
||||
return dotItem;
|
||||
});
|
||||
450
vendor/node_modules/recharts/es6/cartesian/Bar.js
generated
vendored
Normal file
450
vendor/node_modules/recharts/es6/cartesian/Bar.js
generated
vendored
Normal file
@@ -0,0 +1,450 @@
|
||||
var _excluded = ["value", "background"];
|
||||
var _Bar;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Render a group of bar
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import Animate from 'react-smooth';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isNil from 'lodash/isNil';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { ErrorBar } from './ErrorBar';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { uniqueId, mathSign, interpolateNumber } from '../util/DataUtils';
|
||||
import { filterProps, findAllByType } from '../util/ReactUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { getCateCoordinateOfBar, getValueByDataKey, truncateByDomain, getBaseValueOfBar, findPositionOfBar, getTooltipItem } from '../util/ChartUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { BarRectangle, minPointSizeCallback } from '../util/BarUtils';
|
||||
export var Bar = /*#__PURE__*/function (_PureComponent) {
|
||||
function Bar() {
|
||||
var _this;
|
||||
_classCallCheck(this, Bar);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, Bar, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
isAnimationFinished: false
|
||||
});
|
||||
_defineProperty(_this, "id", uniqueId('recharts-bar-'));
|
||||
_defineProperty(_this, "handleAnimationEnd", function () {
|
||||
var onAnimationEnd = _this.props.onAnimationEnd;
|
||||
_this.setState({
|
||||
isAnimationFinished: true
|
||||
});
|
||||
if (onAnimationEnd) {
|
||||
onAnimationEnd();
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationStart", function () {
|
||||
var onAnimationStart = _this.props.onAnimationStart;
|
||||
_this.setState({
|
||||
isAnimationFinished: false
|
||||
});
|
||||
if (onAnimationStart) {
|
||||
onAnimationStart();
|
||||
}
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_inherits(Bar, _PureComponent);
|
||||
return _createClass(Bar, [{
|
||||
key: "renderRectanglesStatically",
|
||||
value: function renderRectanglesStatically(data) {
|
||||
var _this2 = this;
|
||||
var _this$props = this.props,
|
||||
shape = _this$props.shape,
|
||||
dataKey = _this$props.dataKey,
|
||||
activeIndex = _this$props.activeIndex,
|
||||
activeBar = _this$props.activeBar;
|
||||
var baseProps = filterProps(this.props, false);
|
||||
return data && data.map(function (entry, i) {
|
||||
var isActive = i === activeIndex;
|
||||
var option = isActive ? activeBar : shape;
|
||||
var props = _objectSpread(_objectSpread(_objectSpread({}, baseProps), entry), {}, {
|
||||
isActive: isActive,
|
||||
option: option,
|
||||
index: i,
|
||||
dataKey: dataKey,
|
||||
onAnimationStart: _this2.handleAnimationStart,
|
||||
onAnimationEnd: _this2.handleAnimationEnd
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: "recharts-bar-rectangle"
|
||||
}, adaptEventsOfChild(_this2.props, entry, i), {
|
||||
// https://github.com/recharts/recharts/issues/5415
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key: "rectangle-".concat(entry === null || entry === void 0 ? void 0 : entry.x, "-").concat(entry === null || entry === void 0 ? void 0 : entry.y, "-").concat(entry === null || entry === void 0 ? void 0 : entry.value, "-").concat(i)
|
||||
}), /*#__PURE__*/React.createElement(BarRectangle, props));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderRectanglesWithAnimation",
|
||||
value: function renderRectanglesWithAnimation() {
|
||||
var _this3 = this;
|
||||
var _this$props2 = this.props,
|
||||
data = _this$props2.data,
|
||||
layout = _this$props2.layout,
|
||||
isAnimationActive = _this$props2.isAnimationActive,
|
||||
animationBegin = _this$props2.animationBegin,
|
||||
animationDuration = _this$props2.animationDuration,
|
||||
animationEasing = _this$props2.animationEasing,
|
||||
animationId = _this$props2.animationId;
|
||||
var prevData = this.state.prevData;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing,
|
||||
from: {
|
||||
t: 0
|
||||
},
|
||||
to: {
|
||||
t: 1
|
||||
},
|
||||
key: "bar-".concat(animationId),
|
||||
onAnimationEnd: this.handleAnimationEnd,
|
||||
onAnimationStart: this.handleAnimationStart
|
||||
}, function (_ref) {
|
||||
var t = _ref.t;
|
||||
var stepData = data.map(function (entry, index) {
|
||||
var prev = prevData && prevData[index];
|
||||
if (prev) {
|
||||
var interpolatorX = interpolateNumber(prev.x, entry.x);
|
||||
var interpolatorY = interpolateNumber(prev.y, entry.y);
|
||||
var interpolatorWidth = interpolateNumber(prev.width, entry.width);
|
||||
var interpolatorHeight = interpolateNumber(prev.height, entry.height);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: interpolatorX(t),
|
||||
y: interpolatorY(t),
|
||||
width: interpolatorWidth(t),
|
||||
height: interpolatorHeight(t)
|
||||
});
|
||||
}
|
||||
if (layout === 'horizontal') {
|
||||
var _interpolatorHeight = interpolateNumber(0, entry.height);
|
||||
var h = _interpolatorHeight(t);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
y: entry.y + entry.height - h,
|
||||
height: h
|
||||
});
|
||||
}
|
||||
var interpolator = interpolateNumber(0, entry.width);
|
||||
var w = interpolator(t);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
width: w
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, null, _this3.renderRectanglesStatically(stepData));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderRectangles",
|
||||
value: function renderRectangles() {
|
||||
var _this$props3 = this.props,
|
||||
data = _this$props3.data,
|
||||
isAnimationActive = _this$props3.isAnimationActive;
|
||||
var prevData = this.state.prevData;
|
||||
if (isAnimationActive && data && data.length && (!prevData || !isEqual(prevData, data))) {
|
||||
return this.renderRectanglesWithAnimation();
|
||||
}
|
||||
return this.renderRectanglesStatically(data);
|
||||
}
|
||||
}, {
|
||||
key: "renderBackground",
|
||||
value: function renderBackground() {
|
||||
var _this4 = this;
|
||||
var _this$props4 = this.props,
|
||||
data = _this$props4.data,
|
||||
dataKey = _this$props4.dataKey,
|
||||
activeIndex = _this$props4.activeIndex;
|
||||
var backgroundProps = filterProps(this.props.background, false);
|
||||
return data.map(function (entry, i) {
|
||||
var value = entry.value,
|
||||
background = entry.background,
|
||||
rest = _objectWithoutProperties(entry, _excluded);
|
||||
if (!background) {
|
||||
return null;
|
||||
}
|
||||
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, rest), {}, {
|
||||
fill: '#eee'
|
||||
}, background), backgroundProps), adaptEventsOfChild(_this4.props, entry, i)), {}, {
|
||||
onAnimationStart: _this4.handleAnimationStart,
|
||||
onAnimationEnd: _this4.handleAnimationEnd,
|
||||
dataKey: dataKey,
|
||||
index: i,
|
||||
className: 'recharts-bar-background-rectangle'
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(BarRectangle, _extends({
|
||||
key: "background-bar-".concat(i),
|
||||
option: _this4.props.background,
|
||||
isActive: i === activeIndex
|
||||
}, props));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderErrorBar",
|
||||
value: function renderErrorBar(needClip, clipPathId) {
|
||||
if (this.props.isAnimationActive && !this.state.isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props5 = this.props,
|
||||
data = _this$props5.data,
|
||||
xAxis = _this$props5.xAxis,
|
||||
yAxis = _this$props5.yAxis,
|
||||
layout = _this$props5.layout,
|
||||
children = _this$props5.children;
|
||||
var errorBarItems = findAllByType(children, ErrorBar);
|
||||
if (!errorBarItems) {
|
||||
return null;
|
||||
}
|
||||
var offset = layout === 'vertical' ? data[0].height / 2 : data[0].width / 2;
|
||||
var dataPointFormatter = function dataPointFormatter(dataPoint, dataKey) {
|
||||
/**
|
||||
* if the value coming from `getComposedData` is an array then this is a stacked bar chart.
|
||||
* arr[1] represents end value of the bar since the data is in the form of [startValue, endValue].
|
||||
* */
|
||||
var value = Array.isArray(dataPoint.value) ? dataPoint.value[1] : dataPoint.value;
|
||||
return {
|
||||
x: dataPoint.x,
|
||||
y: dataPoint.y,
|
||||
value: value,
|
||||
errorVal: getValueByDataKey(dataPoint, dataKey)
|
||||
};
|
||||
};
|
||||
var errorBarProps = {
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : null
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Layer, errorBarProps, errorBarItems.map(function (item) {
|
||||
return /*#__PURE__*/React.cloneElement(item, {
|
||||
key: "error-bar-".concat(clipPathId, "-").concat(item.props.dataKey),
|
||||
data: data,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
layout: layout,
|
||||
offset: offset,
|
||||
dataPointFormatter: dataPointFormatter
|
||||
});
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props6 = this.props,
|
||||
hide = _this$props6.hide,
|
||||
data = _this$props6.data,
|
||||
className = _this$props6.className,
|
||||
xAxis = _this$props6.xAxis,
|
||||
yAxis = _this$props6.yAxis,
|
||||
left = _this$props6.left,
|
||||
top = _this$props6.top,
|
||||
width = _this$props6.width,
|
||||
height = _this$props6.height,
|
||||
isAnimationActive = _this$props6.isAnimationActive,
|
||||
background = _this$props6.background,
|
||||
id = _this$props6.id;
|
||||
if (hide || !data || !data.length) {
|
||||
return null;
|
||||
}
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
var layerClass = clsx('recharts-bar', className);
|
||||
var needClipX = xAxis && xAxis.allowDataOverflow;
|
||||
var needClipY = yAxis && yAxis.allowDataOverflow;
|
||||
var needClip = needClipX || needClipY;
|
||||
var clipPathId = isNil(id) ? this.id : id;
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, needClipX || needClipY ? /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "clipPath-".concat(clipPathId)
|
||||
}, /*#__PURE__*/React.createElement("rect", {
|
||||
x: needClipX ? left : left - width / 2,
|
||||
y: needClipY ? top : top - height / 2,
|
||||
width: needClipX ? width : width * 2,
|
||||
height: needClipY ? height : height * 2
|
||||
}))) : null, /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-bar-rectangles",
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : null
|
||||
}, background ? this.renderBackground() : null, this.renderRectangles()), this.renderErrorBar(needClip, clipPathId), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, data));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (nextProps.animationId !== prevState.prevAnimationId) {
|
||||
return {
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curData: nextProps.data,
|
||||
prevData: prevState.curData
|
||||
};
|
||||
}
|
||||
if (nextProps.data !== prevState.curData) {
|
||||
return {
|
||||
curData: nextProps.data
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_Bar = Bar;
|
||||
_defineProperty(Bar, "displayName", 'Bar');
|
||||
_defineProperty(Bar, "defaultProps", {
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
legendType: 'rect',
|
||||
minPointSize: 0,
|
||||
hide: false,
|
||||
data: [],
|
||||
layout: 'vertical',
|
||||
activeBar: false,
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 0,
|
||||
animationDuration: 400,
|
||||
animationEasing: 'ease'
|
||||
});
|
||||
/**
|
||||
* Compose the data of each group
|
||||
* @param {Object} props Props for the component
|
||||
* @param {Object} item An instance of Bar
|
||||
* @param {Array} barPosition The offset and size of each bar
|
||||
* @param {Object} xAxis The configuration of x-axis
|
||||
* @param {Object} yAxis The configuration of y-axis
|
||||
* @param {Array} stackedData The stacked data of a bar item
|
||||
* @return{Array} Composed data
|
||||
*/
|
||||
_defineProperty(Bar, "getComposedData", function (_ref2) {
|
||||
var props = _ref2.props,
|
||||
item = _ref2.item,
|
||||
barPosition = _ref2.barPosition,
|
||||
bandSize = _ref2.bandSize,
|
||||
xAxis = _ref2.xAxis,
|
||||
yAxis = _ref2.yAxis,
|
||||
xAxisTicks = _ref2.xAxisTicks,
|
||||
yAxisTicks = _ref2.yAxisTicks,
|
||||
stackedData = _ref2.stackedData,
|
||||
dataStartIndex = _ref2.dataStartIndex,
|
||||
displayedData = _ref2.displayedData,
|
||||
offset = _ref2.offset;
|
||||
var pos = findPositionOfBar(barPosition, item);
|
||||
if (!pos) {
|
||||
return null;
|
||||
}
|
||||
var layout = props.layout;
|
||||
var itemDefaultProps = item.type.defaultProps;
|
||||
var itemProps = itemDefaultProps !== undefined ? _objectSpread(_objectSpread({}, itemDefaultProps), item.props) : item.props;
|
||||
var dataKey = itemProps.dataKey,
|
||||
children = itemProps.children,
|
||||
minPointSizeProp = itemProps.minPointSize;
|
||||
var numericAxis = layout === 'horizontal' ? yAxis : xAxis;
|
||||
var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
|
||||
var baseValue = getBaseValueOfBar({
|
||||
numericAxis: numericAxis
|
||||
});
|
||||
var cells = findAllByType(children, Cell);
|
||||
var rects = displayedData.map(function (entry, index) {
|
||||
var value, x, y, width, height, background;
|
||||
if (stackedData) {
|
||||
value = truncateByDomain(stackedData[dataStartIndex + index], stackedDomain);
|
||||
} else {
|
||||
value = getValueByDataKey(entry, dataKey);
|
||||
if (!Array.isArray(value)) {
|
||||
value = [baseValue, value];
|
||||
}
|
||||
}
|
||||
var minPointSize = minPointSizeCallback(minPointSizeProp, _Bar.defaultProps.minPointSize)(value[1], index);
|
||||
if (layout === 'horizontal') {
|
||||
var _ref4;
|
||||
var _ref3 = [yAxis.scale(value[0]), yAxis.scale(value[1])],
|
||||
baseValueScale = _ref3[0],
|
||||
currentValueScale = _ref3[1];
|
||||
x = getCateCoordinateOfBar({
|
||||
axis: xAxis,
|
||||
ticks: xAxisTicks,
|
||||
bandSize: bandSize,
|
||||
offset: pos.offset,
|
||||
entry: entry,
|
||||
index: index
|
||||
});
|
||||
y = (_ref4 = currentValueScale !== null && currentValueScale !== void 0 ? currentValueScale : baseValueScale) !== null && _ref4 !== void 0 ? _ref4 : undefined;
|
||||
width = pos.size;
|
||||
var computedHeight = baseValueScale - currentValueScale;
|
||||
height = Number.isNaN(computedHeight) ? 0 : computedHeight;
|
||||
background = {
|
||||
x: x,
|
||||
y: yAxis.y,
|
||||
width: width,
|
||||
height: yAxis.height
|
||||
};
|
||||
if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
|
||||
var delta = mathSign(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
|
||||
y -= delta;
|
||||
height += delta;
|
||||
}
|
||||
} else {
|
||||
var _ref5 = [xAxis.scale(value[0]), xAxis.scale(value[1])],
|
||||
_baseValueScale = _ref5[0],
|
||||
_currentValueScale = _ref5[1];
|
||||
x = _baseValueScale;
|
||||
y = getCateCoordinateOfBar({
|
||||
axis: yAxis,
|
||||
ticks: yAxisTicks,
|
||||
bandSize: bandSize,
|
||||
offset: pos.offset,
|
||||
entry: entry,
|
||||
index: index
|
||||
});
|
||||
width = _currentValueScale - _baseValueScale;
|
||||
height = pos.size;
|
||||
background = {
|
||||
x: xAxis.x,
|
||||
y: y,
|
||||
width: xAxis.width,
|
||||
height: height
|
||||
};
|
||||
if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
|
||||
var _delta = mathSign(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
|
||||
width += _delta;
|
||||
}
|
||||
}
|
||||
return _objectSpread(_objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
value: stackedData ? value : value[1],
|
||||
payload: entry,
|
||||
background: background
|
||||
}, cells && cells[index] && cells[index].props), {}, {
|
||||
tooltipPayload: [getTooltipItem(item, entry)],
|
||||
tooltipPosition: {
|
||||
x: x + width / 2,
|
||||
y: y + height / 2
|
||||
}
|
||||
});
|
||||
});
|
||||
return _objectSpread({
|
||||
data: rects,
|
||||
layout: layout
|
||||
}, offset);
|
||||
});
|
||||
621
vendor/node_modules/recharts/es6/cartesian/Brush.js
generated
vendored
Normal file
621
vendor/node_modules/recharts/es6/cartesian/Brush.js
generated
vendored
Normal file
@@ -0,0 +1,621 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Brush
|
||||
*/
|
||||
import React, { PureComponent, Children } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { scalePoint } from 'victory-vendor/d3-scale';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import range from 'lodash/range';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Text } from '../component/Text';
|
||||
import { getValueByDataKey } from '../util/ChartUtils';
|
||||
import { isNumber } from '../util/DataUtils';
|
||||
import { generatePrefixStyle } from '../util/CssPrefixUtils';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var createScale = function createScale(_ref) {
|
||||
var data = _ref.data,
|
||||
startIndex = _ref.startIndex,
|
||||
endIndex = _ref.endIndex,
|
||||
x = _ref.x,
|
||||
width = _ref.width,
|
||||
travellerWidth = _ref.travellerWidth;
|
||||
if (!data || !data.length) {
|
||||
return {};
|
||||
}
|
||||
var len = data.length;
|
||||
var scale = scalePoint().domain(range(0, len)).range([x, x + width - travellerWidth]);
|
||||
var scaleValues = scale.domain().map(function (entry) {
|
||||
return scale(entry);
|
||||
});
|
||||
return {
|
||||
isTextActive: false,
|
||||
isSlideMoving: false,
|
||||
isTravellerMoving: false,
|
||||
isTravellerFocused: false,
|
||||
startX: scale(startIndex),
|
||||
endX: scale(endIndex),
|
||||
scale: scale,
|
||||
scaleValues: scaleValues
|
||||
};
|
||||
};
|
||||
var isTouch = function isTouch(e) {
|
||||
return e.changedTouches && !!e.changedTouches.length;
|
||||
};
|
||||
export var Brush = /*#__PURE__*/function (_PureComponent) {
|
||||
function Brush(props) {
|
||||
var _this;
|
||||
_classCallCheck(this, Brush);
|
||||
_this = _callSuper(this, Brush, [props]);
|
||||
_defineProperty(_this, "handleDrag", function (e) {
|
||||
if (_this.leaveTimer) {
|
||||
clearTimeout(_this.leaveTimer);
|
||||
_this.leaveTimer = null;
|
||||
}
|
||||
if (_this.state.isTravellerMoving) {
|
||||
_this.handleTravellerMove(e);
|
||||
} else if (_this.state.isSlideMoving) {
|
||||
_this.handleSlideDrag(e);
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleTouchMove", function (e) {
|
||||
if (e.changedTouches != null && e.changedTouches.length > 0) {
|
||||
_this.handleDrag(e.changedTouches[0]);
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleDragEnd", function () {
|
||||
_this.setState({
|
||||
isTravellerMoving: false,
|
||||
isSlideMoving: false
|
||||
}, function () {
|
||||
var _this$props = _this.props,
|
||||
endIndex = _this$props.endIndex,
|
||||
onDragEnd = _this$props.onDragEnd,
|
||||
startIndex = _this$props.startIndex;
|
||||
onDragEnd === null || onDragEnd === void 0 || onDragEnd({
|
||||
endIndex: endIndex,
|
||||
startIndex: startIndex
|
||||
});
|
||||
});
|
||||
_this.detachDragEndListener();
|
||||
});
|
||||
_defineProperty(_this, "handleLeaveWrapper", function () {
|
||||
if (_this.state.isTravellerMoving || _this.state.isSlideMoving) {
|
||||
_this.leaveTimer = window.setTimeout(_this.handleDragEnd, _this.props.leaveTimeOut);
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleEnterSlideOrTraveller", function () {
|
||||
_this.setState({
|
||||
isTextActive: true
|
||||
});
|
||||
});
|
||||
_defineProperty(_this, "handleLeaveSlideOrTraveller", function () {
|
||||
_this.setState({
|
||||
isTextActive: false
|
||||
});
|
||||
});
|
||||
_defineProperty(_this, "handleSlideDragStart", function (e) {
|
||||
var event = isTouch(e) ? e.changedTouches[0] : e;
|
||||
_this.setState({
|
||||
isTravellerMoving: false,
|
||||
isSlideMoving: true,
|
||||
slideMoveStartX: event.pageX
|
||||
});
|
||||
_this.attachDragEndListener();
|
||||
});
|
||||
_this.travellerDragStartHandlers = {
|
||||
startX: _this.handleTravellerDragStart.bind(_this, 'startX'),
|
||||
endX: _this.handleTravellerDragStart.bind(_this, 'endX')
|
||||
};
|
||||
_this.state = {};
|
||||
return _this;
|
||||
}
|
||||
_inherits(Brush, _PureComponent);
|
||||
return _createClass(Brush, [{
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
if (this.leaveTimer) {
|
||||
clearTimeout(this.leaveTimer);
|
||||
this.leaveTimer = null;
|
||||
}
|
||||
this.detachDragEndListener();
|
||||
}
|
||||
}, {
|
||||
key: "getIndex",
|
||||
value: function getIndex(_ref2) {
|
||||
var startX = _ref2.startX,
|
||||
endX = _ref2.endX;
|
||||
var scaleValues = this.state.scaleValues;
|
||||
var _this$props2 = this.props,
|
||||
gap = _this$props2.gap,
|
||||
data = _this$props2.data;
|
||||
var lastIndex = data.length - 1;
|
||||
var min = Math.min(startX, endX);
|
||||
var max = Math.max(startX, endX);
|
||||
var minIndex = Brush.getIndexInRange(scaleValues, min);
|
||||
var maxIndex = Brush.getIndexInRange(scaleValues, max);
|
||||
return {
|
||||
startIndex: minIndex - minIndex % gap,
|
||||
endIndex: maxIndex === lastIndex ? lastIndex : maxIndex - maxIndex % gap
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "getTextOfTick",
|
||||
value: function getTextOfTick(index) {
|
||||
var _this$props3 = this.props,
|
||||
data = _this$props3.data,
|
||||
tickFormatter = _this$props3.tickFormatter,
|
||||
dataKey = _this$props3.dataKey;
|
||||
var text = getValueByDataKey(data[index], dataKey, index);
|
||||
return isFunction(tickFormatter) ? tickFormatter(text, index) : text;
|
||||
}
|
||||
}, {
|
||||
key: "attachDragEndListener",
|
||||
value: function attachDragEndListener() {
|
||||
window.addEventListener('mouseup', this.handleDragEnd, true);
|
||||
window.addEventListener('touchend', this.handleDragEnd, true);
|
||||
window.addEventListener('mousemove', this.handleDrag, true);
|
||||
}
|
||||
}, {
|
||||
key: "detachDragEndListener",
|
||||
value: function detachDragEndListener() {
|
||||
window.removeEventListener('mouseup', this.handleDragEnd, true);
|
||||
window.removeEventListener('touchend', this.handleDragEnd, true);
|
||||
window.removeEventListener('mousemove', this.handleDrag, true);
|
||||
}
|
||||
}, {
|
||||
key: "handleSlideDrag",
|
||||
value: function handleSlideDrag(e) {
|
||||
var _this$state = this.state,
|
||||
slideMoveStartX = _this$state.slideMoveStartX,
|
||||
startX = _this$state.startX,
|
||||
endX = _this$state.endX;
|
||||
var _this$props4 = this.props,
|
||||
x = _this$props4.x,
|
||||
width = _this$props4.width,
|
||||
travellerWidth = _this$props4.travellerWidth,
|
||||
startIndex = _this$props4.startIndex,
|
||||
endIndex = _this$props4.endIndex,
|
||||
onChange = _this$props4.onChange;
|
||||
var delta = e.pageX - slideMoveStartX;
|
||||
if (delta > 0) {
|
||||
delta = Math.min(delta, x + width - travellerWidth - endX, x + width - travellerWidth - startX);
|
||||
} else if (delta < 0) {
|
||||
delta = Math.max(delta, x - startX, x - endX);
|
||||
}
|
||||
var newIndex = this.getIndex({
|
||||
startX: startX + delta,
|
||||
endX: endX + delta
|
||||
});
|
||||
if ((newIndex.startIndex !== startIndex || newIndex.endIndex !== endIndex) && onChange) {
|
||||
onChange(newIndex);
|
||||
}
|
||||
this.setState({
|
||||
startX: startX + delta,
|
||||
endX: endX + delta,
|
||||
slideMoveStartX: e.pageX
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "handleTravellerDragStart",
|
||||
value: function handleTravellerDragStart(id, e) {
|
||||
var event = isTouch(e) ? e.changedTouches[0] : e;
|
||||
this.setState({
|
||||
isSlideMoving: false,
|
||||
isTravellerMoving: true,
|
||||
movingTravellerId: id,
|
||||
brushMoveStartX: event.pageX
|
||||
});
|
||||
this.attachDragEndListener();
|
||||
}
|
||||
}, {
|
||||
key: "handleTravellerMove",
|
||||
value: function handleTravellerMove(e) {
|
||||
var _this$state2 = this.state,
|
||||
brushMoveStartX = _this$state2.brushMoveStartX,
|
||||
movingTravellerId = _this$state2.movingTravellerId,
|
||||
endX = _this$state2.endX,
|
||||
startX = _this$state2.startX;
|
||||
var prevValue = this.state[movingTravellerId];
|
||||
var _this$props5 = this.props,
|
||||
x = _this$props5.x,
|
||||
width = _this$props5.width,
|
||||
travellerWidth = _this$props5.travellerWidth,
|
||||
onChange = _this$props5.onChange,
|
||||
gap = _this$props5.gap,
|
||||
data = _this$props5.data;
|
||||
var params = {
|
||||
startX: this.state.startX,
|
||||
endX: this.state.endX
|
||||
};
|
||||
var delta = e.pageX - brushMoveStartX;
|
||||
if (delta > 0) {
|
||||
delta = Math.min(delta, x + width - travellerWidth - prevValue);
|
||||
} else if (delta < 0) {
|
||||
delta = Math.max(delta, x - prevValue);
|
||||
}
|
||||
params[movingTravellerId] = prevValue + delta;
|
||||
var newIndex = this.getIndex(params);
|
||||
var startIndex = newIndex.startIndex,
|
||||
endIndex = newIndex.endIndex;
|
||||
var isFullGap = function isFullGap() {
|
||||
var lastIndex = data.length - 1;
|
||||
if (movingTravellerId === 'startX' && (endX > startX ? startIndex % gap === 0 : endIndex % gap === 0) || endX < startX && endIndex === lastIndex || movingTravellerId === 'endX' && (endX > startX ? endIndex % gap === 0 : startIndex % gap === 0) || endX > startX && endIndex === lastIndex) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
this.setState(_defineProperty(_defineProperty({}, movingTravellerId, prevValue + delta), "brushMoveStartX", e.pageX), function () {
|
||||
if (onChange) {
|
||||
if (isFullGap()) {
|
||||
onChange(newIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "handleTravellerMoveKeyboard",
|
||||
value: function handleTravellerMoveKeyboard(direction, id) {
|
||||
var _this2 = this;
|
||||
// scaleValues are a list of coordinates. For example: [65, 250, 435, 620, 805, 990].
|
||||
var _this$state3 = this.state,
|
||||
scaleValues = _this$state3.scaleValues,
|
||||
startX = _this$state3.startX,
|
||||
endX = _this$state3.endX;
|
||||
// currentScaleValue refers to which coordinate the current traveller should be placed at.
|
||||
var currentScaleValue = this.state[id];
|
||||
var currentIndex = scaleValues.indexOf(currentScaleValue);
|
||||
if (currentIndex === -1) {
|
||||
return;
|
||||
}
|
||||
var newIndex = currentIndex + direction;
|
||||
if (newIndex === -1 || newIndex >= scaleValues.length) {
|
||||
return;
|
||||
}
|
||||
var newScaleValue = scaleValues[newIndex];
|
||||
|
||||
// Prevent travellers from being on top of each other or overlapping
|
||||
if (id === 'startX' && newScaleValue >= endX || id === 'endX' && newScaleValue <= startX) {
|
||||
return;
|
||||
}
|
||||
this.setState(_defineProperty({}, id, newScaleValue), function () {
|
||||
_this2.props.onChange(_this2.getIndex({
|
||||
startX: _this2.state.startX,
|
||||
endX: _this2.state.endX
|
||||
}));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderBackground",
|
||||
value: function renderBackground() {
|
||||
var _this$props6 = this.props,
|
||||
x = _this$props6.x,
|
||||
y = _this$props6.y,
|
||||
width = _this$props6.width,
|
||||
height = _this$props6.height,
|
||||
fill = _this$props6.fill,
|
||||
stroke = _this$props6.stroke;
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
stroke: stroke,
|
||||
fill: fill,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderPanorama",
|
||||
value: function renderPanorama() {
|
||||
var _this$props7 = this.props,
|
||||
x = _this$props7.x,
|
||||
y = _this$props7.y,
|
||||
width = _this$props7.width,
|
||||
height = _this$props7.height,
|
||||
data = _this$props7.data,
|
||||
children = _this$props7.children,
|
||||
padding = _this$props7.padding;
|
||||
var chartElement = Children.only(children);
|
||||
if (!chartElement) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.cloneElement(chartElement, {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
margin: padding,
|
||||
compact: true,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderTravellerLayer",
|
||||
value: function renderTravellerLayer(travellerX, id) {
|
||||
var _data$startIndex,
|
||||
_data$endIndex,
|
||||
_this3 = this;
|
||||
var _this$props8 = this.props,
|
||||
y = _this$props8.y,
|
||||
travellerWidth = _this$props8.travellerWidth,
|
||||
height = _this$props8.height,
|
||||
traveller = _this$props8.traveller,
|
||||
ariaLabel = _this$props8.ariaLabel,
|
||||
data = _this$props8.data,
|
||||
startIndex = _this$props8.startIndex,
|
||||
endIndex = _this$props8.endIndex;
|
||||
var x = Math.max(travellerX, this.props.x);
|
||||
var travellerProps = _objectSpread(_objectSpread({}, filterProps(this.props, false)), {}, {
|
||||
x: x,
|
||||
y: y,
|
||||
width: travellerWidth,
|
||||
height: height
|
||||
});
|
||||
var ariaLabelBrush = ariaLabel || "Min value: ".concat((_data$startIndex = data[startIndex]) === null || _data$startIndex === void 0 ? void 0 : _data$startIndex.name, ", Max value: ").concat((_data$endIndex = data[endIndex]) === null || _data$endIndex === void 0 ? void 0 : _data$endIndex.name);
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
tabIndex: 0,
|
||||
role: "slider",
|
||||
"aria-label": ariaLabelBrush,
|
||||
"aria-valuenow": travellerX,
|
||||
className: "recharts-brush-traveller",
|
||||
onMouseEnter: this.handleEnterSlideOrTraveller,
|
||||
onMouseLeave: this.handleLeaveSlideOrTraveller,
|
||||
onMouseDown: this.travellerDragStartHandlers[id],
|
||||
onTouchStart: this.travellerDragStartHandlers[id],
|
||||
onKeyDown: function onKeyDown(e) {
|
||||
if (!['ArrowLeft', 'ArrowRight'].includes(e.key)) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
_this3.handleTravellerMoveKeyboard(e.key === 'ArrowRight' ? 1 : -1, id);
|
||||
},
|
||||
onFocus: function onFocus() {
|
||||
_this3.setState({
|
||||
isTravellerFocused: true
|
||||
});
|
||||
},
|
||||
onBlur: function onBlur() {
|
||||
_this3.setState({
|
||||
isTravellerFocused: false
|
||||
});
|
||||
},
|
||||
style: {
|
||||
cursor: 'col-resize'
|
||||
}
|
||||
}, Brush.renderTraveller(traveller, travellerProps));
|
||||
}
|
||||
}, {
|
||||
key: "renderSlide",
|
||||
value: function renderSlide(startX, endX) {
|
||||
var _this$props9 = this.props,
|
||||
y = _this$props9.y,
|
||||
height = _this$props9.height,
|
||||
stroke = _this$props9.stroke,
|
||||
travellerWidth = _this$props9.travellerWidth;
|
||||
var x = Math.min(startX, endX) + travellerWidth;
|
||||
var width = Math.max(Math.abs(endX - startX) - travellerWidth, 0);
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
className: "recharts-brush-slide",
|
||||
onMouseEnter: this.handleEnterSlideOrTraveller,
|
||||
onMouseLeave: this.handleLeaveSlideOrTraveller,
|
||||
onMouseDown: this.handleSlideDragStart,
|
||||
onTouchStart: this.handleSlideDragStart,
|
||||
style: {
|
||||
cursor: 'move'
|
||||
},
|
||||
stroke: "none",
|
||||
fill: stroke,
|
||||
fillOpacity: 0.2,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderText",
|
||||
value: function renderText() {
|
||||
var _this$props10 = this.props,
|
||||
startIndex = _this$props10.startIndex,
|
||||
endIndex = _this$props10.endIndex,
|
||||
y = _this$props10.y,
|
||||
height = _this$props10.height,
|
||||
travellerWidth = _this$props10.travellerWidth,
|
||||
stroke = _this$props10.stroke;
|
||||
var _this$state4 = this.state,
|
||||
startX = _this$state4.startX,
|
||||
endX = _this$state4.endX;
|
||||
var offset = 5;
|
||||
var attrs = {
|
||||
pointerEvents: 'none',
|
||||
fill: stroke
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-brush-texts"
|
||||
}, /*#__PURE__*/React.createElement(Text, _extends({
|
||||
textAnchor: "end",
|
||||
verticalAnchor: "middle",
|
||||
x: Math.min(startX, endX) - offset,
|
||||
y: y + height / 2
|
||||
}, attrs), this.getTextOfTick(startIndex)), /*#__PURE__*/React.createElement(Text, _extends({
|
||||
textAnchor: "start",
|
||||
verticalAnchor: "middle",
|
||||
x: Math.max(startX, endX) + travellerWidth + offset,
|
||||
y: y + height / 2
|
||||
}, attrs), this.getTextOfTick(endIndex)));
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props11 = this.props,
|
||||
data = _this$props11.data,
|
||||
className = _this$props11.className,
|
||||
children = _this$props11.children,
|
||||
x = _this$props11.x,
|
||||
y = _this$props11.y,
|
||||
width = _this$props11.width,
|
||||
height = _this$props11.height,
|
||||
alwaysShowText = _this$props11.alwaysShowText;
|
||||
var _this$state5 = this.state,
|
||||
startX = _this$state5.startX,
|
||||
endX = _this$state5.endX,
|
||||
isTextActive = _this$state5.isTextActive,
|
||||
isSlideMoving = _this$state5.isSlideMoving,
|
||||
isTravellerMoving = _this$state5.isTravellerMoving,
|
||||
isTravellerFocused = _this$state5.isTravellerFocused;
|
||||
if (!data || !data.length || !isNumber(x) || !isNumber(y) || !isNumber(width) || !isNumber(height) || width <= 0 || height <= 0) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-brush', className);
|
||||
var isPanoramic = React.Children.count(children) === 1;
|
||||
var style = generatePrefixStyle('userSelect', 'none');
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass,
|
||||
onMouseLeave: this.handleLeaveWrapper,
|
||||
onTouchMove: this.handleTouchMove,
|
||||
style: style
|
||||
}, this.renderBackground(), isPanoramic && this.renderPanorama(), this.renderSlide(startX, endX), this.renderTravellerLayer(startX, 'startX'), this.renderTravellerLayer(endX, 'endX'), (isTextActive || isSlideMoving || isTravellerMoving || isTravellerFocused || alwaysShowText) && this.renderText());
|
||||
}
|
||||
}], [{
|
||||
key: "renderDefaultTraveller",
|
||||
value: function renderDefaultTraveller(props) {
|
||||
var x = props.x,
|
||||
y = props.y,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
stroke = props.stroke;
|
||||
var lineY = Math.floor(y + height / 2) - 1;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("rect", {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
fill: stroke,
|
||||
stroke: "none"
|
||||
}), /*#__PURE__*/React.createElement("line", {
|
||||
x1: x + 1,
|
||||
y1: lineY,
|
||||
x2: x + width - 1,
|
||||
y2: lineY,
|
||||
fill: "none",
|
||||
stroke: "#fff"
|
||||
}), /*#__PURE__*/React.createElement("line", {
|
||||
x1: x + 1,
|
||||
y1: lineY + 2,
|
||||
x2: x + width - 1,
|
||||
y2: lineY + 2,
|
||||
fill: "none",
|
||||
stroke: "#fff"
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderTraveller",
|
||||
value: function renderTraveller(option, props) {
|
||||
var rectangle;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
rectangle = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
rectangle = option(props);
|
||||
} else {
|
||||
rectangle = Brush.renderDefaultTraveller(props);
|
||||
}
|
||||
return rectangle;
|
||||
}
|
||||
}, {
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
var data = nextProps.data,
|
||||
width = nextProps.width,
|
||||
x = nextProps.x,
|
||||
travellerWidth = nextProps.travellerWidth,
|
||||
updateId = nextProps.updateId,
|
||||
startIndex = nextProps.startIndex,
|
||||
endIndex = nextProps.endIndex;
|
||||
if (data !== prevState.prevData || updateId !== prevState.prevUpdateId) {
|
||||
return _objectSpread({
|
||||
prevData: data,
|
||||
prevTravellerWidth: travellerWidth,
|
||||
prevUpdateId: updateId,
|
||||
prevX: x,
|
||||
prevWidth: width
|
||||
}, data && data.length ? createScale({
|
||||
data: data,
|
||||
width: width,
|
||||
x: x,
|
||||
travellerWidth: travellerWidth,
|
||||
startIndex: startIndex,
|
||||
endIndex: endIndex
|
||||
}) : {
|
||||
scale: null,
|
||||
scaleValues: null
|
||||
});
|
||||
}
|
||||
if (prevState.scale && (width !== prevState.prevWidth || x !== prevState.prevX || travellerWidth !== prevState.prevTravellerWidth)) {
|
||||
prevState.scale.range([x, x + width - travellerWidth]);
|
||||
var scaleValues = prevState.scale.domain().map(function (entry) {
|
||||
return prevState.scale(entry);
|
||||
});
|
||||
return {
|
||||
prevData: data,
|
||||
prevTravellerWidth: travellerWidth,
|
||||
prevUpdateId: updateId,
|
||||
prevX: x,
|
||||
prevWidth: width,
|
||||
startX: prevState.scale(nextProps.startIndex),
|
||||
endX: prevState.scale(nextProps.endIndex),
|
||||
scaleValues: scaleValues
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "getIndexInRange",
|
||||
value: function getIndexInRange(valueRange, x) {
|
||||
var len = valueRange.length;
|
||||
var start = 0;
|
||||
var end = len - 1;
|
||||
while (end - start > 1) {
|
||||
var middle = Math.floor((start + end) / 2);
|
||||
if (valueRange[middle] > x) {
|
||||
end = middle;
|
||||
} else {
|
||||
start = middle;
|
||||
}
|
||||
}
|
||||
return x >= valueRange[end] ? end : start;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(Brush, "displayName", 'Brush');
|
||||
_defineProperty(Brush, "defaultProps", {
|
||||
height: 40,
|
||||
travellerWidth: 5,
|
||||
gap: 1,
|
||||
fill: '#fff',
|
||||
stroke: '#666',
|
||||
padding: {
|
||||
top: 1,
|
||||
right: 1,
|
||||
bottom: 1,
|
||||
left: 1
|
||||
},
|
||||
leaveTimeOut: 1000,
|
||||
alwaysShowText: false
|
||||
});
|
||||
358
vendor/node_modules/recharts/es6/cartesian/CartesianAxis.js
generated
vendored
Normal file
358
vendor/node_modules/recharts/es6/cartesian/CartesianAxis.js
generated
vendored
Normal file
@@ -0,0 +1,358 @@
|
||||
var _excluded = ["viewBox"],
|
||||
_excluded2 = ["viewBox"],
|
||||
_excluded3 = ["ticks"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Cartesian Axis
|
||||
*/
|
||||
import React, { Component } from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import get from 'lodash/get';
|
||||
import clsx from 'clsx';
|
||||
import { shallowEqual } from '../util/ShallowEqual';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Text } from '../component/Text';
|
||||
import { Label } from '../component/Label';
|
||||
import { isNumber } from '../util/DataUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { getTicks } from './getTicks';
|
||||
|
||||
/** The orientation of the axis in correspondence to the chart */
|
||||
|
||||
/** A unit to be appended to a value */
|
||||
|
||||
/** The formatter function of tick */
|
||||
|
||||
export var CartesianAxis = /*#__PURE__*/function (_Component) {
|
||||
function CartesianAxis(props) {
|
||||
var _this;
|
||||
_classCallCheck(this, CartesianAxis);
|
||||
_this = _callSuper(this, CartesianAxis, [props]);
|
||||
_this.state = {
|
||||
fontSize: '',
|
||||
letterSpacing: ''
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
_inherits(CartesianAxis, _Component);
|
||||
return _createClass(CartesianAxis, [{
|
||||
key: "shouldComponentUpdate",
|
||||
value: function shouldComponentUpdate(_ref, nextState) {
|
||||
var viewBox = _ref.viewBox,
|
||||
restProps = _objectWithoutProperties(_ref, _excluded);
|
||||
// props.viewBox is sometimes generated every time -
|
||||
// check that specially as object equality is likely to fail
|
||||
var _this$props = this.props,
|
||||
viewBoxOld = _this$props.viewBox,
|
||||
restPropsOld = _objectWithoutProperties(_this$props, _excluded2);
|
||||
return !shallowEqual(viewBox, viewBoxOld) || !shallowEqual(restProps, restPropsOld) || !shallowEqual(nextState, this.state);
|
||||
}
|
||||
}, {
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
var htmlLayer = this.layerReference;
|
||||
if (!htmlLayer) return;
|
||||
var tick = htmlLayer.getElementsByClassName('recharts-cartesian-axis-tick-value')[0];
|
||||
if (tick) {
|
||||
this.setState({
|
||||
fontSize: window.getComputedStyle(tick).fontSize,
|
||||
letterSpacing: window.getComputedStyle(tick).letterSpacing
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the coordinates of endpoints in ticks
|
||||
* @param {Object} data The data of a simple tick
|
||||
* @return {Object} (x1, y1): The coordinate of endpoint close to tick text
|
||||
* (x2, y2): The coordinate of endpoint close to axis
|
||||
*/
|
||||
}, {
|
||||
key: "getTickLineCoord",
|
||||
value: function getTickLineCoord(data) {
|
||||
var _this$props2 = this.props,
|
||||
x = _this$props2.x,
|
||||
y = _this$props2.y,
|
||||
width = _this$props2.width,
|
||||
height = _this$props2.height,
|
||||
orientation = _this$props2.orientation,
|
||||
tickSize = _this$props2.tickSize,
|
||||
mirror = _this$props2.mirror,
|
||||
tickMargin = _this$props2.tickMargin;
|
||||
var x1, x2, y1, y2, tx, ty;
|
||||
var sign = mirror ? -1 : 1;
|
||||
var finalTickSize = data.tickSize || tickSize;
|
||||
var tickCoord = isNumber(data.tickCoord) ? data.tickCoord : data.coordinate;
|
||||
switch (orientation) {
|
||||
case 'top':
|
||||
x1 = x2 = data.coordinate;
|
||||
y2 = y + +!mirror * height;
|
||||
y1 = y2 - sign * finalTickSize;
|
||||
ty = y1 - sign * tickMargin;
|
||||
tx = tickCoord;
|
||||
break;
|
||||
case 'left':
|
||||
y1 = y2 = data.coordinate;
|
||||
x2 = x + +!mirror * width;
|
||||
x1 = x2 - sign * finalTickSize;
|
||||
tx = x1 - sign * tickMargin;
|
||||
ty = tickCoord;
|
||||
break;
|
||||
case 'right':
|
||||
y1 = y2 = data.coordinate;
|
||||
x2 = x + +mirror * width;
|
||||
x1 = x2 + sign * finalTickSize;
|
||||
tx = x1 + sign * tickMargin;
|
||||
ty = tickCoord;
|
||||
break;
|
||||
default:
|
||||
x1 = x2 = data.coordinate;
|
||||
y2 = y + +mirror * height;
|
||||
y1 = y2 + sign * finalTickSize;
|
||||
ty = y1 + sign * tickMargin;
|
||||
tx = tickCoord;
|
||||
break;
|
||||
}
|
||||
return {
|
||||
line: {
|
||||
x1: x1,
|
||||
y1: y1,
|
||||
x2: x2,
|
||||
y2: y2
|
||||
},
|
||||
tick: {
|
||||
x: tx,
|
||||
y: ty
|
||||
}
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "getTickTextAnchor",
|
||||
value: function getTickTextAnchor() {
|
||||
var _this$props3 = this.props,
|
||||
orientation = _this$props3.orientation,
|
||||
mirror = _this$props3.mirror;
|
||||
var textAnchor;
|
||||
switch (orientation) {
|
||||
case 'left':
|
||||
textAnchor = mirror ? 'start' : 'end';
|
||||
break;
|
||||
case 'right':
|
||||
textAnchor = mirror ? 'end' : 'start';
|
||||
break;
|
||||
default:
|
||||
textAnchor = 'middle';
|
||||
break;
|
||||
}
|
||||
return textAnchor;
|
||||
}
|
||||
}, {
|
||||
key: "getTickVerticalAnchor",
|
||||
value: function getTickVerticalAnchor() {
|
||||
var _this$props4 = this.props,
|
||||
orientation = _this$props4.orientation,
|
||||
mirror = _this$props4.mirror;
|
||||
var verticalAnchor = 'end';
|
||||
switch (orientation) {
|
||||
case 'left':
|
||||
case 'right':
|
||||
verticalAnchor = 'middle';
|
||||
break;
|
||||
case 'top':
|
||||
verticalAnchor = mirror ? 'start' : 'end';
|
||||
break;
|
||||
default:
|
||||
verticalAnchor = mirror ? 'end' : 'start';
|
||||
break;
|
||||
}
|
||||
return verticalAnchor;
|
||||
}
|
||||
}, {
|
||||
key: "renderAxisLine",
|
||||
value: function renderAxisLine() {
|
||||
var _this$props5 = this.props,
|
||||
x = _this$props5.x,
|
||||
y = _this$props5.y,
|
||||
width = _this$props5.width,
|
||||
height = _this$props5.height,
|
||||
orientation = _this$props5.orientation,
|
||||
mirror = _this$props5.mirror,
|
||||
axisLine = _this$props5.axisLine;
|
||||
var props = _objectSpread(_objectSpread(_objectSpread({}, filterProps(this.props, false)), filterProps(axisLine, false)), {}, {
|
||||
fill: 'none'
|
||||
});
|
||||
if (orientation === 'top' || orientation === 'bottom') {
|
||||
var needHeight = +(orientation === 'top' && !mirror || orientation === 'bottom' && mirror);
|
||||
props = _objectSpread(_objectSpread({}, props), {}, {
|
||||
x1: x,
|
||||
y1: y + needHeight * height,
|
||||
x2: x + width,
|
||||
y2: y + needHeight * height
|
||||
});
|
||||
} else {
|
||||
var needWidth = +(orientation === 'left' && !mirror || orientation === 'right' && mirror);
|
||||
props = _objectSpread(_objectSpread({}, props), {}, {
|
||||
x1: x + needWidth * width,
|
||||
y1: y,
|
||||
x2: x + needWidth * width,
|
||||
y2: y + height
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("line", _extends({}, props, {
|
||||
className: clsx('recharts-cartesian-axis-line', get(axisLine, 'className'))
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderTicks",
|
||||
value:
|
||||
/**
|
||||
* render the ticks
|
||||
* @param {Array} ticks The ticks to actually render (overrides what was passed in props)
|
||||
* @param {string} fontSize Fontsize to consider for tick spacing
|
||||
* @param {string} letterSpacing Letterspacing to consider for tick spacing
|
||||
* @return {ReactComponent} renderedTicks
|
||||
*/
|
||||
function renderTicks(ticks, fontSize, letterSpacing) {
|
||||
var _this2 = this;
|
||||
var _this$props6 = this.props,
|
||||
tickLine = _this$props6.tickLine,
|
||||
stroke = _this$props6.stroke,
|
||||
tick = _this$props6.tick,
|
||||
tickFormatter = _this$props6.tickFormatter,
|
||||
unit = _this$props6.unit;
|
||||
var finalTicks = getTicks(_objectSpread(_objectSpread({}, this.props), {}, {
|
||||
ticks: ticks
|
||||
}), fontSize, letterSpacing);
|
||||
var textAnchor = this.getTickTextAnchor();
|
||||
var verticalAnchor = this.getTickVerticalAnchor();
|
||||
var axisProps = filterProps(this.props, false);
|
||||
var customTickProps = filterProps(tick, false);
|
||||
var tickLineProps = _objectSpread(_objectSpread({}, axisProps), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(tickLine, false));
|
||||
var items = finalTicks.map(function (entry, i) {
|
||||
var _this2$getTickLineCoo = _this2.getTickLineCoord(entry),
|
||||
lineCoord = _this2$getTickLineCoo.line,
|
||||
tickCoord = _this2$getTickLineCoo.tick;
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
textAnchor: textAnchor,
|
||||
verticalAnchor: verticalAnchor
|
||||
}, axisProps), {}, {
|
||||
stroke: 'none',
|
||||
fill: stroke
|
||||
}, customTickProps), tickCoord), {}, {
|
||||
index: i,
|
||||
payload: entry,
|
||||
visibleTicksCount: finalTicks.length,
|
||||
tickFormatter: tickFormatter
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: "recharts-cartesian-axis-tick",
|
||||
key: "tick-".concat(entry.value, "-").concat(entry.coordinate, "-").concat(entry.tickCoord)
|
||||
}, adaptEventsOfChild(_this2.props, entry, i)), tickLine && /*#__PURE__*/React.createElement("line", _extends({}, tickLineProps, lineCoord, {
|
||||
className: clsx('recharts-cartesian-axis-tick-line', get(tickLine, 'className'))
|
||||
})), tick && CartesianAxis.renderTickItem(tick, tickProps, "".concat(isFunction(tickFormatter) ? tickFormatter(entry.value, i) : entry.value).concat(unit || '')));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-cartesian-axis-ticks"
|
||||
}, items);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this3 = this;
|
||||
var _this$props7 = this.props,
|
||||
axisLine = _this$props7.axisLine,
|
||||
width = _this$props7.width,
|
||||
height = _this$props7.height,
|
||||
ticksGenerator = _this$props7.ticksGenerator,
|
||||
className = _this$props7.className,
|
||||
hide = _this$props7.hide;
|
||||
if (hide) {
|
||||
return null;
|
||||
}
|
||||
var _this$props8 = this.props,
|
||||
ticks = _this$props8.ticks,
|
||||
noTicksProps = _objectWithoutProperties(_this$props8, _excluded3);
|
||||
var finalTicks = ticks;
|
||||
if (isFunction(ticksGenerator)) {
|
||||
finalTicks = ticks && ticks.length > 0 ? ticksGenerator(this.props) : ticksGenerator(noTicksProps);
|
||||
}
|
||||
if (width <= 0 || height <= 0 || !finalTicks || !finalTicks.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-cartesian-axis', className),
|
||||
ref: function ref(_ref2) {
|
||||
_this3.layerReference = _ref2;
|
||||
}
|
||||
}, axisLine && this.renderAxisLine(), this.renderTicks(finalTicks, this.state.fontSize, this.state.letterSpacing), Label.renderCallByParent(this.props));
|
||||
}
|
||||
}], [{
|
||||
key: "renderTickItem",
|
||||
value: function renderTickItem(option, props, value) {
|
||||
var tickItem;
|
||||
var combinedClassName = clsx(props.className, 'recharts-cartesian-axis-tick-value');
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
tickItem = /*#__PURE__*/React.cloneElement(option, _objectSpread(_objectSpread({}, props), {}, {
|
||||
className: combinedClassName
|
||||
}));
|
||||
} else if (isFunction(option)) {
|
||||
tickItem = option(_objectSpread(_objectSpread({}, props), {}, {
|
||||
className: combinedClassName
|
||||
}));
|
||||
} else {
|
||||
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
className: "recharts-cartesian-axis-tick-value"
|
||||
}), value);
|
||||
}
|
||||
return tickItem;
|
||||
}
|
||||
}]);
|
||||
}(Component);
|
||||
_defineProperty(CartesianAxis, "displayName", 'CartesianAxis');
|
||||
_defineProperty(CartesianAxis, "defaultProps", {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
viewBox: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0
|
||||
},
|
||||
// The orientation of axis
|
||||
orientation: 'bottom',
|
||||
// The ticks
|
||||
ticks: [],
|
||||
stroke: '#666',
|
||||
tickLine: true,
|
||||
axisLine: true,
|
||||
tick: true,
|
||||
mirror: false,
|
||||
minTickGap: 5,
|
||||
// The width or height of tick
|
||||
tickSize: 6,
|
||||
tickMargin: 2,
|
||||
interval: 'preserveEnd'
|
||||
});
|
||||
369
vendor/node_modules/recharts/es6/cartesian/CartesianGrid.js
generated
vendored
Normal file
369
vendor/node_modules/recharts/es6/cartesian/CartesianGrid.js
generated
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
var _excluded = ["x1", "y1", "x2", "y2", "key"],
|
||||
_excluded2 = ["offset"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
/**
|
||||
* @fileOverview Cartesian Grid
|
||||
*/
|
||||
import React from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { isNumber } from '../util/DataUtils';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { getCoordinatesOfGrid, getTicksOfAxis } from '../util/ChartUtils';
|
||||
import { getTicks } from './getTicks';
|
||||
import { CartesianAxis } from './CartesianAxis';
|
||||
import { useArbitraryXAxis, useChartHeight, useChartWidth, useOffset, useYAxisWithFiniteDomainOrRandom } from '../context/chartLayoutContext';
|
||||
|
||||
/**
|
||||
* The <CartesianGrid horizontal
|
||||
*/
|
||||
|
||||
var Background = function Background(props) {
|
||||
var fill = props.fill;
|
||||
if (!fill || fill === 'none') {
|
||||
return null;
|
||||
}
|
||||
var fillOpacity = props.fillOpacity,
|
||||
x = props.x,
|
||||
y = props.y,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
ry = props.ry;
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
x: x,
|
||||
y: y,
|
||||
ry: ry,
|
||||
width: width,
|
||||
height: height,
|
||||
stroke: "none",
|
||||
fill: fill,
|
||||
fillOpacity: fillOpacity,
|
||||
className: "recharts-cartesian-grid-bg"
|
||||
});
|
||||
};
|
||||
function renderLineItem(option, props) {
|
||||
var lineItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
// @ts-expect-error typescript does not see the props type when cloning an element
|
||||
lineItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
lineItem = option(props);
|
||||
} else {
|
||||
var x1 = props.x1,
|
||||
y1 = props.y1,
|
||||
x2 = props.x2,
|
||||
y2 = props.y2,
|
||||
key = props.key,
|
||||
others = _objectWithoutProperties(props, _excluded);
|
||||
var _filterProps = filterProps(others, false),
|
||||
__ = _filterProps.offset,
|
||||
restOfFilteredProps = _objectWithoutProperties(_filterProps, _excluded2);
|
||||
lineItem = /*#__PURE__*/React.createElement("line", _extends({}, restOfFilteredProps, {
|
||||
x1: x1,
|
||||
y1: y1,
|
||||
x2: x2,
|
||||
y2: y2,
|
||||
fill: "none",
|
||||
key: key
|
||||
}));
|
||||
}
|
||||
return lineItem;
|
||||
}
|
||||
function HorizontalGridLines(props) {
|
||||
var x = props.x,
|
||||
width = props.width,
|
||||
_props$horizontal = props.horizontal,
|
||||
horizontal = _props$horizontal === void 0 ? true : _props$horizontal,
|
||||
horizontalPoints = props.horizontalPoints;
|
||||
if (!horizontal || !horizontalPoints || !horizontalPoints.length) {
|
||||
return null;
|
||||
}
|
||||
var items = horizontalPoints.map(function (entry, i) {
|
||||
var lineItemProps = _objectSpread(_objectSpread({}, props), {}, {
|
||||
x1: x,
|
||||
y1: entry,
|
||||
x2: x + width,
|
||||
y2: entry,
|
||||
key: "line-".concat(i),
|
||||
index: i
|
||||
});
|
||||
return renderLineItem(horizontal, lineItemProps);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-cartesian-grid-horizontal"
|
||||
}, items);
|
||||
}
|
||||
function VerticalGridLines(props) {
|
||||
var y = props.y,
|
||||
height = props.height,
|
||||
_props$vertical = props.vertical,
|
||||
vertical = _props$vertical === void 0 ? true : _props$vertical,
|
||||
verticalPoints = props.verticalPoints;
|
||||
if (!vertical || !verticalPoints || !verticalPoints.length) {
|
||||
return null;
|
||||
}
|
||||
var items = verticalPoints.map(function (entry, i) {
|
||||
var lineItemProps = _objectSpread(_objectSpread({}, props), {}, {
|
||||
x1: entry,
|
||||
y1: y,
|
||||
x2: entry,
|
||||
y2: y + height,
|
||||
key: "line-".concat(i),
|
||||
index: i
|
||||
});
|
||||
return renderLineItem(vertical, lineItemProps);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-cartesian-grid-vertical"
|
||||
}, items);
|
||||
}
|
||||
function HorizontalStripes(props) {
|
||||
var horizontalFill = props.horizontalFill,
|
||||
fillOpacity = props.fillOpacity,
|
||||
x = props.x,
|
||||
y = props.y,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
horizontalPoints = props.horizontalPoints,
|
||||
_props$horizontal2 = props.horizontal,
|
||||
horizontal = _props$horizontal2 === void 0 ? true : _props$horizontal2;
|
||||
if (!horizontal || !horizontalFill || !horizontalFill.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Why =y -y? I was trying to find any difference that this makes, with floating point numbers and edge cases but ... nothing.
|
||||
var roundedSortedHorizontalPoints = horizontalPoints.map(function (e) {
|
||||
return Math.round(e + y - y);
|
||||
}).sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
// Why is this condition `!==` instead of `<=` ?
|
||||
if (y !== roundedSortedHorizontalPoints[0]) {
|
||||
roundedSortedHorizontalPoints.unshift(0);
|
||||
}
|
||||
var items = roundedSortedHorizontalPoints.map(function (entry, i) {
|
||||
// Why do we strip only the last stripe if it is invisible, and not all invisible stripes?
|
||||
var lastStripe = !roundedSortedHorizontalPoints[i + 1];
|
||||
var lineHeight = lastStripe ? y + height - entry : roundedSortedHorizontalPoints[i + 1] - entry;
|
||||
if (lineHeight <= 0) {
|
||||
return null;
|
||||
}
|
||||
var colorIndex = i % horizontalFill.length;
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
key: "react-".concat(i) // eslint-disable-line react/no-array-index-key
|
||||
,
|
||||
y: entry,
|
||||
x: x,
|
||||
height: lineHeight,
|
||||
width: width,
|
||||
stroke: "none",
|
||||
fill: horizontalFill[colorIndex],
|
||||
fillOpacity: fillOpacity,
|
||||
className: "recharts-cartesian-grid-bg"
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-cartesian-gridstripes-horizontal"
|
||||
}, items);
|
||||
}
|
||||
function VerticalStripes(props) {
|
||||
var _props$vertical2 = props.vertical,
|
||||
vertical = _props$vertical2 === void 0 ? true : _props$vertical2,
|
||||
verticalFill = props.verticalFill,
|
||||
fillOpacity = props.fillOpacity,
|
||||
x = props.x,
|
||||
y = props.y,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
verticalPoints = props.verticalPoints;
|
||||
if (!vertical || !verticalFill || !verticalFill.length) {
|
||||
return null;
|
||||
}
|
||||
var roundedSortedVerticalPoints = verticalPoints.map(function (e) {
|
||||
return Math.round(e + x - x);
|
||||
}).sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
if (x !== roundedSortedVerticalPoints[0]) {
|
||||
roundedSortedVerticalPoints.unshift(0);
|
||||
}
|
||||
var items = roundedSortedVerticalPoints.map(function (entry, i) {
|
||||
var lastStripe = !roundedSortedVerticalPoints[i + 1];
|
||||
var lineWidth = lastStripe ? x + width - entry : roundedSortedVerticalPoints[i + 1] - entry;
|
||||
if (lineWidth <= 0) {
|
||||
return null;
|
||||
}
|
||||
var colorIndex = i % verticalFill.length;
|
||||
return /*#__PURE__*/React.createElement("rect", {
|
||||
key: "react-".concat(i) // eslint-disable-line react/no-array-index-key
|
||||
,
|
||||
x: entry,
|
||||
y: y,
|
||||
width: lineWidth,
|
||||
height: height,
|
||||
stroke: "none",
|
||||
fill: verticalFill[colorIndex],
|
||||
fillOpacity: fillOpacity,
|
||||
className: "recharts-cartesian-grid-bg"
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-cartesian-gridstripes-vertical"
|
||||
}, items);
|
||||
}
|
||||
var defaultVerticalCoordinatesGenerator = function defaultVerticalCoordinatesGenerator(_ref, syncWithTicks) {
|
||||
var xAxis = _ref.xAxis,
|
||||
width = _ref.width,
|
||||
height = _ref.height,
|
||||
offset = _ref.offset;
|
||||
return getCoordinatesOfGrid(getTicks(_objectSpread(_objectSpread(_objectSpread({}, CartesianAxis.defaultProps), xAxis), {}, {
|
||||
ticks: getTicksOfAxis(xAxis, true),
|
||||
viewBox: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
})), offset.left, offset.left + offset.width, syncWithTicks);
|
||||
};
|
||||
var defaultHorizontalCoordinatesGenerator = function defaultHorizontalCoordinatesGenerator(_ref2, syncWithTicks) {
|
||||
var yAxis = _ref2.yAxis,
|
||||
width = _ref2.width,
|
||||
height = _ref2.height,
|
||||
offset = _ref2.offset;
|
||||
return getCoordinatesOfGrid(getTicks(_objectSpread(_objectSpread(_objectSpread({}, CartesianAxis.defaultProps), yAxis), {}, {
|
||||
ticks: getTicksOfAxis(yAxis, true),
|
||||
viewBox: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
})), offset.top, offset.top + offset.height, syncWithTicks);
|
||||
};
|
||||
var defaultProps = {
|
||||
horizontal: true,
|
||||
vertical: true,
|
||||
// The ordinates of horizontal grid lines
|
||||
horizontalPoints: [],
|
||||
// The abscissas of vertical grid lines
|
||||
verticalPoints: [],
|
||||
stroke: '#ccc',
|
||||
fill: 'none',
|
||||
// The fill of colors of grid lines
|
||||
verticalFill: [],
|
||||
horizontalFill: []
|
||||
};
|
||||
export function CartesianGrid(props) {
|
||||
var _props$stroke, _props$fill, _props$horizontal3, _props$horizontalFill, _props$vertical3, _props$verticalFill;
|
||||
var chartWidth = useChartWidth();
|
||||
var chartHeight = useChartHeight();
|
||||
var offset = useOffset();
|
||||
var propsIncludingDefaults = _objectSpread(_objectSpread({}, props), {}, {
|
||||
stroke: (_props$stroke = props.stroke) !== null && _props$stroke !== void 0 ? _props$stroke : defaultProps.stroke,
|
||||
fill: (_props$fill = props.fill) !== null && _props$fill !== void 0 ? _props$fill : defaultProps.fill,
|
||||
horizontal: (_props$horizontal3 = props.horizontal) !== null && _props$horizontal3 !== void 0 ? _props$horizontal3 : defaultProps.horizontal,
|
||||
horizontalFill: (_props$horizontalFill = props.horizontalFill) !== null && _props$horizontalFill !== void 0 ? _props$horizontalFill : defaultProps.horizontalFill,
|
||||
vertical: (_props$vertical3 = props.vertical) !== null && _props$vertical3 !== void 0 ? _props$vertical3 : defaultProps.vertical,
|
||||
verticalFill: (_props$verticalFill = props.verticalFill) !== null && _props$verticalFill !== void 0 ? _props$verticalFill : defaultProps.verticalFill,
|
||||
x: isNumber(props.x) ? props.x : offset.left,
|
||||
y: isNumber(props.y) ? props.y : offset.top,
|
||||
width: isNumber(props.width) ? props.width : offset.width,
|
||||
height: isNumber(props.height) ? props.height : offset.height
|
||||
});
|
||||
var x = propsIncludingDefaults.x,
|
||||
y = propsIncludingDefaults.y,
|
||||
width = propsIncludingDefaults.width,
|
||||
height = propsIncludingDefaults.height,
|
||||
syncWithTicks = propsIncludingDefaults.syncWithTicks,
|
||||
horizontalValues = propsIncludingDefaults.horizontalValues,
|
||||
verticalValues = propsIncludingDefaults.verticalValues;
|
||||
|
||||
// @ts-expect-error the scale prop is mixed up - we need to untagle this at some point
|
||||
var xAxis = useArbitraryXAxis();
|
||||
// @ts-expect-error the scale prop is mixed up - we need to untagle this at some point
|
||||
var yAxis = useYAxisWithFiniteDomainOrRandom();
|
||||
if (!isNumber(width) || width <= 0 || !isNumber(height) || height <= 0 || !isNumber(x) || x !== +x || !isNumber(y) || y !== +y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* verticalCoordinatesGenerator and horizontalCoordinatesGenerator are defined
|
||||
* outside of the propsIncludingDefaults because they were never part of the original props
|
||||
* and they were never passed as a prop down to horizontal/vertical custom elements.
|
||||
* If we add these two to propsIncludingDefaults then we are changing public API.
|
||||
* Not a bad thing per se but also not necessary.
|
||||
*/
|
||||
var verticalCoordinatesGenerator = propsIncludingDefaults.verticalCoordinatesGenerator || defaultVerticalCoordinatesGenerator;
|
||||
var horizontalCoordinatesGenerator = propsIncludingDefaults.horizontalCoordinatesGenerator || defaultHorizontalCoordinatesGenerator;
|
||||
var horizontalPoints = propsIncludingDefaults.horizontalPoints,
|
||||
verticalPoints = propsIncludingDefaults.verticalPoints;
|
||||
|
||||
// No horizontal points are specified
|
||||
if ((!horizontalPoints || !horizontalPoints.length) && isFunction(horizontalCoordinatesGenerator)) {
|
||||
var isHorizontalValues = horizontalValues && horizontalValues.length;
|
||||
var generatorResult = horizontalCoordinatesGenerator({
|
||||
yAxis: yAxis ? _objectSpread(_objectSpread({}, yAxis), {}, {
|
||||
ticks: isHorizontalValues ? horizontalValues : yAxis.ticks
|
||||
}) : undefined,
|
||||
width: chartWidth,
|
||||
height: chartHeight,
|
||||
offset: offset
|
||||
}, isHorizontalValues ? true : syncWithTicks);
|
||||
warn(Array.isArray(generatorResult), "horizontalCoordinatesGenerator should return Array but instead it returned [".concat(_typeof(generatorResult), "]"));
|
||||
if (Array.isArray(generatorResult)) {
|
||||
horizontalPoints = generatorResult;
|
||||
}
|
||||
}
|
||||
|
||||
// No vertical points are specified
|
||||
if ((!verticalPoints || !verticalPoints.length) && isFunction(verticalCoordinatesGenerator)) {
|
||||
var isVerticalValues = verticalValues && verticalValues.length;
|
||||
var _generatorResult = verticalCoordinatesGenerator({
|
||||
xAxis: xAxis ? _objectSpread(_objectSpread({}, xAxis), {}, {
|
||||
ticks: isVerticalValues ? verticalValues : xAxis.ticks
|
||||
}) : undefined,
|
||||
width: chartWidth,
|
||||
height: chartHeight,
|
||||
offset: offset
|
||||
}, isVerticalValues ? true : syncWithTicks);
|
||||
warn(Array.isArray(_generatorResult), "verticalCoordinatesGenerator should return Array but instead it returned [".concat(_typeof(_generatorResult), "]"));
|
||||
if (Array.isArray(_generatorResult)) {
|
||||
verticalPoints = _generatorResult;
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-cartesian-grid"
|
||||
}, /*#__PURE__*/React.createElement(Background, {
|
||||
fill: propsIncludingDefaults.fill,
|
||||
fillOpacity: propsIncludingDefaults.fillOpacity,
|
||||
x: propsIncludingDefaults.x,
|
||||
y: propsIncludingDefaults.y,
|
||||
width: propsIncludingDefaults.width,
|
||||
height: propsIncludingDefaults.height,
|
||||
ry: propsIncludingDefaults.ry
|
||||
}), /*#__PURE__*/React.createElement(HorizontalGridLines, _extends({}, propsIncludingDefaults, {
|
||||
offset: offset,
|
||||
horizontalPoints: horizontalPoints,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis
|
||||
})), /*#__PURE__*/React.createElement(VerticalGridLines, _extends({}, propsIncludingDefaults, {
|
||||
offset: offset,
|
||||
verticalPoints: verticalPoints,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis
|
||||
})), /*#__PURE__*/React.createElement(HorizontalStripes, _extends({}, propsIncludingDefaults, {
|
||||
horizontalPoints: horizontalPoints
|
||||
})), /*#__PURE__*/React.createElement(VerticalStripes, _extends({}, propsIncludingDefaults, {
|
||||
verticalPoints: verticalPoints
|
||||
})));
|
||||
}
|
||||
CartesianGrid.displayName = 'CartesianGrid';
|
||||
157
vendor/node_modules/recharts/es6/cartesian/ErrorBar.js
generated
vendored
Normal file
157
vendor/node_modules/recharts/es6/cartesian/ErrorBar.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
var _excluded = ["offset", "layout", "width", "dataKey", "data", "dataPointFormatter", "xAxis", "yAxis"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Render a group of error bar
|
||||
*/
|
||||
import React from 'react';
|
||||
import invariant from 'tiny-invariant';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var ErrorBar = /*#__PURE__*/function (_React$Component) {
|
||||
function ErrorBar() {
|
||||
_classCallCheck(this, ErrorBar);
|
||||
return _callSuper(this, ErrorBar, arguments);
|
||||
}
|
||||
_inherits(ErrorBar, _React$Component);
|
||||
return _createClass(ErrorBar, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props = this.props,
|
||||
offset = _this$props.offset,
|
||||
layout = _this$props.layout,
|
||||
width = _this$props.width,
|
||||
dataKey = _this$props.dataKey,
|
||||
data = _this$props.data,
|
||||
dataPointFormatter = _this$props.dataPointFormatter,
|
||||
xAxis = _this$props.xAxis,
|
||||
yAxis = _this$props.yAxis,
|
||||
others = _objectWithoutProperties(_this$props, _excluded);
|
||||
var svgProps = filterProps(others, false);
|
||||
!!(this.props.direction === 'x' && xAxis.type !== 'number') ? process.env.NODE_ENV !== "production" ? invariant(false, 'ErrorBar requires Axis type property to be "number".') : invariant(false) : void 0;
|
||||
var errorBars = data.map(function (entry) {
|
||||
var _dataPointFormatter = dataPointFormatter(entry, dataKey),
|
||||
x = _dataPointFormatter.x,
|
||||
y = _dataPointFormatter.y,
|
||||
value = _dataPointFormatter.value,
|
||||
errorVal = _dataPointFormatter.errorVal;
|
||||
if (!errorVal) {
|
||||
return null;
|
||||
}
|
||||
var lineCoordinates = [];
|
||||
var lowBound, highBound;
|
||||
if (Array.isArray(errorVal)) {
|
||||
var _errorVal = _slicedToArray(errorVal, 2);
|
||||
lowBound = _errorVal[0];
|
||||
highBound = _errorVal[1];
|
||||
} else {
|
||||
lowBound = highBound = errorVal;
|
||||
}
|
||||
if (layout === 'vertical') {
|
||||
// error bar for horizontal charts, the y is fixed, x is a range value
|
||||
var scale = xAxis.scale;
|
||||
var yMid = y + offset;
|
||||
var yMin = yMid + width;
|
||||
var yMax = yMid - width;
|
||||
var xMin = scale(value - lowBound);
|
||||
var xMax = scale(value + highBound);
|
||||
|
||||
// the right line of |--|
|
||||
lineCoordinates.push({
|
||||
x1: xMax,
|
||||
y1: yMin,
|
||||
x2: xMax,
|
||||
y2: yMax
|
||||
});
|
||||
// the middle line of |--|
|
||||
lineCoordinates.push({
|
||||
x1: xMin,
|
||||
y1: yMid,
|
||||
x2: xMax,
|
||||
y2: yMid
|
||||
});
|
||||
// the left line of |--|
|
||||
lineCoordinates.push({
|
||||
x1: xMin,
|
||||
y1: yMin,
|
||||
x2: xMin,
|
||||
y2: yMax
|
||||
});
|
||||
} else if (layout === 'horizontal') {
|
||||
// error bar for horizontal charts, the x is fixed, y is a range value
|
||||
var _scale = yAxis.scale;
|
||||
var xMid = x + offset;
|
||||
var _xMin = xMid - width;
|
||||
var _xMax = xMid + width;
|
||||
var _yMin = _scale(value - lowBound);
|
||||
var _yMax = _scale(value + highBound);
|
||||
|
||||
// the top line
|
||||
lineCoordinates.push({
|
||||
x1: _xMin,
|
||||
y1: _yMax,
|
||||
x2: _xMax,
|
||||
y2: _yMax
|
||||
});
|
||||
// the middle line
|
||||
lineCoordinates.push({
|
||||
x1: xMid,
|
||||
y1: _yMin,
|
||||
x2: xMid,
|
||||
y2: _yMax
|
||||
});
|
||||
// the bottom line
|
||||
lineCoordinates.push({
|
||||
x1: _xMin,
|
||||
y1: _yMin,
|
||||
x2: _xMax,
|
||||
y2: _yMin
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: "recharts-errorBar",
|
||||
key: "bar-".concat(lineCoordinates.map(function (c) {
|
||||
return "".concat(c.x1, "-").concat(c.x2, "-").concat(c.y1, "-").concat(c.y2);
|
||||
}))
|
||||
}, svgProps), lineCoordinates.map(function (coordinates) {
|
||||
return /*#__PURE__*/React.createElement("line", _extends({}, coordinates, {
|
||||
key: "line-".concat(coordinates.x1, "-").concat(coordinates.x2, "-").concat(coordinates.y1, "-").concat(coordinates.y2)
|
||||
}));
|
||||
}));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-errorBars"
|
||||
}, errorBars);
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(ErrorBar, "defaultProps", {
|
||||
stroke: 'black',
|
||||
strokeWidth: 1.5,
|
||||
width: 5,
|
||||
offset: 0,
|
||||
layout: 'horizontal'
|
||||
});
|
||||
_defineProperty(ErrorBar, "displayName", 'ErrorBar');
|
||||
511
vendor/node_modules/recharts/es6/cartesian/Line.js
generated
vendored
Normal file
511
vendor/node_modules/recharts/es6/cartesian/Line.js
generated
vendored
Normal file
@@ -0,0 +1,511 @@
|
||||
var _excluded = ["type", "layout", "connectNulls", "ref"],
|
||||
_excluded2 = ["key"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Line
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import Animate from 'react-smooth';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import clsx from 'clsx';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { Dot } from '../shape/Dot';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { ErrorBar } from './ErrorBar';
|
||||
import { uniqueId, interpolateNumber } from '../util/DataUtils';
|
||||
import { findAllByType, filterProps, hasClipDot } from '../util/ReactUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { getCateCoordinateOfLine, getValueByDataKey } from '../util/ChartUtils';
|
||||
export var Line = /*#__PURE__*/function (_PureComponent) {
|
||||
function Line() {
|
||||
var _this;
|
||||
_classCallCheck(this, Line);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, Line, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
isAnimationFinished: true,
|
||||
totalLength: 0
|
||||
});
|
||||
_defineProperty(_this, "generateSimpleStrokeDasharray", function (totalLength, length) {
|
||||
return "".concat(length, "px ").concat(totalLength - length, "px");
|
||||
});
|
||||
_defineProperty(_this, "getStrokeDasharray", function (length, totalLength, lines) {
|
||||
var lineLength = lines.reduce(function (pre, next) {
|
||||
return pre + next;
|
||||
});
|
||||
|
||||
// if lineLength is 0 return the default when no strokeDasharray is provided
|
||||
if (!lineLength) {
|
||||
return _this.generateSimpleStrokeDasharray(totalLength, length);
|
||||
}
|
||||
var count = Math.floor(length / lineLength);
|
||||
var remainLength = length % lineLength;
|
||||
var restLength = totalLength - length;
|
||||
var remainLines = [];
|
||||
for (var i = 0, sum = 0; i < lines.length; sum += lines[i], ++i) {
|
||||
if (sum + lines[i] > remainLength) {
|
||||
remainLines = [].concat(_toConsumableArray(lines.slice(0, i)), [remainLength - sum]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
var emptyLines = remainLines.length % 2 === 0 ? [0, restLength] : [restLength];
|
||||
return [].concat(_toConsumableArray(Line.repeat(lines, count)), _toConsumableArray(remainLines), emptyLines).map(function (line) {
|
||||
return "".concat(line, "px");
|
||||
}).join(', ');
|
||||
});
|
||||
_defineProperty(_this, "id", uniqueId('recharts-line-'));
|
||||
_defineProperty(_this, "pathRef", function (node) {
|
||||
_this.mainCurve = node;
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationEnd", function () {
|
||||
_this.setState({
|
||||
isAnimationFinished: true
|
||||
});
|
||||
if (_this.props.onAnimationEnd) {
|
||||
_this.props.onAnimationEnd();
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationStart", function () {
|
||||
_this.setState({
|
||||
isAnimationFinished: false
|
||||
});
|
||||
if (_this.props.onAnimationStart) {
|
||||
_this.props.onAnimationStart();
|
||||
}
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_inherits(Line, _PureComponent);
|
||||
return _createClass(Line, [{
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
if (!this.props.isAnimationActive) {
|
||||
return;
|
||||
}
|
||||
var totalLength = this.getTotalLength();
|
||||
this.setState({
|
||||
totalLength: totalLength
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
if (!this.props.isAnimationActive) {
|
||||
return;
|
||||
}
|
||||
var totalLength = this.getTotalLength();
|
||||
if (totalLength !== this.state.totalLength) {
|
||||
this.setState({
|
||||
totalLength: totalLength
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getTotalLength",
|
||||
value: function getTotalLength() {
|
||||
var curveDom = this.mainCurve;
|
||||
try {
|
||||
return curveDom && curveDom.getTotalLength && curveDom.getTotalLength() || 0;
|
||||
} catch (err) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "renderErrorBar",
|
||||
value: function renderErrorBar(needClip, clipPathId) {
|
||||
if (this.props.isAnimationActive && !this.state.isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props = this.props,
|
||||
points = _this$props.points,
|
||||
xAxis = _this$props.xAxis,
|
||||
yAxis = _this$props.yAxis,
|
||||
layout = _this$props.layout,
|
||||
children = _this$props.children;
|
||||
var errorBarItems = findAllByType(children, ErrorBar);
|
||||
if (!errorBarItems) {
|
||||
return null;
|
||||
}
|
||||
var dataPointFormatter = function dataPointFormatter(dataPoint, dataKey) {
|
||||
return {
|
||||
x: dataPoint.x,
|
||||
y: dataPoint.y,
|
||||
value: dataPoint.value,
|
||||
errorVal: getValueByDataKey(dataPoint.payload, dataKey)
|
||||
};
|
||||
};
|
||||
var errorBarProps = {
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : null
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Layer, errorBarProps, errorBarItems.map(function (item) {
|
||||
return /*#__PURE__*/React.cloneElement(item, {
|
||||
key: "bar-".concat(item.props.dataKey),
|
||||
data: points,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
layout: layout,
|
||||
dataPointFormatter: dataPointFormatter
|
||||
});
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderDots",
|
||||
value: function renderDots(needClip, clipDot, clipPathId) {
|
||||
var isAnimationActive = this.props.isAnimationActive;
|
||||
if (isAnimationActive && !this.state.isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props2 = this.props,
|
||||
dot = _this$props2.dot,
|
||||
points = _this$props2.points,
|
||||
dataKey = _this$props2.dataKey;
|
||||
var lineProps = filterProps(this.props, false);
|
||||
var customDotProps = filterProps(dot, true);
|
||||
var dots = points.map(function (entry, i) {
|
||||
var dotProps = _objectSpread(_objectSpread(_objectSpread({
|
||||
key: "dot-".concat(i),
|
||||
r: 3
|
||||
}, lineProps), customDotProps), {}, {
|
||||
index: i,
|
||||
cx: entry.x,
|
||||
cy: entry.y,
|
||||
value: entry.value,
|
||||
dataKey: dataKey,
|
||||
payload: entry.payload,
|
||||
points: points
|
||||
});
|
||||
return Line.renderDotItem(dot, dotProps);
|
||||
});
|
||||
var dotsProps = {
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipDot ? '' : 'dots-').concat(clipPathId, ")") : null
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: "recharts-line-dots",
|
||||
key: "dots"
|
||||
}, dotsProps), dots);
|
||||
}
|
||||
}, {
|
||||
key: "renderCurveStatically",
|
||||
value: function renderCurveStatically(points, needClip, clipPathId, props) {
|
||||
var _this$props3 = this.props,
|
||||
type = _this$props3.type,
|
||||
layout = _this$props3.layout,
|
||||
connectNulls = _this$props3.connectNulls,
|
||||
ref = _this$props3.ref,
|
||||
others = _objectWithoutProperties(_this$props3, _excluded);
|
||||
var curveProps = _objectSpread(_objectSpread(_objectSpread({}, filterProps(others, true)), {}, {
|
||||
fill: 'none',
|
||||
className: 'recharts-line-curve',
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : null,
|
||||
points: points
|
||||
}, props), {}, {
|
||||
type: type,
|
||||
layout: layout,
|
||||
connectNulls: connectNulls
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Curve, _extends({}, curveProps, {
|
||||
pathRef: this.pathRef
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderCurveWithAnimation",
|
||||
value: function renderCurveWithAnimation(needClip, clipPathId) {
|
||||
var _this2 = this;
|
||||
var _this$props4 = this.props,
|
||||
points = _this$props4.points,
|
||||
strokeDasharray = _this$props4.strokeDasharray,
|
||||
isAnimationActive = _this$props4.isAnimationActive,
|
||||
animationBegin = _this$props4.animationBegin,
|
||||
animationDuration = _this$props4.animationDuration,
|
||||
animationEasing = _this$props4.animationEasing,
|
||||
animationId = _this$props4.animationId,
|
||||
animateNewValues = _this$props4.animateNewValues,
|
||||
width = _this$props4.width,
|
||||
height = _this$props4.height;
|
||||
var _this$state = this.state,
|
||||
prevPoints = _this$state.prevPoints,
|
||||
totalLength = _this$state.totalLength;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing,
|
||||
from: {
|
||||
t: 0
|
||||
},
|
||||
to: {
|
||||
t: 1
|
||||
},
|
||||
key: "line-".concat(animationId),
|
||||
onAnimationEnd: this.handleAnimationEnd,
|
||||
onAnimationStart: this.handleAnimationStart
|
||||
}, function (_ref) {
|
||||
var t = _ref.t;
|
||||
if (prevPoints) {
|
||||
var prevPointsDiffFactor = prevPoints.length / points.length;
|
||||
var stepData = points.map(function (entry, index) {
|
||||
var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
|
||||
if (prevPoints[prevPointIndex]) {
|
||||
var prev = prevPoints[prevPointIndex];
|
||||
var interpolatorX = interpolateNumber(prev.x, entry.x);
|
||||
var interpolatorY = interpolateNumber(prev.y, entry.y);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: interpolatorX(t),
|
||||
y: interpolatorY(t)
|
||||
});
|
||||
}
|
||||
|
||||
// magic number of faking previous x and y location
|
||||
if (animateNewValues) {
|
||||
var _interpolatorX = interpolateNumber(width * 2, entry.x);
|
||||
var _interpolatorY = interpolateNumber(height / 2, entry.y);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: _interpolatorX(t),
|
||||
y: _interpolatorY(t)
|
||||
});
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: entry.x,
|
||||
y: entry.y
|
||||
});
|
||||
});
|
||||
return _this2.renderCurveStatically(stepData, needClip, clipPathId);
|
||||
}
|
||||
var interpolator = interpolateNumber(0, totalLength);
|
||||
var curLength = interpolator(t);
|
||||
var currentStrokeDasharray;
|
||||
if (strokeDasharray) {
|
||||
var lines = "".concat(strokeDasharray).split(/[,\s]+/gim).map(function (num) {
|
||||
return parseFloat(num);
|
||||
});
|
||||
currentStrokeDasharray = _this2.getStrokeDasharray(curLength, totalLength, lines);
|
||||
} else {
|
||||
currentStrokeDasharray = _this2.generateSimpleStrokeDasharray(totalLength, curLength);
|
||||
}
|
||||
return _this2.renderCurveStatically(points, needClip, clipPathId, {
|
||||
strokeDasharray: currentStrokeDasharray
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderCurve",
|
||||
value: function renderCurve(needClip, clipPathId) {
|
||||
var _this$props5 = this.props,
|
||||
points = _this$props5.points,
|
||||
isAnimationActive = _this$props5.isAnimationActive;
|
||||
var _this$state2 = this.state,
|
||||
prevPoints = _this$state2.prevPoints,
|
||||
totalLength = _this$state2.totalLength;
|
||||
if (isAnimationActive && points && points.length && (!prevPoints && totalLength > 0 || !isEqual(prevPoints, points))) {
|
||||
return this.renderCurveWithAnimation(needClip, clipPathId);
|
||||
}
|
||||
return this.renderCurveStatically(points, needClip, clipPathId);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _filterProps;
|
||||
var _this$props6 = this.props,
|
||||
hide = _this$props6.hide,
|
||||
dot = _this$props6.dot,
|
||||
points = _this$props6.points,
|
||||
className = _this$props6.className,
|
||||
xAxis = _this$props6.xAxis,
|
||||
yAxis = _this$props6.yAxis,
|
||||
top = _this$props6.top,
|
||||
left = _this$props6.left,
|
||||
width = _this$props6.width,
|
||||
height = _this$props6.height,
|
||||
isAnimationActive = _this$props6.isAnimationActive,
|
||||
id = _this$props6.id;
|
||||
if (hide || !points || !points.length) {
|
||||
return null;
|
||||
}
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
var hasSinglePoint = points.length === 1;
|
||||
var layerClass = clsx('recharts-line', className);
|
||||
var needClipX = xAxis && xAxis.allowDataOverflow;
|
||||
var needClipY = yAxis && yAxis.allowDataOverflow;
|
||||
var needClip = needClipX || needClipY;
|
||||
var clipPathId = isNil(id) ? this.id : id;
|
||||
var _ref2 = (_filterProps = filterProps(dot, false)) !== null && _filterProps !== void 0 ? _filterProps : {
|
||||
r: 3,
|
||||
strokeWidth: 2
|
||||
},
|
||||
_ref2$r = _ref2.r,
|
||||
r = _ref2$r === void 0 ? 3 : _ref2$r,
|
||||
_ref2$strokeWidth = _ref2.strokeWidth,
|
||||
strokeWidth = _ref2$strokeWidth === void 0 ? 2 : _ref2$strokeWidth;
|
||||
var _ref3 = hasClipDot(dot) ? dot : {},
|
||||
_ref3$clipDot = _ref3.clipDot,
|
||||
clipDot = _ref3$clipDot === void 0 ? true : _ref3$clipDot;
|
||||
var dotSize = r * 2 + strokeWidth;
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, needClipX || needClipY ? /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "clipPath-".concat(clipPathId)
|
||||
}, /*#__PURE__*/React.createElement("rect", {
|
||||
x: needClipX ? left : left - width / 2,
|
||||
y: needClipY ? top : top - height / 2,
|
||||
width: needClipX ? width : width * 2,
|
||||
height: needClipY ? height : height * 2
|
||||
})), !clipDot && /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "clipPath-dots-".concat(clipPathId)
|
||||
}, /*#__PURE__*/React.createElement("rect", {
|
||||
x: left - dotSize / 2,
|
||||
y: top - dotSize / 2,
|
||||
width: width + dotSize,
|
||||
height: height + dotSize
|
||||
}))) : null, !hasSinglePoint && this.renderCurve(needClip, clipPathId), this.renderErrorBar(needClip, clipPathId), (hasSinglePoint || dot) && this.renderDots(needClip, clipDot, clipPathId), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, points));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (nextProps.animationId !== prevState.prevAnimationId) {
|
||||
return {
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curPoints: nextProps.points,
|
||||
prevPoints: prevState.curPoints
|
||||
};
|
||||
}
|
||||
if (nextProps.points !== prevState.curPoints) {
|
||||
return {
|
||||
curPoints: nextProps.points
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "repeat",
|
||||
value: function repeat(lines, count) {
|
||||
var linesUnit = lines.length % 2 !== 0 ? [].concat(_toConsumableArray(lines), [0]) : lines;
|
||||
var result = [];
|
||||
for (var i = 0; i < count; ++i) {
|
||||
result = [].concat(_toConsumableArray(result), _toConsumableArray(linesUnit));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}, {
|
||||
key: "renderDotItem",
|
||||
value: function renderDotItem(option, props) {
|
||||
var dotItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
dotItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
dotItem = option(props);
|
||||
} else {
|
||||
var key = props.key,
|
||||
dotProps = _objectWithoutProperties(props, _excluded2);
|
||||
var className = clsx('recharts-line-dot', typeof option !== 'boolean' ? option.className : '');
|
||||
dotItem = /*#__PURE__*/React.createElement(Dot, _extends({
|
||||
key: key
|
||||
}, dotProps, {
|
||||
className: className
|
||||
}));
|
||||
}
|
||||
return dotItem;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(Line, "displayName", 'Line');
|
||||
_defineProperty(Line, "defaultProps", {
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
connectNulls: false,
|
||||
activeDot: true,
|
||||
dot: true,
|
||||
legendType: 'line',
|
||||
stroke: '#3182bd',
|
||||
strokeWidth: 1,
|
||||
fill: '#fff',
|
||||
points: [],
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animateNewValues: true,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
hide: false,
|
||||
label: false
|
||||
});
|
||||
/**
|
||||
* Compose the data of each group
|
||||
* @param {Object} props The props from the component
|
||||
* @param {Object} xAxis The configuration of x-axis
|
||||
* @param {Object} yAxis The configuration of y-axis
|
||||
* @param {String} dataKey The unique key of a group
|
||||
* @return {Array} Composed data
|
||||
*/
|
||||
_defineProperty(Line, "getComposedData", function (_ref4) {
|
||||
var props = _ref4.props,
|
||||
xAxis = _ref4.xAxis,
|
||||
yAxis = _ref4.yAxis,
|
||||
xAxisTicks = _ref4.xAxisTicks,
|
||||
yAxisTicks = _ref4.yAxisTicks,
|
||||
dataKey = _ref4.dataKey,
|
||||
bandSize = _ref4.bandSize,
|
||||
displayedData = _ref4.displayedData,
|
||||
offset = _ref4.offset;
|
||||
var layout = props.layout;
|
||||
var points = displayedData.map(function (entry, index) {
|
||||
var value = getValueByDataKey(entry, dataKey);
|
||||
if (layout === 'horizontal') {
|
||||
return {
|
||||
x: getCateCoordinateOfLine({
|
||||
axis: xAxis,
|
||||
ticks: xAxisTicks,
|
||||
bandSize: bandSize,
|
||||
entry: entry,
|
||||
index: index
|
||||
}),
|
||||
y: isNil(value) ? null : yAxis.scale(value),
|
||||
value: value,
|
||||
payload: entry
|
||||
};
|
||||
}
|
||||
return {
|
||||
x: isNil(value) ? null : xAxis.scale(value),
|
||||
y: getCateCoordinateOfLine({
|
||||
axis: yAxis,
|
||||
ticks: yAxisTicks,
|
||||
bandSize: bandSize,
|
||||
entry: entry,
|
||||
index: index
|
||||
}),
|
||||
value: value,
|
||||
payload: entry
|
||||
};
|
||||
});
|
||||
return _objectSpread({
|
||||
points: points,
|
||||
layout: layout
|
||||
}, offset);
|
||||
});
|
||||
130
vendor/node_modules/recharts/es6/cartesian/ReferenceArea.js
generated
vendored
Normal file
130
vendor/node_modules/recharts/es6/cartesian/ReferenceArea.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Reference Line
|
||||
*/
|
||||
import React from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Label } from '../component/Label';
|
||||
import { createLabeledScales, rectWithPoints } from '../util/CartesianUtils';
|
||||
import { ifOverflowMatches } from '../util/IfOverflowMatches';
|
||||
import { isNumOrStr } from '../util/DataUtils';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { Rectangle } from '../shape/Rectangle';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var getRect = function getRect(hasX1, hasX2, hasY1, hasY2, props) {
|
||||
var xValue1 = props.x1,
|
||||
xValue2 = props.x2,
|
||||
yValue1 = props.y1,
|
||||
yValue2 = props.y2,
|
||||
xAxis = props.xAxis,
|
||||
yAxis = props.yAxis;
|
||||
if (!xAxis || !yAxis) return null;
|
||||
var scales = createLabeledScales({
|
||||
x: xAxis.scale,
|
||||
y: yAxis.scale
|
||||
});
|
||||
var p1 = {
|
||||
x: hasX1 ? scales.x.apply(xValue1, {
|
||||
position: 'start'
|
||||
}) : scales.x.rangeMin,
|
||||
y: hasY1 ? scales.y.apply(yValue1, {
|
||||
position: 'start'
|
||||
}) : scales.y.rangeMin
|
||||
};
|
||||
var p2 = {
|
||||
x: hasX2 ? scales.x.apply(xValue2, {
|
||||
position: 'end'
|
||||
}) : scales.x.rangeMax,
|
||||
y: hasY2 ? scales.y.apply(yValue2, {
|
||||
position: 'end'
|
||||
}) : scales.y.rangeMax
|
||||
};
|
||||
if (ifOverflowMatches(props, 'discard') && (!scales.isInRange(p1) || !scales.isInRange(p2))) {
|
||||
return null;
|
||||
}
|
||||
return rectWithPoints(p1, p2);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var ReferenceArea = /*#__PURE__*/function (_React$Component) {
|
||||
function ReferenceArea() {
|
||||
_classCallCheck(this, ReferenceArea);
|
||||
return _callSuper(this, ReferenceArea, arguments);
|
||||
}
|
||||
_inherits(ReferenceArea, _React$Component);
|
||||
return _createClass(ReferenceArea, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props = this.props,
|
||||
x1 = _this$props.x1,
|
||||
x2 = _this$props.x2,
|
||||
y1 = _this$props.y1,
|
||||
y2 = _this$props.y2,
|
||||
className = _this$props.className,
|
||||
alwaysShow = _this$props.alwaysShow,
|
||||
clipPathId = _this$props.clipPathId;
|
||||
warn(alwaysShow === undefined, 'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');
|
||||
var hasX1 = isNumOrStr(x1);
|
||||
var hasX2 = isNumOrStr(x2);
|
||||
var hasY1 = isNumOrStr(y1);
|
||||
var hasY2 = isNumOrStr(y2);
|
||||
var shape = this.props.shape;
|
||||
if (!hasX1 && !hasX2 && !hasY1 && !hasY2 && !shape) {
|
||||
return null;
|
||||
}
|
||||
var rect = getRect(hasX1, hasX2, hasY1, hasY2, this.props);
|
||||
if (!rect && !shape) {
|
||||
return null;
|
||||
}
|
||||
var clipPath = ifOverflowMatches(this.props, 'hidden') ? "url(#".concat(clipPathId, ")") : undefined;
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-reference-area', className)
|
||||
}, ReferenceArea.renderRect(shape, _objectSpread(_objectSpread({
|
||||
clipPath: clipPath
|
||||
}, filterProps(this.props, true)), rect)), Label.renderCallByParent(this.props, rect));
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(ReferenceArea, "displayName", 'ReferenceArea');
|
||||
_defineProperty(ReferenceArea, "defaultProps", {
|
||||
isFront: false,
|
||||
ifOverflow: 'discard',
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
r: 10,
|
||||
fill: '#ccc',
|
||||
fillOpacity: 0.5,
|
||||
stroke: 'none',
|
||||
strokeWidth: 1
|
||||
});
|
||||
_defineProperty(ReferenceArea, "renderRect", function (option, props) {
|
||||
var rect;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
rect = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
rect = option(props);
|
||||
} else {
|
||||
rect = /*#__PURE__*/React.createElement(Rectangle, _extends({}, props, {
|
||||
className: "recharts-reference-area-rect"
|
||||
}));
|
||||
}
|
||||
return rect;
|
||||
});
|
||||
128
vendor/node_modules/recharts/es6/cartesian/ReferenceDot.js
generated
vendored
Normal file
128
vendor/node_modules/recharts/es6/cartesian/ReferenceDot.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Reference Dot
|
||||
*/
|
||||
import React from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Dot } from '../shape/Dot';
|
||||
import { Label } from '../component/Label';
|
||||
import { isNumOrStr } from '../util/DataUtils';
|
||||
import { ifOverflowMatches } from '../util/IfOverflowMatches';
|
||||
import { createLabeledScales } from '../util/CartesianUtils';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var getCoordinate = function getCoordinate(props) {
|
||||
var x = props.x,
|
||||
y = props.y,
|
||||
xAxis = props.xAxis,
|
||||
yAxis = props.yAxis;
|
||||
var scales = createLabeledScales({
|
||||
x: xAxis.scale,
|
||||
y: yAxis.scale
|
||||
});
|
||||
var result = scales.apply({
|
||||
x: x,
|
||||
y: y
|
||||
}, {
|
||||
bandAware: true
|
||||
});
|
||||
if (ifOverflowMatches(props, 'discard') && !scales.isInRange(result)) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var ReferenceDot = /*#__PURE__*/function (_React$Component) {
|
||||
function ReferenceDot() {
|
||||
_classCallCheck(this, ReferenceDot);
|
||||
return _callSuper(this, ReferenceDot, arguments);
|
||||
}
|
||||
_inherits(ReferenceDot, _React$Component);
|
||||
return _createClass(ReferenceDot, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props = this.props,
|
||||
x = _this$props.x,
|
||||
y = _this$props.y,
|
||||
r = _this$props.r,
|
||||
alwaysShow = _this$props.alwaysShow,
|
||||
clipPathId = _this$props.clipPathId;
|
||||
var isX = isNumOrStr(x);
|
||||
var isY = isNumOrStr(y);
|
||||
warn(alwaysShow === undefined, 'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');
|
||||
if (!isX || !isY) {
|
||||
return null;
|
||||
}
|
||||
var coordinate = getCoordinate(this.props);
|
||||
if (!coordinate) {
|
||||
return null;
|
||||
}
|
||||
var cx = coordinate.x,
|
||||
cy = coordinate.y;
|
||||
var _this$props2 = this.props,
|
||||
shape = _this$props2.shape,
|
||||
className = _this$props2.className;
|
||||
var clipPath = ifOverflowMatches(this.props, 'hidden') ? "url(#".concat(clipPathId, ")") : undefined;
|
||||
var dotProps = _objectSpread(_objectSpread({
|
||||
clipPath: clipPath
|
||||
}, filterProps(this.props, true)), {}, {
|
||||
cx: cx,
|
||||
cy: cy
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-reference-dot', className)
|
||||
}, ReferenceDot.renderDot(shape, dotProps), Label.renderCallByParent(this.props, {
|
||||
x: cx - r,
|
||||
y: cy - r,
|
||||
width: 2 * r,
|
||||
height: 2 * r
|
||||
}));
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(ReferenceDot, "displayName", 'ReferenceDot');
|
||||
_defineProperty(ReferenceDot, "defaultProps", {
|
||||
isFront: false,
|
||||
ifOverflow: 'discard',
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
r: 10,
|
||||
fill: '#fff',
|
||||
stroke: '#ccc',
|
||||
fillOpacity: 1,
|
||||
strokeWidth: 1
|
||||
});
|
||||
_defineProperty(ReferenceDot, "renderDot", function (option, props) {
|
||||
var dot;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
dot = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
dot = option(props);
|
||||
} else {
|
||||
dot = /*#__PURE__*/React.createElement(Dot, _extends({}, props, {
|
||||
cx: props.cx,
|
||||
cy: props.cy,
|
||||
className: "recharts-reference-dot-dot"
|
||||
}));
|
||||
}
|
||||
return dot;
|
||||
});
|
||||
195
vendor/node_modules/recharts/es6/cartesian/ReferenceLine.js
generated
vendored
Normal file
195
vendor/node_modules/recharts/es6/cartesian/ReferenceLine.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
/**
|
||||
* @fileOverview Reference Line
|
||||
*/
|
||||
import React from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import some from 'lodash/some';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Label } from '../component/Label';
|
||||
import { ifOverflowMatches } from '../util/IfOverflowMatches';
|
||||
import { isNumOrStr } from '../util/DataUtils';
|
||||
import { createLabeledScales, rectWithCoords } from '../util/CartesianUtils';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { useClipPathId, useViewBox, useXAxisOrThrow, useYAxisOrThrow } from '../context/chartLayoutContext';
|
||||
|
||||
/**
|
||||
* This excludes `viewBox` prop from svg for two reasons:
|
||||
* 1. The components wants viewBox of object type, and svg wants string
|
||||
* - so there's a conflict, and the component will throw if it gets string
|
||||
* 2. Internally the component calls `filterProps` which filters the viewBox away anyway
|
||||
*/
|
||||
|
||||
var renderLine = function renderLine(option, props) {
|
||||
var line;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
line = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
line = option(props);
|
||||
} else {
|
||||
line = /*#__PURE__*/React.createElement("line", _extends({}, props, {
|
||||
className: "recharts-reference-line-line"
|
||||
}));
|
||||
}
|
||||
return line;
|
||||
};
|
||||
// TODO: ScaleHelper
|
||||
export var getEndPoints = function getEndPoints(scales, isFixedX, isFixedY, isSegment, viewBox, position, xAxisOrientation, yAxisOrientation, props) {
|
||||
var x = viewBox.x,
|
||||
y = viewBox.y,
|
||||
width = viewBox.width,
|
||||
height = viewBox.height;
|
||||
if (isFixedY) {
|
||||
var yCoord = props.y;
|
||||
var coord = scales.y.apply(yCoord, {
|
||||
position: position
|
||||
});
|
||||
if (ifOverflowMatches(props, 'discard') && !scales.y.isInRange(coord)) {
|
||||
return null;
|
||||
}
|
||||
var points = [{
|
||||
x: x + width,
|
||||
y: coord
|
||||
}, {
|
||||
x: x,
|
||||
y: coord
|
||||
}];
|
||||
return yAxisOrientation === 'left' ? points.reverse() : points;
|
||||
}
|
||||
if (isFixedX) {
|
||||
var xCoord = props.x;
|
||||
var _coord = scales.x.apply(xCoord, {
|
||||
position: position
|
||||
});
|
||||
if (ifOverflowMatches(props, 'discard') && !scales.x.isInRange(_coord)) {
|
||||
return null;
|
||||
}
|
||||
var _points = [{
|
||||
x: _coord,
|
||||
y: y + height
|
||||
}, {
|
||||
x: _coord,
|
||||
y: y
|
||||
}];
|
||||
return xAxisOrientation === 'top' ? _points.reverse() : _points;
|
||||
}
|
||||
if (isSegment) {
|
||||
var segment = props.segment;
|
||||
var _points2 = segment.map(function (p) {
|
||||
return scales.apply(p, {
|
||||
position: position
|
||||
});
|
||||
});
|
||||
if (ifOverflowMatches(props, 'discard') && some(_points2, function (p) {
|
||||
return !scales.isInRange(p);
|
||||
})) {
|
||||
return null;
|
||||
}
|
||||
return _points2;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
function ReferenceLineImpl(props) {
|
||||
var fixedX = props.x,
|
||||
fixedY = props.y,
|
||||
segment = props.segment,
|
||||
xAxisId = props.xAxisId,
|
||||
yAxisId = props.yAxisId,
|
||||
shape = props.shape,
|
||||
className = props.className,
|
||||
alwaysShow = props.alwaysShow;
|
||||
var clipPathId = useClipPathId();
|
||||
var xAxis = useXAxisOrThrow(xAxisId);
|
||||
var yAxis = useYAxisOrThrow(yAxisId);
|
||||
var viewBox = useViewBox();
|
||||
if (!clipPathId || !viewBox) {
|
||||
return null;
|
||||
}
|
||||
warn(alwaysShow === undefined, 'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');
|
||||
var scales = createLabeledScales({
|
||||
x: xAxis.scale,
|
||||
y: yAxis.scale
|
||||
});
|
||||
var isX = isNumOrStr(fixedX);
|
||||
var isY = isNumOrStr(fixedY);
|
||||
var isSegment = segment && segment.length === 2;
|
||||
var endPoints = getEndPoints(scales, isX, isY, isSegment, viewBox, props.position, xAxis.orientation, yAxis.orientation, props);
|
||||
if (!endPoints) {
|
||||
return null;
|
||||
}
|
||||
var _endPoints = _slicedToArray(endPoints, 2),
|
||||
_endPoints$ = _endPoints[0],
|
||||
x1 = _endPoints$.x,
|
||||
y1 = _endPoints$.y,
|
||||
_endPoints$2 = _endPoints[1],
|
||||
x2 = _endPoints$2.x,
|
||||
y2 = _endPoints$2.y;
|
||||
var clipPath = ifOverflowMatches(props, 'hidden') ? "url(#".concat(clipPathId, ")") : undefined;
|
||||
var lineProps = _objectSpread(_objectSpread({
|
||||
clipPath: clipPath
|
||||
}, filterProps(props, true)), {}, {
|
||||
x1: x1,
|
||||
y1: y1,
|
||||
x2: x2,
|
||||
y2: y2
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-reference-line', className)
|
||||
}, renderLine(shape, lineProps), Label.renderCallByParent(props, rectWithCoords({
|
||||
x1: x1,
|
||||
y1: y1,
|
||||
x2: x2,
|
||||
y2: y2
|
||||
})));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var ReferenceLine = /*#__PURE__*/function (_React$Component) {
|
||||
function ReferenceLine() {
|
||||
_classCallCheck(this, ReferenceLine);
|
||||
return _callSuper(this, ReferenceLine, arguments);
|
||||
}
|
||||
_inherits(ReferenceLine, _React$Component);
|
||||
return _createClass(ReferenceLine, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return /*#__PURE__*/React.createElement(ReferenceLineImpl, this.props);
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(ReferenceLine, "displayName", 'ReferenceLine');
|
||||
_defineProperty(ReferenceLine, "defaultProps", {
|
||||
isFront: false,
|
||||
ifOverflow: 'discard',
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
fill: 'none',
|
||||
stroke: '#ccc',
|
||||
fillOpacity: 1,
|
||||
strokeWidth: 1,
|
||||
position: 'middle'
|
||||
});
|
||||
420
vendor/node_modules/recharts/es6/cartesian/Scatter.js
generated
vendored
Normal file
420
vendor/node_modules/recharts/es6/cartesian/Scatter.js
generated
vendored
Normal file
@@ -0,0 +1,420 @@
|
||||
var _Scatter;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Render a group of scatters
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import Animate from 'react-smooth';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { findAllByType, filterProps } from '../util/ReactUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { ZAxis } from './ZAxis';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { ErrorBar } from './ErrorBar';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { uniqueId, interpolateNumber, getLinearRegression } from '../util/DataUtils';
|
||||
import { getValueByDataKey, getCateCoordinateOfLine } from '../util/ChartUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { ScatterSymbol } from '../util/ScatterUtils';
|
||||
export var Scatter = /*#__PURE__*/function (_PureComponent) {
|
||||
function Scatter() {
|
||||
var _this;
|
||||
_classCallCheck(this, Scatter);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, Scatter, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
isAnimationFinished: false
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationEnd", function () {
|
||||
_this.setState({
|
||||
isAnimationFinished: true
|
||||
});
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationStart", function () {
|
||||
_this.setState({
|
||||
isAnimationFinished: false
|
||||
});
|
||||
});
|
||||
_defineProperty(_this, "id", uniqueId('recharts-scatter-'));
|
||||
return _this;
|
||||
}
|
||||
_inherits(Scatter, _PureComponent);
|
||||
return _createClass(Scatter, [{
|
||||
key: "renderSymbolsStatically",
|
||||
value: function renderSymbolsStatically(points) {
|
||||
var _this2 = this;
|
||||
var _this$props = this.props,
|
||||
shape = _this$props.shape,
|
||||
activeShape = _this$props.activeShape,
|
||||
activeIndex = _this$props.activeIndex;
|
||||
var baseProps = filterProps(this.props, false);
|
||||
return points.map(function (entry, i) {
|
||||
var isActive = activeIndex === i;
|
||||
var option = isActive ? activeShape : shape;
|
||||
var props = _objectSpread(_objectSpread({}, baseProps), entry);
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: "recharts-scatter-symbol"
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
,
|
||||
key: "symbol-".concat(entry === null || entry === void 0 ? void 0 : entry.cx, "-").concat(entry === null || entry === void 0 ? void 0 : entry.cy, "-").concat(entry === null || entry === void 0 ? void 0 : entry.size, "-").concat(i)
|
||||
}, adaptEventsOfChild(_this2.props, entry, i), {
|
||||
role: "img"
|
||||
}), /*#__PURE__*/React.createElement(ScatterSymbol, _extends({
|
||||
option: option,
|
||||
isActive: isActive
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
,
|
||||
key: "symbol-".concat(i)
|
||||
}, props)));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderSymbolsWithAnimation",
|
||||
value: function renderSymbolsWithAnimation() {
|
||||
var _this3 = this;
|
||||
var _this$props2 = this.props,
|
||||
points = _this$props2.points,
|
||||
isAnimationActive = _this$props2.isAnimationActive,
|
||||
animationBegin = _this$props2.animationBegin,
|
||||
animationDuration = _this$props2.animationDuration,
|
||||
animationEasing = _this$props2.animationEasing,
|
||||
animationId = _this$props2.animationId;
|
||||
var prevPoints = this.state.prevPoints;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing,
|
||||
from: {
|
||||
t: 0
|
||||
},
|
||||
to: {
|
||||
t: 1
|
||||
},
|
||||
key: "pie-".concat(animationId),
|
||||
onAnimationEnd: this.handleAnimationEnd,
|
||||
onAnimationStart: this.handleAnimationStart
|
||||
}, function (_ref) {
|
||||
var t = _ref.t;
|
||||
var stepData = points.map(function (entry, index) {
|
||||
var prev = prevPoints && prevPoints[index];
|
||||
if (prev) {
|
||||
var interpolatorCx = interpolateNumber(prev.cx, entry.cx);
|
||||
var interpolatorCy = interpolateNumber(prev.cy, entry.cy);
|
||||
var interpolatorSize = interpolateNumber(prev.size, entry.size);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
cx: interpolatorCx(t),
|
||||
cy: interpolatorCy(t),
|
||||
size: interpolatorSize(t)
|
||||
});
|
||||
}
|
||||
var interpolator = interpolateNumber(0, entry.size);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
size: interpolator(t)
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, null, _this3.renderSymbolsStatically(stepData));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderSymbols",
|
||||
value: function renderSymbols() {
|
||||
var _this$props3 = this.props,
|
||||
points = _this$props3.points,
|
||||
isAnimationActive = _this$props3.isAnimationActive;
|
||||
var prevPoints = this.state.prevPoints;
|
||||
if (isAnimationActive && points && points.length && (!prevPoints || !isEqual(prevPoints, points))) {
|
||||
return this.renderSymbolsWithAnimation();
|
||||
}
|
||||
return this.renderSymbolsStatically(points);
|
||||
}
|
||||
}, {
|
||||
key: "renderErrorBar",
|
||||
value: function renderErrorBar() {
|
||||
var isAnimationActive = this.props.isAnimationActive;
|
||||
if (isAnimationActive && !this.state.isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props4 = this.props,
|
||||
points = _this$props4.points,
|
||||
xAxis = _this$props4.xAxis,
|
||||
yAxis = _this$props4.yAxis,
|
||||
children = _this$props4.children;
|
||||
var errorBarItems = findAllByType(children, ErrorBar);
|
||||
if (!errorBarItems) {
|
||||
return null;
|
||||
}
|
||||
return errorBarItems.map(function (item, i) {
|
||||
var _item$props = item.props,
|
||||
direction = _item$props.direction,
|
||||
errorDataKey = _item$props.dataKey;
|
||||
return /*#__PURE__*/React.cloneElement(item, {
|
||||
key: "".concat(direction, "-").concat(errorDataKey, "-").concat(points[i]),
|
||||
data: points,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
layout: direction === 'x' ? 'vertical' : 'horizontal',
|
||||
dataPointFormatter: function dataPointFormatter(dataPoint, dataKey) {
|
||||
return {
|
||||
x: dataPoint.cx,
|
||||
y: dataPoint.cy,
|
||||
value: direction === 'x' ? +dataPoint.node.x : +dataPoint.node.y,
|
||||
errorVal: getValueByDataKey(dataPoint, dataKey)
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderLine",
|
||||
value: function renderLine() {
|
||||
var _this$props5 = this.props,
|
||||
points = _this$props5.points,
|
||||
line = _this$props5.line,
|
||||
lineType = _this$props5.lineType,
|
||||
lineJointType = _this$props5.lineJointType;
|
||||
var scatterProps = filterProps(this.props, false);
|
||||
var customLineProps = filterProps(line, false);
|
||||
var linePoints, lineItem;
|
||||
if (lineType === 'joint') {
|
||||
linePoints = points.map(function (entry) {
|
||||
return {
|
||||
x: entry.cx,
|
||||
y: entry.cy
|
||||
};
|
||||
});
|
||||
} else if (lineType === 'fitting') {
|
||||
var _getLinearRegression = getLinearRegression(points),
|
||||
xmin = _getLinearRegression.xmin,
|
||||
xmax = _getLinearRegression.xmax,
|
||||
a = _getLinearRegression.a,
|
||||
b = _getLinearRegression.b;
|
||||
var linearExp = function linearExp(x) {
|
||||
return a * x + b;
|
||||
};
|
||||
linePoints = [{
|
||||
x: xmin,
|
||||
y: linearExp(xmin)
|
||||
}, {
|
||||
x: xmax,
|
||||
y: linearExp(xmax)
|
||||
}];
|
||||
}
|
||||
var lineProps = _objectSpread(_objectSpread(_objectSpread({}, scatterProps), {}, {
|
||||
fill: 'none',
|
||||
stroke: scatterProps && scatterProps.fill
|
||||
}, customLineProps), {}, {
|
||||
points: linePoints
|
||||
});
|
||||
if ( /*#__PURE__*/React.isValidElement(line)) {
|
||||
lineItem = /*#__PURE__*/React.cloneElement(line, lineProps);
|
||||
} else if (isFunction(line)) {
|
||||
lineItem = line(lineProps);
|
||||
} else {
|
||||
lineItem = /*#__PURE__*/React.createElement(Curve, _extends({}, lineProps, {
|
||||
type: lineJointType
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-scatter-line",
|
||||
key: "recharts-scatter-line"
|
||||
}, lineItem);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props6 = this.props,
|
||||
hide = _this$props6.hide,
|
||||
points = _this$props6.points,
|
||||
line = _this$props6.line,
|
||||
className = _this$props6.className,
|
||||
xAxis = _this$props6.xAxis,
|
||||
yAxis = _this$props6.yAxis,
|
||||
left = _this$props6.left,
|
||||
top = _this$props6.top,
|
||||
width = _this$props6.width,
|
||||
height = _this$props6.height,
|
||||
id = _this$props6.id,
|
||||
isAnimationActive = _this$props6.isAnimationActive;
|
||||
if (hide || !points || !points.length) {
|
||||
return null;
|
||||
}
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
var layerClass = clsx('recharts-scatter', className);
|
||||
var needClipX = xAxis && xAxis.allowDataOverflow;
|
||||
var needClipY = yAxis && yAxis.allowDataOverflow;
|
||||
var needClip = needClipX || needClipY;
|
||||
var clipPathId = isNil(id) ? this.id : id;
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass,
|
||||
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : null
|
||||
}, needClipX || needClipY ? /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
||||
id: "clipPath-".concat(clipPathId)
|
||||
}, /*#__PURE__*/React.createElement("rect", {
|
||||
x: needClipX ? left : left - width / 2,
|
||||
y: needClipY ? top : top - height / 2,
|
||||
width: needClipX ? width : width * 2,
|
||||
height: needClipY ? height : height * 2
|
||||
}))) : null, line && this.renderLine(), this.renderErrorBar(), /*#__PURE__*/React.createElement(Layer, {
|
||||
key: "recharts-scatter-symbols"
|
||||
}, this.renderSymbols()), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, points));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (nextProps.animationId !== prevState.prevAnimationId) {
|
||||
return {
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curPoints: nextProps.points,
|
||||
prevPoints: prevState.curPoints
|
||||
};
|
||||
}
|
||||
if (nextProps.points !== prevState.curPoints) {
|
||||
return {
|
||||
curPoints: nextProps.points
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_Scatter = Scatter;
|
||||
_defineProperty(Scatter, "displayName", 'Scatter');
|
||||
_defineProperty(Scatter, "defaultProps", {
|
||||
xAxisId: 0,
|
||||
yAxisId: 0,
|
||||
zAxisId: 0,
|
||||
legendType: 'circle',
|
||||
lineType: 'joint',
|
||||
lineJointType: 'linear',
|
||||
data: [],
|
||||
shape: 'circle',
|
||||
hide: false,
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 0,
|
||||
animationDuration: 400,
|
||||
animationEasing: 'linear'
|
||||
});
|
||||
/**
|
||||
* Compose the data of each group
|
||||
* @param {Object} xAxis The configuration of x-axis
|
||||
* @param {Object} yAxis The configuration of y-axis
|
||||
* @param {String} dataKey The unique key of a group
|
||||
* @return {Array} Composed data
|
||||
*/
|
||||
_defineProperty(Scatter, "getComposedData", function (_ref2) {
|
||||
var xAxis = _ref2.xAxis,
|
||||
yAxis = _ref2.yAxis,
|
||||
zAxis = _ref2.zAxis,
|
||||
item = _ref2.item,
|
||||
displayedData = _ref2.displayedData,
|
||||
xAxisTicks = _ref2.xAxisTicks,
|
||||
yAxisTicks = _ref2.yAxisTicks,
|
||||
offset = _ref2.offset;
|
||||
var tooltipType = item.props.tooltipType;
|
||||
var cells = findAllByType(item.props.children, Cell);
|
||||
var xAxisDataKey = isNil(xAxis.dataKey) ? item.props.dataKey : xAxis.dataKey;
|
||||
var yAxisDataKey = isNil(yAxis.dataKey) ? item.props.dataKey : yAxis.dataKey;
|
||||
var zAxisDataKey = zAxis && zAxis.dataKey;
|
||||
var defaultRangeZ = zAxis ? zAxis.range : ZAxis.defaultProps.range;
|
||||
var defaultZ = defaultRangeZ && defaultRangeZ[0];
|
||||
var xBandSize = xAxis.scale.bandwidth ? xAxis.scale.bandwidth() : 0;
|
||||
var yBandSize = yAxis.scale.bandwidth ? yAxis.scale.bandwidth() : 0;
|
||||
var points = displayedData.map(function (entry, index) {
|
||||
var x = getValueByDataKey(entry, xAxisDataKey);
|
||||
var y = getValueByDataKey(entry, yAxisDataKey);
|
||||
var z = !isNil(zAxisDataKey) && getValueByDataKey(entry, zAxisDataKey) || '-';
|
||||
var tooltipPayload = [{
|
||||
name: isNil(xAxis.dataKey) ? item.props.name : xAxis.name || xAxis.dataKey,
|
||||
unit: xAxis.unit || '',
|
||||
value: x,
|
||||
payload: entry,
|
||||
dataKey: xAxisDataKey,
|
||||
type: tooltipType
|
||||
}, {
|
||||
name: isNil(yAxis.dataKey) ? item.props.name : yAxis.name || yAxis.dataKey,
|
||||
unit: yAxis.unit || '',
|
||||
value: y,
|
||||
payload: entry,
|
||||
dataKey: yAxisDataKey,
|
||||
type: tooltipType
|
||||
}];
|
||||
if (z !== '-') {
|
||||
tooltipPayload.push({
|
||||
name: zAxis.name || zAxis.dataKey,
|
||||
unit: zAxis.unit || '',
|
||||
value: z,
|
||||
payload: entry,
|
||||
dataKey: zAxisDataKey,
|
||||
type: tooltipType
|
||||
});
|
||||
}
|
||||
var cx = getCateCoordinateOfLine({
|
||||
axis: xAxis,
|
||||
ticks: xAxisTicks,
|
||||
bandSize: xBandSize,
|
||||
entry: entry,
|
||||
index: index,
|
||||
dataKey: xAxisDataKey
|
||||
});
|
||||
var cy = getCateCoordinateOfLine({
|
||||
axis: yAxis,
|
||||
ticks: yAxisTicks,
|
||||
bandSize: yBandSize,
|
||||
entry: entry,
|
||||
index: index,
|
||||
dataKey: yAxisDataKey
|
||||
});
|
||||
var size = z !== '-' ? zAxis.scale(z) : defaultZ;
|
||||
var radius = Math.sqrt(Math.max(size, 0) / Math.PI);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
x: cx - radius,
|
||||
y: cy - radius,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
zAxis: zAxis,
|
||||
width: 2 * radius,
|
||||
height: 2 * radius,
|
||||
size: size,
|
||||
node: {
|
||||
x: x,
|
||||
y: y,
|
||||
z: z
|
||||
},
|
||||
tooltipPayload: tooltipPayload,
|
||||
tooltipPosition: {
|
||||
x: cx,
|
||||
y: cy
|
||||
},
|
||||
payload: entry
|
||||
}, cells && cells[index] && cells[index].props);
|
||||
});
|
||||
return _objectSpread({
|
||||
points: points
|
||||
}, offset);
|
||||
});
|
||||
86
vendor/node_modules/recharts/es6/cartesian/XAxis.js
generated
vendored
Normal file
86
vendor/node_modules/recharts/es6/cartesian/XAxis.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
/**
|
||||
* @fileOverview X Axis
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { useChartHeight, useChartWidth, useXAxisOrThrow } from '../context/chartLayoutContext';
|
||||
import { CartesianAxis } from './CartesianAxis';
|
||||
import { getTicksOfAxis } from '../util/ChartUtils';
|
||||
|
||||
/** Define of XAxis props */
|
||||
|
||||
function XAxisImpl(_ref) {
|
||||
var xAxisId = _ref.xAxisId;
|
||||
var width = useChartWidth();
|
||||
var height = useChartHeight();
|
||||
var axisOptions = useXAxisOrThrow(xAxisId);
|
||||
if (axisOptions == null) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// @ts-expect-error the axisOptions type is not exactly what CartesianAxis is expecting.
|
||||
React.createElement(CartesianAxis, _extends({}, axisOptions, {
|
||||
className: clsx("recharts-".concat(axisOptions.axisType, " ").concat(axisOptions.axisType), axisOptions.className),
|
||||
viewBox: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: height
|
||||
},
|
||||
ticksGenerator: function ticksGenerator(axis) {
|
||||
return getTicksOfAxis(axis, true);
|
||||
}
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var XAxis = /*#__PURE__*/function (_React$Component) {
|
||||
function XAxis() {
|
||||
_classCallCheck(this, XAxis);
|
||||
return _callSuper(this, XAxis, arguments);
|
||||
}
|
||||
_inherits(XAxis, _React$Component);
|
||||
return _createClass(XAxis, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return /*#__PURE__*/React.createElement(XAxisImpl, this.props);
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(XAxis, "displayName", 'XAxis');
|
||||
_defineProperty(XAxis, "defaultProps", {
|
||||
allowDecimals: true,
|
||||
hide: false,
|
||||
orientation: 'bottom',
|
||||
width: 0,
|
||||
height: 30,
|
||||
mirror: false,
|
||||
xAxisId: 0,
|
||||
tickCount: 5,
|
||||
type: 'category',
|
||||
padding: {
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
allowDataOverflow: false,
|
||||
scale: 'auto',
|
||||
reversed: false,
|
||||
allowDuplicatedCategory: true
|
||||
});
|
||||
83
vendor/node_modules/recharts/es6/cartesian/YAxis.js
generated
vendored
Normal file
83
vendor/node_modules/recharts/es6/cartesian/YAxis.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
/**
|
||||
* @fileOverview Y Axis
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { useChartHeight, useChartWidth, useYAxisOrThrow } from '../context/chartLayoutContext';
|
||||
import { CartesianAxis } from './CartesianAxis';
|
||||
import { getTicksOfAxis } from '../util/ChartUtils';
|
||||
var YAxisImpl = function YAxisImpl(_ref) {
|
||||
var yAxisId = _ref.yAxisId;
|
||||
var width = useChartWidth();
|
||||
var height = useChartHeight();
|
||||
var axisOptions = useYAxisOrThrow(yAxisId);
|
||||
if (axisOptions == null) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// @ts-expect-error the axisOptions type is not exactly what CartesianAxis is expecting.
|
||||
React.createElement(CartesianAxis, _extends({}, axisOptions, {
|
||||
className: clsx("recharts-".concat(axisOptions.axisType, " ").concat(axisOptions.axisType), axisOptions.className),
|
||||
viewBox: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: height
|
||||
},
|
||||
ticksGenerator: function ticksGenerator(axis) {
|
||||
return getTicksOfAxis(axis, true);
|
||||
}
|
||||
}))
|
||||
);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var YAxis = /*#__PURE__*/function (_React$Component) {
|
||||
function YAxis() {
|
||||
_classCallCheck(this, YAxis);
|
||||
return _callSuper(this, YAxis, arguments);
|
||||
}
|
||||
_inherits(YAxis, _React$Component);
|
||||
return _createClass(YAxis, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return /*#__PURE__*/React.createElement(YAxisImpl, this.props);
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(YAxis, "displayName", 'YAxis');
|
||||
_defineProperty(YAxis, "defaultProps", {
|
||||
allowDuplicatedCategory: true,
|
||||
allowDecimals: true,
|
||||
hide: false,
|
||||
orientation: 'left',
|
||||
width: 60,
|
||||
height: 0,
|
||||
mirror: false,
|
||||
yAxisId: 0,
|
||||
tickCount: 5,
|
||||
type: 'number',
|
||||
padding: {
|
||||
top: 0,
|
||||
bottom: 0
|
||||
},
|
||||
allowDataOverflow: false,
|
||||
scale: 'auto',
|
||||
reversed: false
|
||||
});
|
||||
39
vendor/node_modules/recharts/es6/cartesian/ZAxis.js
generated
vendored
Normal file
39
vendor/node_modules/recharts/es6/cartesian/ZAxis.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Z Axis
|
||||
*/
|
||||
import * as React from 'react';
|
||||
// eslint-disable-next-line react/prefer-stateless-function -- requires static defaultProps
|
||||
export var ZAxis = /*#__PURE__*/function (_React$Component) {
|
||||
function ZAxis() {
|
||||
_classCallCheck(this, ZAxis);
|
||||
return _callSuper(this, ZAxis, arguments);
|
||||
}
|
||||
_inherits(ZAxis, _React$Component);
|
||||
return _createClass(ZAxis, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
}(React.Component);
|
||||
_defineProperty(ZAxis, "displayName", 'ZAxis');
|
||||
_defineProperty(ZAxis, "defaultProps", {
|
||||
zAxisId: 0,
|
||||
range: [64, 64],
|
||||
scale: 'auto',
|
||||
type: 'number'
|
||||
});
|
||||
55
vendor/node_modules/recharts/es6/cartesian/getEquidistantTicks.js
generated
vendored
Normal file
55
vendor/node_modules/recharts/es6/cartesian/getEquidistantTicks.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { isVisible } from '../util/TickUtils';
|
||||
import { getEveryNthWithCondition } from '../util/getEveryNthWithCondition';
|
||||
export function getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap) {
|
||||
var result = (ticks || []).slice();
|
||||
var initialStart = boundaries.start,
|
||||
end = boundaries.end;
|
||||
var index = 0;
|
||||
// Premature optimisation idea 1: Estimate a lower bound, and start from there.
|
||||
// For now, start from every tick
|
||||
var stepsize = 1;
|
||||
var start = initialStart;
|
||||
var _loop = function _loop() {
|
||||
// Given stepsize, evaluate whether every stepsize-th tick can be shown.
|
||||
// If it can not, then increase the stepsize by 1, and try again.
|
||||
|
||||
var entry = ticks === null || ticks === void 0 ? void 0 : ticks[index];
|
||||
|
||||
// Break condition - If we have evaluate all the ticks, then we are done.
|
||||
if (entry === undefined) {
|
||||
return {
|
||||
v: getEveryNthWithCondition(ticks, stepsize)
|
||||
};
|
||||
}
|
||||
|
||||
// Check if the element collides with the next element
|
||||
var i = index;
|
||||
var size;
|
||||
var getSize = function getSize() {
|
||||
if (size === undefined) {
|
||||
size = getTickSize(entry, i);
|
||||
}
|
||||
return size;
|
||||
};
|
||||
var tickCoord = entry.coordinate;
|
||||
// We will always show the first tick.
|
||||
var isShow = index === 0 || isVisible(sign, tickCoord, getSize, start, end);
|
||||
if (!isShow) {
|
||||
// Start all over with a larger stepsize
|
||||
index = 0;
|
||||
start = initialStart;
|
||||
stepsize += 1;
|
||||
}
|
||||
if (isShow) {
|
||||
// If it can be shown, update the start
|
||||
start = tickCoord + sign * (getSize() / 2 + minTickGap);
|
||||
index += stepsize;
|
||||
}
|
||||
},
|
||||
_ret;
|
||||
while (stepsize <= result.length) {
|
||||
_ret = _loop();
|
||||
if (_ret) return _ret.v;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
155
vendor/node_modules/recharts/es6/cartesian/getTicks.js
generated
vendored
Normal file
155
vendor/node_modules/recharts/es6/cartesian/getTicks.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import { mathSign, isNumber } from '../util/DataUtils';
|
||||
import { getStringSize } from '../util/DOMUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { isVisible, getTickBoundaries, getNumberIntervalTicks, getAngledTickWidth } from '../util/TickUtils';
|
||||
import { getEquidistantTicks } from './getEquidistantTicks';
|
||||
function getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap) {
|
||||
var result = (ticks || []).slice();
|
||||
var len = result.length;
|
||||
var start = boundaries.start;
|
||||
var end = boundaries.end;
|
||||
var _loop = function _loop(i) {
|
||||
var entry = result[i];
|
||||
var size;
|
||||
var getSize = function getSize() {
|
||||
if (size === undefined) {
|
||||
size = getTickSize(entry, i);
|
||||
}
|
||||
return size;
|
||||
};
|
||||
if (i === len - 1) {
|
||||
var gap = sign * (entry.coordinate + sign * getSize() / 2 - end);
|
||||
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
tickCoord: gap > 0 ? entry.coordinate - gap * sign : entry.coordinate
|
||||
});
|
||||
} else {
|
||||
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
tickCoord: entry.coordinate
|
||||
});
|
||||
}
|
||||
var isShow = isVisible(sign, entry.tickCoord, getSize, start, end);
|
||||
if (isShow) {
|
||||
end = entry.tickCoord - sign * (getSize() / 2 + minTickGap);
|
||||
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
isShow: true
|
||||
});
|
||||
}
|
||||
};
|
||||
for (var i = len - 1; i >= 0; i--) {
|
||||
_loop(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, preserveEnd) {
|
||||
var result = (ticks || []).slice();
|
||||
var len = result.length;
|
||||
var start = boundaries.start,
|
||||
end = boundaries.end;
|
||||
if (preserveEnd) {
|
||||
// Try to guarantee the tail to be displayed
|
||||
var tail = ticks[len - 1];
|
||||
var tailSize = getTickSize(tail, len - 1);
|
||||
var tailGap = sign * (tail.coordinate + sign * tailSize / 2 - end);
|
||||
result[len - 1] = tail = _objectSpread(_objectSpread({}, tail), {}, {
|
||||
tickCoord: tailGap > 0 ? tail.coordinate - tailGap * sign : tail.coordinate
|
||||
});
|
||||
var isTailShow = isVisible(sign, tail.tickCoord, function () {
|
||||
return tailSize;
|
||||
}, start, end);
|
||||
if (isTailShow) {
|
||||
end = tail.tickCoord - sign * (tailSize / 2 + minTickGap);
|
||||
result[len - 1] = _objectSpread(_objectSpread({}, tail), {}, {
|
||||
isShow: true
|
||||
});
|
||||
}
|
||||
}
|
||||
var count = preserveEnd ? len - 1 : len;
|
||||
var _loop2 = function _loop2(i) {
|
||||
var entry = result[i];
|
||||
var size;
|
||||
var getSize = function getSize() {
|
||||
if (size === undefined) {
|
||||
size = getTickSize(entry, i);
|
||||
}
|
||||
return size;
|
||||
};
|
||||
if (i === 0) {
|
||||
var gap = sign * (entry.coordinate - sign * getSize() / 2 - start);
|
||||
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
tickCoord: gap < 0 ? entry.coordinate - gap * sign : entry.coordinate
|
||||
});
|
||||
} else {
|
||||
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
tickCoord: entry.coordinate
|
||||
});
|
||||
}
|
||||
var isShow = isVisible(sign, entry.tickCoord, getSize, start, end);
|
||||
if (isShow) {
|
||||
start = entry.tickCoord + sign * (getSize() / 2 + minTickGap);
|
||||
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
isShow: true
|
||||
});
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < count; i++) {
|
||||
_loop2(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export function getTicks(props, fontSize, letterSpacing) {
|
||||
var tick = props.tick,
|
||||
ticks = props.ticks,
|
||||
viewBox = props.viewBox,
|
||||
minTickGap = props.minTickGap,
|
||||
orientation = props.orientation,
|
||||
interval = props.interval,
|
||||
tickFormatter = props.tickFormatter,
|
||||
unit = props.unit,
|
||||
angle = props.angle;
|
||||
if (!ticks || !ticks.length || !tick) {
|
||||
return [];
|
||||
}
|
||||
if (isNumber(interval) || Global.isSsr) {
|
||||
return getNumberIntervalTicks(ticks, typeof interval === 'number' && isNumber(interval) ? interval : 0);
|
||||
}
|
||||
var candidates = [];
|
||||
var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
|
||||
var unitSize = unit && sizeKey === 'width' ? getStringSize(unit, {
|
||||
fontSize: fontSize,
|
||||
letterSpacing: letterSpacing
|
||||
}) : {
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
var getTickSize = function getTickSize(content, index) {
|
||||
var value = isFunction(tickFormatter) ? tickFormatter(content.value, index) : content.value;
|
||||
// Recharts only supports angles when sizeKey === 'width'
|
||||
return sizeKey === 'width' ? getAngledTickWidth(getStringSize(value, {
|
||||
fontSize: fontSize,
|
||||
letterSpacing: letterSpacing
|
||||
}), unitSize, angle) : getStringSize(value, {
|
||||
fontSize: fontSize,
|
||||
letterSpacing: letterSpacing
|
||||
})[sizeKey];
|
||||
};
|
||||
var sign = ticks.length >= 2 ? mathSign(ticks[1].coordinate - ticks[0].coordinate) : 1;
|
||||
var boundaries = getTickBoundaries(viewBox, sign, sizeKey);
|
||||
if (interval === 'equidistantPreserveStart') {
|
||||
return getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap);
|
||||
}
|
||||
if (interval === 'preserveStart' || interval === 'preserveStartEnd') {
|
||||
candidates = getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, interval === 'preserveStartEnd');
|
||||
} else {
|
||||
candidates = getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap);
|
||||
}
|
||||
return candidates.filter(function (entry) {
|
||||
return entry.isShow;
|
||||
});
|
||||
}
|
||||
110
vendor/node_modules/recharts/es6/chart/AccessibilityManager.js
generated
vendored
Normal file
110
vendor/node_modules/recharts/es6/chart/AccessibilityManager.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
export var AccessibilityManager = /*#__PURE__*/function () {
|
||||
function AccessibilityManager() {
|
||||
_classCallCheck(this, AccessibilityManager);
|
||||
_defineProperty(this, "activeIndex", 0);
|
||||
_defineProperty(this, "coordinateList", []);
|
||||
_defineProperty(this, "layout", 'horizontal');
|
||||
}
|
||||
return _createClass(AccessibilityManager, [{
|
||||
key: "setDetails",
|
||||
value: function setDetails(_ref) {
|
||||
var _ref2;
|
||||
var _ref$coordinateList = _ref.coordinateList,
|
||||
coordinateList = _ref$coordinateList === void 0 ? null : _ref$coordinateList,
|
||||
_ref$container = _ref.container,
|
||||
container = _ref$container === void 0 ? null : _ref$container,
|
||||
_ref$layout = _ref.layout,
|
||||
layout = _ref$layout === void 0 ? null : _ref$layout,
|
||||
_ref$offset = _ref.offset,
|
||||
offset = _ref$offset === void 0 ? null : _ref$offset,
|
||||
_ref$mouseHandlerCall = _ref.mouseHandlerCallback,
|
||||
mouseHandlerCallback = _ref$mouseHandlerCall === void 0 ? null : _ref$mouseHandlerCall;
|
||||
this.coordinateList = (_ref2 = coordinateList !== null && coordinateList !== void 0 ? coordinateList : this.coordinateList) !== null && _ref2 !== void 0 ? _ref2 : [];
|
||||
this.container = container !== null && container !== void 0 ? container : this.container;
|
||||
this.layout = layout !== null && layout !== void 0 ? layout : this.layout;
|
||||
this.offset = offset !== null && offset !== void 0 ? offset : this.offset;
|
||||
this.mouseHandlerCallback = mouseHandlerCallback !== null && mouseHandlerCallback !== void 0 ? mouseHandlerCallback : this.mouseHandlerCallback;
|
||||
|
||||
// Keep activeIndex in the bounds between 0 and the last coordinate index
|
||||
this.activeIndex = Math.min(Math.max(this.activeIndex, 0), this.coordinateList.length - 1);
|
||||
}
|
||||
}, {
|
||||
key: "focus",
|
||||
value: function focus() {
|
||||
this.spoofMouse();
|
||||
}
|
||||
}, {
|
||||
key: "keyboardEvent",
|
||||
value: function keyboardEvent(e) {
|
||||
// The AccessibilityManager relies on the Tooltip component. When tooltips suddenly stop existing,
|
||||
// it can cause errors. We use this function to check. We don't want arrow keys to be processed
|
||||
// if there are no tooltips, since that will cause unexpected behavior of users.
|
||||
if (this.coordinateList.length === 0) {
|
||||
return;
|
||||
}
|
||||
switch (e.key) {
|
||||
case 'ArrowRight':
|
||||
{
|
||||
if (this.layout !== 'horizontal') {
|
||||
return;
|
||||
}
|
||||
this.activeIndex = Math.min(this.activeIndex + 1, this.coordinateList.length - 1);
|
||||
this.spoofMouse();
|
||||
break;
|
||||
}
|
||||
case 'ArrowLeft':
|
||||
{
|
||||
if (this.layout !== 'horizontal') {
|
||||
return;
|
||||
}
|
||||
this.activeIndex = Math.max(this.activeIndex - 1, 0);
|
||||
this.spoofMouse();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "setIndex",
|
||||
value: function setIndex(newIndex) {
|
||||
this.activeIndex = newIndex;
|
||||
}
|
||||
}, {
|
||||
key: "spoofMouse",
|
||||
value: function spoofMouse() {
|
||||
var _window, _window2;
|
||||
if (this.layout !== 'horizontal') {
|
||||
return;
|
||||
}
|
||||
|
||||
// This can happen when the tooltips suddenly stop existing as children of the component
|
||||
// That update doesn't otherwise fire events, so we have to double check here.
|
||||
if (this.coordinateList.length === 0) {
|
||||
return;
|
||||
}
|
||||
var _this$container$getBo = this.container.getBoundingClientRect(),
|
||||
x = _this$container$getBo.x,
|
||||
y = _this$container$getBo.y,
|
||||
height = _this$container$getBo.height;
|
||||
var coordinate = this.coordinateList[this.activeIndex].coordinate;
|
||||
var scrollOffsetX = ((_window = window) === null || _window === void 0 ? void 0 : _window.scrollX) || 0;
|
||||
var scrollOffsetY = ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.scrollY) || 0;
|
||||
var pageX = x + coordinate + scrollOffsetX;
|
||||
var pageY = y + this.offset.top + height / 2 + scrollOffsetY;
|
||||
this.mouseHandlerCallback({
|
||||
pageX: pageX,
|
||||
pageY: pageY
|
||||
});
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
20
vendor/node_modules/recharts/es6/chart/AreaChart.js
generated
vendored
Normal file
20
vendor/node_modules/recharts/es6/chart/AreaChart.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @fileOverview Area Chart
|
||||
*/
|
||||
import { generateCategoricalChart } from './generateCategoricalChart';
|
||||
import { Area } from '../cartesian/Area';
|
||||
import { XAxis } from '../cartesian/XAxis';
|
||||
import { YAxis } from '../cartesian/YAxis';
|
||||
import { formatAxisMap } from '../util/CartesianUtils';
|
||||
export var AreaChart = generateCategoricalChart({
|
||||
chartName: 'AreaChart',
|
||||
GraphicalChild: Area,
|
||||
axisComponents: [{
|
||||
axisType: 'xAxis',
|
||||
AxisComp: XAxis
|
||||
}, {
|
||||
axisType: 'yAxis',
|
||||
AxisComp: YAxis
|
||||
}],
|
||||
formatAxisMap: formatAxisMap
|
||||
});
|
||||
27
vendor/node_modules/recharts/es6/chart/ComposedChart.js
generated
vendored
Normal file
27
vendor/node_modules/recharts/es6/chart/ComposedChart.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @fileOverview Composed Chart
|
||||
*/
|
||||
import { generateCategoricalChart } from './generateCategoricalChart';
|
||||
import { Area } from '../cartesian/Area';
|
||||
import { Bar } from '../cartesian/Bar';
|
||||
import { Line } from '../cartesian/Line';
|
||||
import { Scatter } from '../cartesian/Scatter';
|
||||
import { XAxis } from '../cartesian/XAxis';
|
||||
import { YAxis } from '../cartesian/YAxis';
|
||||
import { ZAxis } from '../cartesian/ZAxis';
|
||||
import { formatAxisMap } from '../util/CartesianUtils';
|
||||
export var ComposedChart = generateCategoricalChart({
|
||||
chartName: 'ComposedChart',
|
||||
GraphicalChild: [Line, Area, Bar, Scatter],
|
||||
axisComponents: [{
|
||||
axisType: 'xAxis',
|
||||
AxisComp: XAxis
|
||||
}, {
|
||||
axisType: 'yAxis',
|
||||
AxisComp: YAxis
|
||||
}, {
|
||||
axisType: 'zAxis',
|
||||
AxisComp: ZAxis
|
||||
}],
|
||||
formatAxisMap: formatAxisMap
|
||||
});
|
||||
20
vendor/node_modules/recharts/es6/chart/LineChart.js
generated
vendored
Normal file
20
vendor/node_modules/recharts/es6/chart/LineChart.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @fileOverview Line Chart
|
||||
*/
|
||||
import { generateCategoricalChart } from './generateCategoricalChart';
|
||||
import { Line } from '../cartesian/Line';
|
||||
import { XAxis } from '../cartesian/XAxis';
|
||||
import { YAxis } from '../cartesian/YAxis';
|
||||
import { formatAxisMap } from '../util/CartesianUtils';
|
||||
export var LineChart = generateCategoricalChart({
|
||||
chartName: 'LineChart',
|
||||
GraphicalChild: Line,
|
||||
axisComponents: [{
|
||||
axisType: 'xAxis',
|
||||
AxisComp: XAxis
|
||||
}, {
|
||||
axisType: 'yAxis',
|
||||
AxisComp: YAxis
|
||||
}],
|
||||
formatAxisMap: formatAxisMap
|
||||
});
|
||||
32
vendor/node_modules/recharts/es6/chart/PieChart.js
generated
vendored
Normal file
32
vendor/node_modules/recharts/es6/chart/PieChart.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @fileOverview Pie Chart
|
||||
*/
|
||||
import { generateCategoricalChart } from './generateCategoricalChart';
|
||||
import { PolarAngleAxis } from '../polar/PolarAngleAxis';
|
||||
import { PolarRadiusAxis } from '../polar/PolarRadiusAxis';
|
||||
import { formatAxisMap } from '../util/PolarUtils';
|
||||
import { Pie } from '../polar/Pie';
|
||||
export var PieChart = generateCategoricalChart({
|
||||
chartName: 'PieChart',
|
||||
GraphicalChild: Pie,
|
||||
validateTooltipEventTypes: ['item'],
|
||||
defaultTooltipEventType: 'item',
|
||||
legendContent: 'children',
|
||||
axisComponents: [{
|
||||
axisType: 'angleAxis',
|
||||
AxisComp: PolarAngleAxis
|
||||
}, {
|
||||
axisType: 'radiusAxis',
|
||||
AxisComp: PolarRadiusAxis
|
||||
}],
|
||||
formatAxisMap: formatAxisMap,
|
||||
defaultProps: {
|
||||
layout: 'centric',
|
||||
startAngle: 0,
|
||||
endAngle: 360,
|
||||
cx: '50%',
|
||||
cy: '50%',
|
||||
innerRadius: 0,
|
||||
outerRadius: '80%'
|
||||
}
|
||||
});
|
||||
2099
vendor/node_modules/recharts/es6/chart/generateCategoricalChart.js
generated
vendored
Normal file
2099
vendor/node_modules/recharts/es6/chart/generateCategoricalChart.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
vendor/node_modules/recharts/es6/component/Cell.js
generated
vendored
Normal file
8
vendor/node_modules/recharts/es6/component/Cell.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @fileOverview Cross
|
||||
*/
|
||||
|
||||
export var Cell = function Cell(_props) {
|
||||
return null;
|
||||
};
|
||||
Cell.displayName = 'Cell';
|
||||
80
vendor/node_modules/recharts/es6/component/Cursor.js
generated
vendored
Normal file
80
vendor/node_modules/recharts/es6/component/Cursor.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import { cloneElement, createElement, isValidElement } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { Cross } from '../shape/Cross';
|
||||
import { getCursorRectangle } from '../util/cursor/getCursorRectangle';
|
||||
import { Rectangle } from '../shape/Rectangle';
|
||||
import { getRadialCursorPoints } from '../util/cursor/getRadialCursorPoints';
|
||||
import { Sector } from '../shape/Sector';
|
||||
import { getCursorPoints } from '../util/cursor/getCursorPoints';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
/*
|
||||
* Cursor is the background, or a highlight,
|
||||
* that shows when user mouses over or activates
|
||||
* an area.
|
||||
*
|
||||
* It usually shows together with a tooltip
|
||||
* to emphasise which part of the chart does the tooltip refer to.
|
||||
*/
|
||||
export function Cursor(props) {
|
||||
var _element$props$cursor, _defaultProps;
|
||||
var element = props.element,
|
||||
tooltipEventType = props.tooltipEventType,
|
||||
isActive = props.isActive,
|
||||
activeCoordinate = props.activeCoordinate,
|
||||
activePayload = props.activePayload,
|
||||
offset = props.offset,
|
||||
activeTooltipIndex = props.activeTooltipIndex,
|
||||
tooltipAxisBandSize = props.tooltipAxisBandSize,
|
||||
layout = props.layout,
|
||||
chartName = props.chartName;
|
||||
var elementPropsCursor = (_element$props$cursor = element.props.cursor) !== null && _element$props$cursor !== void 0 ? _element$props$cursor : (_defaultProps = element.type.defaultProps) === null || _defaultProps === void 0 ? void 0 : _defaultProps.cursor;
|
||||
if (!element || !elementPropsCursor || !isActive || !activeCoordinate || chartName !== 'ScatterChart' && tooltipEventType !== 'axis') {
|
||||
return null;
|
||||
}
|
||||
var restProps;
|
||||
var cursorComp = Curve;
|
||||
if (chartName === 'ScatterChart') {
|
||||
restProps = activeCoordinate;
|
||||
cursorComp = Cross;
|
||||
} else if (chartName === 'BarChart') {
|
||||
restProps = getCursorRectangle(layout, activeCoordinate, offset, tooltipAxisBandSize);
|
||||
cursorComp = Rectangle;
|
||||
} else if (layout === 'radial') {
|
||||
var _getRadialCursorPoint = getRadialCursorPoints(activeCoordinate),
|
||||
cx = _getRadialCursorPoint.cx,
|
||||
cy = _getRadialCursorPoint.cy,
|
||||
radius = _getRadialCursorPoint.radius,
|
||||
startAngle = _getRadialCursorPoint.startAngle,
|
||||
endAngle = _getRadialCursorPoint.endAngle;
|
||||
restProps = {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle,
|
||||
innerRadius: radius,
|
||||
outerRadius: radius
|
||||
};
|
||||
cursorComp = Sector;
|
||||
} else {
|
||||
restProps = {
|
||||
points: getCursorPoints(layout, activeCoordinate, offset)
|
||||
};
|
||||
cursorComp = Curve;
|
||||
}
|
||||
var cursorProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
stroke: '#ccc',
|
||||
pointerEvents: 'none'
|
||||
}, offset), restProps), filterProps(elementPropsCursor, false)), {}, {
|
||||
payload: activePayload,
|
||||
payloadIndex: activeTooltipIndex,
|
||||
className: clsx('recharts-tooltip-cursor', elementPropsCursor.className)
|
||||
});
|
||||
return /*#__PURE__*/isValidElement(elementPropsCursor) ? /*#__PURE__*/cloneElement(elementPropsCursor, cursorProps) : /*#__PURE__*/createElement(cursorComp, cursorProps);
|
||||
}
|
||||
185
vendor/node_modules/recharts/es6/component/DefaultLegendContent.js
generated
vendored
Normal file
185
vendor/node_modules/recharts/es6/component/DefaultLegendContent.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Default Legend Content
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { Surface } from '../container/Surface';
|
||||
import { Symbols } from '../shape/Symbols';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
var SIZE = 32;
|
||||
export var DefaultLegendContent = /*#__PURE__*/function (_PureComponent) {
|
||||
function DefaultLegendContent() {
|
||||
_classCallCheck(this, DefaultLegendContent);
|
||||
return _callSuper(this, DefaultLegendContent, arguments);
|
||||
}
|
||||
_inherits(DefaultLegendContent, _PureComponent);
|
||||
return _createClass(DefaultLegendContent, [{
|
||||
key: "renderIcon",
|
||||
value:
|
||||
/**
|
||||
* Render the path of icon
|
||||
* @param {Object} data Data of each legend item
|
||||
* @return {String} Path element
|
||||
*/
|
||||
function renderIcon(data) {
|
||||
var inactiveColor = this.props.inactiveColor;
|
||||
var halfSize = SIZE / 2;
|
||||
var sixthSize = SIZE / 6;
|
||||
var thirdSize = SIZE / 3;
|
||||
var color = data.inactive ? inactiveColor : data.color;
|
||||
if (data.type === 'plainline') {
|
||||
return /*#__PURE__*/React.createElement("line", {
|
||||
strokeWidth: 4,
|
||||
fill: "none",
|
||||
stroke: color,
|
||||
strokeDasharray: data.payload.strokeDasharray,
|
||||
x1: 0,
|
||||
y1: halfSize,
|
||||
x2: SIZE,
|
||||
y2: halfSize,
|
||||
className: "recharts-legend-icon"
|
||||
});
|
||||
}
|
||||
if (data.type === 'line') {
|
||||
return /*#__PURE__*/React.createElement("path", {
|
||||
strokeWidth: 4,
|
||||
fill: "none",
|
||||
stroke: color,
|
||||
d: "M0,".concat(halfSize, "h").concat(thirdSize, "\n A").concat(sixthSize, ",").concat(sixthSize, ",0,1,1,").concat(2 * thirdSize, ",").concat(halfSize, "\n H").concat(SIZE, "M").concat(2 * thirdSize, ",").concat(halfSize, "\n A").concat(sixthSize, ",").concat(sixthSize, ",0,1,1,").concat(thirdSize, ",").concat(halfSize),
|
||||
className: "recharts-legend-icon"
|
||||
});
|
||||
}
|
||||
if (data.type === 'rect') {
|
||||
return /*#__PURE__*/React.createElement("path", {
|
||||
stroke: "none",
|
||||
fill: color,
|
||||
d: "M0,".concat(SIZE / 8, "h").concat(SIZE, "v").concat(SIZE * 3 / 4, "h").concat(-SIZE, "z"),
|
||||
className: "recharts-legend-icon"
|
||||
});
|
||||
}
|
||||
if ( /*#__PURE__*/React.isValidElement(data.legendIcon)) {
|
||||
var iconProps = _objectSpread({}, data);
|
||||
delete iconProps.legendIcon;
|
||||
return /*#__PURE__*/React.cloneElement(data.legendIcon, iconProps);
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Symbols, {
|
||||
fill: color,
|
||||
cx: halfSize,
|
||||
cy: halfSize,
|
||||
size: SIZE,
|
||||
sizeType: "diameter",
|
||||
type: data.type
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw items of legend
|
||||
* @return {ReactElement} Items
|
||||
*/
|
||||
}, {
|
||||
key: "renderItems",
|
||||
value: function renderItems() {
|
||||
var _this = this;
|
||||
var _this$props = this.props,
|
||||
payload = _this$props.payload,
|
||||
iconSize = _this$props.iconSize,
|
||||
layout = _this$props.layout,
|
||||
formatter = _this$props.formatter,
|
||||
inactiveColor = _this$props.inactiveColor;
|
||||
var viewBox = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: SIZE,
|
||||
height: SIZE
|
||||
};
|
||||
var itemStyle = {
|
||||
display: layout === 'horizontal' ? 'inline-block' : 'block',
|
||||
marginRight: 10
|
||||
};
|
||||
var svgStyle = {
|
||||
display: 'inline-block',
|
||||
verticalAlign: 'middle',
|
||||
marginRight: 4
|
||||
};
|
||||
return payload.map(function (entry, i) {
|
||||
var finalFormatter = entry.formatter || formatter;
|
||||
var className = clsx(_defineProperty(_defineProperty({
|
||||
'recharts-legend-item': true
|
||||
}, "legend-item-".concat(i), true), "inactive", entry.inactive));
|
||||
if (entry.type === 'none') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Do not render entry.value as functions. Always require static string properties.
|
||||
var entryValue = !isFunction(entry.value) ? entry.value : null;
|
||||
warn(!isFunction(entry.value), "The name property is also required when using a function for the dataKey of a chart's cartesian components. Ex: <Bar name=\"Name of my Data\"/>" // eslint-disable-line max-len
|
||||
);
|
||||
var color = entry.inactive ? inactiveColor : entry.color;
|
||||
return /*#__PURE__*/React.createElement("li", _extends({
|
||||
className: className,
|
||||
style: itemStyle
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
,
|
||||
key: "legend-item-".concat(i)
|
||||
}, adaptEventsOfChild(_this.props, entry, i)), /*#__PURE__*/React.createElement(Surface, {
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
viewBox: viewBox,
|
||||
style: svgStyle
|
||||
}, _this.renderIcon(entry)), /*#__PURE__*/React.createElement("span", {
|
||||
className: "recharts-legend-item-text",
|
||||
style: {
|
||||
color: color
|
||||
}
|
||||
}, finalFormatter ? finalFormatter(entryValue, entry, i) : entryValue));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props2 = this.props,
|
||||
payload = _this$props2.payload,
|
||||
layout = _this$props2.layout,
|
||||
align = _this$props2.align;
|
||||
if (!payload || !payload.length) {
|
||||
return null;
|
||||
}
|
||||
var finalStyle = {
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
textAlign: layout === 'horizontal' ? align : 'left'
|
||||
};
|
||||
return /*#__PURE__*/React.createElement("ul", {
|
||||
className: "recharts-default-legend",
|
||||
style: finalStyle
|
||||
}, this.renderItems());
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(DefaultLegendContent, "displayName", 'Legend');
|
||||
_defineProperty(DefaultLegendContent, "defaultProps", {
|
||||
iconSize: 14,
|
||||
layout: 'horizontal',
|
||||
align: 'center',
|
||||
verticalAlign: 'middle',
|
||||
inactiveColor: '#ccc'
|
||||
});
|
||||
128
vendor/node_modules/recharts/es6/component/DefaultTooltipContent.js
generated
vendored
Normal file
128
vendor/node_modules/recharts/es6/component/DefaultTooltipContent.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Default Tooltip Content
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import isNil from 'lodash/isNil';
|
||||
import clsx from 'clsx';
|
||||
import { isNumOrStr } from '../util/DataUtils';
|
||||
function defaultFormatter(value) {
|
||||
return Array.isArray(value) && isNumOrStr(value[0]) && isNumOrStr(value[1]) ? value.join(' ~ ') : value;
|
||||
}
|
||||
export var DefaultTooltipContent = function DefaultTooltipContent(props) {
|
||||
var _props$separator = props.separator,
|
||||
separator = _props$separator === void 0 ? ' : ' : _props$separator,
|
||||
_props$contentStyle = props.contentStyle,
|
||||
contentStyle = _props$contentStyle === void 0 ? {} : _props$contentStyle,
|
||||
_props$itemStyle = props.itemStyle,
|
||||
itemStyle = _props$itemStyle === void 0 ? {} : _props$itemStyle,
|
||||
_props$labelStyle = props.labelStyle,
|
||||
labelStyle = _props$labelStyle === void 0 ? {} : _props$labelStyle,
|
||||
payload = props.payload,
|
||||
formatter = props.formatter,
|
||||
itemSorter = props.itemSorter,
|
||||
wrapperClassName = props.wrapperClassName,
|
||||
labelClassName = props.labelClassName,
|
||||
label = props.label,
|
||||
labelFormatter = props.labelFormatter,
|
||||
_props$accessibilityL = props.accessibilityLayer,
|
||||
accessibilityLayer = _props$accessibilityL === void 0 ? false : _props$accessibilityL;
|
||||
var renderContent = function renderContent() {
|
||||
if (payload && payload.length) {
|
||||
var listStyle = {
|
||||
padding: 0,
|
||||
margin: 0
|
||||
};
|
||||
var items = (itemSorter ? sortBy(payload, itemSorter) : payload).map(function (entry, i) {
|
||||
if (entry.type === 'none') {
|
||||
return null;
|
||||
}
|
||||
var finalItemStyle = _objectSpread({
|
||||
display: 'block',
|
||||
paddingTop: 4,
|
||||
paddingBottom: 4,
|
||||
color: entry.color || '#000'
|
||||
}, itemStyle);
|
||||
var finalFormatter = entry.formatter || formatter || defaultFormatter;
|
||||
var value = entry.value,
|
||||
name = entry.name;
|
||||
var finalValue = value;
|
||||
var finalName = name;
|
||||
if (finalFormatter && finalValue != null && finalName != null) {
|
||||
var formatted = finalFormatter(value, name, entry, i, payload);
|
||||
if (Array.isArray(formatted)) {
|
||||
var _formatted = _slicedToArray(formatted, 2);
|
||||
finalValue = _formatted[0];
|
||||
finalName = _formatted[1];
|
||||
} else {
|
||||
finalValue = formatted;
|
||||
}
|
||||
}
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
React.createElement("li", {
|
||||
className: "recharts-tooltip-item",
|
||||
key: "tooltip-item-".concat(i),
|
||||
style: finalItemStyle
|
||||
}, isNumOrStr(finalName) ? /*#__PURE__*/React.createElement("span", {
|
||||
className: "recharts-tooltip-item-name"
|
||||
}, finalName) : null, isNumOrStr(finalName) ? /*#__PURE__*/React.createElement("span", {
|
||||
className: "recharts-tooltip-item-separator"
|
||||
}, separator) : null, /*#__PURE__*/React.createElement("span", {
|
||||
className: "recharts-tooltip-item-value"
|
||||
}, finalValue), /*#__PURE__*/React.createElement("span", {
|
||||
className: "recharts-tooltip-item-unit"
|
||||
}, entry.unit || ''))
|
||||
);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("ul", {
|
||||
className: "recharts-tooltip-item-list",
|
||||
style: listStyle
|
||||
}, items);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
var finalStyle = _objectSpread({
|
||||
margin: 0,
|
||||
padding: 10,
|
||||
backgroundColor: '#fff',
|
||||
border: '1px solid #ccc',
|
||||
whiteSpace: 'nowrap'
|
||||
}, contentStyle);
|
||||
var finalLabelStyle = _objectSpread({
|
||||
margin: 0
|
||||
}, labelStyle);
|
||||
var hasLabel = !isNil(label);
|
||||
var finalLabel = hasLabel ? label : '';
|
||||
var wrapperCN = clsx('recharts-default-tooltip', wrapperClassName);
|
||||
var labelCN = clsx('recharts-tooltip-label', labelClassName);
|
||||
if (hasLabel && labelFormatter && payload !== undefined && payload !== null) {
|
||||
finalLabel = labelFormatter(label, payload);
|
||||
}
|
||||
var accessibilityAttributes = accessibilityLayer ? {
|
||||
role: 'status',
|
||||
'aria-live': 'assertive'
|
||||
} : {};
|
||||
return /*#__PURE__*/React.createElement("div", _extends({
|
||||
className: wrapperCN,
|
||||
style: finalStyle
|
||||
}, accessibilityAttributes), /*#__PURE__*/React.createElement("p", {
|
||||
className: labelCN,
|
||||
style: finalLabelStyle
|
||||
}, /*#__PURE__*/React.isValidElement(finalLabel) ? finalLabel : "".concat(finalLabel)), renderContent());
|
||||
};
|
||||
469
vendor/node_modules/recharts/es6/component/Label.js
generated
vendored
Normal file
469
vendor/node_modules/recharts/es6/component/Label.js
generated
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
var _excluded = ["offset"];
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
import React, { cloneElement, isValidElement, createElement } from 'react';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import isObject from 'lodash/isObject';
|
||||
import clsx from 'clsx';
|
||||
import { Text } from './Text';
|
||||
import { findAllByType, filterProps } from '../util/ReactUtils';
|
||||
import { isNumOrStr, isNumber, isPercent, getPercentValue, uniqueId, mathSign } from '../util/DataUtils';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
var getLabel = function getLabel(props) {
|
||||
var value = props.value,
|
||||
formatter = props.formatter;
|
||||
var label = isNil(props.children) ? value : props.children;
|
||||
if (isFunction(formatter)) {
|
||||
return formatter(label);
|
||||
}
|
||||
return label;
|
||||
};
|
||||
var getDeltaAngle = function getDeltaAngle(startAngle, endAngle) {
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
|
||||
return sign * deltaAngle;
|
||||
};
|
||||
var renderRadialLabel = function renderRadialLabel(labelProps, label, attrs) {
|
||||
var position = labelProps.position,
|
||||
viewBox = labelProps.viewBox,
|
||||
offset = labelProps.offset,
|
||||
className = labelProps.className;
|
||||
var _ref = viewBox,
|
||||
cx = _ref.cx,
|
||||
cy = _ref.cy,
|
||||
innerRadius = _ref.innerRadius,
|
||||
outerRadius = _ref.outerRadius,
|
||||
startAngle = _ref.startAngle,
|
||||
endAngle = _ref.endAngle,
|
||||
clockWise = _ref.clockWise;
|
||||
var radius = (innerRadius + outerRadius) / 2;
|
||||
var deltaAngle = getDeltaAngle(startAngle, endAngle);
|
||||
var sign = deltaAngle >= 0 ? 1 : -1;
|
||||
var labelAngle, direction;
|
||||
if (position === 'insideStart') {
|
||||
labelAngle = startAngle + sign * offset;
|
||||
direction = clockWise;
|
||||
} else if (position === 'insideEnd') {
|
||||
labelAngle = endAngle - sign * offset;
|
||||
direction = !clockWise;
|
||||
} else if (position === 'end') {
|
||||
labelAngle = endAngle + sign * offset;
|
||||
direction = clockWise;
|
||||
}
|
||||
direction = deltaAngle <= 0 ? direction : !direction;
|
||||
var startPoint = polarToCartesian(cx, cy, radius, labelAngle);
|
||||
var endPoint = polarToCartesian(cx, cy, radius, labelAngle + (direction ? 1 : -1) * 359);
|
||||
var path = "M".concat(startPoint.x, ",").concat(startPoint.y, "\n A").concat(radius, ",").concat(radius, ",0,1,").concat(direction ? 0 : 1, ",\n ").concat(endPoint.x, ",").concat(endPoint.y);
|
||||
var id = isNil(labelProps.id) ? uniqueId('recharts-radial-line-') : labelProps.id;
|
||||
return /*#__PURE__*/React.createElement("text", _extends({}, attrs, {
|
||||
dominantBaseline: "central",
|
||||
className: clsx('recharts-radial-bar-label', className)
|
||||
}), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
|
||||
id: id,
|
||||
d: path
|
||||
})), /*#__PURE__*/React.createElement("textPath", {
|
||||
xlinkHref: "#".concat(id)
|
||||
}, label));
|
||||
};
|
||||
var getAttrsOfPolarLabel = function getAttrsOfPolarLabel(props) {
|
||||
var viewBox = props.viewBox,
|
||||
offset = props.offset,
|
||||
position = props.position;
|
||||
var _ref2 = viewBox,
|
||||
cx = _ref2.cx,
|
||||
cy = _ref2.cy,
|
||||
innerRadius = _ref2.innerRadius,
|
||||
outerRadius = _ref2.outerRadius,
|
||||
startAngle = _ref2.startAngle,
|
||||
endAngle = _ref2.endAngle;
|
||||
var midAngle = (startAngle + endAngle) / 2;
|
||||
if (position === 'outside') {
|
||||
var _polarToCartesian = polarToCartesian(cx, cy, outerRadius + offset, midAngle),
|
||||
_x = _polarToCartesian.x,
|
||||
_y = _polarToCartesian.y;
|
||||
return {
|
||||
x: _x,
|
||||
y: _y,
|
||||
textAnchor: _x >= cx ? 'start' : 'end',
|
||||
verticalAnchor: 'middle'
|
||||
};
|
||||
}
|
||||
if (position === 'center') {
|
||||
return {
|
||||
x: cx,
|
||||
y: cy,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: 'middle'
|
||||
};
|
||||
}
|
||||
if (position === 'centerTop') {
|
||||
return {
|
||||
x: cx,
|
||||
y: cy,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: 'start'
|
||||
};
|
||||
}
|
||||
if (position === 'centerBottom') {
|
||||
return {
|
||||
x: cx,
|
||||
y: cy,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: 'end'
|
||||
};
|
||||
}
|
||||
var r = (innerRadius + outerRadius) / 2;
|
||||
var _polarToCartesian2 = polarToCartesian(cx, cy, r, midAngle),
|
||||
x = _polarToCartesian2.x,
|
||||
y = _polarToCartesian2.y;
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: 'middle'
|
||||
};
|
||||
};
|
||||
var getAttrsOfCartesianLabel = function getAttrsOfCartesianLabel(props) {
|
||||
var viewBox = props.viewBox,
|
||||
parentViewBox = props.parentViewBox,
|
||||
offset = props.offset,
|
||||
position = props.position;
|
||||
var _ref3 = viewBox,
|
||||
x = _ref3.x,
|
||||
y = _ref3.y,
|
||||
width = _ref3.width,
|
||||
height = _ref3.height;
|
||||
|
||||
// Define vertical offsets and position inverts based on the value being positive or negative
|
||||
var verticalSign = height >= 0 ? 1 : -1;
|
||||
var verticalOffset = verticalSign * offset;
|
||||
var verticalEnd = verticalSign > 0 ? 'end' : 'start';
|
||||
var verticalStart = verticalSign > 0 ? 'start' : 'end';
|
||||
|
||||
// Define horizontal offsets and position inverts based on the value being positive or negative
|
||||
var horizontalSign = width >= 0 ? 1 : -1;
|
||||
var horizontalOffset = horizontalSign * offset;
|
||||
var horizontalEnd = horizontalSign > 0 ? 'end' : 'start';
|
||||
var horizontalStart = horizontalSign > 0 ? 'start' : 'end';
|
||||
if (position === 'top') {
|
||||
var attrs = {
|
||||
x: x + width / 2,
|
||||
y: y - verticalSign * offset,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: verticalEnd
|
||||
};
|
||||
return _objectSpread(_objectSpread({}, attrs), parentViewBox ? {
|
||||
height: Math.max(y - parentViewBox.y, 0),
|
||||
width: width
|
||||
} : {});
|
||||
}
|
||||
if (position === 'bottom') {
|
||||
var _attrs = {
|
||||
x: x + width / 2,
|
||||
y: y + height + verticalOffset,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: verticalStart
|
||||
};
|
||||
return _objectSpread(_objectSpread({}, _attrs), parentViewBox ? {
|
||||
height: Math.max(parentViewBox.y + parentViewBox.height - (y + height), 0),
|
||||
width: width
|
||||
} : {});
|
||||
}
|
||||
if (position === 'left') {
|
||||
var _attrs2 = {
|
||||
x: x - horizontalOffset,
|
||||
y: y + height / 2,
|
||||
textAnchor: horizontalEnd,
|
||||
verticalAnchor: 'middle'
|
||||
};
|
||||
return _objectSpread(_objectSpread({}, _attrs2), parentViewBox ? {
|
||||
width: Math.max(_attrs2.x - parentViewBox.x, 0),
|
||||
height: height
|
||||
} : {});
|
||||
}
|
||||
if (position === 'right') {
|
||||
var _attrs3 = {
|
||||
x: x + width + horizontalOffset,
|
||||
y: y + height / 2,
|
||||
textAnchor: horizontalStart,
|
||||
verticalAnchor: 'middle'
|
||||
};
|
||||
return _objectSpread(_objectSpread({}, _attrs3), parentViewBox ? {
|
||||
width: Math.max(parentViewBox.x + parentViewBox.width - _attrs3.x, 0),
|
||||
height: height
|
||||
} : {});
|
||||
}
|
||||
var sizeAttrs = parentViewBox ? {
|
||||
width: width,
|
||||
height: height
|
||||
} : {};
|
||||
if (position === 'insideLeft') {
|
||||
return _objectSpread({
|
||||
x: x + horizontalOffset,
|
||||
y: y + height / 2,
|
||||
textAnchor: horizontalStart,
|
||||
verticalAnchor: 'middle'
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideRight') {
|
||||
return _objectSpread({
|
||||
x: x + width - horizontalOffset,
|
||||
y: y + height / 2,
|
||||
textAnchor: horizontalEnd,
|
||||
verticalAnchor: 'middle'
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideTop') {
|
||||
return _objectSpread({
|
||||
x: x + width / 2,
|
||||
y: y + verticalOffset,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: verticalStart
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideBottom') {
|
||||
return _objectSpread({
|
||||
x: x + width / 2,
|
||||
y: y + height - verticalOffset,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: verticalEnd
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideTopLeft') {
|
||||
return _objectSpread({
|
||||
x: x + horizontalOffset,
|
||||
y: y + verticalOffset,
|
||||
textAnchor: horizontalStart,
|
||||
verticalAnchor: verticalStart
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideTopRight') {
|
||||
return _objectSpread({
|
||||
x: x + width - horizontalOffset,
|
||||
y: y + verticalOffset,
|
||||
textAnchor: horizontalEnd,
|
||||
verticalAnchor: verticalStart
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideBottomLeft') {
|
||||
return _objectSpread({
|
||||
x: x + horizontalOffset,
|
||||
y: y + height - verticalOffset,
|
||||
textAnchor: horizontalStart,
|
||||
verticalAnchor: verticalEnd
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (position === 'insideBottomRight') {
|
||||
return _objectSpread({
|
||||
x: x + width - horizontalOffset,
|
||||
y: y + height - verticalOffset,
|
||||
textAnchor: horizontalEnd,
|
||||
verticalAnchor: verticalEnd
|
||||
}, sizeAttrs);
|
||||
}
|
||||
if (isObject(position) && (isNumber(position.x) || isPercent(position.x)) && (isNumber(position.y) || isPercent(position.y))) {
|
||||
return _objectSpread({
|
||||
x: x + getPercentValue(position.x, width),
|
||||
y: y + getPercentValue(position.y, height),
|
||||
textAnchor: 'end',
|
||||
verticalAnchor: 'end'
|
||||
}, sizeAttrs);
|
||||
}
|
||||
return _objectSpread({
|
||||
x: x + width / 2,
|
||||
y: y + height / 2,
|
||||
textAnchor: 'middle',
|
||||
verticalAnchor: 'middle'
|
||||
}, sizeAttrs);
|
||||
};
|
||||
var isPolar = function isPolar(viewBox) {
|
||||
return 'cx' in viewBox && isNumber(viewBox.cx);
|
||||
};
|
||||
export function Label(_ref4) {
|
||||
var _ref4$offset = _ref4.offset,
|
||||
offset = _ref4$offset === void 0 ? 5 : _ref4$offset,
|
||||
restProps = _objectWithoutProperties(_ref4, _excluded);
|
||||
var props = _objectSpread({
|
||||
offset: offset
|
||||
}, restProps);
|
||||
var viewBox = props.viewBox,
|
||||
position = props.position,
|
||||
value = props.value,
|
||||
children = props.children,
|
||||
content = props.content,
|
||||
_props$className = props.className,
|
||||
className = _props$className === void 0 ? '' : _props$className,
|
||||
textBreakAll = props.textBreakAll;
|
||||
if (!viewBox || isNil(value) && isNil(children) && ! /*#__PURE__*/isValidElement(content) && !isFunction(content)) {
|
||||
return null;
|
||||
}
|
||||
if ( /*#__PURE__*/isValidElement(content)) {
|
||||
return /*#__PURE__*/cloneElement(content, props);
|
||||
}
|
||||
var label;
|
||||
if (isFunction(content)) {
|
||||
label = /*#__PURE__*/createElement(content, props);
|
||||
if ( /*#__PURE__*/isValidElement(label)) {
|
||||
return label;
|
||||
}
|
||||
} else {
|
||||
label = getLabel(props);
|
||||
}
|
||||
var isPolarLabel = isPolar(viewBox);
|
||||
var attrs = filterProps(props, true);
|
||||
if (isPolarLabel && (position === 'insideStart' || position === 'insideEnd' || position === 'end')) {
|
||||
return renderRadialLabel(props, label, attrs);
|
||||
}
|
||||
var positionAttrs = isPolarLabel ? getAttrsOfPolarLabel(props) : getAttrsOfCartesianLabel(props);
|
||||
return /*#__PURE__*/React.createElement(Text, _extends({
|
||||
className: clsx('recharts-label', className)
|
||||
}, attrs, positionAttrs, {
|
||||
breakAll: textBreakAll
|
||||
}), label);
|
||||
}
|
||||
Label.displayName = 'Label';
|
||||
var parseViewBox = function parseViewBox(props) {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
angle = props.angle,
|
||||
startAngle = props.startAngle,
|
||||
endAngle = props.endAngle,
|
||||
r = props.r,
|
||||
radius = props.radius,
|
||||
innerRadius = props.innerRadius,
|
||||
outerRadius = props.outerRadius,
|
||||
x = props.x,
|
||||
y = props.y,
|
||||
top = props.top,
|
||||
left = props.left,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
clockWise = props.clockWise,
|
||||
labelViewBox = props.labelViewBox;
|
||||
if (labelViewBox) {
|
||||
return labelViewBox;
|
||||
}
|
||||
if (isNumber(width) && isNumber(height)) {
|
||||
if (isNumber(x) && isNumber(y)) {
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
}
|
||||
if (isNumber(top) && isNumber(left)) {
|
||||
return {
|
||||
x: top,
|
||||
y: left,
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
}
|
||||
}
|
||||
if (isNumber(x) && isNumber(y)) {
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
}
|
||||
if (isNumber(cx) && isNumber(cy)) {
|
||||
return {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
startAngle: startAngle || angle || 0,
|
||||
endAngle: endAngle || angle || 0,
|
||||
innerRadius: innerRadius || 0,
|
||||
outerRadius: outerRadius || radius || r || 0,
|
||||
clockWise: clockWise
|
||||
};
|
||||
}
|
||||
if (props.viewBox) {
|
||||
return props.viewBox;
|
||||
}
|
||||
return {};
|
||||
};
|
||||
var parseLabel = function parseLabel(label, viewBox) {
|
||||
if (!label) {
|
||||
return null;
|
||||
}
|
||||
if (label === true) {
|
||||
return /*#__PURE__*/React.createElement(Label, {
|
||||
key: "label-implicit",
|
||||
viewBox: viewBox
|
||||
});
|
||||
}
|
||||
if (isNumOrStr(label)) {
|
||||
return /*#__PURE__*/React.createElement(Label, {
|
||||
key: "label-implicit",
|
||||
viewBox: viewBox,
|
||||
value: label
|
||||
});
|
||||
}
|
||||
if ( /*#__PURE__*/isValidElement(label)) {
|
||||
if (label.type === Label) {
|
||||
return /*#__PURE__*/cloneElement(label, {
|
||||
key: 'label-implicit',
|
||||
viewBox: viewBox
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Label, {
|
||||
key: "label-implicit",
|
||||
content: label,
|
||||
viewBox: viewBox
|
||||
});
|
||||
}
|
||||
if (isFunction(label)) {
|
||||
return /*#__PURE__*/React.createElement(Label, {
|
||||
key: "label-implicit",
|
||||
content: label,
|
||||
viewBox: viewBox
|
||||
});
|
||||
}
|
||||
if (isObject(label)) {
|
||||
return /*#__PURE__*/React.createElement(Label, _extends({
|
||||
viewBox: viewBox
|
||||
}, label, {
|
||||
key: "label-implicit"
|
||||
}));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
var renderCallByParent = function renderCallByParent(parentProps, viewBox) {
|
||||
var checkPropsLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
if (!parentProps || !parentProps.children && checkPropsLabel && !parentProps.label) {
|
||||
return null;
|
||||
}
|
||||
var children = parentProps.children;
|
||||
var parentViewBox = parseViewBox(parentProps);
|
||||
var explicitChildren = findAllByType(children, Label).map(function (child, index) {
|
||||
return /*#__PURE__*/cloneElement(child, {
|
||||
viewBox: viewBox || parentViewBox,
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key: "label-".concat(index)
|
||||
});
|
||||
});
|
||||
if (!checkPropsLabel) {
|
||||
return explicitChildren;
|
||||
}
|
||||
var implicitLabel = parseLabel(parentProps.label, viewBox || parentViewBox);
|
||||
return [implicitLabel].concat(_toConsumableArray(explicitChildren));
|
||||
};
|
||||
Label.parseViewBox = parseViewBox;
|
||||
Label.renderCallByParent = renderCallByParent;
|
||||
109
vendor/node_modules/recharts/es6/component/LabelList.js
generated
vendored
Normal file
109
vendor/node_modules/recharts/es6/component/LabelList.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
var _excluded = ["valueAccessor"],
|
||||
_excluded2 = ["data", "dataKey", "clockWise", "id", "textBreakAll"];
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
import React, { cloneElement } from 'react';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isObject from 'lodash/isObject';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import last from 'lodash/last';
|
||||
import { Label } from './Label';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { findAllByType, filterProps } from '../util/ReactUtils';
|
||||
import { getValueByDataKey } from '../util/ChartUtils';
|
||||
var defaultAccessor = function defaultAccessor(entry) {
|
||||
return Array.isArray(entry.value) ? last(entry.value) : entry.value;
|
||||
};
|
||||
export function LabelList(_ref) {
|
||||
var _ref$valueAccessor = _ref.valueAccessor,
|
||||
valueAccessor = _ref$valueAccessor === void 0 ? defaultAccessor : _ref$valueAccessor,
|
||||
restProps = _objectWithoutProperties(_ref, _excluded);
|
||||
var data = restProps.data,
|
||||
dataKey = restProps.dataKey,
|
||||
clockWise = restProps.clockWise,
|
||||
id = restProps.id,
|
||||
textBreakAll = restProps.textBreakAll,
|
||||
others = _objectWithoutProperties(restProps, _excluded2);
|
||||
if (!data || !data.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-label-list"
|
||||
}, data.map(function (entry, index) {
|
||||
var value = isNil(dataKey) ? valueAccessor(entry, index) : getValueByDataKey(entry && entry.payload, dataKey);
|
||||
var idProps = isNil(id) ? {} : {
|
||||
id: "".concat(id, "-").concat(index)
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Label, _extends({}, filterProps(entry, true), others, idProps, {
|
||||
parentViewBox: entry.parentViewBox,
|
||||
value: value,
|
||||
textBreakAll: textBreakAll,
|
||||
viewBox: Label.parseViewBox(isNil(clockWise) ? entry : _objectSpread(_objectSpread({}, entry), {}, {
|
||||
clockWise: clockWise
|
||||
})),
|
||||
key: "label-".concat(index) // eslint-disable-line react/no-array-index-key
|
||||
,
|
||||
index: index
|
||||
}));
|
||||
}));
|
||||
}
|
||||
LabelList.displayName = 'LabelList';
|
||||
function parseLabelList(label, data) {
|
||||
if (!label) {
|
||||
return null;
|
||||
}
|
||||
if (label === true) {
|
||||
return /*#__PURE__*/React.createElement(LabelList, {
|
||||
key: "labelList-implicit",
|
||||
data: data
|
||||
});
|
||||
}
|
||||
if ( /*#__PURE__*/React.isValidElement(label) || isFunction(label)) {
|
||||
return /*#__PURE__*/React.createElement(LabelList, {
|
||||
key: "labelList-implicit",
|
||||
data: data,
|
||||
content: label
|
||||
});
|
||||
}
|
||||
if (isObject(label)) {
|
||||
return /*#__PURE__*/React.createElement(LabelList, _extends({
|
||||
data: data
|
||||
}, label, {
|
||||
key: "labelList-implicit"
|
||||
}));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function renderCallByParent(parentProps, data) {
|
||||
var checkPropsLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
if (!parentProps || !parentProps.children && checkPropsLabel && !parentProps.label) {
|
||||
return null;
|
||||
}
|
||||
var children = parentProps.children;
|
||||
var explicitChildren = findAllByType(children, LabelList).map(function (child, index) {
|
||||
return /*#__PURE__*/cloneElement(child, {
|
||||
data: data,
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key: "labelList-".concat(index)
|
||||
});
|
||||
});
|
||||
if (!checkPropsLabel) {
|
||||
return explicitChildren;
|
||||
}
|
||||
var implicitLabelList = parseLabelList(parentProps.label, data);
|
||||
return [implicitLabelList].concat(_toConsumableArray(explicitChildren));
|
||||
}
|
||||
LabelList.renderCallByParent = renderCallByParent;
|
||||
202
vendor/node_modules/recharts/es6/component/Legend.js
generated
vendored
Normal file
202
vendor/node_modules/recharts/es6/component/Legend.js
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
var _excluded = ["ref"];
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
/**
|
||||
* @fileOverview Legend
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import { DefaultLegendContent } from './DefaultLegendContent';
|
||||
import { isNumber } from '../util/DataUtils';
|
||||
import { getUniqPayload } from '../util/payload/getUniqPayload';
|
||||
function defaultUniqBy(entry) {
|
||||
return entry.value;
|
||||
}
|
||||
function renderContent(content, props) {
|
||||
if ( /*#__PURE__*/React.isValidElement(content)) {
|
||||
return /*#__PURE__*/React.cloneElement(content, props);
|
||||
}
|
||||
if (typeof content === 'function') {
|
||||
return /*#__PURE__*/React.createElement(content, props);
|
||||
}
|
||||
var ref = props.ref,
|
||||
otherProps = _objectWithoutProperties(props, _excluded);
|
||||
return /*#__PURE__*/React.createElement(DefaultLegendContent, otherProps);
|
||||
}
|
||||
var EPS = 1;
|
||||
export var Legend = /*#__PURE__*/function (_PureComponent) {
|
||||
function Legend() {
|
||||
var _this;
|
||||
_classCallCheck(this, Legend);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, Legend, [].concat(args));
|
||||
_defineProperty(_this, "lastBoundingBox", {
|
||||
width: -1,
|
||||
height: -1
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_inherits(Legend, _PureComponent);
|
||||
return _createClass(Legend, [{
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
this.updateBBox();
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
this.updateBBox();
|
||||
}
|
||||
}, {
|
||||
key: "getBBox",
|
||||
value: function getBBox() {
|
||||
if (this.wrapperNode && this.wrapperNode.getBoundingClientRect) {
|
||||
var box = this.wrapperNode.getBoundingClientRect();
|
||||
box.height = this.wrapperNode.offsetHeight;
|
||||
box.width = this.wrapperNode.offsetWidth;
|
||||
return box;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "updateBBox",
|
||||
value: function updateBBox() {
|
||||
var onBBoxUpdate = this.props.onBBoxUpdate;
|
||||
var box = this.getBBox();
|
||||
if (box) {
|
||||
if (Math.abs(box.width - this.lastBoundingBox.width) > EPS || Math.abs(box.height - this.lastBoundingBox.height) > EPS) {
|
||||
this.lastBoundingBox.width = box.width;
|
||||
this.lastBoundingBox.height = box.height;
|
||||
if (onBBoxUpdate) {
|
||||
onBBoxUpdate(box);
|
||||
}
|
||||
}
|
||||
} else if (this.lastBoundingBox.width !== -1 || this.lastBoundingBox.height !== -1) {
|
||||
this.lastBoundingBox.width = -1;
|
||||
this.lastBoundingBox.height = -1;
|
||||
if (onBBoxUpdate) {
|
||||
onBBoxUpdate(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getBBoxSnapshot",
|
||||
value: function getBBoxSnapshot() {
|
||||
if (this.lastBoundingBox.width >= 0 && this.lastBoundingBox.height >= 0) {
|
||||
return _objectSpread({}, this.lastBoundingBox);
|
||||
}
|
||||
return {
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "getDefaultPosition",
|
||||
value: function getDefaultPosition(style) {
|
||||
var _this$props = this.props,
|
||||
layout = _this$props.layout,
|
||||
align = _this$props.align,
|
||||
verticalAlign = _this$props.verticalAlign,
|
||||
margin = _this$props.margin,
|
||||
chartWidth = _this$props.chartWidth,
|
||||
chartHeight = _this$props.chartHeight;
|
||||
var hPos, vPos;
|
||||
if (!style || (style.left === undefined || style.left === null) && (style.right === undefined || style.right === null)) {
|
||||
if (align === 'center' && layout === 'vertical') {
|
||||
var box = this.getBBoxSnapshot();
|
||||
hPos = {
|
||||
left: ((chartWidth || 0) - box.width) / 2
|
||||
};
|
||||
} else {
|
||||
hPos = align === 'right' ? {
|
||||
right: margin && margin.right || 0
|
||||
} : {
|
||||
left: margin && margin.left || 0
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!style || (style.top === undefined || style.top === null) && (style.bottom === undefined || style.bottom === null)) {
|
||||
if (verticalAlign === 'middle') {
|
||||
var _box = this.getBBoxSnapshot();
|
||||
vPos = {
|
||||
top: ((chartHeight || 0) - _box.height) / 2
|
||||
};
|
||||
} else {
|
||||
vPos = verticalAlign === 'bottom' ? {
|
||||
bottom: margin && margin.bottom || 0
|
||||
} : {
|
||||
top: margin && margin.top || 0
|
||||
};
|
||||
}
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, hPos), vPos);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
var _this$props2 = this.props,
|
||||
content = _this$props2.content,
|
||||
width = _this$props2.width,
|
||||
height = _this$props2.height,
|
||||
wrapperStyle = _this$props2.wrapperStyle,
|
||||
payloadUniqBy = _this$props2.payloadUniqBy,
|
||||
payload = _this$props2.payload;
|
||||
var outerStyle = _objectSpread(_objectSpread({
|
||||
position: 'absolute',
|
||||
width: width || 'auto',
|
||||
height: height || 'auto'
|
||||
}, this.getDefaultPosition(wrapperStyle)), wrapperStyle);
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
className: "recharts-legend-wrapper",
|
||||
style: outerStyle,
|
||||
ref: function ref(node) {
|
||||
_this2.wrapperNode = node;
|
||||
}
|
||||
}, renderContent(content, _objectSpread(_objectSpread({}, this.props), {}, {
|
||||
payload: getUniqPayload(payload, payloadUniqBy, defaultUniqBy)
|
||||
})));
|
||||
}
|
||||
}], [{
|
||||
key: "getWithHeight",
|
||||
value: function getWithHeight(item, chartWidth) {
|
||||
var _this$defaultProps$it = _objectSpread(_objectSpread({}, this.defaultProps), item.props),
|
||||
layout = _this$defaultProps$it.layout;
|
||||
if (layout === 'vertical' && isNumber(item.props.height)) {
|
||||
return {
|
||||
height: item.props.height
|
||||
};
|
||||
}
|
||||
if (layout === 'horizontal') {
|
||||
return {
|
||||
width: item.props.width || chartWidth
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(Legend, "displayName", 'Legend');
|
||||
_defineProperty(Legend, "defaultProps", {
|
||||
iconSize: 14,
|
||||
layout: 'horizontal',
|
||||
align: 'center',
|
||||
verticalAlign: 'bottom'
|
||||
});
|
||||
159
vendor/node_modules/recharts/es6/component/ResponsiveContainer.js
generated
vendored
Normal file
159
vendor/node_modules/recharts/es6/component/ResponsiveContainer.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
/**
|
||||
* @fileOverview Wrapper component to make charts adapt to the size of parent * DOM
|
||||
*/
|
||||
import clsx from 'clsx';
|
||||
import React, { forwardRef, cloneElement, useState, useImperativeHandle, useRef, useEffect, useMemo, useCallback } from 'react';
|
||||
import throttle from 'lodash/throttle';
|
||||
import { isPercent } from '../util/DataUtils';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { getDisplayName } from '../util/ReactUtils';
|
||||
export var ResponsiveContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
||||
var aspect = _ref.aspect,
|
||||
_ref$initialDimension = _ref.initialDimension,
|
||||
initialDimension = _ref$initialDimension === void 0 ? {
|
||||
width: -1,
|
||||
height: -1
|
||||
} : _ref$initialDimension,
|
||||
_ref$width = _ref.width,
|
||||
width = _ref$width === void 0 ? '100%' : _ref$width,
|
||||
_ref$height = _ref.height,
|
||||
height = _ref$height === void 0 ? '100%' : _ref$height,
|
||||
_ref$minWidth = _ref.minWidth,
|
||||
minWidth = _ref$minWidth === void 0 ? 0 : _ref$minWidth,
|
||||
minHeight = _ref.minHeight,
|
||||
maxHeight = _ref.maxHeight,
|
||||
children = _ref.children,
|
||||
_ref$debounce = _ref.debounce,
|
||||
debounce = _ref$debounce === void 0 ? 0 : _ref$debounce,
|
||||
id = _ref.id,
|
||||
className = _ref.className,
|
||||
onResize = _ref.onResize,
|
||||
_ref$style = _ref.style,
|
||||
style = _ref$style === void 0 ? {} : _ref$style;
|
||||
var containerRef = useRef(null);
|
||||
var onResizeRef = useRef();
|
||||
onResizeRef.current = onResize;
|
||||
useImperativeHandle(ref, function () {
|
||||
return Object.defineProperty(containerRef.current, 'current', {
|
||||
get: function get() {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('The usage of ref.current.current is deprecated and will no longer be supported.');
|
||||
return containerRef.current;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
});
|
||||
var _useState = useState({
|
||||
containerWidth: initialDimension.width,
|
||||
containerHeight: initialDimension.height
|
||||
}),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
sizes = _useState2[0],
|
||||
setSizes = _useState2[1];
|
||||
var setContainerSize = useCallback(function (newWidth, newHeight) {
|
||||
setSizes(function (prevState) {
|
||||
var roundedWidth = Math.round(newWidth);
|
||||
var roundedHeight = Math.round(newHeight);
|
||||
if (prevState.containerWidth === roundedWidth && prevState.containerHeight === roundedHeight) {
|
||||
return prevState;
|
||||
}
|
||||
return {
|
||||
containerWidth: roundedWidth,
|
||||
containerHeight: roundedHeight
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
useEffect(function () {
|
||||
var callback = function callback(entries) {
|
||||
var _onResizeRef$current;
|
||||
var _entries$0$contentRec = entries[0].contentRect,
|
||||
containerWidth = _entries$0$contentRec.width,
|
||||
containerHeight = _entries$0$contentRec.height;
|
||||
setContainerSize(containerWidth, containerHeight);
|
||||
(_onResizeRef$current = onResizeRef.current) === null || _onResizeRef$current === void 0 || _onResizeRef$current.call(onResizeRef, containerWidth, containerHeight);
|
||||
};
|
||||
if (debounce > 0) {
|
||||
callback = throttle(callback, debounce, {
|
||||
trailing: true,
|
||||
leading: false
|
||||
});
|
||||
}
|
||||
var observer = new ResizeObserver(callback);
|
||||
var _containerRef$current = containerRef.current.getBoundingClientRect(),
|
||||
containerWidth = _containerRef$current.width,
|
||||
containerHeight = _containerRef$current.height;
|
||||
setContainerSize(containerWidth, containerHeight);
|
||||
observer.observe(containerRef.current);
|
||||
return function () {
|
||||
observer.disconnect();
|
||||
};
|
||||
}, [setContainerSize, debounce]);
|
||||
var chartContent = useMemo(function () {
|
||||
var containerWidth = sizes.containerWidth,
|
||||
containerHeight = sizes.containerHeight;
|
||||
if (containerWidth < 0 || containerHeight < 0) {
|
||||
return null;
|
||||
}
|
||||
warn(isPercent(width) || isPercent(height), "The width(%s) and height(%s) are both fixed numbers,\n maybe you don't need to use a ResponsiveContainer.", width, height);
|
||||
warn(!aspect || aspect > 0, 'The aspect(%s) must be greater than zero.', aspect);
|
||||
var calculatedWidth = isPercent(width) ? containerWidth : width;
|
||||
var calculatedHeight = isPercent(height) ? containerHeight : height;
|
||||
if (aspect && aspect > 0) {
|
||||
// Preserve the desired aspect ratio
|
||||
if (calculatedWidth) {
|
||||
// Will default to using width for aspect ratio
|
||||
calculatedHeight = calculatedWidth / aspect;
|
||||
} else if (calculatedHeight) {
|
||||
// But we should also take height into consideration
|
||||
calculatedWidth = calculatedHeight * aspect;
|
||||
}
|
||||
|
||||
// if maxHeight is set, overwrite if calculatedHeight is greater than maxHeight
|
||||
if (maxHeight && calculatedHeight > maxHeight) {
|
||||
calculatedHeight = maxHeight;
|
||||
}
|
||||
}
|
||||
warn(calculatedWidth > 0 || calculatedHeight > 0, "The width(%s) and height(%s) of chart should be greater than 0,\n please check the style of container, or the props width(%s) and height(%s),\n or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the\n height and width.", calculatedWidth, calculatedHeight, width, height, minWidth, minHeight, aspect);
|
||||
var isCharts = !Array.isArray(children) && getDisplayName(children.type).endsWith('Chart');
|
||||
return React.Children.map(children, function (child) {
|
||||
if ( /*#__PURE__*/React.isValidElement(child)) {
|
||||
return /*#__PURE__*/cloneElement(child, _objectSpread({
|
||||
width: calculatedWidth,
|
||||
height: calculatedHeight
|
||||
}, isCharts ? {
|
||||
style: _objectSpread({
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
maxHeight: calculatedHeight,
|
||||
maxWidth: calculatedWidth
|
||||
}, child.props.style)
|
||||
} : {}));
|
||||
}
|
||||
return child;
|
||||
});
|
||||
}, [aspect, children, height, maxHeight, minHeight, minWidth, sizes, width]);
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
id: id ? "".concat(id) : undefined,
|
||||
className: clsx('recharts-responsive-container', className),
|
||||
style: _objectSpread(_objectSpread({}, style), {}, {
|
||||
width: width,
|
||||
height: height,
|
||||
minWidth: minWidth,
|
||||
minHeight: minHeight,
|
||||
maxHeight: maxHeight
|
||||
}),
|
||||
ref: containerRef
|
||||
}, chartContent);
|
||||
});
|
||||
250
vendor/node_modules/recharts/es6/component/Text.js
generated
vendored
Normal file
250
vendor/node_modules/recharts/es6/component/Text.js
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
var _excluded = ["x", "y", "lineHeight", "capHeight", "scaleToFit", "textAnchor", "verticalAnchor", "fill"],
|
||||
_excluded2 = ["dx", "dy", "angle", "className", "breakAll"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
import React, { useMemo } from 'react';
|
||||
import isNil from 'lodash/isNil';
|
||||
import clsx from 'clsx';
|
||||
import { isNumber, isNumOrStr } from '../util/DataUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { getStringSize } from '../util/DOMUtils';
|
||||
import { reduceCSSCalc } from '../util/ReduceCSSCalc';
|
||||
var BREAKING_SPACES = /[ \f\n\r\t\v\u2028\u2029]+/;
|
||||
var calculateWordWidths = function calculateWordWidths(_ref) {
|
||||
var children = _ref.children,
|
||||
breakAll = _ref.breakAll,
|
||||
style = _ref.style;
|
||||
try {
|
||||
var words = [];
|
||||
if (!isNil(children)) {
|
||||
if (breakAll) {
|
||||
words = children.toString().split('');
|
||||
} else {
|
||||
words = children.toString().split(BREAKING_SPACES);
|
||||
}
|
||||
}
|
||||
var wordsWithComputedWidth = words.map(function (word) {
|
||||
return {
|
||||
word: word,
|
||||
width: getStringSize(word, style).width
|
||||
};
|
||||
});
|
||||
var spaceWidth = breakAll ? 0 : getStringSize("\xA0", style).width;
|
||||
return {
|
||||
wordsWithComputedWidth: wordsWithComputedWidth,
|
||||
spaceWidth: spaceWidth
|
||||
};
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
var calculateWordsByLines = function calculateWordsByLines(_ref2, initialWordsWithComputedWith, spaceWidth, lineWidth, scaleToFit) {
|
||||
var maxLines = _ref2.maxLines,
|
||||
children = _ref2.children,
|
||||
style = _ref2.style,
|
||||
breakAll = _ref2.breakAll;
|
||||
var shouldLimitLines = isNumber(maxLines);
|
||||
var text = children;
|
||||
var calculate = function calculate() {
|
||||
var words = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
return words.reduce(function (result, _ref3) {
|
||||
var word = _ref3.word,
|
||||
width = _ref3.width;
|
||||
var currentLine = result[result.length - 1];
|
||||
if (currentLine && (lineWidth == null || scaleToFit || currentLine.width + width + spaceWidth < Number(lineWidth))) {
|
||||
// Word can be added to an existing line
|
||||
currentLine.words.push(word);
|
||||
currentLine.width += width + spaceWidth;
|
||||
} else {
|
||||
// Add first word to line or word is too long to scaleToFit on existing line
|
||||
var newLine = {
|
||||
words: [word],
|
||||
width: width
|
||||
};
|
||||
result.push(newLine);
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
};
|
||||
var originalResult = calculate(initialWordsWithComputedWith);
|
||||
var findLongestLine = function findLongestLine(words) {
|
||||
return words.reduce(function (a, b) {
|
||||
return a.width > b.width ? a : b;
|
||||
});
|
||||
};
|
||||
if (!shouldLimitLines) {
|
||||
return originalResult;
|
||||
}
|
||||
var suffix = '…';
|
||||
var checkOverflow = function checkOverflow(index) {
|
||||
var tempText = text.slice(0, index);
|
||||
var words = calculateWordWidths({
|
||||
breakAll: breakAll,
|
||||
style: style,
|
||||
children: tempText + suffix
|
||||
}).wordsWithComputedWidth;
|
||||
var result = calculate(words);
|
||||
var doesOverflow = result.length > maxLines || findLongestLine(result).width > Number(lineWidth);
|
||||
return [doesOverflow, result];
|
||||
};
|
||||
var start = 0;
|
||||
var end = text.length - 1;
|
||||
var iterations = 0;
|
||||
var trimmedResult;
|
||||
while (start <= end && iterations <= text.length - 1) {
|
||||
var middle = Math.floor((start + end) / 2);
|
||||
var prev = middle - 1;
|
||||
var _checkOverflow = checkOverflow(prev),
|
||||
_checkOverflow2 = _slicedToArray(_checkOverflow, 2),
|
||||
doesPrevOverflow = _checkOverflow2[0],
|
||||
result = _checkOverflow2[1];
|
||||
var _checkOverflow3 = checkOverflow(middle),
|
||||
_checkOverflow4 = _slicedToArray(_checkOverflow3, 1),
|
||||
doesMiddleOverflow = _checkOverflow4[0];
|
||||
if (!doesPrevOverflow && !doesMiddleOverflow) {
|
||||
start = middle + 1;
|
||||
}
|
||||
if (doesPrevOverflow && doesMiddleOverflow) {
|
||||
end = middle - 1;
|
||||
}
|
||||
if (!doesPrevOverflow && doesMiddleOverflow) {
|
||||
trimmedResult = result;
|
||||
break;
|
||||
}
|
||||
iterations++;
|
||||
}
|
||||
|
||||
// Fallback to originalResult (result without trimming) if we cannot find the
|
||||
// where to trim. This should not happen :tm:
|
||||
return trimmedResult || originalResult;
|
||||
};
|
||||
var getWordsWithoutCalculate = function getWordsWithoutCalculate(children) {
|
||||
var words = !isNil(children) ? children.toString().split(BREAKING_SPACES) : [];
|
||||
return [{
|
||||
words: words
|
||||
}];
|
||||
};
|
||||
var getWordsByLines = function getWordsByLines(_ref4) {
|
||||
var width = _ref4.width,
|
||||
scaleToFit = _ref4.scaleToFit,
|
||||
children = _ref4.children,
|
||||
style = _ref4.style,
|
||||
breakAll = _ref4.breakAll,
|
||||
maxLines = _ref4.maxLines;
|
||||
// Only perform calculations if using features that require them (multiline, scaleToFit)
|
||||
if ((width || scaleToFit) && !Global.isSsr) {
|
||||
var wordsWithComputedWidth, spaceWidth;
|
||||
var wordWidths = calculateWordWidths({
|
||||
breakAll: breakAll,
|
||||
children: children,
|
||||
style: style
|
||||
});
|
||||
if (wordWidths) {
|
||||
var wcw = wordWidths.wordsWithComputedWidth,
|
||||
sw = wordWidths.spaceWidth;
|
||||
wordsWithComputedWidth = wcw;
|
||||
spaceWidth = sw;
|
||||
} else {
|
||||
return getWordsWithoutCalculate(children);
|
||||
}
|
||||
return calculateWordsByLines({
|
||||
breakAll: breakAll,
|
||||
children: children,
|
||||
maxLines: maxLines,
|
||||
style: style
|
||||
}, wordsWithComputedWidth, spaceWidth, width, scaleToFit);
|
||||
}
|
||||
return getWordsWithoutCalculate(children);
|
||||
};
|
||||
var DEFAULT_FILL = '#808080';
|
||||
export var Text = function Text(_ref5) {
|
||||
var _ref5$x = _ref5.x,
|
||||
propsX = _ref5$x === void 0 ? 0 : _ref5$x,
|
||||
_ref5$y = _ref5.y,
|
||||
propsY = _ref5$y === void 0 ? 0 : _ref5$y,
|
||||
_ref5$lineHeight = _ref5.lineHeight,
|
||||
lineHeight = _ref5$lineHeight === void 0 ? '1em' : _ref5$lineHeight,
|
||||
_ref5$capHeight = _ref5.capHeight,
|
||||
capHeight = _ref5$capHeight === void 0 ? '0.71em' : _ref5$capHeight,
|
||||
_ref5$scaleToFit = _ref5.scaleToFit,
|
||||
scaleToFit = _ref5$scaleToFit === void 0 ? false : _ref5$scaleToFit,
|
||||
_ref5$textAnchor = _ref5.textAnchor,
|
||||
textAnchor = _ref5$textAnchor === void 0 ? 'start' : _ref5$textAnchor,
|
||||
_ref5$verticalAnchor = _ref5.verticalAnchor,
|
||||
verticalAnchor = _ref5$verticalAnchor === void 0 ? 'end' : _ref5$verticalAnchor,
|
||||
_ref5$fill = _ref5.fill,
|
||||
fill = _ref5$fill === void 0 ? DEFAULT_FILL : _ref5$fill,
|
||||
props = _objectWithoutProperties(_ref5, _excluded);
|
||||
var wordsByLines = useMemo(function () {
|
||||
return getWordsByLines({
|
||||
breakAll: props.breakAll,
|
||||
children: props.children,
|
||||
maxLines: props.maxLines,
|
||||
scaleToFit: scaleToFit,
|
||||
style: props.style,
|
||||
width: props.width
|
||||
});
|
||||
}, [props.breakAll, props.children, props.maxLines, scaleToFit, props.style, props.width]);
|
||||
var dx = props.dx,
|
||||
dy = props.dy,
|
||||
angle = props.angle,
|
||||
className = props.className,
|
||||
breakAll = props.breakAll,
|
||||
textProps = _objectWithoutProperties(props, _excluded2);
|
||||
if (!isNumOrStr(propsX) || !isNumOrStr(propsY)) {
|
||||
return null;
|
||||
}
|
||||
var x = propsX + (isNumber(dx) ? dx : 0);
|
||||
var y = propsY + (isNumber(dy) ? dy : 0);
|
||||
var startDy;
|
||||
switch (verticalAnchor) {
|
||||
case 'start':
|
||||
startDy = reduceCSSCalc("calc(".concat(capHeight, ")"));
|
||||
break;
|
||||
case 'middle':
|
||||
startDy = reduceCSSCalc("calc(".concat((wordsByLines.length - 1) / 2, " * -").concat(lineHeight, " + (").concat(capHeight, " / 2))"));
|
||||
break;
|
||||
default:
|
||||
startDy = reduceCSSCalc("calc(".concat(wordsByLines.length - 1, " * -").concat(lineHeight, ")"));
|
||||
break;
|
||||
}
|
||||
var transforms = [];
|
||||
if (scaleToFit) {
|
||||
var lineWidth = wordsByLines[0].width;
|
||||
var width = props.width;
|
||||
transforms.push("scale(".concat((isNumber(width) ? width / lineWidth : 1) / lineWidth, ")"));
|
||||
}
|
||||
if (angle) {
|
||||
transforms.push("rotate(".concat(angle, ", ").concat(x, ", ").concat(y, ")"));
|
||||
}
|
||||
if (transforms.length) {
|
||||
textProps.transform = transforms.join(' ');
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("text", _extends({}, filterProps(textProps, true), {
|
||||
x: x,
|
||||
y: y,
|
||||
className: clsx('recharts-text', className),
|
||||
textAnchor: textAnchor,
|
||||
fill: fill.includes('url') ? DEFAULT_FILL : fill
|
||||
}), wordsByLines.map(function (line, index) {
|
||||
var words = line.words.join(breakAll ? '' : ' ');
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// duplicate words will cause duplicate keys
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
React.createElement("tspan", {
|
||||
x: x,
|
||||
dy: index === 0 ? startDy : lineHeight,
|
||||
key: "".concat(words, "-").concat(index)
|
||||
}, words)
|
||||
);
|
||||
}));
|
||||
};
|
||||
126
vendor/node_modules/recharts/es6/component/Tooltip.js
generated
vendored
Normal file
126
vendor/node_modules/recharts/es6/component/Tooltip.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Tooltip
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import { DefaultTooltipContent } from './DefaultTooltipContent';
|
||||
import { TooltipBoundingBox } from './TooltipBoundingBox';
|
||||
import { Global } from '../util/Global';
|
||||
import { getUniqPayload } from '../util/payload/getUniqPayload';
|
||||
function defaultUniqBy(entry) {
|
||||
return entry.dataKey;
|
||||
}
|
||||
function renderContent(content, props) {
|
||||
if ( /*#__PURE__*/React.isValidElement(content)) {
|
||||
return /*#__PURE__*/React.cloneElement(content, props);
|
||||
}
|
||||
if (typeof content === 'function') {
|
||||
return /*#__PURE__*/React.createElement(content, props);
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(DefaultTooltipContent, props);
|
||||
}
|
||||
export var Tooltip = /*#__PURE__*/function (_PureComponent) {
|
||||
function Tooltip() {
|
||||
_classCallCheck(this, Tooltip);
|
||||
return _callSuper(this, Tooltip, arguments);
|
||||
}
|
||||
_inherits(Tooltip, _PureComponent);
|
||||
return _createClass(Tooltip, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this = this;
|
||||
var _this$props = this.props,
|
||||
active = _this$props.active,
|
||||
allowEscapeViewBox = _this$props.allowEscapeViewBox,
|
||||
animationDuration = _this$props.animationDuration,
|
||||
animationEasing = _this$props.animationEasing,
|
||||
content = _this$props.content,
|
||||
coordinate = _this$props.coordinate,
|
||||
filterNull = _this$props.filterNull,
|
||||
isAnimationActive = _this$props.isAnimationActive,
|
||||
offset = _this$props.offset,
|
||||
payload = _this$props.payload,
|
||||
payloadUniqBy = _this$props.payloadUniqBy,
|
||||
position = _this$props.position,
|
||||
reverseDirection = _this$props.reverseDirection,
|
||||
useTranslate3d = _this$props.useTranslate3d,
|
||||
viewBox = _this$props.viewBox,
|
||||
wrapperStyle = _this$props.wrapperStyle;
|
||||
var finalPayload = payload !== null && payload !== void 0 ? payload : [];
|
||||
if (filterNull && finalPayload.length) {
|
||||
finalPayload = getUniqPayload(payload.filter(function (entry) {
|
||||
return entry.value != null && (entry.hide !== true || _this.props.includeHidden);
|
||||
}), payloadUniqBy, defaultUniqBy);
|
||||
}
|
||||
var hasPayload = finalPayload.length > 0;
|
||||
return /*#__PURE__*/React.createElement(TooltipBoundingBox, {
|
||||
allowEscapeViewBox: allowEscapeViewBox,
|
||||
animationDuration: animationDuration,
|
||||
animationEasing: animationEasing,
|
||||
isAnimationActive: isAnimationActive,
|
||||
active: active,
|
||||
coordinate: coordinate,
|
||||
hasPayload: hasPayload,
|
||||
offset: offset,
|
||||
position: position,
|
||||
reverseDirection: reverseDirection,
|
||||
useTranslate3d: useTranslate3d,
|
||||
viewBox: viewBox,
|
||||
wrapperStyle: wrapperStyle
|
||||
}, renderContent(content, _objectSpread(_objectSpread({}, this.props), {}, {
|
||||
payload: finalPayload
|
||||
})));
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(Tooltip, "displayName", 'Tooltip');
|
||||
_defineProperty(Tooltip, "defaultProps", {
|
||||
accessibilityLayer: false,
|
||||
allowEscapeViewBox: {
|
||||
x: false,
|
||||
y: false
|
||||
},
|
||||
animationDuration: 400,
|
||||
animationEasing: 'ease',
|
||||
contentStyle: {},
|
||||
coordinate: {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
cursor: true,
|
||||
cursorStyle: {},
|
||||
filterNull: true,
|
||||
isAnimationActive: !Global.isSsr,
|
||||
itemStyle: {},
|
||||
labelStyle: {},
|
||||
offset: 10,
|
||||
reverseDirection: {
|
||||
x: false,
|
||||
y: false
|
||||
},
|
||||
separator: ' : ',
|
||||
trigger: 'hover',
|
||||
useTranslate3d: false,
|
||||
viewBox: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
height: 0,
|
||||
width: 0
|
||||
},
|
||||
wrapperStyle: {}
|
||||
});
|
||||
156
vendor/node_modules/recharts/es6/component/TooltipBoundingBox.js
generated
vendored
Normal file
156
vendor/node_modules/recharts/es6/component/TooltipBoundingBox.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import React, { PureComponent } from 'react';
|
||||
import { getTooltipTranslate } from '../util/tooltip/translate';
|
||||
var EPSILON = 1;
|
||||
export var TooltipBoundingBox = /*#__PURE__*/function (_PureComponent) {
|
||||
function TooltipBoundingBox() {
|
||||
var _this;
|
||||
_classCallCheck(this, TooltipBoundingBox);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, TooltipBoundingBox, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
dismissed: false,
|
||||
dismissedAtCoordinate: {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
lastBoundingBox: {
|
||||
width: -1,
|
||||
height: -1
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleKeyDown", function (event) {
|
||||
if (event.key === 'Escape') {
|
||||
var _this$props$coordinat, _this$props$coordinat2, _this$props$coordinat3, _this$props$coordinat4;
|
||||
_this.setState({
|
||||
dismissed: true,
|
||||
dismissedAtCoordinate: {
|
||||
x: (_this$props$coordinat = (_this$props$coordinat2 = _this.props.coordinate) === null || _this$props$coordinat2 === void 0 ? void 0 : _this$props$coordinat2.x) !== null && _this$props$coordinat !== void 0 ? _this$props$coordinat : 0,
|
||||
y: (_this$props$coordinat3 = (_this$props$coordinat4 = _this.props.coordinate) === null || _this$props$coordinat4 === void 0 ? void 0 : _this$props$coordinat4.y) !== null && _this$props$coordinat3 !== void 0 ? _this$props$coordinat3 : 0
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_inherits(TooltipBoundingBox, _PureComponent);
|
||||
return _createClass(TooltipBoundingBox, [{
|
||||
key: "updateBBox",
|
||||
value: function updateBBox() {
|
||||
if (this.wrapperNode && this.wrapperNode.getBoundingClientRect) {
|
||||
var box = this.wrapperNode.getBoundingClientRect();
|
||||
if (Math.abs(box.width - this.state.lastBoundingBox.width) > EPSILON || Math.abs(box.height - this.state.lastBoundingBox.height) > EPSILON) {
|
||||
this.setState({
|
||||
lastBoundingBox: {
|
||||
width: box.width,
|
||||
height: box.height
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (this.state.lastBoundingBox.width !== -1 || this.state.lastBoundingBox.height !== -1) {
|
||||
this.setState({
|
||||
lastBoundingBox: {
|
||||
width: -1,
|
||||
height: -1
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
document.addEventListener('keydown', this.handleKeyDown);
|
||||
this.updateBBox();
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
document.removeEventListener('keydown', this.handleKeyDown);
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
var _this$props$coordinat5, _this$props$coordinat6;
|
||||
if (this.props.active) {
|
||||
this.updateBBox();
|
||||
}
|
||||
if (!this.state.dismissed) {
|
||||
return;
|
||||
}
|
||||
if (((_this$props$coordinat5 = this.props.coordinate) === null || _this$props$coordinat5 === void 0 ? void 0 : _this$props$coordinat5.x) !== this.state.dismissedAtCoordinate.x || ((_this$props$coordinat6 = this.props.coordinate) === null || _this$props$coordinat6 === void 0 ? void 0 : _this$props$coordinat6.y) !== this.state.dismissedAtCoordinate.y) {
|
||||
this.state.dismissed = false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
var _this$props = this.props,
|
||||
active = _this$props.active,
|
||||
allowEscapeViewBox = _this$props.allowEscapeViewBox,
|
||||
animationDuration = _this$props.animationDuration,
|
||||
animationEasing = _this$props.animationEasing,
|
||||
children = _this$props.children,
|
||||
coordinate = _this$props.coordinate,
|
||||
hasPayload = _this$props.hasPayload,
|
||||
isAnimationActive = _this$props.isAnimationActive,
|
||||
offset = _this$props.offset,
|
||||
position = _this$props.position,
|
||||
reverseDirection = _this$props.reverseDirection,
|
||||
useTranslate3d = _this$props.useTranslate3d,
|
||||
viewBox = _this$props.viewBox,
|
||||
wrapperStyle = _this$props.wrapperStyle;
|
||||
var _getTooltipTranslate = getTooltipTranslate({
|
||||
allowEscapeViewBox: allowEscapeViewBox,
|
||||
coordinate: coordinate,
|
||||
offsetTopLeft: offset,
|
||||
position: position,
|
||||
reverseDirection: reverseDirection,
|
||||
tooltipBox: this.state.lastBoundingBox,
|
||||
useTranslate3d: useTranslate3d,
|
||||
viewBox: viewBox
|
||||
}),
|
||||
cssClasses = _getTooltipTranslate.cssClasses,
|
||||
cssProperties = _getTooltipTranslate.cssProperties;
|
||||
var outerStyle = _objectSpread(_objectSpread({
|
||||
transition: isAnimationActive && active ? "transform ".concat(animationDuration, "ms ").concat(animationEasing) : undefined
|
||||
}, cssProperties), {}, {
|
||||
pointerEvents: 'none',
|
||||
visibility: !this.state.dismissed && active && hasPayload ? 'visible' : 'hidden',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0
|
||||
}, wrapperStyle);
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// This element allow listening to the `Escape` key.
|
||||
// See https://github.com/recharts/recharts/pull/2925
|
||||
React.createElement("div", {
|
||||
tabIndex: -1,
|
||||
className: cssClasses,
|
||||
style: outerStyle,
|
||||
ref: function ref(node) {
|
||||
_this2.wrapperNode = node;
|
||||
}
|
||||
}, children)
|
||||
);
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
18
vendor/node_modules/recharts/es6/container/Layer.js
generated
vendored
Normal file
18
vendor/node_modules/recharts/es6/container/Layer.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
var _excluded = ["children", "className"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
export var Layer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var children = props.children,
|
||||
className = props.className,
|
||||
others = _objectWithoutProperties(props, _excluded);
|
||||
var layerClass = clsx('recharts-layer', className);
|
||||
return /*#__PURE__*/React.createElement("g", _extends({
|
||||
className: layerClass
|
||||
}, filterProps(others, true), {
|
||||
ref: ref
|
||||
}), children);
|
||||
});
|
||||
35
vendor/node_modules/recharts/es6/container/Surface.js
generated
vendored
Normal file
35
vendor/node_modules/recharts/es6/container/Surface.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
var _excluded = ["children", "width", "height", "viewBox", "className", "style", "title", "desc"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
/**
|
||||
* @fileOverview Surface
|
||||
*/
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
export function Surface(props) {
|
||||
var children = props.children,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
viewBox = props.viewBox,
|
||||
className = props.className,
|
||||
style = props.style,
|
||||
title = props.title,
|
||||
desc = props.desc,
|
||||
others = _objectWithoutProperties(props, _excluded);
|
||||
var svgView = viewBox || {
|
||||
width: width,
|
||||
height: height,
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
var layerClass = clsx('recharts-surface', className);
|
||||
return /*#__PURE__*/React.createElement("svg", _extends({}, filterProps(others, true, 'svg'), {
|
||||
className: layerClass,
|
||||
width: width,
|
||||
height: height,
|
||||
style: style,
|
||||
viewBox: "".concat(svgView.x, " ").concat(svgView.y, " ").concat(svgView.width, " ").concat(svgView.height)
|
||||
}), /*#__PURE__*/React.createElement("title", null, title), /*#__PURE__*/React.createElement("desc", null, desc), children);
|
||||
}
|
||||
162
vendor/node_modules/recharts/es6/context/chartLayoutContext.js
generated
vendored
Normal file
162
vendor/node_modules/recharts/es6/context/chartLayoutContext.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import invariant from 'tiny-invariant';
|
||||
import find from 'lodash/find';
|
||||
import every from 'lodash/every';
|
||||
import { calculateViewBox } from '../util/calculateViewBox';
|
||||
import { getAnyElementOfObject } from '../util/DataUtils';
|
||||
export var XAxisContext = /*#__PURE__*/createContext(undefined);
|
||||
export var YAxisContext = /*#__PURE__*/createContext(undefined);
|
||||
export var ViewBoxContext = /*#__PURE__*/createContext(undefined);
|
||||
export var OffsetContext = /*#__PURE__*/createContext({});
|
||||
export var ClipPathIdContext = /*#__PURE__*/createContext(undefined);
|
||||
export var ChartHeightContext = /*#__PURE__*/createContext(0);
|
||||
export var ChartWidthContext = /*#__PURE__*/createContext(0);
|
||||
|
||||
/**
|
||||
* Will add all the properties required to render all individual Recharts components into a React Context.
|
||||
*
|
||||
* If you want to read these properties, see the collection of hooks exported from this file.
|
||||
*
|
||||
* @param {object} props CategoricalChartState, plus children
|
||||
* @returns {ReactElement} React Context Provider
|
||||
*/
|
||||
export var ChartLayoutContextProvider = function ChartLayoutContextProvider(props) {
|
||||
var _props$state = props.state,
|
||||
xAxisMap = _props$state.xAxisMap,
|
||||
yAxisMap = _props$state.yAxisMap,
|
||||
offset = _props$state.offset,
|
||||
clipPathId = props.clipPathId,
|
||||
children = props.children,
|
||||
width = props.width,
|
||||
height = props.height;
|
||||
|
||||
/**
|
||||
* Perhaps we should compute this property when reading? Let's see what is more often used
|
||||
*/
|
||||
var viewBox = calculateViewBox(offset);
|
||||
|
||||
/*
|
||||
* This pretends to be a single context but actually is split into multiple smaller ones.
|
||||
* Why?
|
||||
* Because one React Context only allows to set one value.
|
||||
* But we need to set multiple values.
|
||||
* If we do that with one context, then we force re-render on components that might not even be interested
|
||||
* in the part of the state that has changed.
|
||||
*
|
||||
* By splitting into smaller contexts, we allow each components to be optimized and only re-render when its dependencies change.
|
||||
*
|
||||
* To actually achieve the optimal re-render, it is necessary to use React.memo().
|
||||
* See the test file for details.
|
||||
*/
|
||||
return /*#__PURE__*/React.createElement(XAxisContext.Provider, {
|
||||
value: xAxisMap
|
||||
}, /*#__PURE__*/React.createElement(YAxisContext.Provider, {
|
||||
value: yAxisMap
|
||||
}, /*#__PURE__*/React.createElement(OffsetContext.Provider, {
|
||||
value: offset
|
||||
}, /*#__PURE__*/React.createElement(ViewBoxContext.Provider, {
|
||||
value: viewBox
|
||||
}, /*#__PURE__*/React.createElement(ClipPathIdContext.Provider, {
|
||||
value: clipPathId
|
||||
}, /*#__PURE__*/React.createElement(ChartHeightContext.Provider, {
|
||||
value: height
|
||||
}, /*#__PURE__*/React.createElement(ChartWidthContext.Provider, {
|
||||
value: width
|
||||
}, children)))))));
|
||||
};
|
||||
export var useClipPathId = function useClipPathId() {
|
||||
return useContext(ClipPathIdContext);
|
||||
};
|
||||
function getKeysForDebug(object) {
|
||||
var keys = Object.keys(object);
|
||||
if (keys.length === 0) {
|
||||
return 'There are no available ids.';
|
||||
}
|
||||
return "Available ids are: ".concat(keys, ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* This either finds and returns Axis by the specified ID, or throws an exception if an axis with this ID does not exist.
|
||||
*
|
||||
* @param xAxisId identifier of the axis - it's either autogenerated ('0'), or passed via `id` prop as <XAxis id='foo' />
|
||||
* @returns axis configuration object
|
||||
* @throws Error if no axis with this ID exists
|
||||
*/
|
||||
export var useXAxisOrThrow = function useXAxisOrThrow(xAxisId) {
|
||||
var xAxisMap = useContext(XAxisContext);
|
||||
!(xAxisMap != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find Recharts context; are you sure this is rendered inside a Recharts wrapper component?') : invariant(false) : void 0;
|
||||
var xAxis = xAxisMap[xAxisId];
|
||||
!(xAxis != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find xAxis by id \"".concat(xAxisId, "\" [").concat(_typeof(xAxisId), "]. ").concat(getKeysForDebug(xAxisMap))) : invariant(false) : void 0;
|
||||
return xAxis;
|
||||
};
|
||||
|
||||
/**
|
||||
* This will find an arbitrary first XAxis. If there's exactly one it always returns that one
|
||||
* - but if there are multiple then it can return any of those.
|
||||
*
|
||||
* If you want specific XAxis out of multiple then prefer using useXAxisOrThrow
|
||||
*
|
||||
* @returns X axisOptions, or undefined - if there are no X axes
|
||||
*/
|
||||
export var useArbitraryXAxis = function useArbitraryXAxis() {
|
||||
var xAxisMap = useContext(XAxisContext);
|
||||
return getAnyElementOfObject(xAxisMap);
|
||||
};
|
||||
|
||||
/**
|
||||
* This will find an arbitrary first YAxis. If there's exactly one it always returns that one
|
||||
* - but if there are multiple then it can return any of those.
|
||||
*
|
||||
* If you want specific YAxis out of multiple then prefer using useXAxisOrThrow
|
||||
*
|
||||
* @returns Y axisOptions, or undefined - if there are no Y axes
|
||||
*/
|
||||
export var useArbitraryYAxis = function useArbitraryYAxis() {
|
||||
var yAxisMap = useContext(YAxisContext);
|
||||
return getAnyElementOfObject(yAxisMap);
|
||||
};
|
||||
|
||||
/**
|
||||
* This hooks will:
|
||||
* 1st attempt to find an YAxis that has all elements in its domain finite
|
||||
* If no such axis exists, it will return an arbitrary YAxis
|
||||
* if there are no Y axes then it returns undefined
|
||||
*
|
||||
* @returns Either Y axisOptions, or undefined if there are no Y axes
|
||||
*/
|
||||
export var useYAxisWithFiniteDomainOrRandom = function useYAxisWithFiniteDomainOrRandom() {
|
||||
var yAxisMap = useContext(YAxisContext);
|
||||
var yAxisWithFiniteDomain = find(yAxisMap, function (axis) {
|
||||
return every(axis.domain, Number.isFinite);
|
||||
});
|
||||
return yAxisWithFiniteDomain || getAnyElementOfObject(yAxisMap);
|
||||
};
|
||||
|
||||
/**
|
||||
* This either finds and returns Axis by the specified ID, or throws an exception if an axis with this ID does not exist.
|
||||
*
|
||||
* @param yAxisId identifier of the axis - it's either autogenerated ('0'), or passed via `id` prop as <YAxis id='foo' />
|
||||
* @returns axis configuration object
|
||||
* @throws Error if no axis with this ID exists
|
||||
*/
|
||||
export var useYAxisOrThrow = function useYAxisOrThrow(yAxisId) {
|
||||
var yAxisMap = useContext(YAxisContext);
|
||||
!(yAxisMap != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find Recharts context; are you sure this is rendered inside a Recharts wrapper component?') : invariant(false) : void 0;
|
||||
var yAxis = yAxisMap[yAxisId];
|
||||
!(yAxis != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find yAxis by id \"".concat(yAxisId, "\" [").concat(_typeof(yAxisId), "]. ").concat(getKeysForDebug(yAxisMap))) : invariant(false) : void 0;
|
||||
return yAxis;
|
||||
};
|
||||
export var useViewBox = function useViewBox() {
|
||||
var viewBox = useContext(ViewBoxContext);
|
||||
return viewBox;
|
||||
};
|
||||
export var useOffset = function useOffset() {
|
||||
return useContext(OffsetContext);
|
||||
};
|
||||
export var useChartWidth = function useChartWidth() {
|
||||
return useContext(ChartWidthContext);
|
||||
};
|
||||
export var useChartHeight = function useChartHeight() {
|
||||
return useContext(ChartHeightContext);
|
||||
};
|
||||
553
vendor/node_modules/recharts/es6/polar/Pie.js
generated
vendored
Normal file
553
vendor/node_modules/recharts/es6/polar/Pie.js
generated
vendored
Normal file
@@ -0,0 +1,553 @@
|
||||
var _Pie;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Render sectors of a pie
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import Animate from 'react-smooth';
|
||||
import get from 'lodash/get';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { Text } from '../component/Text';
|
||||
import { Label } from '../component/Label';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { findAllByType, filterProps } from '../util/ReactUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { polarToCartesian, getMaxRadius } from '../util/PolarUtils';
|
||||
import { isNumber, getPercentValue, mathSign, interpolateNumber, uniqueId } from '../util/DataUtils';
|
||||
import { getValueByDataKey } from '../util/ChartUtils';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { Shape } from '../util/ActiveShapeUtils';
|
||||
export var Pie = /*#__PURE__*/function (_PureComponent) {
|
||||
function Pie(props) {
|
||||
var _this;
|
||||
_classCallCheck(this, Pie);
|
||||
_this = _callSuper(this, Pie, [props]);
|
||||
_defineProperty(_this, "pieRef", null);
|
||||
_defineProperty(_this, "sectorRefs", []);
|
||||
_defineProperty(_this, "id", uniqueId('recharts-pie-'));
|
||||
_defineProperty(_this, "handleAnimationEnd", function () {
|
||||
var onAnimationEnd = _this.props.onAnimationEnd;
|
||||
_this.setState({
|
||||
isAnimationFinished: true
|
||||
});
|
||||
if (isFunction(onAnimationEnd)) {
|
||||
onAnimationEnd();
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationStart", function () {
|
||||
var onAnimationStart = _this.props.onAnimationStart;
|
||||
_this.setState({
|
||||
isAnimationFinished: false
|
||||
});
|
||||
if (isFunction(onAnimationStart)) {
|
||||
onAnimationStart();
|
||||
}
|
||||
});
|
||||
_this.state = {
|
||||
isAnimationFinished: !props.isAnimationActive,
|
||||
prevIsAnimationActive: props.isAnimationActive,
|
||||
prevAnimationId: props.animationId,
|
||||
sectorToFocus: 0
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
_inherits(Pie, _PureComponent);
|
||||
return _createClass(Pie, [{
|
||||
key: "isActiveIndex",
|
||||
value: function isActiveIndex(i) {
|
||||
var activeIndex = this.props.activeIndex;
|
||||
if (Array.isArray(activeIndex)) {
|
||||
return activeIndex.indexOf(i) !== -1;
|
||||
}
|
||||
return i === activeIndex;
|
||||
}
|
||||
}, {
|
||||
key: "hasActiveIndex",
|
||||
value: function hasActiveIndex() {
|
||||
var activeIndex = this.props.activeIndex;
|
||||
return Array.isArray(activeIndex) ? activeIndex.length !== 0 : activeIndex || activeIndex === 0;
|
||||
}
|
||||
}, {
|
||||
key: "renderLabels",
|
||||
value: function renderLabels(sectors) {
|
||||
var isAnimationActive = this.props.isAnimationActive;
|
||||
if (isAnimationActive && !this.state.isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props = this.props,
|
||||
label = _this$props.label,
|
||||
labelLine = _this$props.labelLine,
|
||||
dataKey = _this$props.dataKey,
|
||||
valueKey = _this$props.valueKey;
|
||||
var pieProps = filterProps(this.props, false);
|
||||
var customLabelProps = filterProps(label, false);
|
||||
var customLabelLineProps = filterProps(labelLine, false);
|
||||
var offsetRadius = label && label.offsetRadius || 20;
|
||||
var labels = sectors.map(function (entry, i) {
|
||||
var midAngle = (entry.startAngle + entry.endAngle) / 2;
|
||||
var endPoint = polarToCartesian(entry.cx, entry.cy, entry.outerRadius + offsetRadius, midAngle);
|
||||
var labelProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
|
||||
stroke: 'none'
|
||||
}, customLabelProps), {}, {
|
||||
index: i,
|
||||
textAnchor: Pie.getTextAnchor(endPoint.x, entry.cx)
|
||||
}, endPoint);
|
||||
var lineProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
|
||||
fill: 'none',
|
||||
stroke: entry.fill
|
||||
}, customLabelLineProps), {}, {
|
||||
index: i,
|
||||
points: [polarToCartesian(entry.cx, entry.cy, entry.outerRadius, midAngle), endPoint]
|
||||
});
|
||||
var realDataKey = dataKey;
|
||||
// TODO: compatible to lower versions
|
||||
if (isNil(dataKey) && isNil(valueKey)) {
|
||||
realDataKey = 'value';
|
||||
} else if (isNil(dataKey)) {
|
||||
realDataKey = valueKey;
|
||||
}
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
React.createElement(Layer, {
|
||||
key: "label-".concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
|
||||
}, labelLine && Pie.renderLabelLineItem(labelLine, lineProps, 'line'), Pie.renderLabelItem(label, labelProps, getValueByDataKey(entry, realDataKey)))
|
||||
);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-pie-labels"
|
||||
}, labels);
|
||||
}
|
||||
}, {
|
||||
key: "renderSectorsStatically",
|
||||
value: function renderSectorsStatically(sectors) {
|
||||
var _this2 = this;
|
||||
var _this$props2 = this.props,
|
||||
activeShape = _this$props2.activeShape,
|
||||
blendStroke = _this$props2.blendStroke,
|
||||
inactiveShapeProp = _this$props2.inactiveShape;
|
||||
return sectors.map(function (entry, i) {
|
||||
if ((entry === null || entry === void 0 ? void 0 : entry.startAngle) === 0 && (entry === null || entry === void 0 ? void 0 : entry.endAngle) === 0 && sectors.length !== 1) return null;
|
||||
var isActive = _this2.isActiveIndex(i);
|
||||
var inactiveShape = inactiveShapeProp && _this2.hasActiveIndex() ? inactiveShapeProp : null;
|
||||
var sectorOptions = isActive ? activeShape : inactiveShape;
|
||||
var sectorProps = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
stroke: blendStroke ? entry.fill : entry.stroke,
|
||||
tabIndex: -1
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
ref: function ref(_ref) {
|
||||
if (_ref && !_this2.sectorRefs.includes(_ref)) {
|
||||
_this2.sectorRefs.push(_ref);
|
||||
}
|
||||
},
|
||||
tabIndex: -1,
|
||||
className: "recharts-pie-sector"
|
||||
}, adaptEventsOfChild(_this2.props, entry, i), {
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key: "sector-".concat(entry === null || entry === void 0 ? void 0 : entry.startAngle, "-").concat(entry === null || entry === void 0 ? void 0 : entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
|
||||
}), /*#__PURE__*/React.createElement(Shape, _extends({
|
||||
option: sectorOptions,
|
||||
isActive: isActive,
|
||||
shapeType: "sector"
|
||||
}, sectorProps)));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderSectorsWithAnimation",
|
||||
value: function renderSectorsWithAnimation() {
|
||||
var _this3 = this;
|
||||
var _this$props3 = this.props,
|
||||
sectors = _this$props3.sectors,
|
||||
isAnimationActive = _this$props3.isAnimationActive,
|
||||
animationBegin = _this$props3.animationBegin,
|
||||
animationDuration = _this$props3.animationDuration,
|
||||
animationEasing = _this$props3.animationEasing,
|
||||
animationId = _this$props3.animationId;
|
||||
var _this$state = this.state,
|
||||
prevSectors = _this$state.prevSectors,
|
||||
prevIsAnimationActive = _this$state.prevIsAnimationActive;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing,
|
||||
from: {
|
||||
t: 0
|
||||
},
|
||||
to: {
|
||||
t: 1
|
||||
},
|
||||
key: "pie-".concat(animationId, "-").concat(prevIsAnimationActive),
|
||||
onAnimationStart: this.handleAnimationStart,
|
||||
onAnimationEnd: this.handleAnimationEnd
|
||||
}, function (_ref2) {
|
||||
var t = _ref2.t;
|
||||
var stepData = [];
|
||||
var first = sectors && sectors[0];
|
||||
var curAngle = first.startAngle;
|
||||
sectors.forEach(function (entry, index) {
|
||||
var prev = prevSectors && prevSectors[index];
|
||||
var paddingAngle = index > 0 ? get(entry, 'paddingAngle', 0) : 0;
|
||||
if (prev) {
|
||||
var angleIp = interpolateNumber(prev.endAngle - prev.startAngle, entry.endAngle - entry.startAngle);
|
||||
var latest = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
startAngle: curAngle + paddingAngle,
|
||||
endAngle: curAngle + angleIp(t) + paddingAngle
|
||||
});
|
||||
stepData.push(latest);
|
||||
curAngle = latest.endAngle;
|
||||
} else {
|
||||
var endAngle = entry.endAngle,
|
||||
startAngle = entry.startAngle;
|
||||
var interpolatorAngle = interpolateNumber(0, endAngle - startAngle);
|
||||
var deltaAngle = interpolatorAngle(t);
|
||||
var _latest = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
startAngle: curAngle + paddingAngle,
|
||||
endAngle: curAngle + deltaAngle + paddingAngle
|
||||
});
|
||||
stepData.push(_latest);
|
||||
curAngle = _latest.endAngle;
|
||||
}
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, null, _this3.renderSectorsStatically(stepData));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "attachKeyboardHandlers",
|
||||
value: function attachKeyboardHandlers(pieRef) {
|
||||
var _this4 = this;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
pieRef.onkeydown = function (e) {
|
||||
if (!e.altKey) {
|
||||
switch (e.key) {
|
||||
case 'ArrowLeft':
|
||||
{
|
||||
var next = ++_this4.state.sectorToFocus % _this4.sectorRefs.length;
|
||||
_this4.sectorRefs[next].focus();
|
||||
_this4.setState({
|
||||
sectorToFocus: next
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'ArrowRight':
|
||||
{
|
||||
var _next = --_this4.state.sectorToFocus < 0 ? _this4.sectorRefs.length - 1 : _this4.state.sectorToFocus % _this4.sectorRefs.length;
|
||||
_this4.sectorRefs[_next].focus();
|
||||
_this4.setState({
|
||||
sectorToFocus: _next
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'Escape':
|
||||
{
|
||||
_this4.sectorRefs[_this4.state.sectorToFocus].blur();
|
||||
_this4.setState({
|
||||
sectorToFocus: 0
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// There is nothing to do here
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "renderSectors",
|
||||
value: function renderSectors() {
|
||||
var _this$props4 = this.props,
|
||||
sectors = _this$props4.sectors,
|
||||
isAnimationActive = _this$props4.isAnimationActive;
|
||||
var prevSectors = this.state.prevSectors;
|
||||
if (isAnimationActive && sectors && sectors.length && (!prevSectors || !isEqual(prevSectors, sectors))) {
|
||||
return this.renderSectorsWithAnimation();
|
||||
}
|
||||
return this.renderSectorsStatically(sectors);
|
||||
}
|
||||
}, {
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
if (this.pieRef) {
|
||||
this.attachKeyboardHandlers(this.pieRef);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this5 = this;
|
||||
var _this$props5 = this.props,
|
||||
hide = _this$props5.hide,
|
||||
sectors = _this$props5.sectors,
|
||||
className = _this$props5.className,
|
||||
label = _this$props5.label,
|
||||
cx = _this$props5.cx,
|
||||
cy = _this$props5.cy,
|
||||
innerRadius = _this$props5.innerRadius,
|
||||
outerRadius = _this$props5.outerRadius,
|
||||
isAnimationActive = _this$props5.isAnimationActive;
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
if (hide || !sectors || !sectors.length || !isNumber(cx) || !isNumber(cy) || !isNumber(innerRadius) || !isNumber(outerRadius)) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-pie', className);
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
tabIndex: this.props.rootTabIndex,
|
||||
className: layerClass,
|
||||
ref: function ref(_ref3) {
|
||||
_this5.pieRef = _ref3;
|
||||
}
|
||||
}, this.renderSectors(), label && this.renderLabels(sectors), Label.renderCallByParent(this.props, null, false), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, sectors, false));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (prevState.prevIsAnimationActive !== nextProps.isAnimationActive) {
|
||||
return {
|
||||
prevIsAnimationActive: nextProps.isAnimationActive,
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curSectors: nextProps.sectors,
|
||||
prevSectors: [],
|
||||
isAnimationFinished: true
|
||||
};
|
||||
}
|
||||
if (nextProps.isAnimationActive && nextProps.animationId !== prevState.prevAnimationId) {
|
||||
return {
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curSectors: nextProps.sectors,
|
||||
prevSectors: prevState.curSectors,
|
||||
isAnimationFinished: true
|
||||
};
|
||||
}
|
||||
if (nextProps.sectors !== prevState.curSectors) {
|
||||
return {
|
||||
curSectors: nextProps.sectors,
|
||||
isAnimationFinished: true
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "getTextAnchor",
|
||||
value: function getTextAnchor(x, cx) {
|
||||
if (x > cx) {
|
||||
return 'start';
|
||||
}
|
||||
if (x < cx) {
|
||||
return 'end';
|
||||
}
|
||||
return 'middle';
|
||||
}
|
||||
}, {
|
||||
key: "renderLabelLineItem",
|
||||
value: function renderLabelLineItem(option, props, key) {
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
return /*#__PURE__*/React.cloneElement(option, props);
|
||||
}
|
||||
if (isFunction(option)) {
|
||||
return option(props);
|
||||
}
|
||||
var className = clsx('recharts-pie-label-line', typeof option !== 'boolean' ? option.className : '');
|
||||
return /*#__PURE__*/React.createElement(Curve, _extends({}, props, {
|
||||
key: key,
|
||||
type: "linear",
|
||||
className: className
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderLabelItem",
|
||||
value: function renderLabelItem(option, props, value) {
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
return /*#__PURE__*/React.cloneElement(option, props);
|
||||
}
|
||||
var label = value;
|
||||
if (isFunction(option)) {
|
||||
label = option(props);
|
||||
if ( /*#__PURE__*/React.isValidElement(label)) {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
var className = clsx('recharts-pie-label-text', typeof option !== 'boolean' && !isFunction(option) ? option.className : '');
|
||||
return /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
alignmentBaseline: "middle",
|
||||
className: className
|
||||
}), label);
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_Pie = Pie;
|
||||
_defineProperty(Pie, "displayName", 'Pie');
|
||||
_defineProperty(Pie, "defaultProps", {
|
||||
stroke: '#fff',
|
||||
fill: '#808080',
|
||||
legendType: 'rect',
|
||||
cx: '50%',
|
||||
cy: '50%',
|
||||
startAngle: 0,
|
||||
endAngle: 360,
|
||||
innerRadius: 0,
|
||||
outerRadius: '80%',
|
||||
paddingAngle: 0,
|
||||
labelLine: true,
|
||||
hide: false,
|
||||
minAngle: 0,
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 400,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
nameKey: 'name',
|
||||
blendStroke: false,
|
||||
rootTabIndex: 0
|
||||
});
|
||||
_defineProperty(Pie, "parseDeltaAngle", function (startAngle, endAngle) {
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
|
||||
return sign * deltaAngle;
|
||||
});
|
||||
_defineProperty(Pie, "getRealPieData", function (itemProps) {
|
||||
var data = itemProps.data,
|
||||
children = itemProps.children;
|
||||
var presentationProps = filterProps(itemProps, false);
|
||||
var cells = findAllByType(children, Cell);
|
||||
if (data && data.length) {
|
||||
return data.map(function (entry, index) {
|
||||
return _objectSpread(_objectSpread(_objectSpread({
|
||||
payload: entry
|
||||
}, presentationProps), entry), cells && cells[index] && cells[index].props);
|
||||
});
|
||||
}
|
||||
if (cells && cells.length) {
|
||||
return cells.map(function (cell) {
|
||||
return _objectSpread(_objectSpread({}, presentationProps), cell.props);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
});
|
||||
_defineProperty(Pie, "parseCoordinateOfPie", function (itemProps, offset) {
|
||||
var top = offset.top,
|
||||
left = offset.left,
|
||||
width = offset.width,
|
||||
height = offset.height;
|
||||
var maxPieRadius = getMaxRadius(width, height);
|
||||
var cx = left + getPercentValue(itemProps.cx, width, width / 2);
|
||||
var cy = top + getPercentValue(itemProps.cy, height, height / 2);
|
||||
var innerRadius = getPercentValue(itemProps.innerRadius, maxPieRadius, 0);
|
||||
var outerRadius = getPercentValue(itemProps.outerRadius, maxPieRadius, maxPieRadius * 0.8);
|
||||
var maxRadius = itemProps.maxRadius || Math.sqrt(width * width + height * height) / 2;
|
||||
return {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
maxRadius: maxRadius
|
||||
};
|
||||
});
|
||||
_defineProperty(Pie, "getComposedData", function (_ref4) {
|
||||
var item = _ref4.item,
|
||||
offset = _ref4.offset;
|
||||
var itemProps = item.type.defaultProps !== undefined ? _objectSpread(_objectSpread({}, item.type.defaultProps), item.props) : item.props;
|
||||
var pieData = _Pie.getRealPieData(itemProps);
|
||||
if (!pieData || !pieData.length) {
|
||||
return null;
|
||||
}
|
||||
var cornerRadius = itemProps.cornerRadius,
|
||||
startAngle = itemProps.startAngle,
|
||||
endAngle = itemProps.endAngle,
|
||||
paddingAngle = itemProps.paddingAngle,
|
||||
dataKey = itemProps.dataKey,
|
||||
nameKey = itemProps.nameKey,
|
||||
valueKey = itemProps.valueKey,
|
||||
tooltipType = itemProps.tooltipType;
|
||||
var minAngle = Math.abs(itemProps.minAngle);
|
||||
var coordinate = _Pie.parseCoordinateOfPie(itemProps, offset);
|
||||
var deltaAngle = _Pie.parseDeltaAngle(startAngle, endAngle);
|
||||
var absDeltaAngle = Math.abs(deltaAngle);
|
||||
var realDataKey = dataKey;
|
||||
if (isNil(dataKey) && isNil(valueKey)) {
|
||||
warn(false, "Use \"dataKey\" to specify the value of pie,\n the props \"valueKey\" will be deprecated in 1.1.0");
|
||||
realDataKey = 'value';
|
||||
} else if (isNil(dataKey)) {
|
||||
warn(false, "Use \"dataKey\" to specify the value of pie,\n the props \"valueKey\" will be deprecated in 1.1.0");
|
||||
realDataKey = valueKey;
|
||||
}
|
||||
var notZeroItemCount = pieData.filter(function (entry) {
|
||||
return getValueByDataKey(entry, realDataKey, 0) !== 0;
|
||||
}).length;
|
||||
var totalPadingAngle = (absDeltaAngle >= 360 ? notZeroItemCount : notZeroItemCount - 1) * paddingAngle;
|
||||
var realTotalAngle = absDeltaAngle - notZeroItemCount * minAngle - totalPadingAngle;
|
||||
var sum = pieData.reduce(function (result, entry) {
|
||||
var val = getValueByDataKey(entry, realDataKey, 0);
|
||||
return result + (isNumber(val) ? val : 0);
|
||||
}, 0);
|
||||
var sectors;
|
||||
if (sum > 0) {
|
||||
var prev;
|
||||
sectors = pieData.map(function (entry, i) {
|
||||
var val = getValueByDataKey(entry, realDataKey, 0);
|
||||
var name = getValueByDataKey(entry, nameKey, i);
|
||||
var percent = (isNumber(val) ? val : 0) / sum;
|
||||
var tempStartAngle;
|
||||
if (i) {
|
||||
tempStartAngle = prev.endAngle + mathSign(deltaAngle) * paddingAngle * (val !== 0 ? 1 : 0);
|
||||
} else {
|
||||
tempStartAngle = startAngle;
|
||||
}
|
||||
var tempEndAngle = tempStartAngle + mathSign(deltaAngle) * ((val !== 0 ? minAngle : 0) + percent * realTotalAngle);
|
||||
var midAngle = (tempStartAngle + tempEndAngle) / 2;
|
||||
var middleRadius = (coordinate.innerRadius + coordinate.outerRadius) / 2;
|
||||
var tooltipPayload = [{
|
||||
name: name,
|
||||
value: val,
|
||||
payload: entry,
|
||||
dataKey: realDataKey,
|
||||
type: tooltipType
|
||||
}];
|
||||
var tooltipPosition = polarToCartesian(coordinate.cx, coordinate.cy, middleRadius, midAngle);
|
||||
prev = _objectSpread(_objectSpread(_objectSpread({
|
||||
percent: percent,
|
||||
cornerRadius: cornerRadius,
|
||||
name: name,
|
||||
tooltipPayload: tooltipPayload,
|
||||
midAngle: midAngle,
|
||||
middleRadius: middleRadius,
|
||||
tooltipPosition: tooltipPosition
|
||||
}, entry), coordinate), {}, {
|
||||
value: getValueByDataKey(entry, realDataKey),
|
||||
startAngle: tempStartAngle,
|
||||
endAngle: tempEndAngle,
|
||||
payload: entry,
|
||||
paddingAngle: mathSign(deltaAngle) * paddingAngle
|
||||
});
|
||||
return prev;
|
||||
});
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, coordinate), {}, {
|
||||
sectors: sectors,
|
||||
data: pieData
|
||||
});
|
||||
});
|
||||
204
vendor/node_modules/recharts/es6/polar/PolarAngleAxis.js
generated
vendored
Normal file
204
vendor/node_modules/recharts/es6/polar/PolarAngleAxis.js
generated
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Axis of radial direction
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Dot } from '../shape/Dot';
|
||||
import { Polygon } from '../shape/Polygon';
|
||||
import { Text } from '../component/Text';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { getTickClassName, polarToCartesian } from '../util/PolarUtils';
|
||||
var RADIAN = Math.PI / 180;
|
||||
var eps = 1e-5;
|
||||
export var PolarAngleAxis = /*#__PURE__*/function (_PureComponent) {
|
||||
function PolarAngleAxis() {
|
||||
_classCallCheck(this, PolarAngleAxis);
|
||||
return _callSuper(this, PolarAngleAxis, arguments);
|
||||
}
|
||||
_inherits(PolarAngleAxis, _PureComponent);
|
||||
return _createClass(PolarAngleAxis, [{
|
||||
key: "getTickLineCoord",
|
||||
value:
|
||||
/**
|
||||
* Calculate the coordinate of line endpoint
|
||||
* @param {Object} data The Data if ticks
|
||||
* @return {Object} (x0, y0): The start point of text,
|
||||
* (x1, y1): The end point close to text,
|
||||
* (x2, y2): The end point close to axis
|
||||
*/
|
||||
function getTickLineCoord(data) {
|
||||
var _this$props = this.props,
|
||||
cx = _this$props.cx,
|
||||
cy = _this$props.cy,
|
||||
radius = _this$props.radius,
|
||||
orientation = _this$props.orientation,
|
||||
tickSize = _this$props.tickSize;
|
||||
var tickLineSize = tickSize || 8;
|
||||
var p1 = polarToCartesian(cx, cy, radius, data.coordinate);
|
||||
var p2 = polarToCartesian(cx, cy, radius + (orientation === 'inner' ? -1 : 1) * tickLineSize, data.coordinate);
|
||||
return {
|
||||
x1: p1.x,
|
||||
y1: p1.y,
|
||||
x2: p2.x,
|
||||
y2: p2.y
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text-anchor of each tick
|
||||
* @param {Object} data Data of ticks
|
||||
* @return {String} text-anchor
|
||||
*/
|
||||
}, {
|
||||
key: "getTickTextAnchor",
|
||||
value: function getTickTextAnchor(data) {
|
||||
var orientation = this.props.orientation;
|
||||
var cos = Math.cos(-data.coordinate * RADIAN);
|
||||
var textAnchor;
|
||||
if (cos > eps) {
|
||||
textAnchor = orientation === 'outer' ? 'start' : 'end';
|
||||
} else if (cos < -eps) {
|
||||
textAnchor = orientation === 'outer' ? 'end' : 'start';
|
||||
} else {
|
||||
textAnchor = 'middle';
|
||||
}
|
||||
return textAnchor;
|
||||
}
|
||||
}, {
|
||||
key: "renderAxisLine",
|
||||
value: function renderAxisLine() {
|
||||
var _this$props2 = this.props,
|
||||
cx = _this$props2.cx,
|
||||
cy = _this$props2.cy,
|
||||
radius = _this$props2.radius,
|
||||
axisLine = _this$props2.axisLine,
|
||||
axisLineType = _this$props2.axisLineType;
|
||||
var props = _objectSpread(_objectSpread({}, filterProps(this.props, false)), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(axisLine, false));
|
||||
if (axisLineType === 'circle') {
|
||||
return /*#__PURE__*/React.createElement(Dot, _extends({
|
||||
className: "recharts-polar-angle-axis-line"
|
||||
}, props, {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r: radius
|
||||
}));
|
||||
}
|
||||
var ticks = this.props.ticks;
|
||||
var points = ticks.map(function (entry) {
|
||||
return polarToCartesian(cx, cy, radius, entry.coordinate);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Polygon, _extends({
|
||||
className: "recharts-polar-angle-axis-line"
|
||||
}, props, {
|
||||
points: points
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderTicks",
|
||||
value: function renderTicks() {
|
||||
var _this = this;
|
||||
var _this$props3 = this.props,
|
||||
ticks = _this$props3.ticks,
|
||||
tick = _this$props3.tick,
|
||||
tickLine = _this$props3.tickLine,
|
||||
tickFormatter = _this$props3.tickFormatter,
|
||||
stroke = _this$props3.stroke;
|
||||
var axisProps = filterProps(this.props, false);
|
||||
var customTickProps = filterProps(tick, false);
|
||||
var tickLineProps = _objectSpread(_objectSpread({}, axisProps), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(tickLine, false));
|
||||
var items = ticks.map(function (entry, i) {
|
||||
var lineCoord = _this.getTickLineCoord(entry);
|
||||
var textAnchor = _this.getTickTextAnchor(entry);
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread({
|
||||
textAnchor: textAnchor
|
||||
}, axisProps), {}, {
|
||||
stroke: 'none',
|
||||
fill: stroke
|
||||
}, customTickProps), {}, {
|
||||
index: i,
|
||||
payload: entry,
|
||||
x: lineCoord.x2,
|
||||
y: lineCoord.y2
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: clsx('recharts-polar-angle-axis-tick', getTickClassName(tick)),
|
||||
key: "tick-".concat(entry.coordinate)
|
||||
}, adaptEventsOfChild(_this.props, entry, i)), tickLine && /*#__PURE__*/React.createElement("line", _extends({
|
||||
className: "recharts-polar-angle-axis-tick-line"
|
||||
}, tickLineProps, lineCoord)), tick && PolarAngleAxis.renderTickItem(tick, tickProps, tickFormatter ? tickFormatter(entry.value, i) : entry.value));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-polar-angle-axis-ticks"
|
||||
}, items);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props4 = this.props,
|
||||
ticks = _this$props4.ticks,
|
||||
radius = _this$props4.radius,
|
||||
axisLine = _this$props4.axisLine;
|
||||
if (radius <= 0 || !ticks || !ticks.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-polar-angle-axis', this.props.className)
|
||||
}, axisLine && this.renderAxisLine(), this.renderTicks());
|
||||
}
|
||||
}], [{
|
||||
key: "renderTickItem",
|
||||
value: function renderTickItem(option, props, value) {
|
||||
var tickItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
tickItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
tickItem = option(props);
|
||||
} else {
|
||||
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
className: "recharts-polar-angle-axis-tick-value"
|
||||
}), value);
|
||||
}
|
||||
return tickItem;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(PolarAngleAxis, "displayName", 'PolarAngleAxis');
|
||||
_defineProperty(PolarAngleAxis, "axisType", 'angleAxis');
|
||||
_defineProperty(PolarAngleAxis, "defaultProps", {
|
||||
type: 'category',
|
||||
angleAxisId: 0,
|
||||
scale: 'auto',
|
||||
cx: 0,
|
||||
cy: 0,
|
||||
orientation: 'outer',
|
||||
axisLine: true,
|
||||
tickLine: true,
|
||||
tickSize: 8,
|
||||
tick: true,
|
||||
hide: false,
|
||||
allowDuplicatedCategory: true
|
||||
});
|
||||
209
vendor/node_modules/recharts/es6/polar/PolarRadiusAxis.js
generated
vendored
Normal file
209
vendor/node_modules/recharts/es6/polar/PolarRadiusAxis.js
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
var _excluded = ["cx", "cy", "angle", "ticks", "axisLine"],
|
||||
_excluded2 = ["ticks", "tick", "angle", "tickFormatter", "stroke"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview The axis of polar coordinate system
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import maxBy from 'lodash/maxBy';
|
||||
import minBy from 'lodash/minBy';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Text } from '../component/Text';
|
||||
import { Label } from '../component/Label';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { getTickClassName, polarToCartesian } from '../util/PolarUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
export var PolarRadiusAxis = /*#__PURE__*/function (_PureComponent) {
|
||||
function PolarRadiusAxis() {
|
||||
_classCallCheck(this, PolarRadiusAxis);
|
||||
return _callSuper(this, PolarRadiusAxis, arguments);
|
||||
}
|
||||
_inherits(PolarRadiusAxis, _PureComponent);
|
||||
return _createClass(PolarRadiusAxis, [{
|
||||
key: "getTickValueCoord",
|
||||
value:
|
||||
/**
|
||||
* Calculate the coordinate of tick
|
||||
* @param {Number} coordinate The radius of tick
|
||||
* @return {Object} (x, y)
|
||||
*/
|
||||
function getTickValueCoord(_ref) {
|
||||
var coordinate = _ref.coordinate;
|
||||
var _this$props = this.props,
|
||||
angle = _this$props.angle,
|
||||
cx = _this$props.cx,
|
||||
cy = _this$props.cy;
|
||||
return polarToCartesian(cx, cy, coordinate, angle);
|
||||
}
|
||||
}, {
|
||||
key: "getTickTextAnchor",
|
||||
value: function getTickTextAnchor() {
|
||||
var orientation = this.props.orientation;
|
||||
var textAnchor;
|
||||
switch (orientation) {
|
||||
case 'left':
|
||||
textAnchor = 'end';
|
||||
break;
|
||||
case 'right':
|
||||
textAnchor = 'start';
|
||||
break;
|
||||
default:
|
||||
textAnchor = 'middle';
|
||||
break;
|
||||
}
|
||||
return textAnchor;
|
||||
}
|
||||
}, {
|
||||
key: "getViewBox",
|
||||
value: function getViewBox() {
|
||||
var _this$props2 = this.props,
|
||||
cx = _this$props2.cx,
|
||||
cy = _this$props2.cy,
|
||||
angle = _this$props2.angle,
|
||||
ticks = _this$props2.ticks;
|
||||
var maxRadiusTick = maxBy(ticks, function (entry) {
|
||||
return entry.coordinate || 0;
|
||||
});
|
||||
var minRadiusTick = minBy(ticks, function (entry) {
|
||||
return entry.coordinate || 0;
|
||||
});
|
||||
return {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
startAngle: angle,
|
||||
endAngle: angle,
|
||||
innerRadius: minRadiusTick.coordinate || 0,
|
||||
outerRadius: maxRadiusTick.coordinate || 0
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "renderAxisLine",
|
||||
value: function renderAxisLine() {
|
||||
var _this$props3 = this.props,
|
||||
cx = _this$props3.cx,
|
||||
cy = _this$props3.cy,
|
||||
angle = _this$props3.angle,
|
||||
ticks = _this$props3.ticks,
|
||||
axisLine = _this$props3.axisLine,
|
||||
others = _objectWithoutProperties(_this$props3, _excluded);
|
||||
var extent = ticks.reduce(function (result, entry) {
|
||||
return [Math.min(result[0], entry.coordinate), Math.max(result[1], entry.coordinate)];
|
||||
}, [Infinity, -Infinity]);
|
||||
var point0 = polarToCartesian(cx, cy, extent[0], angle);
|
||||
var point1 = polarToCartesian(cx, cy, extent[1], angle);
|
||||
var props = _objectSpread(_objectSpread(_objectSpread({}, filterProps(others, false)), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(axisLine, false)), {}, {
|
||||
x1: point0.x,
|
||||
y1: point0.y,
|
||||
x2: point1.x,
|
||||
y2: point1.y
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("line", _extends({
|
||||
className: "recharts-polar-radius-axis-line"
|
||||
}, props));
|
||||
}
|
||||
}, {
|
||||
key: "renderTicks",
|
||||
value: function renderTicks() {
|
||||
var _this = this;
|
||||
var _this$props4 = this.props,
|
||||
ticks = _this$props4.ticks,
|
||||
tick = _this$props4.tick,
|
||||
angle = _this$props4.angle,
|
||||
tickFormatter = _this$props4.tickFormatter,
|
||||
stroke = _this$props4.stroke,
|
||||
others = _objectWithoutProperties(_this$props4, _excluded2);
|
||||
var textAnchor = this.getTickTextAnchor();
|
||||
var axisProps = filterProps(others, false);
|
||||
var customTickProps = filterProps(tick, false);
|
||||
var items = ticks.map(function (entry, i) {
|
||||
var coord = _this.getTickValueCoord(entry);
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
textAnchor: textAnchor,
|
||||
transform: "rotate(".concat(90 - angle, ", ").concat(coord.x, ", ").concat(coord.y, ")")
|
||||
}, axisProps), {}, {
|
||||
stroke: 'none',
|
||||
fill: stroke
|
||||
}, customTickProps), {}, {
|
||||
index: i
|
||||
}, coord), {}, {
|
||||
payload: entry
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: clsx('recharts-polar-radius-axis-tick', getTickClassName(tick)),
|
||||
key: "tick-".concat(entry.coordinate)
|
||||
}, adaptEventsOfChild(_this.props, entry, i)), PolarRadiusAxis.renderTickItem(tick, tickProps, tickFormatter ? tickFormatter(entry.value, i) : entry.value));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-polar-radius-axis-ticks"
|
||||
}, items);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props5 = this.props,
|
||||
ticks = _this$props5.ticks,
|
||||
axisLine = _this$props5.axisLine,
|
||||
tick = _this$props5.tick;
|
||||
if (!ticks || !ticks.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-polar-radius-axis', this.props.className)
|
||||
}, axisLine && this.renderAxisLine(), tick && this.renderTicks(), Label.renderCallByParent(this.props, this.getViewBox()));
|
||||
}
|
||||
}], [{
|
||||
key: "renderTickItem",
|
||||
value: function renderTickItem(option, props, value) {
|
||||
var tickItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
tickItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
tickItem = option(props);
|
||||
} else {
|
||||
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
className: "recharts-polar-radius-axis-tick-value"
|
||||
}), value);
|
||||
}
|
||||
return tickItem;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(PolarRadiusAxis, "displayName", 'PolarRadiusAxis');
|
||||
_defineProperty(PolarRadiusAxis, "axisType", 'radiusAxis');
|
||||
_defineProperty(PolarRadiusAxis, "defaultProps", {
|
||||
type: 'number',
|
||||
radiusAxisId: 0,
|
||||
cx: 0,
|
||||
cy: 0,
|
||||
angle: 0,
|
||||
orientation: 'right',
|
||||
stroke: '#ccc',
|
||||
axisLine: true,
|
||||
tick: true,
|
||||
tickCount: 5,
|
||||
allowDataOverflow: false,
|
||||
scale: 'auto',
|
||||
allowDuplicatedCategory: true
|
||||
});
|
||||
51
vendor/node_modules/recharts/es6/shape/Cross.js
generated
vendored
Normal file
51
vendor/node_modules/recharts/es6/shape/Cross.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
var _excluded = ["x", "y", "top", "left", "width", "height", "className"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
/**
|
||||
* @fileOverview Cross
|
||||
*/
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { isNumber } from '../util/DataUtils';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var getPath = function getPath(x, y, width, height, top, left) {
|
||||
return "M".concat(x, ",").concat(top, "v").concat(height, "M").concat(left, ",").concat(y, "h").concat(width);
|
||||
};
|
||||
export var Cross = function Cross(_ref) {
|
||||
var _ref$x = _ref.x,
|
||||
x = _ref$x === void 0 ? 0 : _ref$x,
|
||||
_ref$y = _ref.y,
|
||||
y = _ref$y === void 0 ? 0 : _ref$y,
|
||||
_ref$top = _ref.top,
|
||||
top = _ref$top === void 0 ? 0 : _ref$top,
|
||||
_ref$left = _ref.left,
|
||||
left = _ref$left === void 0 ? 0 : _ref$left,
|
||||
_ref$width = _ref.width,
|
||||
width = _ref$width === void 0 ? 0 : _ref$width,
|
||||
_ref$height = _ref.height,
|
||||
height = _ref$height === void 0 ? 0 : _ref$height,
|
||||
className = _ref.className,
|
||||
rest = _objectWithoutProperties(_ref, _excluded);
|
||||
var props = _objectSpread({
|
||||
x: x,
|
||||
y: y,
|
||||
top: top,
|
||||
left: left,
|
||||
width: width,
|
||||
height: height
|
||||
}, rest);
|
||||
if (!isNumber(x) || !isNumber(y) || !isNumber(width) || !isNumber(height) || !isNumber(top) || !isNumber(left)) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, filterProps(props, true), {
|
||||
className: clsx('recharts-cross', className),
|
||||
d: getPath(x, y, width, height, top, left)
|
||||
}));
|
||||
};
|
||||
116
vendor/node_modules/recharts/es6/shape/Curve.js
generated
vendored
Normal file
116
vendor/node_modules/recharts/es6/shape/Curve.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Curve
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import { line as shapeLine, area as shapeArea, curveBasisClosed, curveBasisOpen, curveBasis, curveBumpX, curveBumpY, curveLinearClosed, curveLinear, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore } from 'victory-vendor/d3-shape';
|
||||
import upperFirst from 'lodash/upperFirst';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { adaptEventHandlers } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { isNumber } from '../util/DataUtils';
|
||||
var CURVE_FACTORIES = {
|
||||
curveBasisClosed: curveBasisClosed,
|
||||
curveBasisOpen: curveBasisOpen,
|
||||
curveBasis: curveBasis,
|
||||
curveBumpX: curveBumpX,
|
||||
curveBumpY: curveBumpY,
|
||||
curveLinearClosed: curveLinearClosed,
|
||||
curveLinear: curveLinear,
|
||||
curveMonotoneX: curveMonotoneX,
|
||||
curveMonotoneY: curveMonotoneY,
|
||||
curveNatural: curveNatural,
|
||||
curveStep: curveStep,
|
||||
curveStepAfter: curveStepAfter,
|
||||
curveStepBefore: curveStepBefore
|
||||
};
|
||||
var defined = function defined(p) {
|
||||
return p.x === +p.x && p.y === +p.y;
|
||||
};
|
||||
var getX = function getX(p) {
|
||||
return p.x;
|
||||
};
|
||||
var getY = function getY(p) {
|
||||
return p.y;
|
||||
};
|
||||
var getCurveFactory = function getCurveFactory(type, layout) {
|
||||
if (isFunction(type)) {
|
||||
return type;
|
||||
}
|
||||
var name = "curve".concat(upperFirst(type));
|
||||
if ((name === 'curveMonotone' || name === 'curveBump') && layout) {
|
||||
return CURVE_FACTORIES["".concat(name).concat(layout === 'vertical' ? 'Y' : 'X')];
|
||||
}
|
||||
return CURVE_FACTORIES[name] || curveLinear;
|
||||
};
|
||||
/**
|
||||
* Calculate the path of curve. Returns null if points is an empty array.
|
||||
* @return path or null
|
||||
*/
|
||||
export var getPath = function getPath(_ref) {
|
||||
var _ref$type = _ref.type,
|
||||
type = _ref$type === void 0 ? 'linear' : _ref$type,
|
||||
_ref$points = _ref.points,
|
||||
points = _ref$points === void 0 ? [] : _ref$points,
|
||||
baseLine = _ref.baseLine,
|
||||
layout = _ref.layout,
|
||||
_ref$connectNulls = _ref.connectNulls,
|
||||
connectNulls = _ref$connectNulls === void 0 ? false : _ref$connectNulls;
|
||||
var curveFactory = getCurveFactory(type, layout);
|
||||
var formatPoints = connectNulls ? points.filter(function (entry) {
|
||||
return defined(entry);
|
||||
}) : points;
|
||||
var lineFunction;
|
||||
if (Array.isArray(baseLine)) {
|
||||
var formatBaseLine = connectNulls ? baseLine.filter(function (base) {
|
||||
return defined(base);
|
||||
}) : baseLine;
|
||||
var areaPoints = formatPoints.map(function (entry, index) {
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
base: formatBaseLine[index]
|
||||
});
|
||||
});
|
||||
if (layout === 'vertical') {
|
||||
lineFunction = shapeArea().y(getY).x1(getX).x0(function (d) {
|
||||
return d.base.x;
|
||||
});
|
||||
} else {
|
||||
lineFunction = shapeArea().x(getX).y1(getY).y0(function (d) {
|
||||
return d.base.y;
|
||||
});
|
||||
}
|
||||
lineFunction.defined(defined).curve(curveFactory);
|
||||
return lineFunction(areaPoints);
|
||||
}
|
||||
if (layout === 'vertical' && isNumber(baseLine)) {
|
||||
lineFunction = shapeArea().y(getY).x1(getX).x0(baseLine);
|
||||
} else if (isNumber(baseLine)) {
|
||||
lineFunction = shapeArea().x(getX).y1(getY).y0(baseLine);
|
||||
} else {
|
||||
lineFunction = shapeLine().x(getX).y(getY);
|
||||
}
|
||||
lineFunction.defined(defined).curve(curveFactory);
|
||||
return lineFunction(formatPoints);
|
||||
};
|
||||
export var Curve = function Curve(props) {
|
||||
var className = props.className,
|
||||
points = props.points,
|
||||
path = props.path,
|
||||
pathRef = props.pathRef;
|
||||
if ((!points || !points.length) && !path) {
|
||||
return null;
|
||||
}
|
||||
var realPath = points && points.length ? getPath(props) : path;
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, filterProps(props, false), adaptEventHandlers(props), {
|
||||
className: clsx('recharts-curve', className),
|
||||
d: realPath,
|
||||
ref: pathRef
|
||||
}));
|
||||
};
|
||||
24
vendor/node_modules/recharts/es6/shape/Dot.js
generated
vendored
Normal file
24
vendor/node_modules/recharts/es6/shape/Dot.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
/**
|
||||
* @fileOverview Dot
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { adaptEventHandlers } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
export var Dot = function Dot(props) {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
r = props.r,
|
||||
className = props.className;
|
||||
var layerClass = clsx('recharts-dot', className);
|
||||
if (cx === +cx && cy === +cy && r === +r) {
|
||||
return /*#__PURE__*/React.createElement("circle", _extends({}, filterProps(props, false), adaptEventHandlers(props), {
|
||||
className: layerClass,
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r: r
|
||||
}));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
90
vendor/node_modules/recharts/es6/shape/Polygon.js
generated
vendored
Normal file
90
vendor/node_modules/recharts/es6/shape/Polygon.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
var _excluded = ["points", "className", "baseLinePoints", "connectNulls"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
/**
|
||||
* @fileOverview Polygon
|
||||
*/
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var isValidatePoint = function isValidatePoint(point) {
|
||||
return point && point.x === +point.x && point.y === +point.y;
|
||||
};
|
||||
var getParsedPoints = function getParsedPoints() {
|
||||
var points = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var segmentPoints = [[]];
|
||||
points.forEach(function (entry) {
|
||||
if (isValidatePoint(entry)) {
|
||||
segmentPoints[segmentPoints.length - 1].push(entry);
|
||||
} else if (segmentPoints[segmentPoints.length - 1].length > 0) {
|
||||
// add another path
|
||||
segmentPoints.push([]);
|
||||
}
|
||||
});
|
||||
if (isValidatePoint(points[0])) {
|
||||
segmentPoints[segmentPoints.length - 1].push(points[0]);
|
||||
}
|
||||
if (segmentPoints[segmentPoints.length - 1].length <= 0) {
|
||||
segmentPoints = segmentPoints.slice(0, -1);
|
||||
}
|
||||
return segmentPoints;
|
||||
};
|
||||
var getSinglePolygonPath = function getSinglePolygonPath(points, connectNulls) {
|
||||
var segmentPoints = getParsedPoints(points);
|
||||
if (connectNulls) {
|
||||
segmentPoints = [segmentPoints.reduce(function (res, segPoints) {
|
||||
return [].concat(_toConsumableArray(res), _toConsumableArray(segPoints));
|
||||
}, [])];
|
||||
}
|
||||
var polygonPath = segmentPoints.map(function (segPoints) {
|
||||
return segPoints.reduce(function (path, point, index) {
|
||||
return "".concat(path).concat(index === 0 ? 'M' : 'L').concat(point.x, ",").concat(point.y);
|
||||
}, '');
|
||||
}).join('');
|
||||
return segmentPoints.length === 1 ? "".concat(polygonPath, "Z") : polygonPath;
|
||||
};
|
||||
var getRanglePath = function getRanglePath(points, baseLinePoints, connectNulls) {
|
||||
var outerPath = getSinglePolygonPath(points, connectNulls);
|
||||
return "".concat(outerPath.slice(-1) === 'Z' ? outerPath.slice(0, -1) : outerPath, "L").concat(getSinglePolygonPath(baseLinePoints.reverse(), connectNulls).slice(1));
|
||||
};
|
||||
export var Polygon = function Polygon(props) {
|
||||
var points = props.points,
|
||||
className = props.className,
|
||||
baseLinePoints = props.baseLinePoints,
|
||||
connectNulls = props.connectNulls,
|
||||
others = _objectWithoutProperties(props, _excluded);
|
||||
if (!points || !points.length) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-polygon', className);
|
||||
if (baseLinePoints && baseLinePoints.length) {
|
||||
var hasStroke = others.stroke && others.stroke !== 'none';
|
||||
var rangePath = getRanglePath(points, baseLinePoints, connectNulls);
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: layerClass
|
||||
}, /*#__PURE__*/React.createElement("path", _extends({}, filterProps(others, true), {
|
||||
fill: rangePath.slice(-1) === 'Z' ? others.fill : 'none',
|
||||
stroke: "none",
|
||||
d: rangePath
|
||||
})), hasStroke ? /*#__PURE__*/React.createElement("path", _extends({}, filterProps(others, true), {
|
||||
fill: "none",
|
||||
d: getSinglePolygonPath(points, connectNulls)
|
||||
})) : null, hasStroke ? /*#__PURE__*/React.createElement("path", _extends({}, filterProps(others, true), {
|
||||
fill: "none",
|
||||
d: getSinglePolygonPath(baseLinePoints, connectNulls)
|
||||
})) : null);
|
||||
}
|
||||
var singlePath = getSinglePolygonPath(points, connectNulls);
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, filterProps(others, true), {
|
||||
fill: singlePath.slice(-1) === 'Z' ? others.fill : 'none',
|
||||
className: layerClass,
|
||||
d: singlePath
|
||||
}));
|
||||
};
|
||||
168
vendor/node_modules/recharts/es6/shape/Rectangle.js
generated
vendored
Normal file
168
vendor/node_modules/recharts/es6/shape/Rectangle.js
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Rectangle
|
||||
*/
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import Animate from 'react-smooth';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var getRectanglePath = function getRectanglePath(x, y, width, height, radius) {
|
||||
var maxRadius = Math.min(Math.abs(width) / 2, Math.abs(height) / 2);
|
||||
var ySign = height >= 0 ? 1 : -1;
|
||||
var xSign = width >= 0 ? 1 : -1;
|
||||
var clockWise = height >= 0 && width >= 0 || height < 0 && width < 0 ? 1 : 0;
|
||||
var path;
|
||||
if (maxRadius > 0 && radius instanceof Array) {
|
||||
var newRadius = [0, 0, 0, 0];
|
||||
for (var i = 0, len = 4; i < len; i++) {
|
||||
newRadius[i] = radius[i] > maxRadius ? maxRadius : radius[i];
|
||||
}
|
||||
path = "M".concat(x, ",").concat(y + ySign * newRadius[0]);
|
||||
if (newRadius[0] > 0) {
|
||||
path += "A ".concat(newRadius[0], ",").concat(newRadius[0], ",0,0,").concat(clockWise, ",").concat(x + xSign * newRadius[0], ",").concat(y);
|
||||
}
|
||||
path += "L ".concat(x + width - xSign * newRadius[1], ",").concat(y);
|
||||
if (newRadius[1] > 0) {
|
||||
path += "A ".concat(newRadius[1], ",").concat(newRadius[1], ",0,0,").concat(clockWise, ",\n ").concat(x + width, ",").concat(y + ySign * newRadius[1]);
|
||||
}
|
||||
path += "L ".concat(x + width, ",").concat(y + height - ySign * newRadius[2]);
|
||||
if (newRadius[2] > 0) {
|
||||
path += "A ".concat(newRadius[2], ",").concat(newRadius[2], ",0,0,").concat(clockWise, ",\n ").concat(x + width - xSign * newRadius[2], ",").concat(y + height);
|
||||
}
|
||||
path += "L ".concat(x + xSign * newRadius[3], ",").concat(y + height);
|
||||
if (newRadius[3] > 0) {
|
||||
path += "A ".concat(newRadius[3], ",").concat(newRadius[3], ",0,0,").concat(clockWise, ",\n ").concat(x, ",").concat(y + height - ySign * newRadius[3]);
|
||||
}
|
||||
path += 'Z';
|
||||
} else if (maxRadius > 0 && radius === +radius && radius > 0) {
|
||||
var _newRadius = Math.min(maxRadius, radius);
|
||||
path = "M ".concat(x, ",").concat(y + ySign * _newRadius, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x + xSign * _newRadius, ",").concat(y, "\n L ").concat(x + width - xSign * _newRadius, ",").concat(y, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x + width, ",").concat(y + ySign * _newRadius, "\n L ").concat(x + width, ",").concat(y + height - ySign * _newRadius, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x + width - xSign * _newRadius, ",").concat(y + height, "\n L ").concat(x + xSign * _newRadius, ",").concat(y + height, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x, ",").concat(y + height - ySign * _newRadius, " Z");
|
||||
} else {
|
||||
path = "M ".concat(x, ",").concat(y, " h ").concat(width, " v ").concat(height, " h ").concat(-width, " Z");
|
||||
}
|
||||
return path;
|
||||
};
|
||||
export var isInRectangle = function isInRectangle(point, rect) {
|
||||
if (!point || !rect) {
|
||||
return false;
|
||||
}
|
||||
var px = point.x,
|
||||
py = point.y;
|
||||
var x = rect.x,
|
||||
y = rect.y,
|
||||
width = rect.width,
|
||||
height = rect.height;
|
||||
if (Math.abs(width) > 0 && Math.abs(height) > 0) {
|
||||
var minX = Math.min(x, x + width);
|
||||
var maxX = Math.max(x, x + width);
|
||||
var minY = Math.min(y, y + height);
|
||||
var maxY = Math.max(y, y + height);
|
||||
return px >= minX && px <= maxX && py >= minY && py <= maxY;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
var defaultProps = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
// The radius of border
|
||||
// The radius of four corners when radius is a number
|
||||
// The radius of left-top, right-top, right-bottom, left-bottom when radius is an array
|
||||
radius: 0,
|
||||
isAnimationActive: false,
|
||||
isUpdateAnimationActive: false,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease'
|
||||
};
|
||||
export var Rectangle = function Rectangle(rectangleProps) {
|
||||
var props = _objectSpread(_objectSpread({}, defaultProps), rectangleProps);
|
||||
var pathRef = useRef();
|
||||
var _useState = useState(-1),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
totalLength = _useState2[0],
|
||||
setTotalLength = _useState2[1];
|
||||
useEffect(function () {
|
||||
if (pathRef.current && pathRef.current.getTotalLength) {
|
||||
try {
|
||||
var pathTotalLength = pathRef.current.getTotalLength();
|
||||
if (pathTotalLength) {
|
||||
setTotalLength(pathTotalLength);
|
||||
}
|
||||
} catch (err) {
|
||||
// calculate total length error
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
var x = props.x,
|
||||
y = props.y,
|
||||
width = props.width,
|
||||
height = props.height,
|
||||
radius = props.radius,
|
||||
className = props.className;
|
||||
var animationEasing = props.animationEasing,
|
||||
animationDuration = props.animationDuration,
|
||||
animationBegin = props.animationBegin,
|
||||
isAnimationActive = props.isAnimationActive,
|
||||
isUpdateAnimationActive = props.isUpdateAnimationActive;
|
||||
if (x !== +x || y !== +y || width !== +width || height !== +height || width === 0 || height === 0) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-rectangle', className);
|
||||
if (!isUpdateAnimationActive) {
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, filterProps(props, true), {
|
||||
className: layerClass,
|
||||
d: getRectanglePath(x, y, width, height, radius)
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
canBegin: totalLength > 0,
|
||||
from: {
|
||||
width: width,
|
||||
height: height,
|
||||
x: x,
|
||||
y: y
|
||||
},
|
||||
to: {
|
||||
width: width,
|
||||
height: height,
|
||||
x: x,
|
||||
y: y
|
||||
},
|
||||
duration: animationDuration,
|
||||
animationEasing: animationEasing,
|
||||
isActive: isUpdateAnimationActive
|
||||
}, function (_ref) {
|
||||
var currWidth = _ref.width,
|
||||
currHeight = _ref.height,
|
||||
currX = _ref.x,
|
||||
currY = _ref.y;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
canBegin: totalLength > 0,
|
||||
from: "0px ".concat(totalLength === -1 ? 1 : totalLength, "px"),
|
||||
to: "".concat(totalLength, "px 0px"),
|
||||
attributeName: "strokeDasharray",
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing
|
||||
}, /*#__PURE__*/React.createElement("path", _extends({}, filterProps(props, true), {
|
||||
className: layerClass,
|
||||
d: getRectanglePath(currX, currY, currWidth, currHeight, radius),
|
||||
ref: pathRef
|
||||
})));
|
||||
});
|
||||
};
|
||||
213
vendor/node_modules/recharts/es6/shape/Sector.js
generated
vendored
Normal file
213
vendor/node_modules/recharts/es6/shape/Sector.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Sector
|
||||
*/
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { polarToCartesian, RADIAN } from '../util/PolarUtils';
|
||||
import { getPercentValue, mathSign } from '../util/DataUtils';
|
||||
var getDeltaAngle = function getDeltaAngle(startAngle, endAngle) {
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 359.999);
|
||||
return sign * deltaAngle;
|
||||
};
|
||||
var getTangentCircle = function getTangentCircle(_ref) {
|
||||
var cx = _ref.cx,
|
||||
cy = _ref.cy,
|
||||
radius = _ref.radius,
|
||||
angle = _ref.angle,
|
||||
sign = _ref.sign,
|
||||
isExternal = _ref.isExternal,
|
||||
cornerRadius = _ref.cornerRadius,
|
||||
cornerIsExternal = _ref.cornerIsExternal;
|
||||
var centerRadius = cornerRadius * (isExternal ? 1 : -1) + radius;
|
||||
var theta = Math.asin(cornerRadius / centerRadius) / RADIAN;
|
||||
var centerAngle = cornerIsExternal ? angle : angle + sign * theta;
|
||||
var center = polarToCartesian(cx, cy, centerRadius, centerAngle);
|
||||
// The coordinate of point which is tangent to the circle
|
||||
var circleTangency = polarToCartesian(cx, cy, radius, centerAngle);
|
||||
// The coordinate of point which is tangent to the radius line
|
||||
var lineTangencyAngle = cornerIsExternal ? angle - sign * theta : angle;
|
||||
var lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN), lineTangencyAngle);
|
||||
return {
|
||||
center: center,
|
||||
circleTangency: circleTangency,
|
||||
lineTangency: lineTangency,
|
||||
theta: theta
|
||||
};
|
||||
};
|
||||
var getSectorPath = function getSectorPath(_ref2) {
|
||||
var cx = _ref2.cx,
|
||||
cy = _ref2.cy,
|
||||
innerRadius = _ref2.innerRadius,
|
||||
outerRadius = _ref2.outerRadius,
|
||||
startAngle = _ref2.startAngle,
|
||||
endAngle = _ref2.endAngle;
|
||||
var angle = getDeltaAngle(startAngle, endAngle);
|
||||
|
||||
// When the angle of sector equals to 360, star point and end point coincide
|
||||
var tempEndAngle = startAngle + angle;
|
||||
var outerStartPoint = polarToCartesian(cx, cy, outerRadius, startAngle);
|
||||
var outerEndPoint = polarToCartesian(cx, cy, outerRadius, tempEndAngle);
|
||||
var path = "M ".concat(outerStartPoint.x, ",").concat(outerStartPoint.y, "\n A ").concat(outerRadius, ",").concat(outerRadius, ",0,\n ").concat(+(Math.abs(angle) > 180), ",").concat(+(startAngle > tempEndAngle), ",\n ").concat(outerEndPoint.x, ",").concat(outerEndPoint.y, "\n ");
|
||||
if (innerRadius > 0) {
|
||||
var innerStartPoint = polarToCartesian(cx, cy, innerRadius, startAngle);
|
||||
var innerEndPoint = polarToCartesian(cx, cy, innerRadius, tempEndAngle);
|
||||
path += "L ".concat(innerEndPoint.x, ",").concat(innerEndPoint.y, "\n A ").concat(innerRadius, ",").concat(innerRadius, ",0,\n ").concat(+(Math.abs(angle) > 180), ",").concat(+(startAngle <= tempEndAngle), ",\n ").concat(innerStartPoint.x, ",").concat(innerStartPoint.y, " Z");
|
||||
} else {
|
||||
path += "L ".concat(cx, ",").concat(cy, " Z");
|
||||
}
|
||||
return path;
|
||||
};
|
||||
var getSectorWithCorner = function getSectorWithCorner(_ref3) {
|
||||
var cx = _ref3.cx,
|
||||
cy = _ref3.cy,
|
||||
innerRadius = _ref3.innerRadius,
|
||||
outerRadius = _ref3.outerRadius,
|
||||
cornerRadius = _ref3.cornerRadius,
|
||||
forceCornerRadius = _ref3.forceCornerRadius,
|
||||
cornerIsExternal = _ref3.cornerIsExternal,
|
||||
startAngle = _ref3.startAngle,
|
||||
endAngle = _ref3.endAngle;
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var _getTangentCircle = getTangentCircle({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
radius: outerRadius,
|
||||
angle: startAngle,
|
||||
sign: sign,
|
||||
cornerRadius: cornerRadius,
|
||||
cornerIsExternal: cornerIsExternal
|
||||
}),
|
||||
soct = _getTangentCircle.circleTangency,
|
||||
solt = _getTangentCircle.lineTangency,
|
||||
sot = _getTangentCircle.theta;
|
||||
var _getTangentCircle2 = getTangentCircle({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
radius: outerRadius,
|
||||
angle: endAngle,
|
||||
sign: -sign,
|
||||
cornerRadius: cornerRadius,
|
||||
cornerIsExternal: cornerIsExternal
|
||||
}),
|
||||
eoct = _getTangentCircle2.circleTangency,
|
||||
eolt = _getTangentCircle2.lineTangency,
|
||||
eot = _getTangentCircle2.theta;
|
||||
var outerArcAngle = cornerIsExternal ? Math.abs(startAngle - endAngle) : Math.abs(startAngle - endAngle) - sot - eot;
|
||||
if (outerArcAngle < 0) {
|
||||
if (forceCornerRadius) {
|
||||
return "M ".concat(solt.x, ",").concat(solt.y, "\n a").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,1,").concat(cornerRadius * 2, ",0\n a").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,1,").concat(-cornerRadius * 2, ",0\n ");
|
||||
}
|
||||
return getSectorPath({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle
|
||||
});
|
||||
}
|
||||
var path = "M ".concat(solt.x, ",").concat(solt.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(soct.x, ",").concat(soct.y, "\n A").concat(outerRadius, ",").concat(outerRadius, ",0,").concat(+(outerArcAngle > 180), ",").concat(+(sign < 0), ",").concat(eoct.x, ",").concat(eoct.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(eolt.x, ",").concat(eolt.y, "\n ");
|
||||
if (innerRadius > 0) {
|
||||
var _getTangentCircle3 = getTangentCircle({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
radius: innerRadius,
|
||||
angle: startAngle,
|
||||
sign: sign,
|
||||
isExternal: true,
|
||||
cornerRadius: cornerRadius,
|
||||
cornerIsExternal: cornerIsExternal
|
||||
}),
|
||||
sict = _getTangentCircle3.circleTangency,
|
||||
silt = _getTangentCircle3.lineTangency,
|
||||
sit = _getTangentCircle3.theta;
|
||||
var _getTangentCircle4 = getTangentCircle({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
radius: innerRadius,
|
||||
angle: endAngle,
|
||||
sign: -sign,
|
||||
isExternal: true,
|
||||
cornerRadius: cornerRadius,
|
||||
cornerIsExternal: cornerIsExternal
|
||||
}),
|
||||
eict = _getTangentCircle4.circleTangency,
|
||||
eilt = _getTangentCircle4.lineTangency,
|
||||
eit = _getTangentCircle4.theta;
|
||||
var innerArcAngle = cornerIsExternal ? Math.abs(startAngle - endAngle) : Math.abs(startAngle - endAngle) - sit - eit;
|
||||
if (innerArcAngle < 0 && cornerRadius === 0) {
|
||||
return "".concat(path, "L").concat(cx, ",").concat(cy, "Z");
|
||||
}
|
||||
path += "L".concat(eilt.x, ",").concat(eilt.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(eict.x, ",").concat(eict.y, "\n A").concat(innerRadius, ",").concat(innerRadius, ",0,").concat(+(innerArcAngle > 180), ",").concat(+(sign > 0), ",").concat(sict.x, ",").concat(sict.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(silt.x, ",").concat(silt.y, "Z");
|
||||
} else {
|
||||
path += "L".concat(cx, ",").concat(cy, "Z");
|
||||
}
|
||||
return path;
|
||||
};
|
||||
var defaultProps = {
|
||||
cx: 0,
|
||||
cy: 0,
|
||||
innerRadius: 0,
|
||||
outerRadius: 0,
|
||||
startAngle: 0,
|
||||
endAngle: 0,
|
||||
cornerRadius: 0,
|
||||
forceCornerRadius: false,
|
||||
cornerIsExternal: false
|
||||
};
|
||||
export var Sector = function Sector(sectorProps) {
|
||||
var props = _objectSpread(_objectSpread({}, defaultProps), sectorProps);
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
innerRadius = props.innerRadius,
|
||||
outerRadius = props.outerRadius,
|
||||
cornerRadius = props.cornerRadius,
|
||||
forceCornerRadius = props.forceCornerRadius,
|
||||
cornerIsExternal = props.cornerIsExternal,
|
||||
startAngle = props.startAngle,
|
||||
endAngle = props.endAngle,
|
||||
className = props.className;
|
||||
if (outerRadius < innerRadius || startAngle === endAngle) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-sector', className);
|
||||
var deltaRadius = outerRadius - innerRadius;
|
||||
var cr = getPercentValue(cornerRadius, deltaRadius, 0, true);
|
||||
var path;
|
||||
if (cr > 0 && Math.abs(startAngle - endAngle) < 360) {
|
||||
path = getSectorWithCorner({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
cornerRadius: Math.min(cr, deltaRadius / 2),
|
||||
forceCornerRadius: forceCornerRadius,
|
||||
cornerIsExternal: cornerIsExternal,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle
|
||||
});
|
||||
} else {
|
||||
path = getSectorPath({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, filterProps(props, true), {
|
||||
className: layerClass,
|
||||
d: path,
|
||||
role: "img"
|
||||
}));
|
||||
};
|
||||
96
vendor/node_modules/recharts/es6/shape/Symbols.js
generated
vendored
Normal file
96
vendor/node_modules/recharts/es6/shape/Symbols.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
var _excluded = ["type", "size", "sizeType"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
/**
|
||||
* @fileOverview Curve
|
||||
*/
|
||||
import React from 'react';
|
||||
import upperFirst from 'lodash/upperFirst';
|
||||
import { symbol as shapeSymbol, symbolCircle, symbolCross, symbolDiamond, symbolSquare, symbolStar, symbolTriangle, symbolWye } from 'victory-vendor/d3-shape';
|
||||
import clsx from 'clsx';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var symbolFactories = {
|
||||
symbolCircle: symbolCircle,
|
||||
symbolCross: symbolCross,
|
||||
symbolDiamond: symbolDiamond,
|
||||
symbolSquare: symbolSquare,
|
||||
symbolStar: symbolStar,
|
||||
symbolTriangle: symbolTriangle,
|
||||
symbolWye: symbolWye
|
||||
};
|
||||
var RADIAN = Math.PI / 180;
|
||||
var getSymbolFactory = function getSymbolFactory(type) {
|
||||
var name = "symbol".concat(upperFirst(type));
|
||||
return symbolFactories[name] || symbolCircle;
|
||||
};
|
||||
var calculateAreaSize = function calculateAreaSize(size, sizeType, type) {
|
||||
if (sizeType === 'area') {
|
||||
return size;
|
||||
}
|
||||
switch (type) {
|
||||
case 'cross':
|
||||
return 5 * size * size / 9;
|
||||
case 'diamond':
|
||||
return 0.5 * size * size / Math.sqrt(3);
|
||||
case 'square':
|
||||
return size * size;
|
||||
case 'star':
|
||||
{
|
||||
var angle = 18 * RADIAN;
|
||||
return 1.25 * size * size * (Math.tan(angle) - Math.tan(angle * 2) * Math.pow(Math.tan(angle), 2));
|
||||
}
|
||||
case 'triangle':
|
||||
return Math.sqrt(3) * size * size / 4;
|
||||
case 'wye':
|
||||
return (21 - 10 * Math.sqrt(3)) * size * size / 8;
|
||||
default:
|
||||
return Math.PI * size * size / 4;
|
||||
}
|
||||
};
|
||||
var registerSymbol = function registerSymbol(key, factory) {
|
||||
symbolFactories["symbol".concat(upperFirst(key))] = factory;
|
||||
};
|
||||
export var Symbols = function Symbols(_ref) {
|
||||
var _ref$type = _ref.type,
|
||||
type = _ref$type === void 0 ? 'circle' : _ref$type,
|
||||
_ref$size = _ref.size,
|
||||
size = _ref$size === void 0 ? 64 : _ref$size,
|
||||
_ref$sizeType = _ref.sizeType,
|
||||
sizeType = _ref$sizeType === void 0 ? 'area' : _ref$sizeType,
|
||||
rest = _objectWithoutProperties(_ref, _excluded);
|
||||
var props = _objectSpread(_objectSpread({}, rest), {}, {
|
||||
type: type,
|
||||
size: size,
|
||||
sizeType: sizeType
|
||||
});
|
||||
|
||||
/**
|
||||
* Calculate the path of curve
|
||||
* @return {String} path
|
||||
*/
|
||||
var getPath = function getPath() {
|
||||
var symbolFactory = getSymbolFactory(type);
|
||||
var symbol = shapeSymbol().type(symbolFactory).size(calculateAreaSize(size, sizeType, type));
|
||||
return symbol();
|
||||
};
|
||||
var className = props.className,
|
||||
cx = props.cx,
|
||||
cy = props.cy;
|
||||
var filteredProps = filterProps(props, true);
|
||||
if (cx === +cx && cy === +cy && size === +size) {
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, filteredProps, {
|
||||
className: clsx('recharts-symbols', className),
|
||||
transform: "translate(".concat(cx, ", ").concat(cy, ")"),
|
||||
d: getPath()
|
||||
}));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Symbols.registerSymbol = registerSymbol;
|
||||
120
vendor/node_modules/recharts/es6/shape/Trapezoid.js
generated
vendored
Normal file
120
vendor/node_modules/recharts/es6/shape/Trapezoid.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Rectangle
|
||||
*/
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import Animate from 'react-smooth';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var getTrapezoidPath = function getTrapezoidPath(x, y, upperWidth, lowerWidth, height) {
|
||||
var widthGap = upperWidth - lowerWidth;
|
||||
var path;
|
||||
path = "M ".concat(x, ",").concat(y);
|
||||
path += "L ".concat(x + upperWidth, ",").concat(y);
|
||||
path += "L ".concat(x + upperWidth - widthGap / 2, ",").concat(y + height);
|
||||
path += "L ".concat(x + upperWidth - widthGap / 2 - lowerWidth, ",").concat(y + height);
|
||||
path += "L ".concat(x, ",").concat(y, " Z");
|
||||
return path;
|
||||
};
|
||||
var defaultProps = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
upperWidth: 0,
|
||||
lowerWidth: 0,
|
||||
height: 0,
|
||||
isUpdateAnimationActive: false,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease'
|
||||
};
|
||||
export var Trapezoid = function Trapezoid(props) {
|
||||
var trapezoidProps = _objectSpread(_objectSpread({}, defaultProps), props);
|
||||
var pathRef = useRef();
|
||||
var _useState = useState(-1),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
totalLength = _useState2[0],
|
||||
setTotalLength = _useState2[1];
|
||||
useEffect(function () {
|
||||
if (pathRef.current && pathRef.current.getTotalLength) {
|
||||
try {
|
||||
var pathTotalLength = pathRef.current.getTotalLength();
|
||||
if (pathTotalLength) {
|
||||
setTotalLength(pathTotalLength);
|
||||
}
|
||||
} catch (err) {
|
||||
// calculate total length error
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
var x = trapezoidProps.x,
|
||||
y = trapezoidProps.y,
|
||||
upperWidth = trapezoidProps.upperWidth,
|
||||
lowerWidth = trapezoidProps.lowerWidth,
|
||||
height = trapezoidProps.height,
|
||||
className = trapezoidProps.className;
|
||||
var animationEasing = trapezoidProps.animationEasing,
|
||||
animationDuration = trapezoidProps.animationDuration,
|
||||
animationBegin = trapezoidProps.animationBegin,
|
||||
isUpdateAnimationActive = trapezoidProps.isUpdateAnimationActive;
|
||||
if (x !== +x || y !== +y || upperWidth !== +upperWidth || lowerWidth !== +lowerWidth || height !== +height || upperWidth === 0 && lowerWidth === 0 || height === 0) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-trapezoid', className);
|
||||
if (!isUpdateAnimationActive) {
|
||||
return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", _extends({}, filterProps(trapezoidProps, true), {
|
||||
className: layerClass,
|
||||
d: getTrapezoidPath(x, y, upperWidth, lowerWidth, height)
|
||||
})));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
canBegin: totalLength > 0,
|
||||
from: {
|
||||
upperWidth: 0,
|
||||
lowerWidth: 0,
|
||||
height: height,
|
||||
x: x,
|
||||
y: y
|
||||
},
|
||||
to: {
|
||||
upperWidth: upperWidth,
|
||||
lowerWidth: lowerWidth,
|
||||
height: height,
|
||||
x: x,
|
||||
y: y
|
||||
},
|
||||
duration: animationDuration,
|
||||
animationEasing: animationEasing,
|
||||
isActive: isUpdateAnimationActive
|
||||
}, function (_ref) {
|
||||
var currUpperWidth = _ref.upperWidth,
|
||||
currLowerWidth = _ref.lowerWidth,
|
||||
currHeight = _ref.height,
|
||||
currX = _ref.x,
|
||||
currY = _ref.y;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
canBegin: totalLength > 0,
|
||||
from: "0px ".concat(totalLength === -1 ? 1 : totalLength, "px"),
|
||||
to: "".concat(totalLength, "px 0px"),
|
||||
attributeName: "strokeDasharray",
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
easing: animationEasing
|
||||
}, /*#__PURE__*/React.createElement("path", _extends({}, filterProps(trapezoidProps, true), {
|
||||
className: layerClass,
|
||||
d: getTrapezoidPath(currX, currY, currUpperWidth, currLowerWidth, currHeight),
|
||||
ref: pathRef
|
||||
})));
|
||||
});
|
||||
};
|
||||
199
vendor/node_modules/recharts/es6/util/ActiveShapeUtils.js
generated
vendored
Normal file
199
vendor/node_modules/recharts/es6/util/ActiveShapeUtils.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
var _excluded = ["option", "shapeType", "propTransformer", "activeClassName", "isActive"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import React, { isValidElement, cloneElement } from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import isPlainObject from 'lodash/isPlainObject';
|
||||
import isBoolean from 'lodash/isBoolean';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import { Rectangle } from '../shape/Rectangle';
|
||||
import { Trapezoid } from '../shape/Trapezoid';
|
||||
import { Sector } from '../shape/Sector';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Symbols } from '../shape/Symbols';
|
||||
|
||||
/**
|
||||
* This is an abstraction for rendering a user defined prop for a customized shape in several forms.
|
||||
*
|
||||
* <Shape /> is the root and will handle taking in:
|
||||
* - an object of svg properties
|
||||
* - a boolean
|
||||
* - a render prop(inline function that returns jsx)
|
||||
* - a react element
|
||||
*
|
||||
* <ShapeSelector /> is a subcomponent of <Shape /> and used to match a component
|
||||
* to the value of props.shapeType that is passed to the root.
|
||||
*
|
||||
*/
|
||||
|
||||
function defaultPropTransformer(option, props) {
|
||||
return _objectSpread(_objectSpread({}, props), option);
|
||||
}
|
||||
function isSymbolsProps(shapeType, _elementProps) {
|
||||
return shapeType === 'symbols';
|
||||
}
|
||||
function ShapeSelector(_ref) {
|
||||
var shapeType = _ref.shapeType,
|
||||
elementProps = _ref.elementProps;
|
||||
switch (shapeType) {
|
||||
case 'rectangle':
|
||||
return /*#__PURE__*/React.createElement(Rectangle, elementProps);
|
||||
case 'trapezoid':
|
||||
return /*#__PURE__*/React.createElement(Trapezoid, elementProps);
|
||||
case 'sector':
|
||||
return /*#__PURE__*/React.createElement(Sector, elementProps);
|
||||
case 'symbols':
|
||||
if (isSymbolsProps(shapeType, elementProps)) {
|
||||
return /*#__PURE__*/React.createElement(Symbols, elementProps);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function getPropsFromShapeOption(option) {
|
||||
if ( /*#__PURE__*/isValidElement(option)) {
|
||||
return option.props;
|
||||
}
|
||||
return option;
|
||||
}
|
||||
export function Shape(_ref2) {
|
||||
var option = _ref2.option,
|
||||
shapeType = _ref2.shapeType,
|
||||
_ref2$propTransformer = _ref2.propTransformer,
|
||||
propTransformer = _ref2$propTransformer === void 0 ? defaultPropTransformer : _ref2$propTransformer,
|
||||
_ref2$activeClassName = _ref2.activeClassName,
|
||||
activeClassName = _ref2$activeClassName === void 0 ? 'recharts-active-shape' : _ref2$activeClassName,
|
||||
isActive = _ref2.isActive,
|
||||
props = _objectWithoutProperties(_ref2, _excluded);
|
||||
var shape;
|
||||
if ( /*#__PURE__*/isValidElement(option)) {
|
||||
shape = /*#__PURE__*/cloneElement(option, _objectSpread(_objectSpread({}, props), getPropsFromShapeOption(option)));
|
||||
} else if (isFunction(option)) {
|
||||
shape = option(props);
|
||||
} else if (isPlainObject(option) && !isBoolean(option)) {
|
||||
var nextProps = propTransformer(option, props);
|
||||
shape = /*#__PURE__*/React.createElement(ShapeSelector, {
|
||||
shapeType: shapeType,
|
||||
elementProps: nextProps
|
||||
});
|
||||
} else {
|
||||
var elementProps = props;
|
||||
shape = /*#__PURE__*/React.createElement(ShapeSelector, {
|
||||
shapeType: shapeType,
|
||||
elementProps: elementProps
|
||||
});
|
||||
}
|
||||
if (isActive) {
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: activeClassName
|
||||
}, shape);
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an abstraction to handle identifying the active index from a tooltip mouse interaction
|
||||
*/
|
||||
|
||||
export function isFunnel(graphicalItem, _item) {
|
||||
return _item != null && 'trapezoids' in graphicalItem.props;
|
||||
}
|
||||
export function isPie(graphicalItem, _item) {
|
||||
return _item != null && 'sectors' in graphicalItem.props;
|
||||
}
|
||||
export function isScatter(graphicalItem, _item) {
|
||||
return _item != null && 'points' in graphicalItem.props;
|
||||
}
|
||||
export function compareFunnel(shapeData, activeTooltipItem) {
|
||||
var _activeTooltipItem$la, _activeTooltipItem$la2;
|
||||
var xMatches = shapeData.x === (activeTooltipItem === null || activeTooltipItem === void 0 || (_activeTooltipItem$la = activeTooltipItem.labelViewBox) === null || _activeTooltipItem$la === void 0 ? void 0 : _activeTooltipItem$la.x) || shapeData.x === activeTooltipItem.x;
|
||||
var yMatches = shapeData.y === (activeTooltipItem === null || activeTooltipItem === void 0 || (_activeTooltipItem$la2 = activeTooltipItem.labelViewBox) === null || _activeTooltipItem$la2 === void 0 ? void 0 : _activeTooltipItem$la2.y) || shapeData.y === activeTooltipItem.y;
|
||||
return xMatches && yMatches;
|
||||
}
|
||||
export function comparePie(shapeData, activeTooltipItem) {
|
||||
var startAngleMatches = shapeData.endAngle === activeTooltipItem.endAngle;
|
||||
var endAngleMatches = shapeData.startAngle === activeTooltipItem.startAngle;
|
||||
return startAngleMatches && endAngleMatches;
|
||||
}
|
||||
export function compareScatter(shapeData, activeTooltipItem) {
|
||||
var xMatches = shapeData.x === activeTooltipItem.x;
|
||||
var yMatches = shapeData.y === activeTooltipItem.y;
|
||||
var zMatches = shapeData.z === activeTooltipItem.z;
|
||||
return xMatches && yMatches && zMatches;
|
||||
}
|
||||
function getComparisonFn(graphicalItem, activeItem) {
|
||||
var comparison;
|
||||
if (isFunnel(graphicalItem, activeItem)) {
|
||||
comparison = compareFunnel;
|
||||
} else if (isPie(graphicalItem, activeItem)) {
|
||||
comparison = comparePie;
|
||||
} else if (isScatter(graphicalItem, activeItem)) {
|
||||
comparison = compareScatter;
|
||||
}
|
||||
return comparison;
|
||||
}
|
||||
function getShapeDataKey(graphicalItem, activeItem) {
|
||||
var shapeKey;
|
||||
if (isFunnel(graphicalItem, activeItem)) {
|
||||
shapeKey = 'trapezoids';
|
||||
} else if (isPie(graphicalItem, activeItem)) {
|
||||
shapeKey = 'sectors';
|
||||
} else if (isScatter(graphicalItem, activeItem)) {
|
||||
shapeKey = 'points';
|
||||
}
|
||||
return shapeKey;
|
||||
}
|
||||
function getActiveShapeTooltipPayload(graphicalItem, activeItem) {
|
||||
if (isFunnel(graphicalItem, activeItem)) {
|
||||
var _activeItem$tooltipPa;
|
||||
return (_activeItem$tooltipPa = activeItem.tooltipPayload) === null || _activeItem$tooltipPa === void 0 || (_activeItem$tooltipPa = _activeItem$tooltipPa[0]) === null || _activeItem$tooltipPa === void 0 || (_activeItem$tooltipPa = _activeItem$tooltipPa.payload) === null || _activeItem$tooltipPa === void 0 ? void 0 : _activeItem$tooltipPa.payload;
|
||||
}
|
||||
if (isPie(graphicalItem, activeItem)) {
|
||||
var _activeItem$tooltipPa2;
|
||||
return (_activeItem$tooltipPa2 = activeItem.tooltipPayload) === null || _activeItem$tooltipPa2 === void 0 || (_activeItem$tooltipPa2 = _activeItem$tooltipPa2[0]) === null || _activeItem$tooltipPa2 === void 0 || (_activeItem$tooltipPa2 = _activeItem$tooltipPa2.payload) === null || _activeItem$tooltipPa2 === void 0 ? void 0 : _activeItem$tooltipPa2.payload;
|
||||
}
|
||||
if (isScatter(graphicalItem, activeItem)) {
|
||||
return activeItem.payload;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {GetActiveShapeIndexForTooltip} arg an object of incoming attributes from Tooltip
|
||||
* @returns {number}
|
||||
*
|
||||
* To handle possible duplicates in the data set,
|
||||
* match both the data value of the active item to a data value on a graph item,
|
||||
* and match the mouse coordinates of the active item to the coordinates of in a particular components shape data.
|
||||
* This assumes equal lengths of shape objects to data items.
|
||||
*/
|
||||
export function getActiveShapeIndexForTooltip(_ref3) {
|
||||
var activeTooltipItem = _ref3.activeTooltipItem,
|
||||
graphicalItem = _ref3.graphicalItem,
|
||||
itemData = _ref3.itemData;
|
||||
var shapeKey = getShapeDataKey(graphicalItem, activeTooltipItem);
|
||||
var tooltipPayload = getActiveShapeTooltipPayload(graphicalItem, activeTooltipItem);
|
||||
var activeItemMatches = itemData.filter(function (datum, dataIndex) {
|
||||
var valuesMatch = isEqual(tooltipPayload, datum);
|
||||
var mouseCoordinateMatches = graphicalItem.props[shapeKey].filter(function (shapeData) {
|
||||
var comparison = getComparisonFn(graphicalItem, activeTooltipItem);
|
||||
return comparison(shapeData, activeTooltipItem);
|
||||
});
|
||||
|
||||
// get the last index in case of multiple matches
|
||||
var indexOfMouseCoordinates = graphicalItem.props[shapeKey].indexOf(mouseCoordinateMatches[mouseCoordinateMatches.length - 1]);
|
||||
var coordinatesMatch = dataIndex === indexOfMouseCoordinates;
|
||||
return valuesMatch && coordinatesMatch;
|
||||
});
|
||||
|
||||
// get the last index in case of multiple matches
|
||||
var activeIndex = itemData.indexOf(activeItemMatches[activeItemMatches.length - 1]);
|
||||
return activeIndex;
|
||||
}
|
||||
68
vendor/node_modules/recharts/es6/util/BarUtils.js
generated
vendored
Normal file
68
vendor/node_modules/recharts/es6/util/BarUtils.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
var _excluded = ["x", "y"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
import React from 'react';
|
||||
import invariant from 'tiny-invariant';
|
||||
import { Shape } from './ActiveShapeUtils';
|
||||
import { isNullish, isNumber } from './DataUtils';
|
||||
|
||||
// Rectangle props is expecting x, y, height, width as numbers, name as a string, and radius as a custom type
|
||||
// When props are being spread in from a user defined component in Bar,
|
||||
// the prop types of an SVGElement have these typed as something else.
|
||||
// This function will return the passed in props
|
||||
// along with x, y, height as numbers, name as a string, and radius as number | [number, number, number, number]
|
||||
function typeguardBarRectangleProps(_ref, props) {
|
||||
var xProp = _ref.x,
|
||||
yProp = _ref.y,
|
||||
option = _objectWithoutProperties(_ref, _excluded);
|
||||
var xValue = "".concat(xProp);
|
||||
var x = parseInt(xValue, 10);
|
||||
var yValue = "".concat(yProp);
|
||||
var y = parseInt(yValue, 10);
|
||||
var heightValue = "".concat(props.height || option.height);
|
||||
var height = parseInt(heightValue, 10);
|
||||
var widthValue = "".concat(props.width || option.width);
|
||||
var width = parseInt(widthValue, 10);
|
||||
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), option), x ? {
|
||||
x: x
|
||||
} : {}), y ? {
|
||||
y: y
|
||||
} : {}), {}, {
|
||||
height: height,
|
||||
width: width,
|
||||
name: props.name,
|
||||
radius: props.radius
|
||||
});
|
||||
}
|
||||
export function BarRectangle(props) {
|
||||
return /*#__PURE__*/React.createElement(Shape, _extends({
|
||||
shapeType: "rectangle",
|
||||
propTransformer: typeguardBarRectangleProps,
|
||||
activeClassName: "recharts-active-bar"
|
||||
}, props));
|
||||
}
|
||||
/**
|
||||
* Safely gets minPointSize from from the minPointSize prop if it is a function
|
||||
* @param minPointSize minPointSize as passed to the Bar component
|
||||
* @param defaultValue default minPointSize
|
||||
* @returns minPointSize
|
||||
*/
|
||||
export var minPointSizeCallback = function minPointSizeCallback(minPointSize) {
|
||||
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
return function (value, index) {
|
||||
if (typeof minPointSize === 'number') return minPointSize;
|
||||
var isValueNumberOrNil = isNumber(value) || isNullish(value);
|
||||
if (isValueNumberOrNil) {
|
||||
return minPointSize(value, index);
|
||||
}
|
||||
!isValueNumberOrNil ? process.env.NODE_ENV !== "production" ? invariant(false, "minPointSize callback function received a value with type of ".concat(_typeof(value), ". Currently only numbers or null/undefined are supported.")) : invariant(false) : void 0;
|
||||
return defaultValue;
|
||||
};
|
||||
};
|
||||
282
vendor/node_modules/recharts/es6/util/CartesianUtils.js
generated
vendored
Normal file
282
vendor/node_modules/recharts/es6/util/CartesianUtils.js
generated
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import mapValues from 'lodash/mapValues';
|
||||
import every from 'lodash/every';
|
||||
import { getTicksOfScale, parseScale, checkDomainOfScale, getBandSizeOfAxis } from './ChartUtils';
|
||||
import { findChildByType } from './ReactUtils';
|
||||
import { compareValues, getPercentValue } from './DataUtils';
|
||||
import { Bar } from '../cartesian/Bar';
|
||||
|
||||
/**
|
||||
* Calculate the scale function, position, width, height of axes
|
||||
* @param {Object} props Latest props
|
||||
* @param {Object} axisMap The configuration of axes
|
||||
* @param {Object} offset The offset of main part in the svg element
|
||||
* @param {String} axisType The type of axes, x-axis or y-axis
|
||||
* @param {String} chartName The name of chart
|
||||
* @return {Object} Configuration
|
||||
*/
|
||||
export var formatAxisMap = function formatAxisMap(props, axisMap, offset, axisType, chartName) {
|
||||
var width = props.width,
|
||||
height = props.height,
|
||||
layout = props.layout,
|
||||
children = props.children;
|
||||
var ids = Object.keys(axisMap);
|
||||
var steps = {
|
||||
left: offset.left,
|
||||
leftMirror: offset.left,
|
||||
right: width - offset.right,
|
||||
rightMirror: width - offset.right,
|
||||
top: offset.top,
|
||||
topMirror: offset.top,
|
||||
bottom: height - offset.bottom,
|
||||
bottomMirror: height - offset.bottom
|
||||
};
|
||||
var hasBar = !!findChildByType(children, Bar);
|
||||
return ids.reduce(function (result, id) {
|
||||
var axis = axisMap[id];
|
||||
var orientation = axis.orientation,
|
||||
domain = axis.domain,
|
||||
_axis$padding = axis.padding,
|
||||
padding = _axis$padding === void 0 ? {} : _axis$padding,
|
||||
mirror = axis.mirror,
|
||||
reversed = axis.reversed;
|
||||
var offsetKey = "".concat(orientation).concat(mirror ? 'Mirror' : '');
|
||||
var calculatedPadding, range, x, y, needSpace;
|
||||
if (axis.type === 'number' && (axis.padding === 'gap' || axis.padding === 'no-gap')) {
|
||||
var diff = domain[1] - domain[0];
|
||||
var smallestDistanceBetweenValues = Infinity;
|
||||
var sortedValues = axis.categoricalDomain.sort(compareValues);
|
||||
sortedValues.forEach(function (value, index) {
|
||||
if (index > 0) {
|
||||
smallestDistanceBetweenValues = Math.min((value || 0) - (sortedValues[index - 1] || 0), smallestDistanceBetweenValues);
|
||||
}
|
||||
});
|
||||
if (Number.isFinite(smallestDistanceBetweenValues)) {
|
||||
var smallestDistanceInPercent = smallestDistanceBetweenValues / diff;
|
||||
var rangeWidth = axis.layout === 'vertical' ? offset.height : offset.width;
|
||||
if (axis.padding === 'gap') {
|
||||
calculatedPadding = smallestDistanceInPercent * rangeWidth / 2;
|
||||
}
|
||||
if (axis.padding === 'no-gap') {
|
||||
var gap = getPercentValue(props.barCategoryGap, smallestDistanceInPercent * rangeWidth);
|
||||
var halfBand = smallestDistanceInPercent * rangeWidth / 2;
|
||||
calculatedPadding = halfBand - gap - (halfBand - gap) / rangeWidth * gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (axisType === 'xAxis') {
|
||||
range = [offset.left + (padding.left || 0) + (calculatedPadding || 0), offset.left + offset.width - (padding.right || 0) - (calculatedPadding || 0)];
|
||||
} else if (axisType === 'yAxis') {
|
||||
range = layout === 'horizontal' ? [offset.top + offset.height - (padding.bottom || 0), offset.top + (padding.top || 0)] : [offset.top + (padding.top || 0) + (calculatedPadding || 0), offset.top + offset.height - (padding.bottom || 0) - (calculatedPadding || 0)];
|
||||
} else {
|
||||
range = axis.range;
|
||||
}
|
||||
if (reversed) {
|
||||
range = [range[1], range[0]];
|
||||
}
|
||||
var _parseScale = parseScale(axis, chartName, hasBar),
|
||||
scale = _parseScale.scale,
|
||||
realScaleType = _parseScale.realScaleType;
|
||||
scale.domain(domain).range(range);
|
||||
checkDomainOfScale(scale);
|
||||
var ticks = getTicksOfScale(scale, _objectSpread(_objectSpread({}, axis), {}, {
|
||||
realScaleType: realScaleType
|
||||
}));
|
||||
if (axisType === 'xAxis') {
|
||||
needSpace = orientation === 'top' && !mirror || orientation === 'bottom' && mirror;
|
||||
x = offset.left;
|
||||
y = steps[offsetKey] - needSpace * axis.height;
|
||||
} else if (axisType === 'yAxis') {
|
||||
needSpace = orientation === 'left' && !mirror || orientation === 'right' && mirror;
|
||||
x = steps[offsetKey] - needSpace * axis.width;
|
||||
y = offset.top;
|
||||
}
|
||||
var finalAxis = _objectSpread(_objectSpread(_objectSpread({}, axis), ticks), {}, {
|
||||
realScaleType: realScaleType,
|
||||
x: x,
|
||||
y: y,
|
||||
scale: scale,
|
||||
width: axisType === 'xAxis' ? offset.width : axis.width,
|
||||
height: axisType === 'yAxis' ? offset.height : axis.height
|
||||
});
|
||||
finalAxis.bandSize = getBandSizeOfAxis(finalAxis, ticks);
|
||||
if (!axis.hide && axisType === 'xAxis') {
|
||||
steps[offsetKey] += (needSpace ? -1 : 1) * finalAxis.height;
|
||||
} else if (!axis.hide) {
|
||||
steps[offsetKey] += (needSpace ? -1 : 1) * finalAxis.width;
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, result), {}, _defineProperty({}, id, finalAxis));
|
||||
}, {});
|
||||
};
|
||||
export var rectWithPoints = function rectWithPoints(_ref, _ref2) {
|
||||
var x1 = _ref.x,
|
||||
y1 = _ref.y;
|
||||
var x2 = _ref2.x,
|
||||
y2 = _ref2.y;
|
||||
return {
|
||||
x: Math.min(x1, x2),
|
||||
y: Math.min(y1, y2),
|
||||
width: Math.abs(x2 - x1),
|
||||
height: Math.abs(y2 - y1)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute the x, y, width, and height of a box from two reference points.
|
||||
* @param {Object} coords x1, x2, y1, and y2
|
||||
* @return {Object} object
|
||||
*/
|
||||
export var rectWithCoords = function rectWithCoords(_ref3) {
|
||||
var x1 = _ref3.x1,
|
||||
y1 = _ref3.y1,
|
||||
x2 = _ref3.x2,
|
||||
y2 = _ref3.y2;
|
||||
return rectWithPoints({
|
||||
x: x1,
|
||||
y: y1
|
||||
}, {
|
||||
x: x2,
|
||||
y: y2
|
||||
});
|
||||
};
|
||||
export var ScaleHelper = /*#__PURE__*/function () {
|
||||
function ScaleHelper(scale) {
|
||||
_classCallCheck(this, ScaleHelper);
|
||||
this.scale = scale;
|
||||
}
|
||||
return _createClass(ScaleHelper, [{
|
||||
key: "domain",
|
||||
get: function get() {
|
||||
return this.scale.domain;
|
||||
}
|
||||
}, {
|
||||
key: "range",
|
||||
get: function get() {
|
||||
return this.scale.range;
|
||||
}
|
||||
}, {
|
||||
key: "rangeMin",
|
||||
get: function get() {
|
||||
return this.range()[0];
|
||||
}
|
||||
}, {
|
||||
key: "rangeMax",
|
||||
get: function get() {
|
||||
return this.range()[1];
|
||||
}
|
||||
}, {
|
||||
key: "bandwidth",
|
||||
get: function get() {
|
||||
return this.scale.bandwidth;
|
||||
}
|
||||
}, {
|
||||
key: "apply",
|
||||
value: function apply(value) {
|
||||
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
bandAware = _ref4.bandAware,
|
||||
position = _ref4.position;
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (position) {
|
||||
switch (position) {
|
||||
case 'start':
|
||||
{
|
||||
return this.scale(value);
|
||||
}
|
||||
case 'middle':
|
||||
{
|
||||
var offset = this.bandwidth ? this.bandwidth() / 2 : 0;
|
||||
return this.scale(value) + offset;
|
||||
}
|
||||
case 'end':
|
||||
{
|
||||
var _offset = this.bandwidth ? this.bandwidth() : 0;
|
||||
return this.scale(value) + _offset;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return this.scale(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bandAware) {
|
||||
var _offset2 = this.bandwidth ? this.bandwidth() / 2 : 0;
|
||||
return this.scale(value) + _offset2;
|
||||
}
|
||||
return this.scale(value);
|
||||
}
|
||||
}, {
|
||||
key: "isInRange",
|
||||
value: function isInRange(value) {
|
||||
var range = this.range();
|
||||
var first = range[0];
|
||||
var last = range[range.length - 1];
|
||||
return first <= last ? value >= first && value <= last : value >= last && value <= first;
|
||||
}
|
||||
}], [{
|
||||
key: "create",
|
||||
value: function create(obj) {
|
||||
return new ScaleHelper(obj);
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
_defineProperty(ScaleHelper, "EPS", 1e-4);
|
||||
export var createLabeledScales = function createLabeledScales(options) {
|
||||
var scales = Object.keys(options).reduce(function (res, key) {
|
||||
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, key, ScaleHelper.create(options[key])));
|
||||
}, {});
|
||||
return _objectSpread(_objectSpread({}, scales), {}, {
|
||||
apply: function apply(coord) {
|
||||
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
bandAware = _ref5.bandAware,
|
||||
position = _ref5.position;
|
||||
return mapValues(coord, function (value, label) {
|
||||
return scales[label].apply(value, {
|
||||
bandAware: bandAware,
|
||||
position: position
|
||||
});
|
||||
});
|
||||
},
|
||||
isInRange: function isInRange(coord) {
|
||||
return every(coord, function (value, label) {
|
||||
return scales[label].isInRange(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** Normalizes the angle so that 0 <= angle < 180.
|
||||
* @param {number} angle Angle in degrees.
|
||||
* @return {number} the normalized angle with a value of at least 0 and never greater or equal to 180. */
|
||||
export function normalizeAngle(angle) {
|
||||
return (angle % 180 + 180) % 180;
|
||||
}
|
||||
|
||||
/** Calculates the width of the largest horizontal line that fits inside a rectangle that is displayed at an angle.
|
||||
* @param {Object} size Width and height of the text in a horizontal position.
|
||||
* @param {number} angle Angle in degrees in which the text is displayed.
|
||||
* @return {number} The width of the largest horizontal line that fits inside a rectangle that is displayed at an angle.
|
||||
*/
|
||||
export var getAngledRectangleWidth = function getAngledRectangleWidth(_ref6) {
|
||||
var width = _ref6.width,
|
||||
height = _ref6.height;
|
||||
var angle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
// Ensure angle is >= 0 && < 180
|
||||
var normalizedAngle = normalizeAngle(angle);
|
||||
var angleRadians = normalizedAngle * Math.PI / 180;
|
||||
|
||||
/* Depending on the height and width of the rectangle, we may need to use different formulas to calculate the angled
|
||||
* width. This threshold defines when each formula should kick in. */
|
||||
var angleThreshold = Math.atan(height / width);
|
||||
var angledWidth = angleRadians > angleThreshold && angleRadians < Math.PI - angleThreshold ? height / Math.sin(angleRadians) : width / Math.cos(angleRadians);
|
||||
return Math.abs(angledWidth);
|
||||
};
|
||||
1061
vendor/node_modules/recharts/es6/util/ChartUtils.js
generated
vendored
Normal file
1061
vendor/node_modules/recharts/es6/util/ChartUtils.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
vendor/node_modules/recharts/es6/util/CssPrefixUtils.js
generated
vendored
Normal file
20
vendor/node_modules/recharts/es6/util/CssPrefixUtils.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var PREFIX_LIST = ['Webkit', 'Moz', 'O', 'ms'];
|
||||
export var generatePrefixStyle = function generatePrefixStyle(name, value) {
|
||||
if (!name) {
|
||||
return null;
|
||||
}
|
||||
var camelName = name.replace(/(\w)/, function (v) {
|
||||
return v.toUpperCase();
|
||||
});
|
||||
var result = PREFIX_LIST.reduce(function (res, entry) {
|
||||
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, entry + camelName, value));
|
||||
}, {});
|
||||
result[name] = value;
|
||||
return result;
|
||||
};
|
||||
112
vendor/node_modules/recharts/es6/util/DOMUtils.js
generated
vendored
Normal file
112
vendor/node_modules/recharts/es6/util/DOMUtils.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
import { Global } from './Global';
|
||||
var stringCache = {
|
||||
widthCache: {},
|
||||
cacheCount: 0
|
||||
};
|
||||
var MAX_CACHE_NUM = 2000;
|
||||
var SPAN_STYLE = {
|
||||
position: 'absolute',
|
||||
top: '-20000px',
|
||||
left: 0,
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
border: 'none',
|
||||
whiteSpace: 'pre'
|
||||
};
|
||||
var STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'lineHeight', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
||||
var MEASUREMENT_SPAN_ID = 'recharts_measurement_span';
|
||||
function autoCompleteStyle(name, value) {
|
||||
if (STYLE_LIST.indexOf(name) >= 0 && value === +value) {
|
||||
return "".concat(value, "px");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function camelToMiddleLine(text) {
|
||||
var strs = text.split('');
|
||||
var formatStrs = strs.reduce(function (result, entry) {
|
||||
if (entry === entry.toUpperCase()) {
|
||||
return [].concat(_toConsumableArray(result), ['-', entry.toLowerCase()]);
|
||||
}
|
||||
return [].concat(_toConsumableArray(result), [entry]);
|
||||
}, []);
|
||||
return formatStrs.join('');
|
||||
}
|
||||
export var getStyleString = function getStyleString(style) {
|
||||
return Object.keys(style).reduce(function (result, s) {
|
||||
return "".concat(result).concat(camelToMiddleLine(s), ":").concat(autoCompleteStyle(s, style[s]), ";");
|
||||
}, '');
|
||||
};
|
||||
function removeInvalidKeys(obj) {
|
||||
var copyObj = _objectSpread({}, obj);
|
||||
Object.keys(copyObj).forEach(function (key) {
|
||||
if (!copyObj[key]) {
|
||||
delete copyObj[key];
|
||||
}
|
||||
});
|
||||
return copyObj;
|
||||
}
|
||||
export var getStringSize = function getStringSize(text) {
|
||||
var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
if (text === undefined || text === null || Global.isSsr) {
|
||||
return {
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
}
|
||||
var copyStyle = removeInvalidKeys(style);
|
||||
var cacheKey = JSON.stringify({
|
||||
text: text,
|
||||
copyStyle: copyStyle
|
||||
});
|
||||
if (stringCache.widthCache[cacheKey]) {
|
||||
return stringCache.widthCache[cacheKey];
|
||||
}
|
||||
try {
|
||||
var measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
|
||||
if (!measurementSpan) {
|
||||
measurementSpan = document.createElement('span');
|
||||
measurementSpan.setAttribute('id', MEASUREMENT_SPAN_ID);
|
||||
measurementSpan.setAttribute('aria-hidden', 'true');
|
||||
document.body.appendChild(measurementSpan);
|
||||
}
|
||||
// Need to use CSS Object Model (CSSOM) to be able to comply with Content Security Policy (CSP)
|
||||
// https://en.wikipedia.org/wiki/Content_Security_Policy
|
||||
var measurementSpanStyle = _objectSpread(_objectSpread({}, SPAN_STYLE), copyStyle);
|
||||
Object.assign(measurementSpan.style, measurementSpanStyle);
|
||||
measurementSpan.textContent = "".concat(text);
|
||||
var rect = measurementSpan.getBoundingClientRect();
|
||||
var result = {
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
};
|
||||
stringCache.widthCache[cacheKey] = result;
|
||||
if (++stringCache.cacheCount > MAX_CACHE_NUM) {
|
||||
stringCache.cacheCount = 0;
|
||||
stringCache.widthCache = {};
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
return {
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
}
|
||||
};
|
||||
export var getOffset = function getOffset(rect) {
|
||||
return {
|
||||
top: rect.top + window.scrollY - document.documentElement.clientTop,
|
||||
left: rect.left + window.scrollX - document.documentElement.clientLeft
|
||||
};
|
||||
};
|
||||
170
vendor/node_modules/recharts/es6/util/DataUtils.js
generated
vendored
Normal file
170
vendor/node_modules/recharts/es6/util/DataUtils.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
import isString from 'lodash/isString';
|
||||
import isNan from 'lodash/isNaN';
|
||||
import get from 'lodash/get';
|
||||
import lodashIsNumber from 'lodash/isNumber';
|
||||
import isNil from 'lodash/isNil';
|
||||
export var mathSign = function mathSign(value) {
|
||||
if (value === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (value > 0) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
export var isPercent = function isPercent(value) {
|
||||
return isString(value) && value.indexOf('%') === value.length - 1;
|
||||
};
|
||||
export var isNumber = function isNumber(value) {
|
||||
return lodashIsNumber(value) && !isNan(value);
|
||||
};
|
||||
export var isNullish = function isNullish(value) {
|
||||
return isNil(value);
|
||||
};
|
||||
export var isNumOrStr = function isNumOrStr(value) {
|
||||
return isNumber(value) || isString(value);
|
||||
};
|
||||
var idCounter = 0;
|
||||
export var uniqueId = function uniqueId(prefix) {
|
||||
var id = ++idCounter;
|
||||
return "".concat(prefix || '').concat(id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get percent value of a total value
|
||||
* @param {number|string} percent A percent
|
||||
* @param {number} totalValue Total value
|
||||
* @param {number} defaultValue The value returned when percent is undefined or invalid
|
||||
* @param {boolean} validate If set to be true, the result will be validated
|
||||
* @return {number} value
|
||||
*/
|
||||
export var getPercentValue = function getPercentValue(percent, totalValue) {
|
||||
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
var validate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
if (!isNumber(percent) && !isString(percent)) {
|
||||
return defaultValue;
|
||||
}
|
||||
var value;
|
||||
if (isPercent(percent)) {
|
||||
var index = percent.indexOf('%');
|
||||
value = totalValue * parseFloat(percent.slice(0, index)) / 100;
|
||||
} else {
|
||||
value = +percent;
|
||||
}
|
||||
if (isNan(value)) {
|
||||
value = defaultValue;
|
||||
}
|
||||
if (validate && value > totalValue) {
|
||||
value = totalValue;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
export var getAnyElementOfObject = function getAnyElementOfObject(obj) {
|
||||
if (!obj) {
|
||||
return null;
|
||||
}
|
||||
var keys = Object.keys(obj);
|
||||
if (keys && keys.length) {
|
||||
return obj[keys[0]];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
export var hasDuplicate = function hasDuplicate(ary) {
|
||||
if (!Array.isArray(ary)) {
|
||||
return false;
|
||||
}
|
||||
var len = ary.length;
|
||||
var cache = {};
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (!cache[ary[i]]) {
|
||||
cache[ary[i]] = true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/* @todo consider to rename this function into `getInterpolator` */
|
||||
export var interpolateNumber = function interpolateNumber(numberA, numberB) {
|
||||
if (isNumber(numberA) && isNumber(numberB)) {
|
||||
return function (t) {
|
||||
return numberA + t * (numberB - numberA);
|
||||
};
|
||||
}
|
||||
return function () {
|
||||
return numberB;
|
||||
};
|
||||
};
|
||||
export function findEntryInArray(ary, specifiedKey, specifiedValue) {
|
||||
if (!ary || !ary.length) {
|
||||
return null;
|
||||
}
|
||||
return ary.find(function (entry) {
|
||||
return entry && (typeof specifiedKey === 'function' ? specifiedKey(entry) : get(entry, specifiedKey)) === specifiedValue;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The least square linear regression
|
||||
* @param {Array} data The array of points
|
||||
* @returns {Object} The domain of x, and the parameter of linear function
|
||||
*/
|
||||
export var getLinearRegression = function getLinearRegression(data) {
|
||||
if (!data || !data.length) {
|
||||
return null;
|
||||
}
|
||||
var len = data.length;
|
||||
var xsum = 0;
|
||||
var ysum = 0;
|
||||
var xysum = 0;
|
||||
var xxsum = 0;
|
||||
var xmin = Infinity;
|
||||
var xmax = -Infinity;
|
||||
var xcurrent = 0;
|
||||
var ycurrent = 0;
|
||||
for (var i = 0; i < len; i++) {
|
||||
xcurrent = data[i].cx || 0;
|
||||
ycurrent = data[i].cy || 0;
|
||||
xsum += xcurrent;
|
||||
ysum += ycurrent;
|
||||
xysum += xcurrent * ycurrent;
|
||||
xxsum += xcurrent * xcurrent;
|
||||
xmin = Math.min(xmin, xcurrent);
|
||||
xmax = Math.max(xmax, xcurrent);
|
||||
}
|
||||
var a = len * xxsum !== xsum * xsum ? (len * xysum - xsum * ysum) / (len * xxsum - xsum * xsum) : 0;
|
||||
return {
|
||||
xmin: xmin,
|
||||
xmax: xmax,
|
||||
a: a,
|
||||
b: (ysum - a * xsum) / len
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Compare values.
|
||||
*
|
||||
* This function is intended to be passed to `Array.prototype.sort()`. It properly compares generic homogeneous arrays that are either `string[]`,
|
||||
* `number[]`, or `Date[]`. When comparing heterogeneous arrays or homogeneous arrays of other types, it will attempt to compare items properly but
|
||||
* will fall back to string comparison for mismatched or unsupported types.
|
||||
*
|
||||
* For some background, `Array.prototype.sort()`'s default comparator coerces each of the array's items into a string and compares the strings. This
|
||||
* often leads to undesirable behavior, especially with numerical items.
|
||||
*
|
||||
* @param {unknown} a The first item to compare
|
||||
* @param {unknown} b The second item to compare
|
||||
* @return {number} A negative number if a < b, a positive number if a > b, 0 if equal
|
||||
*/
|
||||
export var compareValues = function compareValues(a, b) {
|
||||
if (isNumber(a) && isNumber(b)) {
|
||||
return a - b;
|
||||
}
|
||||
if (isString(a) && isString(b)) {
|
||||
return a.localeCompare(b);
|
||||
}
|
||||
if (a instanceof Date && b instanceof Date) {
|
||||
return a.getTime() - b.getTime();
|
||||
}
|
||||
return String(a).localeCompare(String(b));
|
||||
};
|
||||
51
vendor/node_modules/recharts/es6/util/DetectReferenceElementsDomain.js
generated
vendored
Normal file
51
vendor/node_modules/recharts/es6/util/DetectReferenceElementsDomain.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
import { ReferenceDot } from '../cartesian/ReferenceDot';
|
||||
import { ReferenceLine } from '../cartesian/ReferenceLine';
|
||||
import { ReferenceArea } from '../cartesian/ReferenceArea';
|
||||
import { ifOverflowMatches } from './IfOverflowMatches';
|
||||
import { findAllByType } from './ReactUtils';
|
||||
import { isNumber } from './DataUtils';
|
||||
export var detectReferenceElementsDomain = function detectReferenceElementsDomain(children, domain, axisId, axisType, specifiedTicks) {
|
||||
var lines = findAllByType(children, ReferenceLine);
|
||||
var dots = findAllByType(children, ReferenceDot);
|
||||
var elements = [].concat(_toConsumableArray(lines), _toConsumableArray(dots));
|
||||
var areas = findAllByType(children, ReferenceArea);
|
||||
var idKey = "".concat(axisType, "Id");
|
||||
var valueKey = axisType[0];
|
||||
var finalDomain = domain;
|
||||
if (elements.length) {
|
||||
finalDomain = elements.reduce(function (result, el) {
|
||||
if (el.props[idKey] === axisId && ifOverflowMatches(el.props, 'extendDomain') && isNumber(el.props[valueKey])) {
|
||||
var value = el.props[valueKey];
|
||||
return [Math.min(result[0], value), Math.max(result[1], value)];
|
||||
}
|
||||
return result;
|
||||
}, finalDomain);
|
||||
}
|
||||
if (areas.length) {
|
||||
var key1 = "".concat(valueKey, "1");
|
||||
var key2 = "".concat(valueKey, "2");
|
||||
finalDomain = areas.reduce(function (result, el) {
|
||||
if (el.props[idKey] === axisId && ifOverflowMatches(el.props, 'extendDomain') && isNumber(el.props[key1]) && isNumber(el.props[key2])) {
|
||||
var value1 = el.props[key1];
|
||||
var value2 = el.props[key2];
|
||||
return [Math.min(result[0], value1, value2), Math.max(result[1], value1, value2)];
|
||||
}
|
||||
return result;
|
||||
}, finalDomain);
|
||||
}
|
||||
if (specifiedTicks && specifiedTicks.length) {
|
||||
finalDomain = specifiedTicks.reduce(function (result, tick) {
|
||||
if (isNumber(tick)) {
|
||||
return [Math.min(result[0], tick), Math.max(result[1], tick)];
|
||||
}
|
||||
return result;
|
||||
}, finalDomain);
|
||||
}
|
||||
return finalDomain;
|
||||
};
|
||||
4
vendor/node_modules/recharts/es6/util/Events.js
generated
vendored
Normal file
4
vendor/node_modules/recharts/es6/util/Events.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import EventEmitter from 'eventemitter3';
|
||||
var eventCenter = new EventEmitter();
|
||||
export { eventCenter };
|
||||
export var SYNC_EVENT = 'recharts.syncMouseEvents';
|
||||
21
vendor/node_modules/recharts/es6/util/Global.js
generated
vendored
Normal file
21
vendor/node_modules/recharts/es6/util/Global.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var parseIsSsrByDefault = function parseIsSsrByDefault() {
|
||||
return !(typeof window !== 'undefined' && window.document && window.document.createElement && window.setTimeout);
|
||||
};
|
||||
export var Global = {
|
||||
isSsr: parseIsSsrByDefault(),
|
||||
get: function get(key) {
|
||||
return Global[key];
|
||||
},
|
||||
set: function set(key, value) {
|
||||
if (typeof key === 'string') {
|
||||
Global[key] = value;
|
||||
} else {
|
||||
var keys = Object.keys(key);
|
||||
if (keys && keys.length) {
|
||||
keys.forEach(function (k) {
|
||||
Global[k] = key[k];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
8
vendor/node_modules/recharts/es6/util/IfOverflowMatches.js
generated
vendored
Normal file
8
vendor/node_modules/recharts/es6/util/IfOverflowMatches.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export var ifOverflowMatches = function ifOverflowMatches(props, value) {
|
||||
var alwaysShow = props.alwaysShow;
|
||||
var ifOverflow = props.ifOverflow;
|
||||
if (alwaysShow) {
|
||||
ifOverflow = 'extendDomain';
|
||||
}
|
||||
return ifOverflow === value;
|
||||
};
|
||||
22
vendor/node_modules/recharts/es6/util/LogUtils.js
generated
vendored
Normal file
22
vendor/node_modules/recharts/es6/util/LogUtils.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/* eslint no-console: 0 */
|
||||
var isDev = process.env.NODE_ENV !== 'production';
|
||||
export var warn = function warn(condition, format) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
||||
args[_key - 2] = arguments[_key];
|
||||
}
|
||||
if (isDev && typeof console !== 'undefined' && console.warn) {
|
||||
if (format === undefined) {
|
||||
console.warn('LogUtils requires an error message argument');
|
||||
}
|
||||
if (!condition) {
|
||||
if (format === undefined) {
|
||||
console.warn('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
||||
} else {
|
||||
var argIndex = 0;
|
||||
console.warn(format.replace(/%s/g, function () {
|
||||
return args[argIndex++];
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
208
vendor/node_modules/recharts/es6/util/PolarUtils.js
generated
vendored
Normal file
208
vendor/node_modules/recharts/es6/util/PolarUtils.js
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
import isNil from 'lodash/isNil';
|
||||
import { isValidElement } from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import { getPercentValue } from './DataUtils';
|
||||
import { parseScale, checkDomainOfScale, getTicksOfScale } from './ChartUtils';
|
||||
export var RADIAN = Math.PI / 180;
|
||||
export var degreeToRadian = function degreeToRadian(angle) {
|
||||
return angle * Math.PI / 180;
|
||||
};
|
||||
export var radianToDegree = function radianToDegree(angleInRadian) {
|
||||
return angleInRadian * 180 / Math.PI;
|
||||
};
|
||||
export var polarToCartesian = function polarToCartesian(cx, cy, radius, angle) {
|
||||
return {
|
||||
x: cx + Math.cos(-RADIAN * angle) * radius,
|
||||
y: cy + Math.sin(-RADIAN * angle) * radius
|
||||
};
|
||||
};
|
||||
export var getMaxRadius = function getMaxRadius(width, height) {
|
||||
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0
|
||||
};
|
||||
return Math.min(Math.abs(width - (offset.left || 0) - (offset.right || 0)), Math.abs(height - (offset.top || 0) - (offset.bottom || 0))) / 2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the scale function, position, width, height of axes
|
||||
* @param {Object} props Latest props
|
||||
* @param {Object} axisMap The configuration of axes
|
||||
* @param {Object} offset The offset of main part in the svg element
|
||||
* @param {Object} axisType The type of axes, radius-axis or angle-axis
|
||||
* @param {String} chartName The name of chart
|
||||
* @return {Object} Configuration
|
||||
*/
|
||||
export var formatAxisMap = function formatAxisMap(props, axisMap, offset, axisType, chartName) {
|
||||
var width = props.width,
|
||||
height = props.height;
|
||||
var startAngle = props.startAngle,
|
||||
endAngle = props.endAngle;
|
||||
var cx = getPercentValue(props.cx, width, width / 2);
|
||||
var cy = getPercentValue(props.cy, height, height / 2);
|
||||
var maxRadius = getMaxRadius(width, height, offset);
|
||||
var innerRadius = getPercentValue(props.innerRadius, maxRadius, 0);
|
||||
var outerRadius = getPercentValue(props.outerRadius, maxRadius, maxRadius * 0.8);
|
||||
var ids = Object.keys(axisMap);
|
||||
return ids.reduce(function (result, id) {
|
||||
var axis = axisMap[id];
|
||||
var domain = axis.domain,
|
||||
reversed = axis.reversed;
|
||||
var range;
|
||||
if (isNil(axis.range)) {
|
||||
if (axisType === 'angleAxis') {
|
||||
range = [startAngle, endAngle];
|
||||
} else if (axisType === 'radiusAxis') {
|
||||
range = [innerRadius, outerRadius];
|
||||
}
|
||||
if (reversed) {
|
||||
range = [range[1], range[0]];
|
||||
}
|
||||
} else {
|
||||
range = axis.range;
|
||||
var _range = range;
|
||||
var _range2 = _slicedToArray(_range, 2);
|
||||
startAngle = _range2[0];
|
||||
endAngle = _range2[1];
|
||||
}
|
||||
var _parseScale = parseScale(axis, chartName),
|
||||
realScaleType = _parseScale.realScaleType,
|
||||
scale = _parseScale.scale;
|
||||
scale.domain(domain).range(range);
|
||||
checkDomainOfScale(scale);
|
||||
var ticks = getTicksOfScale(scale, _objectSpread(_objectSpread({}, axis), {}, {
|
||||
realScaleType: realScaleType
|
||||
}));
|
||||
var finalAxis = _objectSpread(_objectSpread(_objectSpread({}, axis), ticks), {}, {
|
||||
range: range,
|
||||
radius: outerRadius,
|
||||
realScaleType: realScaleType,
|
||||
scale: scale,
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle
|
||||
});
|
||||
return _objectSpread(_objectSpread({}, result), {}, _defineProperty({}, id, finalAxis));
|
||||
}, {});
|
||||
};
|
||||
export var distanceBetweenPoints = function distanceBetweenPoints(point, anotherPoint) {
|
||||
var x1 = point.x,
|
||||
y1 = point.y;
|
||||
var x2 = anotherPoint.x,
|
||||
y2 = anotherPoint.y;
|
||||
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
|
||||
};
|
||||
export var getAngleOfPoint = function getAngleOfPoint(_ref, _ref2) {
|
||||
var x = _ref.x,
|
||||
y = _ref.y;
|
||||
var cx = _ref2.cx,
|
||||
cy = _ref2.cy;
|
||||
var radius = distanceBetweenPoints({
|
||||
x: x,
|
||||
y: y
|
||||
}, {
|
||||
x: cx,
|
||||
y: cy
|
||||
});
|
||||
if (radius <= 0) {
|
||||
return {
|
||||
radius: radius
|
||||
};
|
||||
}
|
||||
var cos = (x - cx) / radius;
|
||||
var angleInRadian = Math.acos(cos);
|
||||
if (y > cy) {
|
||||
angleInRadian = 2 * Math.PI - angleInRadian;
|
||||
}
|
||||
return {
|
||||
radius: radius,
|
||||
angle: radianToDegree(angleInRadian),
|
||||
angleInRadian: angleInRadian
|
||||
};
|
||||
};
|
||||
export var formatAngleOfSector = function formatAngleOfSector(_ref3) {
|
||||
var startAngle = _ref3.startAngle,
|
||||
endAngle = _ref3.endAngle;
|
||||
var startCnt = Math.floor(startAngle / 360);
|
||||
var endCnt = Math.floor(endAngle / 360);
|
||||
var min = Math.min(startCnt, endCnt);
|
||||
return {
|
||||
startAngle: startAngle - min * 360,
|
||||
endAngle: endAngle - min * 360
|
||||
};
|
||||
};
|
||||
var reverseFormatAngleOfSetor = function reverseFormatAngleOfSetor(angle, _ref4) {
|
||||
var startAngle = _ref4.startAngle,
|
||||
endAngle = _ref4.endAngle;
|
||||
var startCnt = Math.floor(startAngle / 360);
|
||||
var endCnt = Math.floor(endAngle / 360);
|
||||
var min = Math.min(startCnt, endCnt);
|
||||
return angle + min * 360;
|
||||
};
|
||||
export var inRangeOfSector = function inRangeOfSector(_ref5, sector) {
|
||||
var x = _ref5.x,
|
||||
y = _ref5.y;
|
||||
var _getAngleOfPoint = getAngleOfPoint({
|
||||
x: x,
|
||||
y: y
|
||||
}, sector),
|
||||
radius = _getAngleOfPoint.radius,
|
||||
angle = _getAngleOfPoint.angle;
|
||||
var innerRadius = sector.innerRadius,
|
||||
outerRadius = sector.outerRadius;
|
||||
if (radius < innerRadius || radius > outerRadius) {
|
||||
return false;
|
||||
}
|
||||
if (radius === 0) {
|
||||
return true;
|
||||
}
|
||||
var _formatAngleOfSector = formatAngleOfSector(sector),
|
||||
startAngle = _formatAngleOfSector.startAngle,
|
||||
endAngle = _formatAngleOfSector.endAngle;
|
||||
var formatAngle = angle;
|
||||
var inRange;
|
||||
if (startAngle <= endAngle) {
|
||||
while (formatAngle > endAngle) {
|
||||
formatAngle -= 360;
|
||||
}
|
||||
while (formatAngle < startAngle) {
|
||||
formatAngle += 360;
|
||||
}
|
||||
inRange = formatAngle >= startAngle && formatAngle <= endAngle;
|
||||
} else {
|
||||
while (formatAngle > startAngle) {
|
||||
formatAngle -= 360;
|
||||
}
|
||||
while (formatAngle < endAngle) {
|
||||
formatAngle += 360;
|
||||
}
|
||||
inRange = formatAngle >= endAngle && formatAngle <= startAngle;
|
||||
}
|
||||
if (inRange) {
|
||||
return _objectSpread(_objectSpread({}, sector), {}, {
|
||||
radius: radius,
|
||||
angle: reverseFormatAngleOfSetor(formatAngle, sector)
|
||||
});
|
||||
}
|
||||
return null;
|
||||
};
|
||||
export var getTickClassName = function getTickClassName(tick) {
|
||||
return ! /*#__PURE__*/isValidElement(tick) && !isFunction(tick) && typeof tick !== 'boolean' ? tick.className : '';
|
||||
};
|
||||
301
vendor/node_modules/recharts/es6/util/ReactUtils.js
generated
vendored
Normal file
301
vendor/node_modules/recharts/es6/util/ReactUtils.js
generated
vendored
Normal file
@@ -0,0 +1,301 @@
|
||||
var _excluded = ["children"],
|
||||
_excluded2 = ["children"];
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
import get from 'lodash/get';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isString from 'lodash/isString';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import isObject from 'lodash/isObject';
|
||||
import { Children, isValidElement } from 'react';
|
||||
import { isFragment } from 'react-is';
|
||||
import { isNumber } from './DataUtils';
|
||||
import { shallowEqual } from './ShallowEqual';
|
||||
import { FilteredElementKeyMap, SVGElementPropKeys, EventKeys } from './types';
|
||||
var REACT_BROWSER_EVENT_MAP = {
|
||||
click: 'onClick',
|
||||
mousedown: 'onMouseDown',
|
||||
mouseup: 'onMouseUp',
|
||||
mouseover: 'onMouseOver',
|
||||
mousemove: 'onMouseMove',
|
||||
mouseout: 'onMouseOut',
|
||||
mouseenter: 'onMouseEnter',
|
||||
mouseleave: 'onMouseLeave',
|
||||
touchcancel: 'onTouchCancel',
|
||||
touchend: 'onTouchEnd',
|
||||
touchmove: 'onTouchMove',
|
||||
touchstart: 'onTouchStart',
|
||||
contextmenu: 'onContextMenu',
|
||||
dblclick: 'onDoubleClick'
|
||||
};
|
||||
export var SCALE_TYPES = ['auto', 'linear', 'pow', 'sqrt', 'log', 'identity', 'time', 'band', 'point', 'ordinal', 'quantile', 'quantize', 'utc', 'sequential', 'threshold'];
|
||||
export var LEGEND_TYPES = ['plainline', 'line', 'square', 'rect', 'circle', 'cross', 'diamond', 'star', 'triangle', 'wye', 'none'];
|
||||
export var TOOLTIP_TYPES = ['none'];
|
||||
|
||||
/**
|
||||
* Get the display name of a component
|
||||
* @param {Object} Comp Specified Component
|
||||
* @return {String} Display name of Component
|
||||
*/
|
||||
export var getDisplayName = function getDisplayName(Comp) {
|
||||
if (typeof Comp === 'string') {
|
||||
return Comp;
|
||||
}
|
||||
if (!Comp) {
|
||||
return '';
|
||||
}
|
||||
return Comp.displayName || Comp.name || 'Component';
|
||||
};
|
||||
|
||||
// `toArray` gets called multiple times during the render
|
||||
// so we can memoize last invocation (since reference to `children` is the same)
|
||||
var lastChildren = null;
|
||||
var lastResult = null;
|
||||
export var toArray = function toArray(children) {
|
||||
if (children === lastChildren && Array.isArray(lastResult)) {
|
||||
return lastResult;
|
||||
}
|
||||
var result = [];
|
||||
Children.forEach(children, function (child) {
|
||||
if (isNil(child)) return;
|
||||
if (isFragment(child)) {
|
||||
result = result.concat(toArray(child.props.children));
|
||||
} else {
|
||||
// @ts-expect-error this could still be Iterable<ReactNode> and TS does not like that
|
||||
result.push(child);
|
||||
}
|
||||
});
|
||||
lastResult = result;
|
||||
lastChildren = children;
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
* Find and return all matched children by type.
|
||||
* `type` must be a React.ComponentType
|
||||
*/
|
||||
export function findAllByType(children, type) {
|
||||
var result = [];
|
||||
var types = [];
|
||||
if (Array.isArray(type)) {
|
||||
types = type.map(function (t) {
|
||||
return getDisplayName(t);
|
||||
});
|
||||
} else {
|
||||
types = [getDisplayName(type)];
|
||||
}
|
||||
toArray(children).forEach(function (child) {
|
||||
var childType = get(child, 'type.displayName') || get(child, 'type.name');
|
||||
if (types.indexOf(childType) !== -1) {
|
||||
result.push(child);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the first matched child by type, return null otherwise.
|
||||
* `type` must be a React.ComponentType
|
||||
*/
|
||||
export function findChildByType(children, type) {
|
||||
var result = findAllByType(children, type);
|
||||
return result && result[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new array of children excluding the ones matched the type
|
||||
*/
|
||||
export var withoutType = function withoutType(children, type) {
|
||||
var newChildren = [];
|
||||
var types;
|
||||
if (Array.isArray(type)) {
|
||||
types = type.map(function (t) {
|
||||
return getDisplayName(t);
|
||||
});
|
||||
} else {
|
||||
types = [getDisplayName(type)];
|
||||
}
|
||||
toArray(children).forEach(function (child) {
|
||||
var displayName = get(child, 'type.displayName');
|
||||
if (displayName && types.indexOf(displayName) !== -1) {
|
||||
return;
|
||||
}
|
||||
newChildren.push(child);
|
||||
});
|
||||
return newChildren;
|
||||
};
|
||||
|
||||
/**
|
||||
* validate the width and height props of a chart element
|
||||
* @param {Object} el A chart element
|
||||
* @return {Boolean} true If the props width and height are number, and greater than 0
|
||||
*/
|
||||
export var validateWidthHeight = function validateWidthHeight(el) {
|
||||
if (!el || !el.props) {
|
||||
return false;
|
||||
}
|
||||
var _el$props = el.props,
|
||||
width = _el$props.width,
|
||||
height = _el$props.height;
|
||||
if (!isNumber(width) || width <= 0 || !isNumber(height) || height <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
var SVG_TAGS = ['a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColormatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-url', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'lineGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'set', 'stop', 'style', 'svg', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'];
|
||||
var isSvgElement = function isSvgElement(child) {
|
||||
return child && child.type && isString(child.type) && SVG_TAGS.indexOf(child.type) >= 0;
|
||||
};
|
||||
export var hasClipDot = function hasClipDot(dot) {
|
||||
return dot && _typeof(dot) === 'object' && 'clipDot' in dot;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the property is valid to spread onto an SVG element or onto a specific component
|
||||
* @param {unknown} property property value currently being compared
|
||||
* @param {string} key property key currently being compared
|
||||
* @param {boolean} includeEvents if events are included in spreadable props
|
||||
* @param {boolean} svgElementType checks against map of SVG element types to attributes
|
||||
* @returns {boolean} is prop valid
|
||||
*/
|
||||
export var isValidSpreadableProp = function isValidSpreadableProp(property, key, includeEvents, svgElementType) {
|
||||
var _FilteredElementKeyMa;
|
||||
/**
|
||||
* If the svg element type is explicitly included, check against the filtered element key map
|
||||
* to determine if there are attributes that should only exist on that element type.
|
||||
* @todo Add an internal cjs version of https://github.com/wooorm/svg-element-attributes for full coverage.
|
||||
*/
|
||||
var matchingElementTypeKeys = (_FilteredElementKeyMa = FilteredElementKeyMap === null || FilteredElementKeyMap === void 0 ? void 0 : FilteredElementKeyMap[svgElementType]) !== null && _FilteredElementKeyMa !== void 0 ? _FilteredElementKeyMa : [];
|
||||
return key.startsWith('data-') || !isFunction(property) && (svgElementType && matchingElementTypeKeys.includes(key) || SVGElementPropKeys.includes(key)) || includeEvents && EventKeys.includes(key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter all the svg elements of children
|
||||
* @param {Array} children The children of a react element
|
||||
* @return {Array} All the svg elements
|
||||
*/
|
||||
export var filterSvgElements = function filterSvgElements(children) {
|
||||
var svgElements = [];
|
||||
toArray(children).forEach(function (entry) {
|
||||
if (isSvgElement(entry)) {
|
||||
svgElements.push(entry);
|
||||
}
|
||||
});
|
||||
return svgElements;
|
||||
};
|
||||
export var filterProps = function filterProps(props, includeEvents, svgElementType) {
|
||||
if (!props || typeof props === 'function' || typeof props === 'boolean') {
|
||||
return null;
|
||||
}
|
||||
var inputProps = props;
|
||||
if ( /*#__PURE__*/isValidElement(props)) {
|
||||
inputProps = props.props;
|
||||
}
|
||||
if (!isObject(inputProps)) {
|
||||
return null;
|
||||
}
|
||||
var out = {};
|
||||
|
||||
/**
|
||||
* Props are blindly spread onto SVG elements. This loop filters out properties that we don't want to spread.
|
||||
* Items filtered out are as follows:
|
||||
* - functions in properties that are SVG attributes (functions are included when includeEvents is true)
|
||||
* - props that are SVG attributes but don't matched the passed svgElementType
|
||||
* - any prop that is not in SVGElementPropKeys (or in EventKeys if includeEvents is true)
|
||||
*/
|
||||
Object.keys(inputProps).forEach(function (key) {
|
||||
var _inputProps;
|
||||
if (isValidSpreadableProp((_inputProps = inputProps) === null || _inputProps === void 0 ? void 0 : _inputProps[key], key, includeEvents, svgElementType)) {
|
||||
out[key] = inputProps[key];
|
||||
}
|
||||
});
|
||||
return out;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wether props of children changed
|
||||
* @param {Object} nextChildren The latest children
|
||||
* @param {Object} prevChildren The prev children
|
||||
* @return {Boolean} equal or not
|
||||
*/
|
||||
export var isChildrenEqual = function isChildrenEqual(nextChildren, prevChildren) {
|
||||
if (nextChildren === prevChildren) {
|
||||
return true;
|
||||
}
|
||||
var count = Children.count(nextChildren);
|
||||
if (count !== Children.count(prevChildren)) {
|
||||
return false;
|
||||
}
|
||||
if (count === 0) {
|
||||
return true;
|
||||
}
|
||||
if (count === 1) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
return isSingleChildEqual(Array.isArray(nextChildren) ? nextChildren[0] : nextChildren, Array.isArray(prevChildren) ? prevChildren[0] : prevChildren);
|
||||
}
|
||||
for (var i = 0; i < count; i++) {
|
||||
var nextChild = nextChildren[i];
|
||||
var prevChild = prevChildren[i];
|
||||
if (Array.isArray(nextChild) || Array.isArray(prevChild)) {
|
||||
if (!isChildrenEqual(nextChild, prevChild)) {
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
} else if (!isSingleChildEqual(nextChild, prevChild)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
export var isSingleChildEqual = function isSingleChildEqual(nextChild, prevChild) {
|
||||
if (isNil(nextChild) && isNil(prevChild)) {
|
||||
return true;
|
||||
}
|
||||
if (!isNil(nextChild) && !isNil(prevChild)) {
|
||||
var _ref = nextChild.props || {},
|
||||
nextChildren = _ref.children,
|
||||
nextProps = _objectWithoutProperties(_ref, _excluded);
|
||||
var _ref2 = prevChild.props || {},
|
||||
prevChildren = _ref2.children,
|
||||
prevProps = _objectWithoutProperties(_ref2, _excluded2);
|
||||
if (nextChildren && prevChildren) {
|
||||
return shallowEqual(nextProps, prevProps) && isChildrenEqual(nextChildren, prevChildren);
|
||||
}
|
||||
if (!nextChildren && !prevChildren) {
|
||||
return shallowEqual(nextProps, prevProps);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export var renderByOrder = function renderByOrder(children, renderMap) {
|
||||
var elements = [];
|
||||
var record = {};
|
||||
toArray(children).forEach(function (child, index) {
|
||||
if (isSvgElement(child)) {
|
||||
elements.push(child);
|
||||
} else if (child) {
|
||||
var displayName = getDisplayName(child.type);
|
||||
var _ref3 = renderMap[displayName] || {},
|
||||
handler = _ref3.handler,
|
||||
once = _ref3.once;
|
||||
if (handler && (!once || !record[displayName])) {
|
||||
var results = handler(child, displayName, index);
|
||||
elements.push(results);
|
||||
record[displayName] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return elements;
|
||||
};
|
||||
export var getReactEventByType = function getReactEventByType(e) {
|
||||
var type = e && e.type;
|
||||
if (type && REACT_BROWSER_EVENT_MAP[type]) {
|
||||
return REACT_BROWSER_EVENT_MAP[type];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
export var parseChildIndex = function parseChildIndex(child, children) {
|
||||
return toArray(children).indexOf(child);
|
||||
};
|
||||
173
vendor/node_modules/recharts/es6/util/ReduceCSSCalc.js
generated
vendored
Normal file
173
vendor/node_modules/recharts/es6/util/ReduceCSSCalc.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var MULTIPLY_OR_DIVIDE_REGEX = /(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/;
|
||||
var ADD_OR_SUBTRACT_REGEX = /(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/;
|
||||
var CSS_LENGTH_UNIT_REGEX = /^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/;
|
||||
var NUM_SPLIT_REGEX = /(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/;
|
||||
var CONVERSION_RATES = {
|
||||
cm: 96 / 2.54,
|
||||
mm: 96 / 25.4,
|
||||
pt: 96 / 72,
|
||||
pc: 96 / 6,
|
||||
"in": 96,
|
||||
Q: 96 / (2.54 * 40),
|
||||
px: 1
|
||||
};
|
||||
var FIXED_CSS_LENGTH_UNITS = Object.keys(CONVERSION_RATES);
|
||||
var STR_NAN = 'NaN';
|
||||
function convertToPx(value, unit) {
|
||||
return value * CONVERSION_RATES[unit];
|
||||
}
|
||||
var DecimalCSS = /*#__PURE__*/function () {
|
||||
function DecimalCSS(num, unit) {
|
||||
_classCallCheck(this, DecimalCSS);
|
||||
this.num = num;
|
||||
this.unit = unit;
|
||||
this.num = num;
|
||||
this.unit = unit;
|
||||
if (Number.isNaN(num)) {
|
||||
this.unit = '';
|
||||
}
|
||||
if (unit !== '' && !CSS_LENGTH_UNIT_REGEX.test(unit)) {
|
||||
this.num = NaN;
|
||||
this.unit = '';
|
||||
}
|
||||
if (FIXED_CSS_LENGTH_UNITS.includes(unit)) {
|
||||
this.num = convertToPx(num, unit);
|
||||
this.unit = 'px';
|
||||
}
|
||||
}
|
||||
return _createClass(DecimalCSS, [{
|
||||
key: "add",
|
||||
value: function add(other) {
|
||||
if (this.unit !== other.unit) {
|
||||
return new DecimalCSS(NaN, '');
|
||||
}
|
||||
return new DecimalCSS(this.num + other.num, this.unit);
|
||||
}
|
||||
}, {
|
||||
key: "subtract",
|
||||
value: function subtract(other) {
|
||||
if (this.unit !== other.unit) {
|
||||
return new DecimalCSS(NaN, '');
|
||||
}
|
||||
return new DecimalCSS(this.num - other.num, this.unit);
|
||||
}
|
||||
}, {
|
||||
key: "multiply",
|
||||
value: function multiply(other) {
|
||||
if (this.unit !== '' && other.unit !== '' && this.unit !== other.unit) {
|
||||
return new DecimalCSS(NaN, '');
|
||||
}
|
||||
return new DecimalCSS(this.num * other.num, this.unit || other.unit);
|
||||
}
|
||||
}, {
|
||||
key: "divide",
|
||||
value: function divide(other) {
|
||||
if (this.unit !== '' && other.unit !== '' && this.unit !== other.unit) {
|
||||
return new DecimalCSS(NaN, '');
|
||||
}
|
||||
return new DecimalCSS(this.num / other.num, this.unit || other.unit);
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return "".concat(this.num).concat(this.unit);
|
||||
}
|
||||
}, {
|
||||
key: "isNaN",
|
||||
value: function isNaN() {
|
||||
return Number.isNaN(this.num);
|
||||
}
|
||||
}], [{
|
||||
key: "parse",
|
||||
value: function parse(str) {
|
||||
var _NUM_SPLIT_REGEX$exec;
|
||||
var _ref = (_NUM_SPLIT_REGEX$exec = NUM_SPLIT_REGEX.exec(str)) !== null && _NUM_SPLIT_REGEX$exec !== void 0 ? _NUM_SPLIT_REGEX$exec : [],
|
||||
_ref2 = _slicedToArray(_ref, 3),
|
||||
numStr = _ref2[1],
|
||||
unit = _ref2[2];
|
||||
return new DecimalCSS(parseFloat(numStr), unit !== null && unit !== void 0 ? unit : '');
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
function calculateArithmetic(expr) {
|
||||
if (expr.includes(STR_NAN)) {
|
||||
return STR_NAN;
|
||||
}
|
||||
var newExpr = expr;
|
||||
while (newExpr.includes('*') || newExpr.includes('/')) {
|
||||
var _MULTIPLY_OR_DIVIDE_R;
|
||||
var _ref3 = (_MULTIPLY_OR_DIVIDE_R = MULTIPLY_OR_DIVIDE_REGEX.exec(newExpr)) !== null && _MULTIPLY_OR_DIVIDE_R !== void 0 ? _MULTIPLY_OR_DIVIDE_R : [],
|
||||
_ref4 = _slicedToArray(_ref3, 4),
|
||||
leftOperand = _ref4[1],
|
||||
operator = _ref4[2],
|
||||
rightOperand = _ref4[3];
|
||||
var lTs = DecimalCSS.parse(leftOperand !== null && leftOperand !== void 0 ? leftOperand : '');
|
||||
var rTs = DecimalCSS.parse(rightOperand !== null && rightOperand !== void 0 ? rightOperand : '');
|
||||
var result = operator === '*' ? lTs.multiply(rTs) : lTs.divide(rTs);
|
||||
if (result.isNaN()) {
|
||||
return STR_NAN;
|
||||
}
|
||||
newExpr = newExpr.replace(MULTIPLY_OR_DIVIDE_REGEX, result.toString());
|
||||
}
|
||||
while (newExpr.includes('+') || /.-\d+(?:\.\d+)?/.test(newExpr)) {
|
||||
var _ADD_OR_SUBTRACT_REGE;
|
||||
var _ref5 = (_ADD_OR_SUBTRACT_REGE = ADD_OR_SUBTRACT_REGEX.exec(newExpr)) !== null && _ADD_OR_SUBTRACT_REGE !== void 0 ? _ADD_OR_SUBTRACT_REGE : [],
|
||||
_ref6 = _slicedToArray(_ref5, 4),
|
||||
_leftOperand = _ref6[1],
|
||||
_operator = _ref6[2],
|
||||
_rightOperand = _ref6[3];
|
||||
var _lTs = DecimalCSS.parse(_leftOperand !== null && _leftOperand !== void 0 ? _leftOperand : '');
|
||||
var _rTs = DecimalCSS.parse(_rightOperand !== null && _rightOperand !== void 0 ? _rightOperand : '');
|
||||
var _result = _operator === '+' ? _lTs.add(_rTs) : _lTs.subtract(_rTs);
|
||||
if (_result.isNaN()) {
|
||||
return STR_NAN;
|
||||
}
|
||||
newExpr = newExpr.replace(ADD_OR_SUBTRACT_REGEX, _result.toString());
|
||||
}
|
||||
return newExpr;
|
||||
}
|
||||
var PARENTHESES_REGEX = /\(([^()]*)\)/;
|
||||
function calculateParentheses(expr) {
|
||||
var newExpr = expr;
|
||||
while (newExpr.includes('(')) {
|
||||
var _PARENTHESES_REGEX$ex = PARENTHESES_REGEX.exec(newExpr),
|
||||
_PARENTHESES_REGEX$ex2 = _slicedToArray(_PARENTHESES_REGEX$ex, 2),
|
||||
parentheticalExpression = _PARENTHESES_REGEX$ex2[1];
|
||||
newExpr = newExpr.replace(PARENTHESES_REGEX, calculateArithmetic(parentheticalExpression));
|
||||
}
|
||||
return newExpr;
|
||||
}
|
||||
function evaluateExpression(expression) {
|
||||
var newExpr = expression.replace(/\s+/g, '');
|
||||
newExpr = calculateParentheses(newExpr);
|
||||
newExpr = calculateArithmetic(newExpr);
|
||||
return newExpr;
|
||||
}
|
||||
export function safeEvaluateExpression(expression) {
|
||||
try {
|
||||
return evaluateExpression(expression);
|
||||
} catch (e) {
|
||||
/* istanbul ignore next */
|
||||
return STR_NAN;
|
||||
}
|
||||
}
|
||||
export function reduceCSSCalc(expression) {
|
||||
var result = safeEvaluateExpression(expression.slice(5, -1));
|
||||
if (result === STR_NAN) {
|
||||
// notify the user
|
||||
return '';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
26
vendor/node_modules/recharts/es6/util/ScatterUtils.js
generated
vendored
Normal file
26
vendor/node_modules/recharts/es6/util/ScatterUtils.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var _excluded = ["option", "isActive"];
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
import * as React from 'react';
|
||||
import { Symbols } from '../shape/Symbols';
|
||||
import { Shape } from './ActiveShapeUtils';
|
||||
export function ScatterSymbol(_ref) {
|
||||
var option = _ref.option,
|
||||
isActive = _ref.isActive,
|
||||
props = _objectWithoutProperties(_ref, _excluded);
|
||||
if (typeof option === 'string') {
|
||||
return /*#__PURE__*/React.createElement(Shape, _extends({
|
||||
option: /*#__PURE__*/React.createElement(Symbols, _extends({
|
||||
type: option
|
||||
}, props)),
|
||||
isActive: isActive,
|
||||
shapeType: "symbols"
|
||||
}, props));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Shape, _extends({
|
||||
option: option,
|
||||
isActive: isActive,
|
||||
shapeType: "symbols"
|
||||
}, props));
|
||||
}
|
||||
14
vendor/node_modules/recharts/es6/util/ShallowEqual.js
generated
vendored
Normal file
14
vendor/node_modules/recharts/es6/util/ShallowEqual.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export function shallowEqual(a, b) {
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
for (var key in a) {
|
||||
if ({}.hasOwnProperty.call(a, key) && (!{}.hasOwnProperty.call(b, key) || a[key] !== b[key])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (var _key in b) {
|
||||
if ({}.hasOwnProperty.call(b, _key) && !{}.hasOwnProperty.call(a, _key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
38
vendor/node_modules/recharts/es6/util/TickUtils.js
generated
vendored
Normal file
38
vendor/node_modules/recharts/es6/util/TickUtils.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { getAngledRectangleWidth } from './CartesianUtils';
|
||||
import { getEveryNthWithCondition } from './getEveryNthWithCondition';
|
||||
export function getAngledTickWidth(contentSize, unitSize, angle) {
|
||||
var size = {
|
||||
width: contentSize.width + unitSize.width,
|
||||
height: contentSize.height + unitSize.height
|
||||
};
|
||||
return getAngledRectangleWidth(size, angle);
|
||||
}
|
||||
export function getTickBoundaries(viewBox, sign, sizeKey) {
|
||||
var isWidth = sizeKey === 'width';
|
||||
var x = viewBox.x,
|
||||
y = viewBox.y,
|
||||
width = viewBox.width,
|
||||
height = viewBox.height;
|
||||
if (sign === 1) {
|
||||
return {
|
||||
start: isWidth ? x : y,
|
||||
end: isWidth ? x + width : y + height
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: isWidth ? x + width : y + height,
|
||||
end: isWidth ? x : y
|
||||
};
|
||||
}
|
||||
export function isVisible(sign, tickPosition, getSize, start, end) {
|
||||
/* Since getSize() is expensive (it reads the ticks' size from the DOM), we do this check first to avoid calculating
|
||||
* the tick's size. */
|
||||
if (sign * tickPosition < sign * start || sign * tickPosition > sign * end) {
|
||||
return false;
|
||||
}
|
||||
var size = getSize();
|
||||
return sign * (tickPosition - sign * size / 2 - start) >= 0 && sign * (tickPosition + sign * size / 2 - end) <= 0;
|
||||
}
|
||||
export function getNumberIntervalTicks(ticks, interval) {
|
||||
return getEveryNthWithCondition(ticks, interval + 1);
|
||||
}
|
||||
18
vendor/node_modules/recharts/es6/util/calculateViewBox.js
generated
vendored
Normal file
18
vendor/node_modules/recharts/es6/util/calculateViewBox.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import memoize from 'lodash/memoize';
|
||||
/**
|
||||
* This is memoized because the viewBox is unlikely to change often
|
||||
* - but because it is computed from offset, any change to it would re-render all children.
|
||||
*
|
||||
* And because we have many readers of the viewBox, and update it only rarely,
|
||||
* then let's optimize with memoization.
|
||||
*/
|
||||
export var calculateViewBox = memoize(function (offset) {
|
||||
return {
|
||||
x: offset.left,
|
||||
y: offset.top,
|
||||
width: offset.width,
|
||||
height: offset.height
|
||||
};
|
||||
}, function (offset) {
|
||||
return ['l', offset.left, 't', offset.top, 'w', offset.width, 'h', offset.height].join('');
|
||||
});
|
||||
39
vendor/node_modules/recharts/es6/util/cursor/getCursorPoints.js
generated
vendored
Normal file
39
vendor/node_modules/recharts/es6/util/cursor/getCursorPoints.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { polarToCartesian } from '../PolarUtils';
|
||||
import { getRadialCursorPoints } from './getRadialCursorPoints';
|
||||
export function getCursorPoints(layout, activeCoordinate, offset) {
|
||||
var x1, y1, x2, y2;
|
||||
if (layout === 'horizontal') {
|
||||
x1 = activeCoordinate.x;
|
||||
x2 = x1;
|
||||
y1 = offset.top;
|
||||
y2 = offset.top + offset.height;
|
||||
} else if (layout === 'vertical') {
|
||||
y1 = activeCoordinate.y;
|
||||
y2 = y1;
|
||||
x1 = offset.left;
|
||||
x2 = offset.left + offset.width;
|
||||
} else if (activeCoordinate.cx != null && activeCoordinate.cy != null) {
|
||||
if (layout === 'centric') {
|
||||
var cx = activeCoordinate.cx,
|
||||
cy = activeCoordinate.cy,
|
||||
innerRadius = activeCoordinate.innerRadius,
|
||||
outerRadius = activeCoordinate.outerRadius,
|
||||
angle = activeCoordinate.angle;
|
||||
var innerPoint = polarToCartesian(cx, cy, innerRadius, angle);
|
||||
var outerPoint = polarToCartesian(cx, cy, outerRadius, angle);
|
||||
x1 = innerPoint.x;
|
||||
y1 = innerPoint.y;
|
||||
x2 = outerPoint.x;
|
||||
y2 = outerPoint.y;
|
||||
} else {
|
||||
return getRadialCursorPoints(activeCoordinate);
|
||||
}
|
||||
}
|
||||
return [{
|
||||
x: x1,
|
||||
y: y1
|
||||
}, {
|
||||
x: x2,
|
||||
y: y2
|
||||
}];
|
||||
}
|
||||
11
vendor/node_modules/recharts/es6/util/cursor/getCursorRectangle.js
generated
vendored
Normal file
11
vendor/node_modules/recharts/es6/util/cursor/getCursorRectangle.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export function getCursorRectangle(layout, activeCoordinate, offset, tooltipAxisBandSize) {
|
||||
var halfSize = tooltipAxisBandSize / 2;
|
||||
return {
|
||||
stroke: 'none',
|
||||
fill: '#ccc',
|
||||
x: layout === 'horizontal' ? activeCoordinate.x - halfSize : offset.left + 0.5,
|
||||
y: layout === 'horizontal' ? offset.top + 0.5 : activeCoordinate.y - halfSize,
|
||||
width: layout === 'horizontal' ? tooltipAxisBandSize : offset.width - 1,
|
||||
height: layout === 'horizontal' ? offset.height - 1 : tooltipAxisBandSize
|
||||
};
|
||||
}
|
||||
23
vendor/node_modules/recharts/es6/util/cursor/getRadialCursorPoints.js
generated
vendored
Normal file
23
vendor/node_modules/recharts/es6/util/cursor/getRadialCursorPoints.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { polarToCartesian } from '../PolarUtils';
|
||||
/**
|
||||
* Only applicable for radial layouts
|
||||
* @param {Object} activeCoordinate ChartCoordinate
|
||||
* @returns {Object} RadialCursorPoints
|
||||
*/
|
||||
export function getRadialCursorPoints(activeCoordinate) {
|
||||
var cx = activeCoordinate.cx,
|
||||
cy = activeCoordinate.cy,
|
||||
radius = activeCoordinate.radius,
|
||||
startAngle = activeCoordinate.startAngle,
|
||||
endAngle = activeCoordinate.endAngle;
|
||||
var startPoint = polarToCartesian(cx, cy, radius, startAngle);
|
||||
var endPoint = polarToCartesian(cx, cy, radius, endAngle);
|
||||
return {
|
||||
points: [startPoint, endPoint],
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
radius: radius,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle
|
||||
};
|
||||
}
|
||||
26
vendor/node_modules/recharts/es6/util/getEveryNthWithCondition.js
generated
vendored
Normal file
26
vendor/node_modules/recharts/es6/util/getEveryNthWithCondition.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Given an array and a number N, return a new array which contains every nTh
|
||||
* element of the input array. For n below 1, an empty array is returned.
|
||||
* If isValid is provided, all candidates must suffice the condition, else undefined is returned.
|
||||
* @param {T[]} array An input array.
|
||||
* @param {integer} n A number
|
||||
* @param {Function} isValid A function to evaluate a candidate form the array
|
||||
* @returns {T[]} The result array of the same type as the input array.
|
||||
*/
|
||||
export function getEveryNthWithCondition(array, n, isValid) {
|
||||
if (n < 1) {
|
||||
return [];
|
||||
}
|
||||
if (n === 1 && isValid === undefined) {
|
||||
return array;
|
||||
}
|
||||
var result = [];
|
||||
for (var i = 0; i < array.length; i += n) {
|
||||
if (isValid === undefined || isValid(array[i]) === true) {
|
||||
result.push(array[i]);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
62
vendor/node_modules/recharts/es6/util/getLegendProps.js
generated
vendored
Normal file
62
vendor/node_modules/recharts/es6/util/getLegendProps.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import { Legend } from '../component/Legend';
|
||||
import { getMainColorOfGraphicItem } from './ChartUtils';
|
||||
import { findChildByType } from './ReactUtils';
|
||||
export var getLegendProps = function getLegendProps(_ref) {
|
||||
var children = _ref.children,
|
||||
formattedGraphicalItems = _ref.formattedGraphicalItems,
|
||||
legendWidth = _ref.legendWidth,
|
||||
legendContent = _ref.legendContent;
|
||||
var legendItem = findChildByType(children, Legend);
|
||||
if (!legendItem) {
|
||||
return null;
|
||||
}
|
||||
var legendDefaultProps = Legend.defaultProps;
|
||||
var legendProps = legendDefaultProps !== undefined ? _objectSpread(_objectSpread({}, legendDefaultProps), legendItem.props) : {};
|
||||
var legendData;
|
||||
if (legendItem.props && legendItem.props.payload) {
|
||||
legendData = legendItem.props && legendItem.props.payload;
|
||||
} else if (legendContent === 'children') {
|
||||
legendData = (formattedGraphicalItems || []).reduce(function (result, _ref2) {
|
||||
var item = _ref2.item,
|
||||
props = _ref2.props;
|
||||
var data = props.sectors || props.data || [];
|
||||
return result.concat(data.map(function (entry) {
|
||||
return {
|
||||
type: legendItem.props.iconType || item.props.legendType,
|
||||
value: entry.name,
|
||||
color: entry.fill,
|
||||
payload: entry
|
||||
};
|
||||
}));
|
||||
}, []);
|
||||
} else {
|
||||
legendData = (formattedGraphicalItems || []).map(function (_ref3) {
|
||||
var item = _ref3.item;
|
||||
var itemDefaultProps = item.type.defaultProps;
|
||||
var itemProps = itemDefaultProps !== undefined ? _objectSpread(_objectSpread({}, itemDefaultProps), item.props) : {};
|
||||
var dataKey = itemProps.dataKey,
|
||||
name = itemProps.name,
|
||||
legendType = itemProps.legendType,
|
||||
hide = itemProps.hide;
|
||||
return {
|
||||
inactive: hide,
|
||||
dataKey: dataKey,
|
||||
type: legendProps.iconType || legendType || 'square',
|
||||
color: getMainColorOfGraphicItem(item),
|
||||
value: name || dataKey,
|
||||
// @ts-expect-error property strokeDasharray is required in Payload but optional in props
|
||||
payload: itemProps
|
||||
};
|
||||
});
|
||||
}
|
||||
return _objectSpread(_objectSpread(_objectSpread({}, legendProps), Legend.getWithHeight(legendItem, legendWidth)), {}, {
|
||||
payload: legendData,
|
||||
item: legendItem
|
||||
});
|
||||
};
|
||||
23
vendor/node_modules/recharts/es6/util/isDomainSpecifiedByUser.js
generated
vendored
Normal file
23
vendor/node_modules/recharts/es6/util/isDomainSpecifiedByUser.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { isNumber } from './DataUtils';
|
||||
/**
|
||||
* Takes a domain and user props to determine whether he provided the domain via props or if we need to calculate it.
|
||||
* @param {AxisDomain} domain The potential domain from props
|
||||
* @param {Boolean} allowDataOverflow from props
|
||||
* @param {String} axisType from props
|
||||
* @returns {Boolean} `true` if domain is specified by user
|
||||
*/
|
||||
export function isDomainSpecifiedByUser(domain, allowDataOverflow, axisType) {
|
||||
if (axisType === 'number' && allowDataOverflow === true && Array.isArray(domain)) {
|
||||
var domainStart = domain === null || domain === void 0 ? void 0 : domain[0];
|
||||
var domainEnd = domain === null || domain === void 0 ? void 0 : domain[1];
|
||||
|
||||
/*
|
||||
* The `isNumber` check is needed because the user could also provide strings like "dataMin" via the domain props.
|
||||
* In such case, we have to compute the domain from the data.
|
||||
*/
|
||||
if (!!domainStart && !!domainEnd && isNumber(domainStart) && isNumber(domainEnd)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
20
vendor/node_modules/recharts/es6/util/payload/getUniqPayload.js
generated
vendored
Normal file
20
vendor/node_modules/recharts/es6/util/payload/getUniqPayload.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import uniqBy from 'lodash/uniqBy';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
|
||||
/**
|
||||
* This is configuration option that decides how to filter for unique values only:
|
||||
*
|
||||
* - `false` means "no filter"
|
||||
* - `true` means "use recharts default filter"
|
||||
* - function means "use return of this function as the default key"
|
||||
*/
|
||||
|
||||
export function getUniqPayload(payload, option, defaultUniqBy) {
|
||||
if (option === true) {
|
||||
return uniqBy(payload, defaultUniqBy);
|
||||
}
|
||||
if (isFunction(option)) {
|
||||
return uniqBy(payload, option);
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
107
vendor/node_modules/recharts/es6/util/tooltip/translate.js
generated
vendored
Normal file
107
vendor/node_modules/recharts/es6/util/tooltip/translate.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import clsx from 'clsx';
|
||||
import { isNumber } from '../DataUtils';
|
||||
var CSS_CLASS_PREFIX = 'recharts-tooltip-wrapper';
|
||||
var TOOLTIP_HIDDEN = {
|
||||
visibility: 'hidden'
|
||||
};
|
||||
export function getTooltipCSSClassName(_ref) {
|
||||
var coordinate = _ref.coordinate,
|
||||
translateX = _ref.translateX,
|
||||
translateY = _ref.translateY;
|
||||
return clsx(CSS_CLASS_PREFIX, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(CSS_CLASS_PREFIX, "-right"), isNumber(translateX) && coordinate && isNumber(coordinate.x) && translateX >= coordinate.x), "".concat(CSS_CLASS_PREFIX, "-left"), isNumber(translateX) && coordinate && isNumber(coordinate.x) && translateX < coordinate.x), "".concat(CSS_CLASS_PREFIX, "-bottom"), isNumber(translateY) && coordinate && isNumber(coordinate.y) && translateY >= coordinate.y), "".concat(CSS_CLASS_PREFIX, "-top"), isNumber(translateY) && coordinate && isNumber(coordinate.y) && translateY < coordinate.y));
|
||||
}
|
||||
export function getTooltipTranslateXY(_ref2) {
|
||||
var allowEscapeViewBox = _ref2.allowEscapeViewBox,
|
||||
coordinate = _ref2.coordinate,
|
||||
key = _ref2.key,
|
||||
offsetTopLeft = _ref2.offsetTopLeft,
|
||||
position = _ref2.position,
|
||||
reverseDirection = _ref2.reverseDirection,
|
||||
tooltipDimension = _ref2.tooltipDimension,
|
||||
viewBox = _ref2.viewBox,
|
||||
viewBoxDimension = _ref2.viewBoxDimension;
|
||||
if (position && isNumber(position[key])) {
|
||||
return position[key];
|
||||
}
|
||||
var negative = coordinate[key] - tooltipDimension - offsetTopLeft;
|
||||
var positive = coordinate[key] + offsetTopLeft;
|
||||
if (allowEscapeViewBox[key]) {
|
||||
return reverseDirection[key] ? negative : positive;
|
||||
}
|
||||
if (reverseDirection[key]) {
|
||||
var _tooltipBoundary = negative;
|
||||
var _viewBoxBoundary = viewBox[key];
|
||||
if (_tooltipBoundary < _viewBoxBoundary) {
|
||||
return Math.max(positive, viewBox[key]);
|
||||
}
|
||||
return Math.max(negative, viewBox[key]);
|
||||
}
|
||||
var tooltipBoundary = positive + tooltipDimension;
|
||||
var viewBoxBoundary = viewBox[key] + viewBoxDimension;
|
||||
if (tooltipBoundary > viewBoxBoundary) {
|
||||
return Math.max(negative, viewBox[key]);
|
||||
}
|
||||
return Math.max(positive, viewBox[key]);
|
||||
}
|
||||
export function getTransformStyle(_ref3) {
|
||||
var translateX = _ref3.translateX,
|
||||
translateY = _ref3.translateY,
|
||||
useTranslate3d = _ref3.useTranslate3d;
|
||||
return {
|
||||
transform: useTranslate3d ? "translate3d(".concat(translateX, "px, ").concat(translateY, "px, 0)") : "translate(".concat(translateX, "px, ").concat(translateY, "px)")
|
||||
};
|
||||
}
|
||||
export function getTooltipTranslate(_ref4) {
|
||||
var allowEscapeViewBox = _ref4.allowEscapeViewBox,
|
||||
coordinate = _ref4.coordinate,
|
||||
offsetTopLeft = _ref4.offsetTopLeft,
|
||||
position = _ref4.position,
|
||||
reverseDirection = _ref4.reverseDirection,
|
||||
tooltipBox = _ref4.tooltipBox,
|
||||
useTranslate3d = _ref4.useTranslate3d,
|
||||
viewBox = _ref4.viewBox;
|
||||
var cssProperties, translateX, translateY;
|
||||
if (tooltipBox.height > 0 && tooltipBox.width > 0 && coordinate) {
|
||||
translateX = getTooltipTranslateXY({
|
||||
allowEscapeViewBox: allowEscapeViewBox,
|
||||
coordinate: coordinate,
|
||||
key: 'x',
|
||||
offsetTopLeft: offsetTopLeft,
|
||||
position: position,
|
||||
reverseDirection: reverseDirection,
|
||||
tooltipDimension: tooltipBox.width,
|
||||
viewBox: viewBox,
|
||||
viewBoxDimension: viewBox.width
|
||||
});
|
||||
translateY = getTooltipTranslateXY({
|
||||
allowEscapeViewBox: allowEscapeViewBox,
|
||||
coordinate: coordinate,
|
||||
key: 'y',
|
||||
offsetTopLeft: offsetTopLeft,
|
||||
position: position,
|
||||
reverseDirection: reverseDirection,
|
||||
tooltipDimension: tooltipBox.height,
|
||||
viewBox: viewBox,
|
||||
viewBoxDimension: viewBox.height
|
||||
});
|
||||
cssProperties = getTransformStyle({
|
||||
translateX: translateX,
|
||||
translateY: translateY,
|
||||
useTranslate3d: useTranslate3d
|
||||
});
|
||||
} else {
|
||||
cssProperties = TOOLTIP_HIDDEN;
|
||||
}
|
||||
return {
|
||||
cssProperties: cssProperties,
|
||||
cssClasses: getTooltipCSSClassName({
|
||||
translateX: translateX,
|
||||
translateY: translateY,
|
||||
coordinate: coordinate
|
||||
})
|
||||
};
|
||||
}
|
||||
126
vendor/node_modules/recharts/es6/util/types.js
generated
vendored
Normal file
126
vendor/node_modules/recharts/es6/util/types.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
import { isValidElement } from 'react';
|
||||
import isObject from 'lodash/isObject';
|
||||
|
||||
/**
|
||||
* Determines how values are stacked:
|
||||
*
|
||||
* - `none` is the default, it adds values on top of each other. No smarts. Negative values will overlap.
|
||||
* - `expand` make it so that the values always add up to 1 - so the chart will look like a rectangle.
|
||||
* - `wiggle` and `silhouette` tries to keep the chart centered.
|
||||
* - `sign` stacks positive values above zero and negative values below zero. Similar to `none` but handles negatives.
|
||||
* - `positive` ignores all negative values, and then behaves like \`none\`.
|
||||
*
|
||||
* Also see https://d3js.org/d3-shape/stack#stack-offsets
|
||||
* (note that the `diverging` offset in d3 is named `sign` in recharts)
|
||||
*/
|
||||
|
||||
//
|
||||
// Event Handler Types -- Copied from @types/react/index.d.ts and adapted for Props.
|
||||
//
|
||||
|
||||
var SVGContainerPropKeys = ['viewBox', 'children'];
|
||||
export var SVGElementPropKeys = ['aria-activedescendant', 'aria-atomic', 'aria-autocomplete', 'aria-busy', 'aria-checked', 'aria-colcount', 'aria-colindex', 'aria-colspan', 'aria-controls', 'aria-current', 'aria-describedby', 'aria-details', 'aria-disabled', 'aria-errormessage', 'aria-expanded', 'aria-flowto', 'aria-haspopup', 'aria-hidden', 'aria-invalid', 'aria-keyshortcuts', 'aria-label', 'aria-labelledby', 'aria-level', 'aria-live', 'aria-modal', 'aria-multiline', 'aria-multiselectable', 'aria-orientation', 'aria-owns', 'aria-placeholder', 'aria-posinset', 'aria-pressed', 'aria-readonly', 'aria-relevant', 'aria-required', 'aria-roledescription', 'aria-rowcount', 'aria-rowindex', 'aria-rowspan', 'aria-selected', 'aria-setsize', 'aria-sort', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'className', 'color', 'height', 'id', 'lang', 'max', 'media', 'method', 'min', 'name', 'style',
|
||||
/*
|
||||
* removed 'type' SVGElementPropKey because we do not currently use any SVG elements
|
||||
* that can use it and it conflicts with the recharts prop 'type'
|
||||
* https://github.com/recharts/recharts/pull/3327
|
||||
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/type
|
||||
*/
|
||||
// 'type',
|
||||
'target', 'width', 'role', 'tabIndex', 'accentHeight', 'accumulate', 'additive', 'alignmentBaseline', 'allowReorder', 'alphabetic', 'amplitude', 'arabicForm', 'ascent', 'attributeName', 'attributeType', 'autoReverse', 'azimuth', 'baseFrequency', 'baselineShift', 'baseProfile', 'bbox', 'begin', 'bias', 'by', 'calcMode', 'capHeight', 'clip', 'clipPath', 'clipPathUnits', 'clipRule', 'colorInterpolation', 'colorInterpolationFilters', 'colorProfile', 'colorRendering', 'contentScriptType', 'contentStyleType', 'cursor', 'cx', 'cy', 'd', 'decelerate', 'descent', 'diffuseConstant', 'direction', 'display', 'divisor', 'dominantBaseline', 'dur', 'dx', 'dy', 'edgeMode', 'elevation', 'enableBackground', 'end', 'exponent', 'externalResourcesRequired', 'fill', 'fillOpacity', 'fillRule', 'filter', 'filterRes', 'filterUnits', 'floodColor', 'floodOpacity', 'focusable', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'format', 'from', 'fx', 'fy', 'g1', 'g2', 'glyphName', 'glyphOrientationHorizontal', 'glyphOrientationVertical', 'glyphRef', 'gradientTransform', 'gradientUnits', 'hanging', 'horizAdvX', 'horizOriginX', 'href', 'ideographic', 'imageRendering', 'in2', 'in', 'intercept', 'k1', 'k2', 'k3', 'k4', 'k', 'kernelMatrix', 'kernelUnitLength', 'kerning', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'letterSpacing', 'lightingColor', 'limitingConeAngle', 'local', 'markerEnd', 'markerHeight', 'markerMid', 'markerStart', 'markerUnits', 'markerWidth', 'mask', 'maskContentUnits', 'maskUnits', 'mathematical', 'mode', 'numOctaves', 'offset', 'opacity', 'operator', 'order', 'orient', 'orientation', 'origin', 'overflow', 'overlinePosition', 'overlineThickness', 'paintOrder', 'panose1', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointerEvents', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'r', 'radius', 'refX', 'refY', 'renderingIntent', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'result', 'rotate', 'rx', 'ry', 'seed', 'shapeRendering', 'slope', 'spacing', 'specularConstant', 'specularExponent', 'speed', 'spreadMethod', 'startOffset', 'stdDeviation', 'stemh', 'stemv', 'stitchTiles', 'stopColor', 'stopOpacity', 'strikethroughPosition', 'strikethroughThickness', 'string', 'stroke', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textAnchor', 'textDecoration', 'textLength', 'textRendering', 'to', 'transform', 'u1', 'u2', 'underlinePosition', 'underlineThickness', 'unicode', 'unicodeBidi', 'unicodeRange', 'unitsPerEm', 'vAlphabetic', 'values', 'vectorEffect', 'version', 'vertAdvY', 'vertOriginX', 'vertOriginY', 'vHanging', 'vIdeographic', 'viewTarget', 'visibility', 'vMathematical', 'widths', 'wordSpacing', 'writingMode', 'x1', 'x2', 'x', 'xChannelSelector', 'xHeight', 'xlinkActuate', 'xlinkArcrole', 'xlinkHref', 'xlinkRole', 'xlinkShow', 'xlinkTitle', 'xlinkType', 'xmlBase', 'xmlLang', 'xmlns', 'xmlnsXlink', 'xmlSpace', 'y1', 'y2', 'y', 'yChannelSelector', 'z', 'zoomAndPan', 'ref', 'key', 'angle'];
|
||||
var PolyElementKeys = ['points', 'pathLength'];
|
||||
|
||||
/** svg element types that have specific attribute filtration requirements */
|
||||
|
||||
/** map of svg element types to unique svg attributes that belong to that element */
|
||||
export var FilteredElementKeyMap = {
|
||||
svg: SVGContainerPropKeys,
|
||||
polygon: PolyElementKeys,
|
||||
polyline: PolyElementKeys
|
||||
};
|
||||
export var EventKeys = ['dangerouslySetInnerHTML', 'onCopy', 'onCopyCapture', 'onCut', 'onCutCapture', 'onPaste', 'onPasteCapture', 'onCompositionEnd', 'onCompositionEndCapture', 'onCompositionStart', 'onCompositionStartCapture', 'onCompositionUpdate', 'onCompositionUpdateCapture', 'onFocus', 'onFocusCapture', 'onBlur', 'onBlurCapture', 'onChange', 'onChangeCapture', 'onBeforeInput', 'onBeforeInputCapture', 'onInput', 'onInputCapture', 'onReset', 'onResetCapture', 'onSubmit', 'onSubmitCapture', 'onInvalid', 'onInvalidCapture', 'onLoad', 'onLoadCapture', 'onError', 'onErrorCapture', 'onKeyDown', 'onKeyDownCapture', 'onKeyPress', 'onKeyPressCapture', 'onKeyUp', 'onKeyUpCapture', 'onAbort', 'onAbortCapture', 'onCanPlay', 'onCanPlayCapture', 'onCanPlayThrough', 'onCanPlayThroughCapture', 'onDurationChange', 'onDurationChangeCapture', 'onEmptied', 'onEmptiedCapture', 'onEncrypted', 'onEncryptedCapture', 'onEnded', 'onEndedCapture', 'onLoadedData', 'onLoadedDataCapture', 'onLoadedMetadata', 'onLoadedMetadataCapture', 'onLoadStart', 'onLoadStartCapture', 'onPause', 'onPauseCapture', 'onPlay', 'onPlayCapture', 'onPlaying', 'onPlayingCapture', 'onProgress', 'onProgressCapture', 'onRateChange', 'onRateChangeCapture', 'onSeeked', 'onSeekedCapture', 'onSeeking', 'onSeekingCapture', 'onStalled', 'onStalledCapture', 'onSuspend', 'onSuspendCapture', 'onTimeUpdate', 'onTimeUpdateCapture', 'onVolumeChange', 'onVolumeChangeCapture', 'onWaiting', 'onWaitingCapture', 'onAuxClick', 'onAuxClickCapture', 'onClick', 'onClickCapture', 'onContextMenu', 'onContextMenuCapture', 'onDoubleClick', 'onDoubleClickCapture', 'onDrag', 'onDragCapture', 'onDragEnd', 'onDragEndCapture', 'onDragEnter', 'onDragEnterCapture', 'onDragExit', 'onDragExitCapture', 'onDragLeave', 'onDragLeaveCapture', 'onDragOver', 'onDragOverCapture', 'onDragStart', 'onDragStartCapture', 'onDrop', 'onDropCapture', 'onMouseDown', 'onMouseDownCapture', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseMoveCapture', 'onMouseOut', 'onMouseOutCapture', 'onMouseOver', 'onMouseOverCapture', 'onMouseUp', 'onMouseUpCapture', 'onSelect', 'onSelectCapture', 'onTouchCancel', 'onTouchCancelCapture', 'onTouchEnd', 'onTouchEndCapture', 'onTouchMove', 'onTouchMoveCapture', 'onTouchStart', 'onTouchStartCapture', 'onPointerDown', 'onPointerDownCapture', 'onPointerMove', 'onPointerMoveCapture', 'onPointerUp', 'onPointerUpCapture', 'onPointerCancel', 'onPointerCancelCapture', 'onPointerEnter', 'onPointerEnterCapture', 'onPointerLeave', 'onPointerLeaveCapture', 'onPointerOver', 'onPointerOverCapture', 'onPointerOut', 'onPointerOutCapture', 'onGotPointerCapture', 'onGotPointerCaptureCapture', 'onLostPointerCapture', 'onLostPointerCaptureCapture', 'onScroll', 'onScrollCapture', 'onWheel', 'onWheelCapture', 'onAnimationStart', 'onAnimationStartCapture', 'onAnimationEnd', 'onAnimationEndCapture', 'onAnimationIteration', 'onAnimationIterationCapture', 'onTransitionEnd', 'onTransitionEndCapture'];
|
||||
|
||||
/** The type of easing function to use for animations */
|
||||
|
||||
/** Specifies the duration of animation, the unit of this option is ms. */
|
||||
|
||||
/** the offset of a chart, which define the blank space all around */
|
||||
|
||||
/**
|
||||
* The domain of axis.
|
||||
* This is the definition
|
||||
*
|
||||
* Numeric domain is always defined by an array of exactly two values, for the min and the max of the axis.
|
||||
* Categorical domain is defined as array of all possible values.
|
||||
*
|
||||
* Can be specified in many ways:
|
||||
* - array of numbers
|
||||
* - with special strings like 'dataMin' and 'dataMax'
|
||||
* - with special string math like 'dataMin - 100'
|
||||
* - with keyword 'auto'
|
||||
* - or a function
|
||||
* - array of functions
|
||||
* - or a combination of the above
|
||||
*/
|
||||
|
||||
/**
|
||||
* NumberDomain is an evaluated {@link AxisDomain}.
|
||||
* Unlike {@link AxisDomain}, it has no variety - it's a tuple of two number.
|
||||
* This is after all the keywords and functions were evaluated and what is left is [min, max].
|
||||
*
|
||||
* Know that the min, max values are not guaranteed to be nice numbers - values like -Infinity or NaN are possible.
|
||||
*
|
||||
* There are also `category` axes that have different things than numbers in their domain.
|
||||
*/
|
||||
|
||||
/** The props definition of base axis */
|
||||
|
||||
/** Defines how ticks are placed and whether / how tick collisions are handled.
|
||||
* 'preserveStart' keeps the left tick on collision and ensures that the first tick is always shown.
|
||||
* 'preserveEnd' keeps the right tick on collision and ensures that the last tick is always shown.
|
||||
* 'preserveStartEnd' keeps the left tick on collision and ensures that the first and last ticks are always shown.
|
||||
* 'equidistantPreserveStart' selects a number N such that every nTh tick will be shown without collision.
|
||||
*/
|
||||
|
||||
export var adaptEventHandlers = function adaptEventHandlers(props, newHandler) {
|
||||
if (!props || typeof props === 'function' || typeof props === 'boolean') {
|
||||
return null;
|
||||
}
|
||||
var inputProps = props;
|
||||
if ( /*#__PURE__*/isValidElement(props)) {
|
||||
inputProps = props.props;
|
||||
}
|
||||
if (!isObject(inputProps)) {
|
||||
return null;
|
||||
}
|
||||
var out = {};
|
||||
Object.keys(inputProps).forEach(function (key) {
|
||||
if (EventKeys.includes(key)) {
|
||||
out[key] = newHandler || function (e) {
|
||||
return inputProps[key](inputProps, e);
|
||||
};
|
||||
}
|
||||
});
|
||||
return out;
|
||||
};
|
||||
var getEventHandlerOfChild = function getEventHandlerOfChild(originalHandler, data, index) {
|
||||
return function (e) {
|
||||
originalHandler(data, index, e);
|
||||
return null;
|
||||
};
|
||||
};
|
||||
export var adaptEventsOfChild = function adaptEventsOfChild(props, data, index) {
|
||||
if (!isObject(props) || _typeof(props) !== 'object') {
|
||||
return null;
|
||||
}
|
||||
var out = null;
|
||||
Object.keys(props).forEach(function (key) {
|
||||
var item = props[key];
|
||||
if (EventKeys.includes(key) && typeof item === 'function') {
|
||||
if (!out) out = {};
|
||||
out[key] = getEventHandlerOfChild(item, data, index);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
};
|
||||
Reference in New Issue
Block a user