v1.0 with SW PWA enabled
This commit is contained in:
553
frontend/node_modules/recharts/es6/polar/Pie.js
generated
vendored
Normal file
553
frontend/node_modules/recharts/es6/polar/Pie.js
generated
vendored
Normal file
@ -0,0 +1,553 @@
|
||||
var _Pie;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Render sectors of a pie
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import Animate from 'react-smooth';
|
||||
import get from 'lodash/get';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isNil from 'lodash/isNil';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { Text } from '../component/Text';
|
||||
import { Label } from '../component/Label';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { findAllByType, filterProps } from '../util/ReactUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { polarToCartesian, getMaxRadius } from '../util/PolarUtils';
|
||||
import { isNumber, getPercentValue, mathSign, interpolateNumber, uniqueId } from '../util/DataUtils';
|
||||
import { getValueByDataKey } from '../util/ChartUtils';
|
||||
import { warn } from '../util/LogUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { Shape } from '../util/ActiveShapeUtils';
|
||||
export var Pie = /*#__PURE__*/function (_PureComponent) {
|
||||
function Pie(props) {
|
||||
var _this;
|
||||
_classCallCheck(this, Pie);
|
||||
_this = _callSuper(this, Pie, [props]);
|
||||
_defineProperty(_this, "pieRef", null);
|
||||
_defineProperty(_this, "sectorRefs", []);
|
||||
_defineProperty(_this, "id", uniqueId('recharts-pie-'));
|
||||
_defineProperty(_this, "handleAnimationEnd", function () {
|
||||
var onAnimationEnd = _this.props.onAnimationEnd;
|
||||
_this.setState({
|
||||
isAnimationFinished: true
|
||||
});
|
||||
if (isFunction(onAnimationEnd)) {
|
||||
onAnimationEnd();
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleAnimationStart", function () {
|
||||
var onAnimationStart = _this.props.onAnimationStart;
|
||||
_this.setState({
|
||||
isAnimationFinished: false
|
||||
});
|
||||
if (isFunction(onAnimationStart)) {
|
||||
onAnimationStart();
|
||||
}
|
||||
});
|
||||
_this.state = {
|
||||
isAnimationFinished: !props.isAnimationActive,
|
||||
prevIsAnimationActive: props.isAnimationActive,
|
||||
prevAnimationId: props.animationId,
|
||||
sectorToFocus: 0
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
_inherits(Pie, _PureComponent);
|
||||
return _createClass(Pie, [{
|
||||
key: "isActiveIndex",
|
||||
value: function isActiveIndex(i) {
|
||||
var activeIndex = this.props.activeIndex;
|
||||
if (Array.isArray(activeIndex)) {
|
||||
return activeIndex.indexOf(i) !== -1;
|
||||
}
|
||||
return i === activeIndex;
|
||||
}
|
||||
}, {
|
||||
key: "hasActiveIndex",
|
||||
value: function hasActiveIndex() {
|
||||
var activeIndex = this.props.activeIndex;
|
||||
return Array.isArray(activeIndex) ? activeIndex.length !== 0 : activeIndex || activeIndex === 0;
|
||||
}
|
||||
}, {
|
||||
key: "renderLabels",
|
||||
value: function renderLabels(sectors) {
|
||||
var isAnimationActive = this.props.isAnimationActive;
|
||||
if (isAnimationActive && !this.state.isAnimationFinished) {
|
||||
return null;
|
||||
}
|
||||
var _this$props = this.props,
|
||||
label = _this$props.label,
|
||||
labelLine = _this$props.labelLine,
|
||||
dataKey = _this$props.dataKey,
|
||||
valueKey = _this$props.valueKey;
|
||||
var pieProps = filterProps(this.props, false);
|
||||
var customLabelProps = filterProps(label, false);
|
||||
var customLabelLineProps = filterProps(labelLine, false);
|
||||
var offsetRadius = label && label.offsetRadius || 20;
|
||||
var labels = sectors.map(function (entry, i) {
|
||||
var midAngle = (entry.startAngle + entry.endAngle) / 2;
|
||||
var endPoint = polarToCartesian(entry.cx, entry.cy, entry.outerRadius + offsetRadius, midAngle);
|
||||
var labelProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
|
||||
stroke: 'none'
|
||||
}, customLabelProps), {}, {
|
||||
index: i,
|
||||
textAnchor: Pie.getTextAnchor(endPoint.x, entry.cx)
|
||||
}, endPoint);
|
||||
var lineProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
|
||||
fill: 'none',
|
||||
stroke: entry.fill
|
||||
}, customLabelLineProps), {}, {
|
||||
index: i,
|
||||
points: [polarToCartesian(entry.cx, entry.cy, entry.outerRadius, midAngle), endPoint]
|
||||
});
|
||||
var realDataKey = dataKey;
|
||||
// TODO: compatible to lower versions
|
||||
if (isNil(dataKey) && isNil(valueKey)) {
|
||||
realDataKey = 'value';
|
||||
} else if (isNil(dataKey)) {
|
||||
realDataKey = valueKey;
|
||||
}
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
React.createElement(Layer, {
|
||||
key: "label-".concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
|
||||
}, labelLine && Pie.renderLabelLineItem(labelLine, lineProps, 'line'), Pie.renderLabelItem(label, labelProps, getValueByDataKey(entry, realDataKey)))
|
||||
);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-pie-labels"
|
||||
}, labels);
|
||||
}
|
||||
}, {
|
||||
key: "renderSectorsStatically",
|
||||
value: function renderSectorsStatically(sectors) {
|
||||
var _this2 = this;
|
||||
var _this$props2 = this.props,
|
||||
activeShape = _this$props2.activeShape,
|
||||
blendStroke = _this$props2.blendStroke,
|
||||
inactiveShapeProp = _this$props2.inactiveShape;
|
||||
return sectors.map(function (entry, i) {
|
||||
if ((entry === null || entry === void 0 ? void 0 : entry.startAngle) === 0 && (entry === null || entry === void 0 ? void 0 : entry.endAngle) === 0 && sectors.length !== 1) return null;
|
||||
var isActive = _this2.isActiveIndex(i);
|
||||
var inactiveShape = inactiveShapeProp && _this2.hasActiveIndex() ? inactiveShapeProp : null;
|
||||
var sectorOptions = isActive ? activeShape : inactiveShape;
|
||||
var sectorProps = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
stroke: blendStroke ? entry.fill : entry.stroke,
|
||||
tabIndex: -1
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
ref: function ref(_ref) {
|
||||
if (_ref && !_this2.sectorRefs.includes(_ref)) {
|
||||
_this2.sectorRefs.push(_ref);
|
||||
}
|
||||
},
|
||||
tabIndex: -1,
|
||||
className: "recharts-pie-sector"
|
||||
}, adaptEventsOfChild(_this2.props, entry, i), {
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key: "sector-".concat(entry === null || entry === void 0 ? void 0 : entry.startAngle, "-").concat(entry === null || entry === void 0 ? void 0 : entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
|
||||
}), /*#__PURE__*/React.createElement(Shape, _extends({
|
||||
option: sectorOptions,
|
||||
isActive: isActive,
|
||||
shapeType: "sector"
|
||||
}, sectorProps)));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderSectorsWithAnimation",
|
||||
value: function renderSectorsWithAnimation() {
|
||||
var _this3 = this;
|
||||
var _this$props3 = this.props,
|
||||
sectors = _this$props3.sectors,
|
||||
isAnimationActive = _this$props3.isAnimationActive,
|
||||
animationBegin = _this$props3.animationBegin,
|
||||
animationDuration = _this$props3.animationDuration,
|
||||
animationEasing = _this$props3.animationEasing,
|
||||
animationId = _this$props3.animationId;
|
||||
var _this$state = this.state,
|
||||
prevSectors = _this$state.prevSectors,
|
||||
prevIsAnimationActive = _this$state.prevIsAnimationActive;
|
||||
return /*#__PURE__*/React.createElement(Animate, {
|
||||
begin: animationBegin,
|
||||
duration: animationDuration,
|
||||
isActive: isAnimationActive,
|
||||
easing: animationEasing,
|
||||
from: {
|
||||
t: 0
|
||||
},
|
||||
to: {
|
||||
t: 1
|
||||
},
|
||||
key: "pie-".concat(animationId, "-").concat(prevIsAnimationActive),
|
||||
onAnimationStart: this.handleAnimationStart,
|
||||
onAnimationEnd: this.handleAnimationEnd
|
||||
}, function (_ref2) {
|
||||
var t = _ref2.t;
|
||||
var stepData = [];
|
||||
var first = sectors && sectors[0];
|
||||
var curAngle = first.startAngle;
|
||||
sectors.forEach(function (entry, index) {
|
||||
var prev = prevSectors && prevSectors[index];
|
||||
var paddingAngle = index > 0 ? get(entry, 'paddingAngle', 0) : 0;
|
||||
if (prev) {
|
||||
var angleIp = interpolateNumber(prev.endAngle - prev.startAngle, entry.endAngle - entry.startAngle);
|
||||
var latest = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
startAngle: curAngle + paddingAngle,
|
||||
endAngle: curAngle + angleIp(t) + paddingAngle
|
||||
});
|
||||
stepData.push(latest);
|
||||
curAngle = latest.endAngle;
|
||||
} else {
|
||||
var endAngle = entry.endAngle,
|
||||
startAngle = entry.startAngle;
|
||||
var interpolatorAngle = interpolateNumber(0, endAngle - startAngle);
|
||||
var deltaAngle = interpolatorAngle(t);
|
||||
var _latest = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
startAngle: curAngle + paddingAngle,
|
||||
endAngle: curAngle + deltaAngle + paddingAngle
|
||||
});
|
||||
stepData.push(_latest);
|
||||
curAngle = _latest.endAngle;
|
||||
}
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, null, _this3.renderSectorsStatically(stepData));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "attachKeyboardHandlers",
|
||||
value: function attachKeyboardHandlers(pieRef) {
|
||||
var _this4 = this;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
pieRef.onkeydown = function (e) {
|
||||
if (!e.altKey) {
|
||||
switch (e.key) {
|
||||
case 'ArrowLeft':
|
||||
{
|
||||
var next = ++_this4.state.sectorToFocus % _this4.sectorRefs.length;
|
||||
_this4.sectorRefs[next].focus();
|
||||
_this4.setState({
|
||||
sectorToFocus: next
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'ArrowRight':
|
||||
{
|
||||
var _next = --_this4.state.sectorToFocus < 0 ? _this4.sectorRefs.length - 1 : _this4.state.sectorToFocus % _this4.sectorRefs.length;
|
||||
_this4.sectorRefs[_next].focus();
|
||||
_this4.setState({
|
||||
sectorToFocus: _next
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'Escape':
|
||||
{
|
||||
_this4.sectorRefs[_this4.state.sectorToFocus].blur();
|
||||
_this4.setState({
|
||||
sectorToFocus: 0
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// There is nothing to do here
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "renderSectors",
|
||||
value: function renderSectors() {
|
||||
var _this$props4 = this.props,
|
||||
sectors = _this$props4.sectors,
|
||||
isAnimationActive = _this$props4.isAnimationActive;
|
||||
var prevSectors = this.state.prevSectors;
|
||||
if (isAnimationActive && sectors && sectors.length && (!prevSectors || !isEqual(prevSectors, sectors))) {
|
||||
return this.renderSectorsWithAnimation();
|
||||
}
|
||||
return this.renderSectorsStatically(sectors);
|
||||
}
|
||||
}, {
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
if (this.pieRef) {
|
||||
this.attachKeyboardHandlers(this.pieRef);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this5 = this;
|
||||
var _this$props5 = this.props,
|
||||
hide = _this$props5.hide,
|
||||
sectors = _this$props5.sectors,
|
||||
className = _this$props5.className,
|
||||
label = _this$props5.label,
|
||||
cx = _this$props5.cx,
|
||||
cy = _this$props5.cy,
|
||||
innerRadius = _this$props5.innerRadius,
|
||||
outerRadius = _this$props5.outerRadius,
|
||||
isAnimationActive = _this$props5.isAnimationActive;
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
if (hide || !sectors || !sectors.length || !isNumber(cx) || !isNumber(cy) || !isNumber(innerRadius) || !isNumber(outerRadius)) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-pie', className);
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
tabIndex: this.props.rootTabIndex,
|
||||
className: layerClass,
|
||||
ref: function ref(_ref3) {
|
||||
_this5.pieRef = _ref3;
|
||||
}
|
||||
}, this.renderSectors(), label && this.renderLabels(sectors), Label.renderCallByParent(this.props, null, false), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, sectors, false));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (prevState.prevIsAnimationActive !== nextProps.isAnimationActive) {
|
||||
return {
|
||||
prevIsAnimationActive: nextProps.isAnimationActive,
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curSectors: nextProps.sectors,
|
||||
prevSectors: [],
|
||||
isAnimationFinished: true
|
||||
};
|
||||
}
|
||||
if (nextProps.isAnimationActive && nextProps.animationId !== prevState.prevAnimationId) {
|
||||
return {
|
||||
prevAnimationId: nextProps.animationId,
|
||||
curSectors: nextProps.sectors,
|
||||
prevSectors: prevState.curSectors,
|
||||
isAnimationFinished: true
|
||||
};
|
||||
}
|
||||
if (nextProps.sectors !== prevState.curSectors) {
|
||||
return {
|
||||
curSectors: nextProps.sectors,
|
||||
isAnimationFinished: true
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "getTextAnchor",
|
||||
value: function getTextAnchor(x, cx) {
|
||||
if (x > cx) {
|
||||
return 'start';
|
||||
}
|
||||
if (x < cx) {
|
||||
return 'end';
|
||||
}
|
||||
return 'middle';
|
||||
}
|
||||
}, {
|
||||
key: "renderLabelLineItem",
|
||||
value: function renderLabelLineItem(option, props, key) {
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
return /*#__PURE__*/React.cloneElement(option, props);
|
||||
}
|
||||
if (isFunction(option)) {
|
||||
return option(props);
|
||||
}
|
||||
var className = clsx('recharts-pie-label-line', typeof option !== 'boolean' ? option.className : '');
|
||||
return /*#__PURE__*/React.createElement(Curve, _extends({}, props, {
|
||||
key: key,
|
||||
type: "linear",
|
||||
className: className
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderLabelItem",
|
||||
value: function renderLabelItem(option, props, value) {
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
return /*#__PURE__*/React.cloneElement(option, props);
|
||||
}
|
||||
var label = value;
|
||||
if (isFunction(option)) {
|
||||
label = option(props);
|
||||
if ( /*#__PURE__*/React.isValidElement(label)) {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
var className = clsx('recharts-pie-label-text', typeof option !== 'boolean' && !isFunction(option) ? option.className : '');
|
||||
return /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
alignmentBaseline: "middle",
|
||||
className: className
|
||||
}), label);
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_Pie = Pie;
|
||||
_defineProperty(Pie, "displayName", 'Pie');
|
||||
_defineProperty(Pie, "defaultProps", {
|
||||
stroke: '#fff',
|
||||
fill: '#808080',
|
||||
legendType: 'rect',
|
||||
cx: '50%',
|
||||
cy: '50%',
|
||||
startAngle: 0,
|
||||
endAngle: 360,
|
||||
innerRadius: 0,
|
||||
outerRadius: '80%',
|
||||
paddingAngle: 0,
|
||||
labelLine: true,
|
||||
hide: false,
|
||||
minAngle: 0,
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 400,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
nameKey: 'name',
|
||||
blendStroke: false,
|
||||
rootTabIndex: 0
|
||||
});
|
||||
_defineProperty(Pie, "parseDeltaAngle", function (startAngle, endAngle) {
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
|
||||
return sign * deltaAngle;
|
||||
});
|
||||
_defineProperty(Pie, "getRealPieData", function (itemProps) {
|
||||
var data = itemProps.data,
|
||||
children = itemProps.children;
|
||||
var presentationProps = filterProps(itemProps, false);
|
||||
var cells = findAllByType(children, Cell);
|
||||
if (data && data.length) {
|
||||
return data.map(function (entry, index) {
|
||||
return _objectSpread(_objectSpread(_objectSpread({
|
||||
payload: entry
|
||||
}, presentationProps), entry), cells && cells[index] && cells[index].props);
|
||||
});
|
||||
}
|
||||
if (cells && cells.length) {
|
||||
return cells.map(function (cell) {
|
||||
return _objectSpread(_objectSpread({}, presentationProps), cell.props);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
});
|
||||
_defineProperty(Pie, "parseCoordinateOfPie", function (itemProps, offset) {
|
||||
var top = offset.top,
|
||||
left = offset.left,
|
||||
width = offset.width,
|
||||
height = offset.height;
|
||||
var maxPieRadius = getMaxRadius(width, height);
|
||||
var cx = left + getPercentValue(itemProps.cx, width, width / 2);
|
||||
var cy = top + getPercentValue(itemProps.cy, height, height / 2);
|
||||
var innerRadius = getPercentValue(itemProps.innerRadius, maxPieRadius, 0);
|
||||
var outerRadius = getPercentValue(itemProps.outerRadius, maxPieRadius, maxPieRadius * 0.8);
|
||||
var maxRadius = itemProps.maxRadius || Math.sqrt(width * width + height * height) / 2;
|
||||
return {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
maxRadius: maxRadius
|
||||
};
|
||||
});
|
||||
_defineProperty(Pie, "getComposedData", function (_ref4) {
|
||||
var item = _ref4.item,
|
||||
offset = _ref4.offset;
|
||||
var itemProps = item.type.defaultProps !== undefined ? _objectSpread(_objectSpread({}, item.type.defaultProps), item.props) : item.props;
|
||||
var pieData = _Pie.getRealPieData(itemProps);
|
||||
if (!pieData || !pieData.length) {
|
||||
return null;
|
||||
}
|
||||
var cornerRadius = itemProps.cornerRadius,
|
||||
startAngle = itemProps.startAngle,
|
||||
endAngle = itemProps.endAngle,
|
||||
paddingAngle = itemProps.paddingAngle,
|
||||
dataKey = itemProps.dataKey,
|
||||
nameKey = itemProps.nameKey,
|
||||
valueKey = itemProps.valueKey,
|
||||
tooltipType = itemProps.tooltipType;
|
||||
var minAngle = Math.abs(itemProps.minAngle);
|
||||
var coordinate = _Pie.parseCoordinateOfPie(itemProps, offset);
|
||||
var deltaAngle = _Pie.parseDeltaAngle(startAngle, endAngle);
|
||||
var absDeltaAngle = Math.abs(deltaAngle);
|
||||
var realDataKey = dataKey;
|
||||
if (isNil(dataKey) && isNil(valueKey)) {
|
||||
warn(false, "Use \"dataKey\" to specify the value of pie,\n the props \"valueKey\" will be deprecated in 1.1.0");
|
||||
realDataKey = 'value';
|
||||
} else if (isNil(dataKey)) {
|
||||
warn(false, "Use \"dataKey\" to specify the value of pie,\n the props \"valueKey\" will be deprecated in 1.1.0");
|
||||
realDataKey = valueKey;
|
||||
}
|
||||
var notZeroItemCount = pieData.filter(function (entry) {
|
||||
return getValueByDataKey(entry, realDataKey, 0) !== 0;
|
||||
}).length;
|
||||
var totalPadingAngle = (absDeltaAngle >= 360 ? notZeroItemCount : notZeroItemCount - 1) * paddingAngle;
|
||||
var realTotalAngle = absDeltaAngle - notZeroItemCount * minAngle - totalPadingAngle;
|
||||
var sum = pieData.reduce(function (result, entry) {
|
||||
var val = getValueByDataKey(entry, realDataKey, 0);
|
||||
return result + (isNumber(val) ? val : 0);
|
||||
}, 0);
|
||||
var sectors;
|
||||
if (sum > 0) {
|
||||
var prev;
|
||||
sectors = pieData.map(function (entry, i) {
|
||||
var val = getValueByDataKey(entry, realDataKey, 0);
|
||||
var name = getValueByDataKey(entry, nameKey, i);
|
||||
var percent = (isNumber(val) ? val : 0) / sum;
|
||||
var tempStartAngle;
|
||||
if (i) {
|
||||
tempStartAngle = prev.endAngle + mathSign(deltaAngle) * paddingAngle * (val !== 0 ? 1 : 0);
|
||||
} else {
|
||||
tempStartAngle = startAngle;
|
||||
}
|
||||
var tempEndAngle = tempStartAngle + mathSign(deltaAngle) * ((val !== 0 ? minAngle : 0) + percent * realTotalAngle);
|
||||
var midAngle = (tempStartAngle + tempEndAngle) / 2;
|
||||
var middleRadius = (coordinate.innerRadius + coordinate.outerRadius) / 2;
|
||||
var tooltipPayload = [{
|
||||
name: name,
|
||||
value: val,
|
||||
payload: entry,
|
||||
dataKey: realDataKey,
|
||||
type: tooltipType
|
||||
}];
|
||||
var tooltipPosition = polarToCartesian(coordinate.cx, coordinate.cy, middleRadius, midAngle);
|
||||
prev = _objectSpread(_objectSpread(_objectSpread({
|
||||
percent: percent,
|
||||
cornerRadius: cornerRadius,
|
||||
name: name,
|
||||
tooltipPayload: tooltipPayload,
|
||||
midAngle: midAngle,
|
||||
middleRadius: middleRadius,
|
||||
tooltipPosition: tooltipPosition
|
||||
}, entry), coordinate), {}, {
|
||||
value: getValueByDataKey(entry, realDataKey),
|
||||
startAngle: tempStartAngle,
|
||||
endAngle: tempEndAngle,
|
||||
payload: entry,
|
||||
paddingAngle: mathSign(deltaAngle) * paddingAngle
|
||||
});
|
||||
return prev;
|
||||
});
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, coordinate), {}, {
|
||||
sectors: sectors,
|
||||
data: pieData
|
||||
});
|
||||
});
|
||||
204
frontend/node_modules/recharts/es6/polar/PolarAngleAxis.js
generated
vendored
Normal file
204
frontend/node_modules/recharts/es6/polar/PolarAngleAxis.js
generated
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview Axis of radial direction
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Dot } from '../shape/Dot';
|
||||
import { Polygon } from '../shape/Polygon';
|
||||
import { Text } from '../component/Text';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
import { getTickClassName, polarToCartesian } from '../util/PolarUtils';
|
||||
var RADIAN = Math.PI / 180;
|
||||
var eps = 1e-5;
|
||||
export var PolarAngleAxis = /*#__PURE__*/function (_PureComponent) {
|
||||
function PolarAngleAxis() {
|
||||
_classCallCheck(this, PolarAngleAxis);
|
||||
return _callSuper(this, PolarAngleAxis, arguments);
|
||||
}
|
||||
_inherits(PolarAngleAxis, _PureComponent);
|
||||
return _createClass(PolarAngleAxis, [{
|
||||
key: "getTickLineCoord",
|
||||
value:
|
||||
/**
|
||||
* Calculate the coordinate of line endpoint
|
||||
* @param {Object} data The Data if ticks
|
||||
* @return {Object} (x0, y0): The start point of text,
|
||||
* (x1, y1): The end point close to text,
|
||||
* (x2, y2): The end point close to axis
|
||||
*/
|
||||
function getTickLineCoord(data) {
|
||||
var _this$props = this.props,
|
||||
cx = _this$props.cx,
|
||||
cy = _this$props.cy,
|
||||
radius = _this$props.radius,
|
||||
orientation = _this$props.orientation,
|
||||
tickSize = _this$props.tickSize;
|
||||
var tickLineSize = tickSize || 8;
|
||||
var p1 = polarToCartesian(cx, cy, radius, data.coordinate);
|
||||
var p2 = polarToCartesian(cx, cy, radius + (orientation === 'inner' ? -1 : 1) * tickLineSize, data.coordinate);
|
||||
return {
|
||||
x1: p1.x,
|
||||
y1: p1.y,
|
||||
x2: p2.x,
|
||||
y2: p2.y
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text-anchor of each tick
|
||||
* @param {Object} data Data of ticks
|
||||
* @return {String} text-anchor
|
||||
*/
|
||||
}, {
|
||||
key: "getTickTextAnchor",
|
||||
value: function getTickTextAnchor(data) {
|
||||
var orientation = this.props.orientation;
|
||||
var cos = Math.cos(-data.coordinate * RADIAN);
|
||||
var textAnchor;
|
||||
if (cos > eps) {
|
||||
textAnchor = orientation === 'outer' ? 'start' : 'end';
|
||||
} else if (cos < -eps) {
|
||||
textAnchor = orientation === 'outer' ? 'end' : 'start';
|
||||
} else {
|
||||
textAnchor = 'middle';
|
||||
}
|
||||
return textAnchor;
|
||||
}
|
||||
}, {
|
||||
key: "renderAxisLine",
|
||||
value: function renderAxisLine() {
|
||||
var _this$props2 = this.props,
|
||||
cx = _this$props2.cx,
|
||||
cy = _this$props2.cy,
|
||||
radius = _this$props2.radius,
|
||||
axisLine = _this$props2.axisLine,
|
||||
axisLineType = _this$props2.axisLineType;
|
||||
var props = _objectSpread(_objectSpread({}, filterProps(this.props, false)), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(axisLine, false));
|
||||
if (axisLineType === 'circle') {
|
||||
return /*#__PURE__*/React.createElement(Dot, _extends({
|
||||
className: "recharts-polar-angle-axis-line"
|
||||
}, props, {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r: radius
|
||||
}));
|
||||
}
|
||||
var ticks = this.props.ticks;
|
||||
var points = ticks.map(function (entry) {
|
||||
return polarToCartesian(cx, cy, radius, entry.coordinate);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Polygon, _extends({
|
||||
className: "recharts-polar-angle-axis-line"
|
||||
}, props, {
|
||||
points: points
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "renderTicks",
|
||||
value: function renderTicks() {
|
||||
var _this = this;
|
||||
var _this$props3 = this.props,
|
||||
ticks = _this$props3.ticks,
|
||||
tick = _this$props3.tick,
|
||||
tickLine = _this$props3.tickLine,
|
||||
tickFormatter = _this$props3.tickFormatter,
|
||||
stroke = _this$props3.stroke;
|
||||
var axisProps = filterProps(this.props, false);
|
||||
var customTickProps = filterProps(tick, false);
|
||||
var tickLineProps = _objectSpread(_objectSpread({}, axisProps), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(tickLine, false));
|
||||
var items = ticks.map(function (entry, i) {
|
||||
var lineCoord = _this.getTickLineCoord(entry);
|
||||
var textAnchor = _this.getTickTextAnchor(entry);
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread({
|
||||
textAnchor: textAnchor
|
||||
}, axisProps), {}, {
|
||||
stroke: 'none',
|
||||
fill: stroke
|
||||
}, customTickProps), {}, {
|
||||
index: i,
|
||||
payload: entry,
|
||||
x: lineCoord.x2,
|
||||
y: lineCoord.y2
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: clsx('recharts-polar-angle-axis-tick', getTickClassName(tick)),
|
||||
key: "tick-".concat(entry.coordinate)
|
||||
}, adaptEventsOfChild(_this.props, entry, i)), tickLine && /*#__PURE__*/React.createElement("line", _extends({
|
||||
className: "recharts-polar-angle-axis-tick-line"
|
||||
}, tickLineProps, lineCoord)), tick && PolarAngleAxis.renderTickItem(tick, tickProps, tickFormatter ? tickFormatter(entry.value, i) : entry.value));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-polar-angle-axis-ticks"
|
||||
}, items);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props4 = this.props,
|
||||
ticks = _this$props4.ticks,
|
||||
radius = _this$props4.radius,
|
||||
axisLine = _this$props4.axisLine;
|
||||
if (radius <= 0 || !ticks || !ticks.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-polar-angle-axis', this.props.className)
|
||||
}, axisLine && this.renderAxisLine(), this.renderTicks());
|
||||
}
|
||||
}], [{
|
||||
key: "renderTickItem",
|
||||
value: function renderTickItem(option, props, value) {
|
||||
var tickItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
tickItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
tickItem = option(props);
|
||||
} else {
|
||||
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
className: "recharts-polar-angle-axis-tick-value"
|
||||
}), value);
|
||||
}
|
||||
return tickItem;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(PolarAngleAxis, "displayName", 'PolarAngleAxis');
|
||||
_defineProperty(PolarAngleAxis, "axisType", 'angleAxis');
|
||||
_defineProperty(PolarAngleAxis, "defaultProps", {
|
||||
type: 'category',
|
||||
angleAxisId: 0,
|
||||
scale: 'auto',
|
||||
cx: 0,
|
||||
cy: 0,
|
||||
orientation: 'outer',
|
||||
axisLine: true,
|
||||
tickLine: true,
|
||||
tickSize: 8,
|
||||
tick: true,
|
||||
hide: false,
|
||||
allowDuplicatedCategory: true
|
||||
});
|
||||
158
frontend/node_modules/recharts/es6/polar/PolarGrid.js
generated
vendored
Normal file
158
frontend/node_modules/recharts/es6/polar/PolarGrid.js
generated
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
var _excluded = ["cx", "cy", "innerRadius", "outerRadius", "gridType", "radialLines"];
|
||||
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 _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 Polar Grid
|
||||
*/
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
var getPolygonPath = function getPolygonPath(radius, cx, cy, polarAngles) {
|
||||
var path = '';
|
||||
polarAngles.forEach(function (angle, i) {
|
||||
var point = polarToCartesian(cx, cy, radius, angle);
|
||||
if (i) {
|
||||
path += "L ".concat(point.x, ",").concat(point.y);
|
||||
} else {
|
||||
path += "M ".concat(point.x, ",").concat(point.y);
|
||||
}
|
||||
});
|
||||
path += 'Z';
|
||||
return path;
|
||||
};
|
||||
|
||||
// Draw axis of radial line
|
||||
var PolarAngles = function PolarAngles(props) {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
innerRadius = props.innerRadius,
|
||||
outerRadius = props.outerRadius,
|
||||
polarAngles = props.polarAngles,
|
||||
radialLines = props.radialLines;
|
||||
if (!polarAngles || !polarAngles.length || !radialLines) {
|
||||
return null;
|
||||
}
|
||||
var polarAnglesProps = _objectSpread({
|
||||
stroke: '#ccc'
|
||||
}, filterProps(props, false));
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-polar-grid-angle"
|
||||
}, polarAngles.map(function (entry) {
|
||||
var start = polarToCartesian(cx, cy, innerRadius, entry);
|
||||
var end = polarToCartesian(cx, cy, outerRadius, entry);
|
||||
return /*#__PURE__*/React.createElement("line", _extends({}, polarAnglesProps, {
|
||||
key: "line-".concat(entry),
|
||||
x1: start.x,
|
||||
y1: start.y,
|
||||
x2: end.x,
|
||||
y2: end.y
|
||||
}));
|
||||
}));
|
||||
};
|
||||
|
||||
// Draw concentric circles
|
||||
var ConcentricCircle = function ConcentricCircle(props) {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
radius = props.radius,
|
||||
index = props.index;
|
||||
var concentricCircleProps = _objectSpread(_objectSpread({
|
||||
stroke: '#ccc'
|
||||
}, filterProps(props, false)), {}, {
|
||||
fill: 'none'
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("circle", _extends({}, concentricCircleProps, {
|
||||
className: clsx('recharts-polar-grid-concentric-circle', props.className),
|
||||
key: "circle-".concat(index),
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r: radius
|
||||
}));
|
||||
};
|
||||
|
||||
// Draw concentric polygons
|
||||
var ConcentricPolygon = function ConcentricPolygon(props) {
|
||||
var radius = props.radius,
|
||||
index = props.index;
|
||||
var concentricPolygonProps = _objectSpread(_objectSpread({
|
||||
stroke: '#ccc'
|
||||
}, filterProps(props, false)), {}, {
|
||||
fill: 'none'
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, concentricPolygonProps, {
|
||||
className: clsx('recharts-polar-grid-concentric-polygon', props.className),
|
||||
key: "path-".concat(index),
|
||||
d: getPolygonPath(radius, props.cx, props.cy, props.polarAngles)
|
||||
}));
|
||||
};
|
||||
|
||||
// Draw concentric axis
|
||||
// TODO Optimize the name
|
||||
var ConcentricPath = function ConcentricPath(props) {
|
||||
var polarRadius = props.polarRadius,
|
||||
gridType = props.gridType;
|
||||
if (!polarRadius || !polarRadius.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-polar-grid-concentric"
|
||||
}, polarRadius.map(function (entry, i) {
|
||||
var key = i;
|
||||
if (gridType === 'circle') return /*#__PURE__*/React.createElement(ConcentricCircle, _extends({
|
||||
key: key
|
||||
}, props, {
|
||||
radius: entry,
|
||||
index: i
|
||||
}));
|
||||
return /*#__PURE__*/React.createElement(ConcentricPolygon, _extends({
|
||||
key: key
|
||||
}, props, {
|
||||
radius: entry,
|
||||
index: i
|
||||
}));
|
||||
}));
|
||||
};
|
||||
export var PolarGrid = function PolarGrid(_ref) {
|
||||
var _ref$cx = _ref.cx,
|
||||
cx = _ref$cx === void 0 ? 0 : _ref$cx,
|
||||
_ref$cy = _ref.cy,
|
||||
cy = _ref$cy === void 0 ? 0 : _ref$cy,
|
||||
_ref$innerRadius = _ref.innerRadius,
|
||||
innerRadius = _ref$innerRadius === void 0 ? 0 : _ref$innerRadius,
|
||||
_ref$outerRadius = _ref.outerRadius,
|
||||
outerRadius = _ref$outerRadius === void 0 ? 0 : _ref$outerRadius,
|
||||
_ref$gridType = _ref.gridType,
|
||||
gridType = _ref$gridType === void 0 ? 'polygon' : _ref$gridType,
|
||||
_ref$radialLines = _ref.radialLines,
|
||||
radialLines = _ref$radialLines === void 0 ? true : _ref$radialLines,
|
||||
props = _objectWithoutProperties(_ref, _excluded);
|
||||
if (outerRadius <= 0) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-polar-grid"
|
||||
}, /*#__PURE__*/React.createElement(PolarAngles, _extends({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
gridType: gridType,
|
||||
radialLines: radialLines
|
||||
}, props)), /*#__PURE__*/React.createElement(ConcentricPath, _extends({
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
gridType: gridType,
|
||||
radialLines: radialLines
|
||||
}, props)));
|
||||
};
|
||||
PolarGrid.displayName = 'PolarGrid';
|
||||
209
frontend/node_modules/recharts/es6/polar/PolarRadiusAxis.js
generated
vendored
Normal file
209
frontend/node_modules/recharts/es6/polar/PolarRadiusAxis.js
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
var _excluded = ["cx", "cy", "angle", "ticks", "axisLine"],
|
||||
_excluded2 = ["ticks", "tick", "angle", "tickFormatter", "stroke"];
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
||||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
/**
|
||||
* @fileOverview The axis of polar coordinate system
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import maxBy from 'lodash/maxBy';
|
||||
import minBy from 'lodash/minBy';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { Text } from '../component/Text';
|
||||
import { Label } from '../component/Label';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { getTickClassName, polarToCartesian } from '../util/PolarUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
export var PolarRadiusAxis = /*#__PURE__*/function (_PureComponent) {
|
||||
function PolarRadiusAxis() {
|
||||
_classCallCheck(this, PolarRadiusAxis);
|
||||
return _callSuper(this, PolarRadiusAxis, arguments);
|
||||
}
|
||||
_inherits(PolarRadiusAxis, _PureComponent);
|
||||
return _createClass(PolarRadiusAxis, [{
|
||||
key: "getTickValueCoord",
|
||||
value:
|
||||
/**
|
||||
* Calculate the coordinate of tick
|
||||
* @param {Number} coordinate The radius of tick
|
||||
* @return {Object} (x, y)
|
||||
*/
|
||||
function getTickValueCoord(_ref) {
|
||||
var coordinate = _ref.coordinate;
|
||||
var _this$props = this.props,
|
||||
angle = _this$props.angle,
|
||||
cx = _this$props.cx,
|
||||
cy = _this$props.cy;
|
||||
return polarToCartesian(cx, cy, coordinate, angle);
|
||||
}
|
||||
}, {
|
||||
key: "getTickTextAnchor",
|
||||
value: function getTickTextAnchor() {
|
||||
var orientation = this.props.orientation;
|
||||
var textAnchor;
|
||||
switch (orientation) {
|
||||
case 'left':
|
||||
textAnchor = 'end';
|
||||
break;
|
||||
case 'right':
|
||||
textAnchor = 'start';
|
||||
break;
|
||||
default:
|
||||
textAnchor = 'middle';
|
||||
break;
|
||||
}
|
||||
return textAnchor;
|
||||
}
|
||||
}, {
|
||||
key: "getViewBox",
|
||||
value: function getViewBox() {
|
||||
var _this$props2 = this.props,
|
||||
cx = _this$props2.cx,
|
||||
cy = _this$props2.cy,
|
||||
angle = _this$props2.angle,
|
||||
ticks = _this$props2.ticks;
|
||||
var maxRadiusTick = maxBy(ticks, function (entry) {
|
||||
return entry.coordinate || 0;
|
||||
});
|
||||
var minRadiusTick = minBy(ticks, function (entry) {
|
||||
return entry.coordinate || 0;
|
||||
});
|
||||
return {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
startAngle: angle,
|
||||
endAngle: angle,
|
||||
innerRadius: minRadiusTick.coordinate || 0,
|
||||
outerRadius: maxRadiusTick.coordinate || 0
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "renderAxisLine",
|
||||
value: function renderAxisLine() {
|
||||
var _this$props3 = this.props,
|
||||
cx = _this$props3.cx,
|
||||
cy = _this$props3.cy,
|
||||
angle = _this$props3.angle,
|
||||
ticks = _this$props3.ticks,
|
||||
axisLine = _this$props3.axisLine,
|
||||
others = _objectWithoutProperties(_this$props3, _excluded);
|
||||
var extent = ticks.reduce(function (result, entry) {
|
||||
return [Math.min(result[0], entry.coordinate), Math.max(result[1], entry.coordinate)];
|
||||
}, [Infinity, -Infinity]);
|
||||
var point0 = polarToCartesian(cx, cy, extent[0], angle);
|
||||
var point1 = polarToCartesian(cx, cy, extent[1], angle);
|
||||
var props = _objectSpread(_objectSpread(_objectSpread({}, filterProps(others, false)), {}, {
|
||||
fill: 'none'
|
||||
}, filterProps(axisLine, false)), {}, {
|
||||
x1: point0.x,
|
||||
y1: point0.y,
|
||||
x2: point1.x,
|
||||
y2: point1.y
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("line", _extends({
|
||||
className: "recharts-polar-radius-axis-line"
|
||||
}, props));
|
||||
}
|
||||
}, {
|
||||
key: "renderTicks",
|
||||
value: function renderTicks() {
|
||||
var _this = this;
|
||||
var _this$props4 = this.props,
|
||||
ticks = _this$props4.ticks,
|
||||
tick = _this$props4.tick,
|
||||
angle = _this$props4.angle,
|
||||
tickFormatter = _this$props4.tickFormatter,
|
||||
stroke = _this$props4.stroke,
|
||||
others = _objectWithoutProperties(_this$props4, _excluded2);
|
||||
var textAnchor = this.getTickTextAnchor();
|
||||
var axisProps = filterProps(others, false);
|
||||
var customTickProps = filterProps(tick, false);
|
||||
var items = ticks.map(function (entry, i) {
|
||||
var coord = _this.getTickValueCoord(entry);
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
textAnchor: textAnchor,
|
||||
transform: "rotate(".concat(90 - angle, ", ").concat(coord.x, ", ").concat(coord.y, ")")
|
||||
}, axisProps), {}, {
|
||||
stroke: 'none',
|
||||
fill: stroke
|
||||
}, customTickProps), {}, {
|
||||
index: i
|
||||
}, coord), {}, {
|
||||
payload: entry
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
className: clsx('recharts-polar-radius-axis-tick', getTickClassName(tick)),
|
||||
key: "tick-".concat(entry.coordinate)
|
||||
}, adaptEventsOfChild(_this.props, entry, i)), PolarRadiusAxis.renderTickItem(tick, tickProps, tickFormatter ? tickFormatter(entry.value, i) : entry.value));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-polar-radius-axis-ticks"
|
||||
}, items);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props5 = this.props,
|
||||
ticks = _this$props5.ticks,
|
||||
axisLine = _this$props5.axisLine,
|
||||
tick = _this$props5.tick;
|
||||
if (!ticks || !ticks.length) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-polar-radius-axis', this.props.className)
|
||||
}, axisLine && this.renderAxisLine(), tick && this.renderTicks(), Label.renderCallByParent(this.props, this.getViewBox()));
|
||||
}
|
||||
}], [{
|
||||
key: "renderTickItem",
|
||||
value: function renderTickItem(option, props, value) {
|
||||
var tickItem;
|
||||
if ( /*#__PURE__*/React.isValidElement(option)) {
|
||||
tickItem = /*#__PURE__*/React.cloneElement(option, props);
|
||||
} else if (isFunction(option)) {
|
||||
tickItem = option(props);
|
||||
} else {
|
||||
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
className: "recharts-polar-radius-axis-tick-value"
|
||||
}), value);
|
||||
}
|
||||
return tickItem;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(PolarRadiusAxis, "displayName", 'PolarRadiusAxis');
|
||||
_defineProperty(PolarRadiusAxis, "axisType", 'radiusAxis');
|
||||
_defineProperty(PolarRadiusAxis, "defaultProps", {
|
||||
type: 'number',
|
||||
radiusAxisId: 0,
|
||||
cx: 0,
|
||||
cy: 0,
|
||||
angle: 0,
|
||||
orientation: 'right',
|
||||
stroke: '#ccc',
|
||||
axisLine: true,
|
||||
tick: true,
|
||||
tickCount: 5,
|
||||
allowDataOverflow: false,
|
||||
scale: 'auto',
|
||||
allowDuplicatedCategory: true
|
||||
});
|
||||
319
frontend/node_modules/recharts/es6/polar/Radar.js
generated
vendored
Normal file
319
frontend/node_modules/recharts/es6/polar/Radar.js
generated
vendored
Normal file
@ -0,0 +1,319 @@
|
||||
var _excluded = ["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 _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 Radar
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import Animate from 'react-smooth';
|
||||
import isNil from 'lodash/isNil';
|
||||
import last from 'lodash/last';
|
||||
import first from 'lodash/first';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import clsx from 'clsx';
|
||||
import { interpolateNumber } from '../util/DataUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
import { getValueByDataKey } from '../util/ChartUtils';
|
||||
import { Polygon } from '../shape/Polygon';
|
||||
import { Dot } from '../shape/Dot';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { filterProps } from '../util/ReactUtils';
|
||||
export var Radar = /*#__PURE__*/function (_PureComponent) {
|
||||
function Radar() {
|
||||
var _this;
|
||||
_classCallCheck(this, Radar);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, Radar, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
isAnimationFinished: false
|
||||
});
|
||||
_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();
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleMouseEnter", function (e) {
|
||||
var onMouseEnter = _this.props.onMouseEnter;
|
||||
if (onMouseEnter) {
|
||||
onMouseEnter(_this.props, e);
|
||||
}
|
||||
});
|
||||
_defineProperty(_this, "handleMouseLeave", function (e) {
|
||||
var onMouseLeave = _this.props.onMouseLeave;
|
||||
if (onMouseLeave) {
|
||||
onMouseLeave(_this.props, e);
|
||||
}
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_inherits(Radar, _PureComponent);
|
||||
return _createClass(Radar, [{
|
||||
key: "renderDots",
|
||||
value: function renderDots(points) {
|
||||
var _this$props = this.props,
|
||||
dot = _this$props.dot,
|
||||
dataKey = _this$props.dataKey;
|
||||
var baseProps = 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
|
||||
}, baseProps), customDotProps), {}, {
|
||||
dataKey: dataKey,
|
||||
cx: entry.x,
|
||||
cy: entry.y,
|
||||
index: i,
|
||||
payload: entry
|
||||
});
|
||||
return Radar.renderDotItem(dot, dotProps);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radar-dots"
|
||||
}, dots);
|
||||
}
|
||||
}, {
|
||||
key: "renderPolygonStatically",
|
||||
value: function renderPolygonStatically(points) {
|
||||
var _this$props2 = this.props,
|
||||
shape = _this$props2.shape,
|
||||
dot = _this$props2.dot,
|
||||
isRange = _this$props2.isRange,
|
||||
baseLinePoints = _this$props2.baseLinePoints,
|
||||
connectNulls = _this$props2.connectNulls;
|
||||
var radar;
|
||||
if ( /*#__PURE__*/React.isValidElement(shape)) {
|
||||
radar = /*#__PURE__*/React.cloneElement(shape, _objectSpread(_objectSpread({}, this.props), {}, {
|
||||
points: points
|
||||
}));
|
||||
} else if (isFunction(shape)) {
|
||||
radar = shape(_objectSpread(_objectSpread({}, this.props), {}, {
|
||||
points: points
|
||||
}));
|
||||
} else {
|
||||
radar = /*#__PURE__*/React.createElement(Polygon, _extends({}, filterProps(this.props, true), {
|
||||
onMouseEnter: this.handleMouseEnter,
|
||||
onMouseLeave: this.handleMouseLeave,
|
||||
points: points,
|
||||
baseLinePoints: isRange ? baseLinePoints : null,
|
||||
connectNulls: connectNulls
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radar-polygon"
|
||||
}, radar, dot ? this.renderDots(points) : null);
|
||||
}
|
||||
}, {
|
||||
key: "renderPolygonWithAnimation",
|
||||
value: function renderPolygonWithAnimation() {
|
||||
var _this2 = this;
|
||||
var _this$props3 = this.props,
|
||||
points = _this$props3.points,
|
||||
isAnimationActive = _this$props3.isAnimationActive,
|
||||
animationBegin = _this$props3.animationBegin,
|
||||
animationDuration = _this$props3.animationDuration,
|
||||
animationEasing = _this$props3.animationEasing,
|
||||
animationId = _this$props3.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: "radar-".concat(animationId),
|
||||
onAnimationEnd: this.handleAnimationEnd,
|
||||
onAnimationStart: this.handleAnimationStart
|
||||
}, function (_ref) {
|
||||
var t = _ref.t;
|
||||
var prevPointsDiffFactor = prevPoints && prevPoints.length / points.length;
|
||||
var stepData = points.map(function (entry, index) {
|
||||
var prev = prevPoints && prevPoints[Math.floor(index * prevPointsDiffFactor)];
|
||||
if (prev) {
|
||||
var _interpolatorX = interpolateNumber(prev.x, entry.x);
|
||||
var _interpolatorY = interpolateNumber(prev.y, entry.y);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: _interpolatorX(t),
|
||||
y: _interpolatorY(t)
|
||||
});
|
||||
}
|
||||
var interpolatorX = interpolateNumber(entry.cx, entry.x);
|
||||
var interpolatorY = interpolateNumber(entry.cy, entry.y);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
x: interpolatorX(t),
|
||||
y: interpolatorY(t)
|
||||
});
|
||||
});
|
||||
return _this2.renderPolygonStatically(stepData);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderPolygon",
|
||||
value: function renderPolygon() {
|
||||
var _this$props4 = this.props,
|
||||
points = _this$props4.points,
|
||||
isAnimationActive = _this$props4.isAnimationActive,
|
||||
isRange = _this$props4.isRange;
|
||||
var prevPoints = this.state.prevPoints;
|
||||
if (isAnimationActive && points && points.length && !isRange && (!prevPoints || !isEqual(prevPoints, points))) {
|
||||
return this.renderPolygonWithAnimation();
|
||||
}
|
||||
return this.renderPolygonStatically(points);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props5 = this.props,
|
||||
hide = _this$props5.hide,
|
||||
className = _this$props5.className,
|
||||
points = _this$props5.points,
|
||||
isAnimationActive = _this$props5.isAnimationActive;
|
||||
if (hide || !points || !points.length) {
|
||||
return null;
|
||||
}
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
var layerClass = clsx('recharts-radar', className);
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, this.renderPolygon(), (!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: "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, _excluded);
|
||||
dotItem = /*#__PURE__*/React.createElement(Dot, _extends({}, dotProps, {
|
||||
key: key,
|
||||
className: clsx('recharts-radar-dot', typeof option !== 'boolean' ? option.className : '')
|
||||
}));
|
||||
}
|
||||
return dotItem;
|
||||
}
|
||||
}]);
|
||||
}(PureComponent);
|
||||
_defineProperty(Radar, "displayName", 'Radar');
|
||||
_defineProperty(Radar, "defaultProps", {
|
||||
angleAxisId: 0,
|
||||
radiusAxisId: 0,
|
||||
hide: false,
|
||||
activeDot: true,
|
||||
dot: false,
|
||||
legendType: 'rect',
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease'
|
||||
});
|
||||
_defineProperty(Radar, "getComposedData", function (_ref2) {
|
||||
var radiusAxis = _ref2.radiusAxis,
|
||||
angleAxis = _ref2.angleAxis,
|
||||
displayedData = _ref2.displayedData,
|
||||
dataKey = _ref2.dataKey,
|
||||
bandSize = _ref2.bandSize;
|
||||
var cx = angleAxis.cx,
|
||||
cy = angleAxis.cy;
|
||||
var isRange = false;
|
||||
var points = [];
|
||||
var angleBandSize = angleAxis.type !== 'number' ? bandSize !== null && bandSize !== void 0 ? bandSize : 0 : 0;
|
||||
displayedData.forEach(function (entry, i) {
|
||||
var name = getValueByDataKey(entry, angleAxis.dataKey, i);
|
||||
var value = getValueByDataKey(entry, dataKey);
|
||||
var angle = angleAxis.scale(name) + angleBandSize;
|
||||
var pointValue = Array.isArray(value) ? last(value) : value;
|
||||
var radius = isNil(pointValue) ? undefined : radiusAxis.scale(pointValue);
|
||||
if (Array.isArray(value) && value.length >= 2) {
|
||||
isRange = true;
|
||||
}
|
||||
points.push(_objectSpread(_objectSpread({}, polarToCartesian(cx, cy, radius, angle)), {}, {
|
||||
name: name,
|
||||
value: value,
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
radius: radius,
|
||||
angle: angle,
|
||||
payload: entry
|
||||
}));
|
||||
});
|
||||
var baseLinePoints = [];
|
||||
if (isRange) {
|
||||
points.forEach(function (point) {
|
||||
if (Array.isArray(point.value)) {
|
||||
var baseValue = first(point.value);
|
||||
var radius = isNil(baseValue) ? undefined : radiusAxis.scale(baseValue);
|
||||
baseLinePoints.push(_objectSpread(_objectSpread({}, point), {}, {
|
||||
radius: radius
|
||||
}, polarToCartesian(cx, cy, radius, point.angle)));
|
||||
} else {
|
||||
baseLinePoints.push(point);
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
points: points,
|
||||
isRange: isRange,
|
||||
baseLinePoints: baseLinePoints
|
||||
};
|
||||
});
|
||||
358
frontend/node_modules/recharts/es6/polar/RadialBar.js
generated
vendored
Normal file
358
frontend/node_modules/recharts/es6/polar/RadialBar.js
generated
vendored
Normal file
@ -0,0 +1,358 @@
|
||||
var _excluded = ["shape", "activeShape", "activeIndex", "cornerRadius"],
|
||||
_excluded2 = ["value", "background"];
|
||||
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 Render a group of radial bar
|
||||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import clsx from 'clsx';
|
||||
import Animate from 'react-smooth';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isFunction from 'lodash/isFunction';
|
||||
import { parseCornerRadius, RadialBarSector } from '../util/RadialBarUtils';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { findAllByType, filterProps } from '../util/ReactUtils';
|
||||
import { Global } from '../util/Global';
|
||||
import { LabelList } from '../component/LabelList';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { mathSign, interpolateNumber } from '../util/DataUtils';
|
||||
import { getCateCoordinateOfBar, findPositionOfBar, getValueByDataKey, truncateByDomain, getBaseValueOfBar, getTooltipItem } from '../util/ChartUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
// TODO: Cause of circular dependency. Needs refactoring of functions that need them.
|
||||
// import { AngleAxisProps, RadiusAxisProps } from './types';
|
||||
|
||||
export var RadialBar = /*#__PURE__*/function (_PureComponent) {
|
||||
function RadialBar() {
|
||||
var _this;
|
||||
_classCallCheck(this, RadialBar);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _callSuper(this, RadialBar, [].concat(args));
|
||||
_defineProperty(_this, "state", {
|
||||
isAnimationFinished: false
|
||||
});
|
||||
_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(RadialBar, _PureComponent);
|
||||
return _createClass(RadialBar, [{
|
||||
key: "getDeltaAngle",
|
||||
value: function getDeltaAngle() {
|
||||
var _this$props = this.props,
|
||||
startAngle = _this$props.startAngle,
|
||||
endAngle = _this$props.endAngle;
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
|
||||
return sign * deltaAngle;
|
||||
}
|
||||
}, {
|
||||
key: "renderSectorsStatically",
|
||||
value: function renderSectorsStatically(sectors) {
|
||||
var _this2 = this;
|
||||
var _this$props2 = this.props,
|
||||
shape = _this$props2.shape,
|
||||
activeShape = _this$props2.activeShape,
|
||||
activeIndex = _this$props2.activeIndex,
|
||||
cornerRadius = _this$props2.cornerRadius,
|
||||
others = _objectWithoutProperties(_this$props2, _excluded);
|
||||
var baseProps = filterProps(others, false);
|
||||
return sectors.map(function (entry, i) {
|
||||
var isActive = i === activeIndex;
|
||||
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseProps), {}, {
|
||||
cornerRadius: parseCornerRadius(cornerRadius)
|
||||
}, entry), adaptEventsOfChild(_this2.props, entry, i)), {}, {
|
||||
className: "recharts-radial-bar-sector ".concat(entry.className),
|
||||
forceCornerRadius: others.forceCornerRadius,
|
||||
cornerIsExternal: others.cornerIsExternal,
|
||||
isActive: isActive,
|
||||
option: isActive ? activeShape : shape
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(RadialBarSector, _extends({}, props, {
|
||||
key: "sector-".concat(i)
|
||||
}));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderSectorsWithAnimation",
|
||||
value: function renderSectorsWithAnimation() {
|
||||
var _this3 = this;
|
||||
var _this$props3 = this.props,
|
||||
data = _this$props3.data,
|
||||
isAnimationActive = _this$props3.isAnimationActive,
|
||||
animationBegin = _this$props3.animationBegin,
|
||||
animationDuration = _this$props3.animationDuration,
|
||||
animationEasing = _this$props3.animationEasing,
|
||||
animationId = _this$props3.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: "radialBar-".concat(animationId),
|
||||
onAnimationStart: this.handleAnimationStart,
|
||||
onAnimationEnd: this.handleAnimationEnd
|
||||
}, function (_ref) {
|
||||
var t = _ref.t;
|
||||
var stepData = data.map(function (entry, index) {
|
||||
var prev = prevData && prevData[index];
|
||||
if (prev) {
|
||||
var interpolatorStartAngle = interpolateNumber(prev.startAngle, entry.startAngle);
|
||||
var interpolatorEndAngle = interpolateNumber(prev.endAngle, entry.endAngle);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
startAngle: interpolatorStartAngle(t),
|
||||
endAngle: interpolatorEndAngle(t)
|
||||
});
|
||||
}
|
||||
var endAngle = entry.endAngle,
|
||||
startAngle = entry.startAngle;
|
||||
var interpolator = interpolateNumber(startAngle, endAngle);
|
||||
return _objectSpread(_objectSpread({}, entry), {}, {
|
||||
endAngle: interpolator(t)
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, null, _this3.renderSectorsStatically(stepData));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "renderSectors",
|
||||
value: function renderSectors() {
|
||||
var _this$props4 = this.props,
|
||||
data = _this$props4.data,
|
||||
isAnimationActive = _this$props4.isAnimationActive;
|
||||
var prevData = this.state.prevData;
|
||||
if (isAnimationActive && data && data.length && (!prevData || !isEqual(prevData, data))) {
|
||||
return this.renderSectorsWithAnimation();
|
||||
}
|
||||
return this.renderSectorsStatically(data);
|
||||
}
|
||||
}, {
|
||||
key: "renderBackground",
|
||||
value: function renderBackground(sectors) {
|
||||
var _this4 = this;
|
||||
var cornerRadius = this.props.cornerRadius;
|
||||
var backgroundProps = filterProps(this.props.background, false);
|
||||
return sectors.map(function (entry, i) {
|
||||
var value = entry.value,
|
||||
background = entry.background,
|
||||
rest = _objectWithoutProperties(entry, _excluded2);
|
||||
if (!background) {
|
||||
return null;
|
||||
}
|
||||
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
cornerRadius: parseCornerRadius(cornerRadius)
|
||||
}, rest), {}, {
|
||||
fill: '#eee'
|
||||
}, background), backgroundProps), adaptEventsOfChild(_this4.props, entry, i)), {}, {
|
||||
index: i,
|
||||
className: clsx('recharts-radial-bar-background-sector', backgroundProps === null || backgroundProps === void 0 ? void 0 : backgroundProps.className),
|
||||
option: background,
|
||||
isActive: false
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(RadialBarSector, _extends({}, props, {
|
||||
key: "sector-".concat(i)
|
||||
}));
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props5 = this.props,
|
||||
hide = _this$props5.hide,
|
||||
data = _this$props5.data,
|
||||
className = _this$props5.className,
|
||||
background = _this$props5.background,
|
||||
isAnimationActive = _this$props5.isAnimationActive;
|
||||
if (hide || !data || !data.length) {
|
||||
return null;
|
||||
}
|
||||
var isAnimationFinished = this.state.isAnimationFinished;
|
||||
var layerClass = clsx('recharts-area', className);
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, background && /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radial-bar-background"
|
||||
}, this.renderBackground(data)), /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radial-bar-sectors"
|
||||
}, this.renderSectors()), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(_objectSpread({}, 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);
|
||||
_defineProperty(RadialBar, "displayName", 'RadialBar');
|
||||
_defineProperty(RadialBar, "defaultProps", {
|
||||
angleAxisId: 0,
|
||||
radiusAxisId: 0,
|
||||
minPointSize: 0,
|
||||
hide: false,
|
||||
legendType: 'rect',
|
||||
data: [],
|
||||
isAnimationActive: !Global.isSsr,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
forceCornerRadius: false,
|
||||
cornerIsExternal: false
|
||||
});
|
||||
_defineProperty(RadialBar, "getComposedData", function (_ref2) {
|
||||
var item = _ref2.item,
|
||||
props = _ref2.props,
|
||||
radiusAxis = _ref2.radiusAxis,
|
||||
radiusAxisTicks = _ref2.radiusAxisTicks,
|
||||
angleAxis = _ref2.angleAxis,
|
||||
angleAxisTicks = _ref2.angleAxisTicks,
|
||||
displayedData = _ref2.displayedData,
|
||||
dataKey = _ref2.dataKey,
|
||||
stackedData = _ref2.stackedData,
|
||||
barPosition = _ref2.barPosition,
|
||||
bandSize = _ref2.bandSize,
|
||||
dataStartIndex = _ref2.dataStartIndex;
|
||||
var pos = findPositionOfBar(barPosition, item);
|
||||
if (!pos) {
|
||||
return null;
|
||||
}
|
||||
var cx = angleAxis.cx,
|
||||
cy = angleAxis.cy;
|
||||
var layout = props.layout;
|
||||
var _item$props = item.props,
|
||||
children = _item$props.children,
|
||||
minPointSize = _item$props.minPointSize;
|
||||
var numericAxis = layout === 'radial' ? angleAxis : radiusAxis;
|
||||
var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
|
||||
var baseValue = getBaseValueOfBar({
|
||||
numericAxis: numericAxis
|
||||
});
|
||||
var cells = findAllByType(children, Cell);
|
||||
var sectors = displayedData.map(function (entry, index) {
|
||||
var value, innerRadius, outerRadius, startAngle, endAngle, backgroundSector;
|
||||
if (stackedData) {
|
||||
value = truncateByDomain(stackedData[dataStartIndex + index], stackedDomain);
|
||||
} else {
|
||||
value = getValueByDataKey(entry, dataKey);
|
||||
if (!Array.isArray(value)) {
|
||||
value = [baseValue, value];
|
||||
}
|
||||
}
|
||||
if (layout === 'radial') {
|
||||
innerRadius = getCateCoordinateOfBar({
|
||||
axis: radiusAxis,
|
||||
ticks: radiusAxisTicks,
|
||||
bandSize: bandSize,
|
||||
offset: pos.offset,
|
||||
entry: entry,
|
||||
index: index
|
||||
});
|
||||
endAngle = angleAxis.scale(value[1]);
|
||||
startAngle = angleAxis.scale(value[0]);
|
||||
outerRadius = innerRadius + pos.size;
|
||||
var deltaAngle = endAngle - startAngle;
|
||||
if (Math.abs(minPointSize) > 0 && Math.abs(deltaAngle) < Math.abs(minPointSize)) {
|
||||
var delta = mathSign(deltaAngle || minPointSize) * (Math.abs(minPointSize) - Math.abs(deltaAngle));
|
||||
endAngle += delta;
|
||||
}
|
||||
backgroundSector = {
|
||||
background: {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
startAngle: props.startAngle,
|
||||
endAngle: props.endAngle
|
||||
}
|
||||
};
|
||||
} else {
|
||||
innerRadius = radiusAxis.scale(value[0]);
|
||||
outerRadius = radiusAxis.scale(value[1]);
|
||||
startAngle = getCateCoordinateOfBar({
|
||||
axis: angleAxis,
|
||||
ticks: angleAxisTicks,
|
||||
bandSize: bandSize,
|
||||
offset: pos.offset,
|
||||
entry: entry,
|
||||
index: index
|
||||
});
|
||||
endAngle = startAngle + pos.size;
|
||||
var deltaRadius = outerRadius - innerRadius;
|
||||
if (Math.abs(minPointSize) > 0 && Math.abs(deltaRadius) < Math.abs(minPointSize)) {
|
||||
var _delta = mathSign(deltaRadius || minPointSize) * (Math.abs(minPointSize) - Math.abs(deltaRadius));
|
||||
outerRadius += _delta;
|
||||
}
|
||||
}
|
||||
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, entry), backgroundSector), {}, {
|
||||
payload: entry,
|
||||
value: stackedData ? value : value[1],
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
innerRadius: innerRadius,
|
||||
outerRadius: outerRadius,
|
||||
startAngle: startAngle,
|
||||
endAngle: endAngle
|
||||
}, cells && cells[index] && cells[index].props), {}, {
|
||||
tooltipPayload: [getTooltipItem(item, entry)],
|
||||
tooltipPosition: polarToCartesian(cx, cy, (innerRadius + outerRadius) / 2, (startAngle + endAngle) / 2)
|
||||
});
|
||||
});
|
||||
return {
|
||||
data: sectors,
|
||||
layout: layout
|
||||
};
|
||||
});
|
||||
1
frontend/node_modules/recharts/es6/polar/types.js
generated
vendored
Normal file
1
frontend/node_modules/recharts/es6/polar/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user