v1.0 with SW PWA enabled
This commit is contained in:
543
frontend/node_modules/recharts/es6/cartesian/Area.js
generated
vendored
Normal file
543
frontend/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
frontend/node_modules/recharts/es6/cartesian/Bar.js
generated
vendored
Normal file
450
frontend/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
frontend/node_modules/recharts/es6/cartesian/Brush.js
generated
vendored
Normal file
621
frontend/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
frontend/node_modules/recharts/es6/cartesian/CartesianAxis.js
generated
vendored
Normal file
358
frontend/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
frontend/node_modules/recharts/es6/cartesian/CartesianGrid.js
generated
vendored
Normal file
369
frontend/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
frontend/node_modules/recharts/es6/cartesian/ErrorBar.js
generated
vendored
Normal file
157
frontend/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
frontend/node_modules/recharts/es6/cartesian/Line.js
generated
vendored
Executable file
511
frontend/node_modules/recharts/es6/cartesian/Line.js
generated
vendored
Executable 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
frontend/node_modules/recharts/es6/cartesian/ReferenceArea.js
generated
vendored
Normal file
130
frontend/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
frontend/node_modules/recharts/es6/cartesian/ReferenceDot.js
generated
vendored
Normal file
128
frontend/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
frontend/node_modules/recharts/es6/cartesian/ReferenceLine.js
generated
vendored
Normal file
195
frontend/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
frontend/node_modules/recharts/es6/cartesian/Scatter.js
generated
vendored
Normal file
420
frontend/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
frontend/node_modules/recharts/es6/cartesian/XAxis.js
generated
vendored
Normal file
86
frontend/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
frontend/node_modules/recharts/es6/cartesian/YAxis.js
generated
vendored
Normal file
83
frontend/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
frontend/node_modules/recharts/es6/cartesian/ZAxis.js
generated
vendored
Normal file
39
frontend/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
frontend/node_modules/recharts/es6/cartesian/getEquidistantTicks.js
generated
vendored
Normal file
55
frontend/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
frontend/node_modules/recharts/es6/cartesian/getTicks.js
generated
vendored
Normal file
155
frontend/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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user