Add settings page for managing forecasting API key and URL via UI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cae411eae7
commit
1c411e402e
19809 changed files with 1962608 additions and 97 deletions
639
frontend/node_modules/recharts/es6/polar/Pie.js
generated
vendored
Normal file
639
frontend/node_modules/recharts/es6/polar/Pie.js
generated
vendored
Normal file
|
|
@ -0,0 +1,639 @@
|
|||
var _excluded = ["key"],
|
||||
_excluded2 = ["onMouseEnter", "onClick", "onMouseLeave"],
|
||||
_excluded3 = ["id"],
|
||||
_excluded4 = ["id"];
|
||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
||||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
||||
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
||||
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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import * as React from 'react';
|
||||
import { useMemo, useRef } from 'react';
|
||||
import get from 'es-toolkit/compat/get';
|
||||
import { clsx } from 'clsx';
|
||||
import { selectPieLegend, selectPieSectors } from '../state/selectors/pieSelectors';
|
||||
import { useAppSelector } from '../state/hooks';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { Curve } from '../shape/Curve';
|
||||
import { Sector } from '../shape/Sector';
|
||||
import { Text } from '../component/Text';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { findAllByType } from '../util/ReactUtils';
|
||||
import { getMaxRadius, polarToCartesian } from '../util/PolarUtils';
|
||||
import { getPercentValue, interpolate, isNumber, mathSign } from '../util/DataUtils';
|
||||
import { getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { Shape } from '../util/ActiveShapeUtils';
|
||||
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
|
||||
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
|
||||
import { selectActiveTooltipDataKey, selectActiveTooltipGraphicalItemId, selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
|
||||
import { SetPolarLegendPayload } from '../state/SetLegendPayload';
|
||||
import { DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME, DATA_ITEM_INDEX_ATTRIBUTE_NAME } from '../util/Constants';
|
||||
import { AnimatedItems, useAnimationCallbacks } from '../animation/AnimatedItems';
|
||||
import { matchAppend } from '../animation/matchBy';
|
||||
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
||||
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
|
||||
import { SetPolarGraphicalItem } from '../state/SetGraphicalItem';
|
||||
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
|
||||
import { LabelListFromLabelProp, PolarLabelListContextProvider } from '../component/LabelList';
|
||||
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
||||
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
||||
import { getClassNameFromUnknown } from '../util/getClassNameFromUnknown';
|
||||
import { usePolarChartLayout } from '../context/chartLayoutContext';
|
||||
|
||||
/**
|
||||
* The `label` prop in Pie accepts a variety of alternatives.
|
||||
*/
|
||||
|
||||
/**
|
||||
* We spread the data object into the sector data item,
|
||||
* so we can't really know what is going to be inside.
|
||||
*
|
||||
* This type represents our best effort, but it all depends on the input data
|
||||
* and what is inside of it.
|
||||
*
|
||||
* https://github.com/recharts/recharts/issues/6380
|
||||
* https://github.com/recharts/recharts/discussions/6375
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal props, combination of external props + defaultProps + private Recharts state
|
||||
*/
|
||||
|
||||
var defaultPieSectorShape = Sector;
|
||||
function SetPiePayloadLegend(props) {
|
||||
var cells = useMemo(() => findAllByType(props.children, Cell), [props.children]);
|
||||
var legendPayload = useAppSelector(state => selectPieLegend(state, props.id, cells));
|
||||
if (legendPayload == null) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(SetPolarLegendPayload, {
|
||||
legendPayload: legendPayload
|
||||
});
|
||||
}
|
||||
function getActiveShapeFill(activeShape) {
|
||||
// activeShape can be boolean/function/element/object; only element/object can carry a static fill value.
|
||||
if (activeShape == null || typeof activeShape === 'boolean' || typeof activeShape === 'function') {
|
||||
return undefined;
|
||||
}
|
||||
if (/*#__PURE__*/React.isValidElement(activeShape)) {
|
||||
var _activeShape$props;
|
||||
// React element form: <Sector fill="..."/> or custom element with fill prop.
|
||||
var _fill = (_activeShape$props = activeShape.props) === null || _activeShape$props === void 0 ? void 0 : _activeShape$props.fill;
|
||||
return typeof _fill === 'string' ? _fill : undefined;
|
||||
}
|
||||
var fill = activeShape.fill;
|
||||
return typeof fill === 'string' ? fill : undefined;
|
||||
}
|
||||
var SetPieTooltipEntrySettings = /*#__PURE__*/React.memo(_ref => {
|
||||
var dataKey = _ref.dataKey,
|
||||
nameKey = _ref.nameKey,
|
||||
sectors = _ref.sectors,
|
||||
stroke = _ref.stroke,
|
||||
strokeWidth = _ref.strokeWidth,
|
||||
fill = _ref.fill,
|
||||
name = _ref.name,
|
||||
hide = _ref.hide,
|
||||
tooltipType = _ref.tooltipType,
|
||||
formatter = _ref.formatter,
|
||||
id = _ref.id,
|
||||
activeShape = _ref.activeShape;
|
||||
var activeShapeFill = getActiveShapeFill(activeShape);
|
||||
var tooltipDataDefinedOnItem = sectors.map(sector => {
|
||||
var sectorTooltipPayload = sector.tooltipPayload;
|
||||
if (activeShapeFill == null || sectorTooltipPayload == null) {
|
||||
return sectorTooltipPayload;
|
||||
}
|
||||
return sectorTooltipPayload.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
||||
color: activeShapeFill,
|
||||
fill: activeShapeFill
|
||||
}));
|
||||
});
|
||||
var tooltipEntrySettings = {
|
||||
dataDefinedOnItem: tooltipDataDefinedOnItem,
|
||||
getPosition: index => {
|
||||
var _sectors$Number;
|
||||
return (_sectors$Number = sectors[Number(index)]) === null || _sectors$Number === void 0 ? void 0 : _sectors$Number.tooltipPosition;
|
||||
},
|
||||
settings: {
|
||||
stroke,
|
||||
strokeWidth,
|
||||
fill,
|
||||
dataKey,
|
||||
nameKey,
|
||||
name: getTooltipNameProp(name, dataKey),
|
||||
hide,
|
||||
type: tooltipType,
|
||||
color: fill,
|
||||
unit: '',
|
||||
// why doesn't Pie support unit?
|
||||
formatter,
|
||||
graphicalItemId: id
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
|
||||
tooltipEntrySettings: tooltipEntrySettings
|
||||
});
|
||||
});
|
||||
var getTextAnchor = (x, cx) => {
|
||||
if (x > cx) {
|
||||
return 'start';
|
||||
}
|
||||
if (x < cx) {
|
||||
return 'end';
|
||||
}
|
||||
return 'middle';
|
||||
};
|
||||
var getOuterRadius = (dataPoint, outerRadius, maxPieRadius) => {
|
||||
if (typeof outerRadius === 'function') {
|
||||
return getPercentValue(outerRadius(dataPoint), maxPieRadius, maxPieRadius * 0.8);
|
||||
}
|
||||
return getPercentValue(outerRadius, maxPieRadius, maxPieRadius * 0.8);
|
||||
};
|
||||
var parseCoordinateOfPie = (pieSettings, offset, dataPoint) => {
|
||||
var top = offset.top,
|
||||
left = offset.left,
|
||||
width = offset.width,
|
||||
height = offset.height;
|
||||
var maxPieRadius = getMaxRadius(width, height);
|
||||
var cx = left + getPercentValue(pieSettings.cx, width, width / 2);
|
||||
var cy = top + getPercentValue(pieSettings.cy, height, height / 2);
|
||||
var innerRadius = getPercentValue(pieSettings.innerRadius, maxPieRadius, 0);
|
||||
var outerRadius = getOuterRadius(dataPoint, pieSettings.outerRadius, maxPieRadius);
|
||||
var maxRadius = pieSettings.maxRadius || Math.sqrt(width * width + height * height) / 2;
|
||||
return {
|
||||
cx,
|
||||
cy,
|
||||
innerRadius,
|
||||
outerRadius,
|
||||
maxRadius
|
||||
};
|
||||
};
|
||||
var parseDeltaAngle = (startAngle, endAngle) => {
|
||||
var sign = mathSign(endAngle - startAngle);
|
||||
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
|
||||
return sign * deltaAngle;
|
||||
};
|
||||
var renderLabelLineItem = (option, props) => {
|
||||
if (/*#__PURE__*/React.isValidElement(option)) {
|
||||
// @ts-expect-error we can't know if the type of props matches the element
|
||||
return /*#__PURE__*/React.cloneElement(option, props);
|
||||
}
|
||||
if (typeof option === 'function') {
|
||||
return option(props);
|
||||
}
|
||||
var className = clsx('recharts-pie-label-line', typeof option !== 'boolean' ? option.className : '');
|
||||
// React doesn't like it when we spread a key property onto an element
|
||||
var key = props.key,
|
||||
otherProps = _objectWithoutProperties(props, _excluded);
|
||||
return /*#__PURE__*/React.createElement(Curve, _extends({}, otherProps, {
|
||||
type: "linear",
|
||||
className: className
|
||||
}));
|
||||
};
|
||||
var renderLabelItem = (option, props, value) => {
|
||||
if (/*#__PURE__*/React.isValidElement(option)) {
|
||||
// @ts-expect-error element cloning is not typed
|
||||
return /*#__PURE__*/React.cloneElement(option, props);
|
||||
}
|
||||
var label = value;
|
||||
if (typeof option === 'function') {
|
||||
label = option(props);
|
||||
if (/*#__PURE__*/React.isValidElement(label)) {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
var className = clsx('recharts-pie-label-text', getClassNameFromUnknown(option));
|
||||
return /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
||||
alignmentBaseline: "middle",
|
||||
className: className
|
||||
}), label);
|
||||
};
|
||||
function PieLabels(_ref2) {
|
||||
var sectors = _ref2.sectors,
|
||||
props = _ref2.props,
|
||||
showLabels = _ref2.showLabels;
|
||||
var label = props.label,
|
||||
labelLine = props.labelLine,
|
||||
dataKey = props.dataKey;
|
||||
if (!showLabels || !label || !sectors) {
|
||||
return null;
|
||||
}
|
||||
var pieProps = svgPropertiesNoEvents(props);
|
||||
var customLabelProps = svgPropertiesNoEventsFromUnknown(label);
|
||||
var customLabelLineProps = svgPropertiesNoEventsFromUnknown(labelLine);
|
||||
var offsetRadius = typeof label === 'object' && 'offsetRadius' in label && typeof label.offsetRadius === 'number' && label.offsetRadius || 20;
|
||||
var labels = sectors.map((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), {}, {
|
||||
// @ts-expect-error customLabelProps is contributing unknown props
|
||||
stroke: 'none'
|
||||
}, customLabelProps), {}, {
|
||||
index: i,
|
||||
textAnchor: getTextAnchor(endPoint.x, entry.cx)
|
||||
}, endPoint);
|
||||
var lineProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
|
||||
// @ts-expect-error customLabelLineProps is contributing unknown props
|
||||
fill: 'none',
|
||||
// @ts-expect-error customLabelLineProps is contributing unknown props
|
||||
stroke: entry.fill
|
||||
}, customLabelLineProps), {}, {
|
||||
index: i,
|
||||
points: [polarToCartesian(entry.cx, entry.cy, entry.outerRadius, midAngle), endPoint],
|
||||
key: 'line'
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: DefaultZIndexes.label,
|
||||
key: "label-".concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
|
||||
}, /*#__PURE__*/React.createElement(Layer, null, labelLine && renderLabelLineItem(labelLine, lineProps), renderLabelItem(label, labelProps, getValueByDataKey(entry, dataKey))));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-pie-labels"
|
||||
}, labels);
|
||||
}
|
||||
function PieLabelList(_ref3) {
|
||||
var sectors = _ref3.sectors,
|
||||
props = _ref3.props,
|
||||
showLabels = _ref3.showLabels;
|
||||
var label = props.label;
|
||||
if (typeof label === 'object' && label != null && 'position' in label) {
|
||||
return /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
|
||||
label: label
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(PieLabels, {
|
||||
sectors: sectors,
|
||||
props: props,
|
||||
showLabels: showLabels
|
||||
});
|
||||
}
|
||||
function PieSectors(props) {
|
||||
var sectors = props.sectors,
|
||||
activeShape = props.activeShape,
|
||||
inactiveShapeProp = props.inactiveShape,
|
||||
allOtherPieProps = props.allOtherPieProps,
|
||||
shape = props.shape,
|
||||
id = props.id,
|
||||
animationElapsedTime = props.animationElapsedTime,
|
||||
isAnimating = props.isAnimating,
|
||||
isEntrance = props.isEntrance;
|
||||
var activeIndex = useAppSelector(selectActiveTooltipIndex);
|
||||
var activeDataKey = useAppSelector(selectActiveTooltipDataKey);
|
||||
var activeGraphicalItemId = useAppSelector(selectActiveTooltipGraphicalItemId);
|
||||
var onMouseEnterFromProps = allOtherPieProps.onMouseEnter,
|
||||
onItemClickFromProps = allOtherPieProps.onClick,
|
||||
onMouseLeaveFromProps = allOtherPieProps.onMouseLeave,
|
||||
restOfAllOtherProps = _objectWithoutProperties(allOtherPieProps, _excluded2);
|
||||
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherPieProps.dataKey, id);
|
||||
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
|
||||
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherPieProps.dataKey, id);
|
||||
if (sectors == null || sectors.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, sectors.map((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;
|
||||
|
||||
// For Pie charts, when multiple Pies share the same dataKey, we need to ensure only the hovered Pie's sector is active.
|
||||
// We do this by checking if the active graphical item ID matches this Pie's ID.
|
||||
var graphicalItemMatches = activeGraphicalItemId == null || activeGraphicalItemId === id;
|
||||
var isActive = String(i) === activeIndex && (activeDataKey == null || allOtherPieProps.dataKey === activeDataKey) && graphicalItemMatches;
|
||||
var inactiveShape = activeIndex ? inactiveShapeProp : null;
|
||||
var sectorOptions = activeShape && isActive ? activeShape : inactiveShape;
|
||||
var sectorProps = _objectSpread(_objectSpread({}, entry), {}, {
|
||||
stroke: entry.stroke,
|
||||
tabIndex: -1,
|
||||
index: i,
|
||||
isActive,
|
||||
animationElapsedTime,
|
||||
isAnimating,
|
||||
isEntrance,
|
||||
[DATA_ITEM_INDEX_ATTRIBUTE_NAME]: i,
|
||||
[DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: id
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, _extends({
|
||||
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),
|
||||
tabIndex: -1,
|
||||
className: "recharts-pie-sector"
|
||||
}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
|
||||
onMouseEnter: onMouseEnterFromContext(entry, i),
|
||||
onMouseLeave: onMouseLeaveFromContext(entry, i),
|
||||
onClick: onClickFromContext(entry, i)
|
||||
}), /*#__PURE__*/React.createElement(Shape, {
|
||||
option: sectorOptions !== null && sectorOptions !== void 0 ? sectorOptions : shape,
|
||||
DefaultShape: defaultPieSectorShape,
|
||||
shapeProps: sectorProps
|
||||
}));
|
||||
}));
|
||||
}
|
||||
export function computePieSectors(_ref4) {
|
||||
var _pieSettings$paddingA;
|
||||
var pieSettings = _ref4.pieSettings,
|
||||
displayedData = _ref4.displayedData,
|
||||
cells = _ref4.cells,
|
||||
offset = _ref4.offset;
|
||||
var cornerRadius = pieSettings.cornerRadius,
|
||||
startAngle = pieSettings.startAngle,
|
||||
endAngle = pieSettings.endAngle,
|
||||
dataKey = pieSettings.dataKey,
|
||||
nameKey = pieSettings.nameKey,
|
||||
tooltipType = pieSettings.tooltipType;
|
||||
var minAngle = Math.abs(pieSettings.minAngle);
|
||||
var deltaAngle = parseDeltaAngle(startAngle, endAngle);
|
||||
var absDeltaAngle = Math.abs(deltaAngle);
|
||||
var paddingAngle = displayedData.length <= 1 ? 0 : (_pieSettings$paddingA = pieSettings.paddingAngle) !== null && _pieSettings$paddingA !== void 0 ? _pieSettings$paddingA : 0;
|
||||
var notZeroItemCount = displayedData.filter(entry => getValueByDataKey(entry, dataKey, 0) !== 0).length;
|
||||
var totalPaddingAngle = (absDeltaAngle >= 360 ? notZeroItemCount : notZeroItemCount - 1) * paddingAngle;
|
||||
var sum = displayedData.reduce((result, entry) => {
|
||||
var val = getValueByDataKey(entry, dataKey, 0);
|
||||
return result + (isNumber(val) ? val : 0);
|
||||
}, 0);
|
||||
|
||||
// Only apply minAngle redistribution when at least one non-zero segment's
|
||||
// natural angle falls below the minAngle threshold. Otherwise, minAngle
|
||||
// unnecessarily shifts all segments even when none need the boost.
|
||||
// See: https://github.com/recharts/recharts/issues/6814
|
||||
var needsMinAngleAdjustment = minAngle > 0 && sum > 0 && displayedData.some(entry => {
|
||||
var val = getValueByDataKey(entry, dataKey, 0);
|
||||
var percent = (isNumber(val) ? val : 0) / sum;
|
||||
return val !== 0 && percent * absDeltaAngle < minAngle;
|
||||
});
|
||||
var effectiveMinAngle = needsMinAngleAdjustment ? minAngle : 0;
|
||||
var realTotalAngle = absDeltaAngle - notZeroItemCount * effectiveMinAngle - totalPaddingAngle;
|
||||
var sectors;
|
||||
if (sum > 0) {
|
||||
var prev;
|
||||
sectors = displayedData.map((entry, i) => {
|
||||
var val = getValueByDataKey(entry, dataKey, 0);
|
||||
var name = getValueByDataKey(entry, nameKey, i);
|
||||
var coordinate = parseCoordinateOfPie(pieSettings, offset, entry);
|
||||
var percent = (isNumber(val) ? val : 0) / sum;
|
||||
var tempStartAngle;
|
||||
|
||||
// @ts-expect-error can't spread unknown
|
||||
var entryWithCellInfo = _objectSpread(_objectSpread({}, entry), cells && cells[i] && cells[i].props);
|
||||
var sectorColor = entryWithCellInfo != null && 'fill' in entryWithCellInfo && typeof entryWithCellInfo.fill === 'string' ? entryWithCellInfo.fill : pieSettings.fill;
|
||||
if (i) {
|
||||
tempStartAngle = prev.endAngle + mathSign(deltaAngle) * paddingAngle * (val !== 0 ? 1 : 0);
|
||||
} else {
|
||||
tempStartAngle = startAngle;
|
||||
}
|
||||
var tempEndAngle = tempStartAngle + mathSign(deltaAngle) * ((val !== 0 ? effectiveMinAngle : 0) + percent * realTotalAngle);
|
||||
var midAngle = (tempStartAngle + tempEndAngle) / 2;
|
||||
var middleRadius = (coordinate.innerRadius + coordinate.outerRadius) / 2;
|
||||
var tooltipPayload = [{
|
||||
name,
|
||||
value: val,
|
||||
payload: entryWithCellInfo,
|
||||
dataKey,
|
||||
type: tooltipType,
|
||||
color: sectorColor,
|
||||
fill: sectorColor,
|
||||
graphicalItemId: pieSettings.id
|
||||
}];
|
||||
var tooltipPosition = polarToCartesian(coordinate.cx, coordinate.cy, middleRadius, midAngle);
|
||||
prev = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieSettings.presentationProps), {}, {
|
||||
percent,
|
||||
cornerRadius: typeof cornerRadius === 'string' ? parseFloat(cornerRadius) : cornerRadius,
|
||||
name,
|
||||
tooltipPayload,
|
||||
midAngle,
|
||||
middleRadius,
|
||||
tooltipPosition
|
||||
}, entryWithCellInfo), coordinate), {}, {
|
||||
value: val,
|
||||
dataKey,
|
||||
startAngle: tempStartAngle,
|
||||
endAngle: tempEndAngle,
|
||||
payload: entryWithCellInfo,
|
||||
paddingAngle: val !== 0 ? mathSign(deltaAngle) * paddingAngle : 0
|
||||
});
|
||||
return prev;
|
||||
});
|
||||
}
|
||||
return sectors;
|
||||
}
|
||||
function PieLabelListProvider(_ref5) {
|
||||
var showLabels = _ref5.showLabels,
|
||||
sectors = _ref5.sectors,
|
||||
children = _ref5.children;
|
||||
var labelListEntries = useMemo(() => {
|
||||
if (!showLabels || !sectors) {
|
||||
return [];
|
||||
}
|
||||
return sectors.map(entry => ({
|
||||
value: entry.value,
|
||||
payload: entry.payload,
|
||||
clockWise: false,
|
||||
parentViewBox: undefined,
|
||||
viewBox: {
|
||||
cx: entry.cx,
|
||||
cy: entry.cy,
|
||||
innerRadius: entry.innerRadius,
|
||||
outerRadius: entry.outerRadius,
|
||||
startAngle: entry.startAngle,
|
||||
endAngle: entry.endAngle,
|
||||
clockWise: false
|
||||
},
|
||||
fill: entry.fill
|
||||
}));
|
||||
}, [sectors, showLabels]);
|
||||
return /*#__PURE__*/React.createElement(PolarLabelListContextProvider, {
|
||||
value: showLabels ? labelListEntries : undefined
|
||||
}, children);
|
||||
}
|
||||
var defaultPieAnimateItems = (items, animationElapsedTime) => {
|
||||
if (items == null) return [];
|
||||
var stepData = [];
|
||||
var firstNonRemoved = items.find(item => item.status !== 'removed');
|
||||
var curAngle = firstNonRemoved ? firstNonRemoved.next.startAngle : 0;
|
||||
items.forEach((item, index) => {
|
||||
if (item.status === 'removed') return;
|
||||
var paddingAngle = index > 0 ? get(item.next, 'paddingAngle', 0) : 0;
|
||||
if (item.status === 'matched') {
|
||||
var angle = interpolate(item.prev.endAngle - item.prev.startAngle, item.next.endAngle - item.next.startAngle, animationElapsedTime);
|
||||
var latest = _objectSpread(_objectSpread({}, item.next), {}, {
|
||||
startAngle: curAngle + paddingAngle,
|
||||
endAngle: curAngle + angle + paddingAngle
|
||||
});
|
||||
stepData.push(latest);
|
||||
curAngle = latest.endAngle;
|
||||
} else {
|
||||
// added
|
||||
var deltaAngle = interpolate(0, item.next.endAngle - item.next.startAngle, animationElapsedTime);
|
||||
var _latest = _objectSpread(_objectSpread({}, item.next), {}, {
|
||||
startAngle: curAngle + paddingAngle,
|
||||
endAngle: curAngle + deltaAngle + paddingAngle
|
||||
});
|
||||
stepData.push(_latest);
|
||||
curAngle = _latest.endAngle;
|
||||
}
|
||||
});
|
||||
return stepData;
|
||||
};
|
||||
function SectorsWithAnimation(_ref6) {
|
||||
var props = _ref6.props,
|
||||
previousSectorsRef = _ref6.previousSectorsRef,
|
||||
id = _ref6.id;
|
||||
var sectors = props.sectors,
|
||||
activeShape = props.activeShape,
|
||||
inactiveShape = props.inactiveShape,
|
||||
animationInterpolateFn = props.animationInterpolateFn;
|
||||
var _useAnimationCallback = useAnimationCallbacks(props.onAnimationStart, props.onAnimationEnd),
|
||||
isAnimating = _useAnimationCallback.isAnimating,
|
||||
handleAnimationStart = _useAnimationCallback.handleAnimationStart,
|
||||
handleAnimationEnd = _useAnimationCallback.handleAnimationEnd;
|
||||
var layout = usePolarChartLayout();
|
||||
if (layout == null) return null;
|
||||
return /*#__PURE__*/React.createElement(PieLabelListProvider, {
|
||||
showLabels: !isAnimating,
|
||||
sectors: sectors
|
||||
}, /*#__PURE__*/React.createElement(AnimatedItems, {
|
||||
animationInput: props,
|
||||
animationIdPrefix: "recharts-pie-",
|
||||
items: sectors,
|
||||
previousItemsRef: previousSectorsRef,
|
||||
isAnimationActive: props.isAnimationActive,
|
||||
animationBegin: props.animationBegin,
|
||||
animationDuration: props.animationDuration,
|
||||
animationEasing: props.animationEasing,
|
||||
onAnimationStart: handleAnimationStart,
|
||||
onAnimationEnd: handleAnimationEnd,
|
||||
animationInterpolateFn: animationInterpolateFn,
|
||||
animationMatchBy: props.animationMatchBy,
|
||||
layout: layout
|
||||
}, (stepData, animationElapsedTime, isEntrance) => /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement(PieSectors, {
|
||||
sectors: stepData,
|
||||
activeShape: activeShape,
|
||||
inactiveShape: inactiveShape,
|
||||
allOtherPieProps: props,
|
||||
shape: props.shape,
|
||||
id: id,
|
||||
animationElapsedTime: animationElapsedTime,
|
||||
isAnimating: isAnimating || animationElapsedTime < 1,
|
||||
isEntrance: isEntrance
|
||||
}))), /*#__PURE__*/React.createElement(PieLabelList, {
|
||||
showLabels: !isAnimating,
|
||||
sectors: sectors,
|
||||
props: props
|
||||
}), props.children);
|
||||
}
|
||||
export var defaultPieProps = {
|
||||
animationBegin: 400,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
animationInterpolateFn: defaultPieAnimateItems,
|
||||
animationMatchBy: matchAppend,
|
||||
cx: '50%',
|
||||
cy: '50%',
|
||||
dataKey: 'value',
|
||||
endAngle: 360,
|
||||
fill: '#808080',
|
||||
hide: false,
|
||||
innerRadius: 0,
|
||||
isAnimationActive: 'auto',
|
||||
label: false,
|
||||
labelLine: true,
|
||||
legendType: 'rect',
|
||||
minAngle: 0,
|
||||
nameKey: 'name',
|
||||
outerRadius: '80%',
|
||||
paddingAngle: 0,
|
||||
rootTabIndex: 0,
|
||||
shape: defaultPieSectorShape,
|
||||
startAngle: 0,
|
||||
stroke: '#fff',
|
||||
zIndex: DefaultZIndexes.area
|
||||
};
|
||||
function PieImpl(props) {
|
||||
var id = props.id,
|
||||
propsWithoutId = _objectWithoutProperties(props, _excluded3);
|
||||
var hide = props.hide,
|
||||
className = props.className,
|
||||
rootTabIndex = props.rootTabIndex;
|
||||
var cells = useMemo(() => findAllByType(props.children, Cell), [props.children]);
|
||||
var sectors = useAppSelector(state => selectPieSectors(state, id, cells));
|
||||
var previousSectorsRef = useRef(null);
|
||||
var layerClass = clsx('recharts-pie', className);
|
||||
if (hide || sectors == null) {
|
||||
previousSectorsRef.current = null;
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
tabIndex: rootTabIndex,
|
||||
className: layerClass
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: props.zIndex
|
||||
}, /*#__PURE__*/React.createElement(SetPieTooltipEntrySettings, {
|
||||
dataKey: props.dataKey,
|
||||
nameKey: props.nameKey,
|
||||
sectors: sectors,
|
||||
stroke: props.stroke,
|
||||
strokeWidth: props.strokeWidth,
|
||||
fill: props.fill,
|
||||
name: props.name,
|
||||
hide: props.hide,
|
||||
tooltipType: props.tooltipType,
|
||||
formatter: props.formatter,
|
||||
id: id,
|
||||
activeShape: props.activeShape
|
||||
}), /*#__PURE__*/React.createElement(Layer, {
|
||||
tabIndex: rootTabIndex,
|
||||
className: layerClass
|
||||
}, /*#__PURE__*/React.createElement(SectorsWithAnimation, {
|
||||
props: _objectSpread(_objectSpread({}, propsWithoutId), {}, {
|
||||
sectors
|
||||
}),
|
||||
previousSectorsRef: previousSectorsRef,
|
||||
id: id
|
||||
})));
|
||||
}
|
||||
/**
|
||||
* @consumes PolarChartContext
|
||||
* @provides LabelListContext
|
||||
* @provides CellReader
|
||||
*/
|
||||
function PieFn(outsideProps) {
|
||||
var props = resolveDefaultProps(outsideProps, defaultPieProps);
|
||||
var externalId = props.id,
|
||||
propsWithoutId = _objectWithoutProperties(props, _excluded4);
|
||||
var presentationProps = svgPropertiesNoEvents(propsWithoutId);
|
||||
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
|
||||
id: externalId,
|
||||
type: "pie"
|
||||
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetPolarGraphicalItem, {
|
||||
type: "pie",
|
||||
id: id,
|
||||
data: propsWithoutId.data,
|
||||
dataKey: propsWithoutId.dataKey,
|
||||
hide: propsWithoutId.hide,
|
||||
angleAxisId: 0,
|
||||
radiusAxisId: 0,
|
||||
name: propsWithoutId.name,
|
||||
nameKey: propsWithoutId.nameKey,
|
||||
tooltipType: propsWithoutId.tooltipType,
|
||||
legendType: propsWithoutId.legendType,
|
||||
fill: propsWithoutId.fill,
|
||||
cx: propsWithoutId.cx,
|
||||
cy: propsWithoutId.cy,
|
||||
startAngle: propsWithoutId.startAngle,
|
||||
endAngle: propsWithoutId.endAngle,
|
||||
paddingAngle: propsWithoutId.paddingAngle,
|
||||
minAngle: propsWithoutId.minAngle,
|
||||
innerRadius: propsWithoutId.innerRadius,
|
||||
outerRadius: propsWithoutId.outerRadius,
|
||||
cornerRadius: propsWithoutId.cornerRadius,
|
||||
presentationProps: presentationProps,
|
||||
maxRadius: props.maxRadius
|
||||
}), /*#__PURE__*/React.createElement(SetPiePayloadLegend, _extends({}, propsWithoutId, {
|
||||
id: id
|
||||
})), /*#__PURE__*/React.createElement(PieImpl, _extends({}, propsWithoutId, {
|
||||
id: id
|
||||
}))));
|
||||
}
|
||||
export var Pie = PieFn;
|
||||
// @ts-expect-error we need to set the displayName for debugging purposes
|
||||
Pie.displayName = 'Pie';
|
||||
271
frontend/node_modules/recharts/es6/polar/PolarAngleAxis.js
generated
vendored
Normal file
271
frontend/node_modules/recharts/es6/polar/PolarAngleAxis.js
generated
vendored
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
var _excluded = ["children", "type"],
|
||||
_excluded2 = ["ref"];
|
||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, 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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
||||
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
||||
import * as React from 'react';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
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 { degreeToRadian, polarToCartesian } from '../util/PolarUtils';
|
||||
import { addAngleAxis, removeAngleAxis } from '../state/polarAxisSlice';
|
||||
import { useAppDispatch, useAppSelector } from '../state/hooks';
|
||||
import { selectPolarAngleAxisTicks, selectPolarAxisScale } from '../state/selectors/polarScaleSelectors';
|
||||
import { selectAngleAxis, selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
|
||||
import { defaultPolarAngleAxisProps } from './defaultPolarAngleAxisProps';
|
||||
import { useIsPanorama } from '../context/PanoramaContext';
|
||||
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
|
||||
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
||||
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
||||
import { usePolarChartLayout } from '../context/chartLayoutContext';
|
||||
import { noop } from '../util/DataUtils';
|
||||
import { getAxisTypeBasedOnLayout } from '../util/getAxisTypeBasedOnLayout';
|
||||
import { getClassNameFromUnknown } from '../util/getClassNameFromUnknown';
|
||||
var eps = 1e-5;
|
||||
var COS_45 = Math.cos(degreeToRadian(45));
|
||||
var AXIS_TYPE = 'angleAxis';
|
||||
function SetAngleAxisSettings(props) {
|
||||
var dispatch = useAppDispatch();
|
||||
var layout = usePolarChartLayout();
|
||||
var settings = useMemo(() => {
|
||||
var children = props.children,
|
||||
typeFromProps = props.type,
|
||||
rest = _objectWithoutProperties(props, _excluded);
|
||||
var evaluatedType = getAxisTypeBasedOnLayout(layout, 'angleAxis', typeFromProps);
|
||||
if (evaluatedType == null) {
|
||||
return undefined;
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, rest), {}, {
|
||||
type: evaluatedType
|
||||
});
|
||||
}, [props, layout]);
|
||||
var synchronizedSettings = useAppSelector(state => selectAngleAxis(state, settings === null || settings === void 0 ? void 0 : settings.id));
|
||||
var settingsAreSynchronized = settings === synchronizedSettings;
|
||||
useEffect(() => {
|
||||
if (settings == null) {
|
||||
return noop;
|
||||
}
|
||||
dispatch(addAngleAxis(settings));
|
||||
return () => {
|
||||
dispatch(removeAngleAxis(settings));
|
||||
};
|
||||
}, [dispatch, settings]);
|
||||
if (settingsAreSynchronized) {
|
||||
return props.children;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the coordinate of line endpoint
|
||||
* @param data The data if there are ticks
|
||||
* @param props axis settings
|
||||
* @return (x1, y1): The point close to text,
|
||||
* (x2, y2): The point close to axis
|
||||
*/
|
||||
var getTickLineCoord = (data, props) => {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
radius = props.radius,
|
||||
orientation = props.orientation,
|
||||
tickSize = 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 data Data of ticks
|
||||
* @param orientation of the axis ticks
|
||||
* @return text-anchor
|
||||
*/
|
||||
var getTickTextAnchor = (data, orientation) => {
|
||||
var cos = Math.cos(degreeToRadian(-data.coordinate));
|
||||
if (cos > eps) {
|
||||
return orientation === 'outer' ? 'start' : 'end';
|
||||
}
|
||||
if (cos < -eps) {
|
||||
return orientation === 'outer' ? 'end' : 'start';
|
||||
}
|
||||
return 'middle';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the text vertical anchor of each tick
|
||||
* @param data Data of a tick
|
||||
* @return text vertical anchor
|
||||
*/
|
||||
var getTickTextVerticalAnchor = data => {
|
||||
var cos = Math.cos(degreeToRadian(-data.coordinate));
|
||||
var sin = Math.sin(degreeToRadian(-data.coordinate));
|
||||
|
||||
// handle top and bottom sectors: 90±45deg and 270±45deg
|
||||
if (Math.abs(cos) <= COS_45) {
|
||||
// sin > 0: top sector, sin < 0: bottom sector
|
||||
return sin > 0 ? 'start' : 'end';
|
||||
}
|
||||
return 'middle';
|
||||
};
|
||||
var AxisLine = props => {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
radius = props.radius,
|
||||
axisLineType = props.axisLineType,
|
||||
axisLine = props.axisLine,
|
||||
ticks = props.ticks;
|
||||
if (!axisLine) {
|
||||
return null;
|
||||
}
|
||||
var axisLineProps = _objectSpread(_objectSpread({}, svgPropertiesNoEvents(props)), {}, {
|
||||
fill: 'none'
|
||||
}, svgPropertiesNoEvents(axisLine));
|
||||
if (axisLineType === 'circle') {
|
||||
// @ts-expect-error wrong SVG element type
|
||||
return /*#__PURE__*/React.createElement(Dot, _extends({
|
||||
className: "recharts-polar-angle-axis-line"
|
||||
}, axisLineProps, {
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r: radius
|
||||
}));
|
||||
}
|
||||
var points = ticks.map(entry => polarToCartesian(cx, cy, radius, entry.coordinate));
|
||||
|
||||
// @ts-expect-error wrong SVG element type
|
||||
return /*#__PURE__*/React.createElement(Polygon, _extends({
|
||||
className: "recharts-polar-angle-axis-line"
|
||||
}, axisLineProps, {
|
||||
points: points
|
||||
}));
|
||||
};
|
||||
var TickItemText = _ref => {
|
||||
var tick = _ref.tick,
|
||||
tickProps = _ref.tickProps,
|
||||
value = _ref.value;
|
||||
if (!tick) {
|
||||
return null;
|
||||
}
|
||||
if (/*#__PURE__*/React.isValidElement(tick)) {
|
||||
return /*#__PURE__*/React.cloneElement(tick, tickProps);
|
||||
}
|
||||
if (typeof tick === 'function') {
|
||||
return tick(tickProps);
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Text, _extends({}, tickProps, {
|
||||
className: "recharts-polar-angle-axis-tick-value"
|
||||
}), value);
|
||||
};
|
||||
var Ticks = props => {
|
||||
var tick = props.tick,
|
||||
tickLine = props.tickLine,
|
||||
tickFormatter = props.tickFormatter,
|
||||
stroke = props.stroke,
|
||||
ticks = props.ticks;
|
||||
var _svgPropertiesNoEvent = svgPropertiesNoEvents(props),
|
||||
ref = _svgPropertiesNoEvent.ref,
|
||||
axisProps = _objectWithoutProperties(_svgPropertiesNoEvent, _excluded2);
|
||||
var customTickProps = svgPropertiesNoEventsFromUnknown(tick);
|
||||
var tickLineProps = _objectSpread(_objectSpread({}, axisProps), {}, {
|
||||
fill: 'none'
|
||||
}, svgPropertiesNoEvents(tickLine));
|
||||
var items = ticks.map((entry, i) => {
|
||||
var lineCoord = getTickLineCoord(entry, props);
|
||||
var textAnchor = getTickTextAnchor(entry, props.orientation);
|
||||
var verticalAnchor = getTickTextVerticalAnchor(entry);
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread({}, axisProps), {}, {
|
||||
// @ts-expect-error customTickProps is contributing unknown props
|
||||
textAnchor,
|
||||
verticalAnchor,
|
||||
// @ts-expect-error customTickProps is contributing unknown props
|
||||
stroke: 'none',
|
||||
// @ts-expect-error customTickProps is contributing unknown props
|
||||
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', getClassNameFromUnknown(tick)),
|
||||
key: "tick-".concat(entry.coordinate)
|
||||
}, adaptEventsOfChild(props, entry, i)), tickLine && /*#__PURE__*/React.createElement("line", _extends({
|
||||
className: "recharts-polar-angle-axis-tick-line"
|
||||
}, tickLineProps, lineCoord)), /*#__PURE__*/React.createElement(TickItemText, {
|
||||
tick: tick,
|
||||
tickProps: tickProps,
|
||||
value: tickFormatter ? tickFormatter(entry.value, i) : entry.value
|
||||
}));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-polar-angle-axis-ticks"
|
||||
}, items);
|
||||
};
|
||||
export var PolarAngleAxisWrapper = defaultsAndInputs => {
|
||||
var angleAxisId = defaultsAndInputs.angleAxisId;
|
||||
var viewBox = useAppSelector(selectPolarViewBox);
|
||||
var scale = useAppSelector(state => selectPolarAxisScale(state, 'angleAxis', angleAxisId));
|
||||
var isPanorama = useIsPanorama();
|
||||
var ticks = useAppSelector(state => selectPolarAngleAxisTicks(state, 'angleAxis', angleAxisId, isPanorama));
|
||||
if (viewBox == null || !ticks || !ticks.length || scale == null) {
|
||||
return null;
|
||||
}
|
||||
var props = _objectSpread(_objectSpread(_objectSpread({}, defaultsAndInputs), {}, {
|
||||
scale
|
||||
}, viewBox), {}, {
|
||||
radius: viewBox.outerRadius,
|
||||
ticks
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: props.zIndex
|
||||
}, /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-polar-angle-axis', AXIS_TYPE, props.className)
|
||||
}, /*#__PURE__*/React.createElement(AxisLine, props), /*#__PURE__*/React.createElement(Ticks, props)));
|
||||
};
|
||||
|
||||
/**
|
||||
* @provides PolarLabelContext
|
||||
* @consumes PolarViewBoxContext
|
||||
*/
|
||||
export function PolarAngleAxis(outsideProps) {
|
||||
var _props$niceTicks;
|
||||
var props = resolveDefaultProps(outsideProps, defaultPolarAngleAxisProps);
|
||||
return /*#__PURE__*/React.createElement(SetAngleAxisSettings, {
|
||||
id: props.angleAxisId,
|
||||
scale: props.scale,
|
||||
type: props.type,
|
||||
dataKey: props.dataKey,
|
||||
unit: undefined,
|
||||
name: props.name,
|
||||
allowDuplicatedCategory: false // Ignoring the prop on purpose because axis calculation behaves as if it was false and Tooltip requires it to be true.
|
||||
,
|
||||
allowDataOverflow: false,
|
||||
reversed: props.reversed,
|
||||
includeHidden: false,
|
||||
allowDecimals: props.allowDecimals,
|
||||
tickCount: props.tickCount,
|
||||
niceTicks: (_props$niceTicks = props.niceTicks) !== null && _props$niceTicks !== void 0 ? _props$niceTicks : 'auto'
|
||||
// @ts-expect-error the type does not match. Is RadiusAxis really expecting what it says?
|
||||
,
|
||||
ticks: props.ticks,
|
||||
tick: props.tick,
|
||||
domain: props.domain
|
||||
}, /*#__PURE__*/React.createElement(PolarAngleAxisWrapper, props));
|
||||
}
|
||||
PolarAngleAxis.displayName = 'PolarAngleAxis';
|
||||
191
frontend/node_modules/recharts/es6/polar/PolarGrid.js
generated
vendored
Normal file
191
frontend/node_modules/recharts/es6/polar/PolarGrid.js
generated
vendored
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
var _excluded = ["gridType", "radialLines", "angleAxisId", "radiusAxisId", "cx", "cy", "innerRadius", "outerRadius", "polarAngles", "polarRadius", "zIndex"];
|
||||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
||||
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, 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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
import { clsx } from 'clsx';
|
||||
import * as React from 'react';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
import { useAppSelector } from '../state/hooks';
|
||||
import { selectPolarGridAngles, selectPolarGridRadii } from '../state/selectors/polarGridSelectors';
|
||||
import { selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
|
||||
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
|
||||
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
||||
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
||||
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
||||
var getPolygonPath = (radius, cx, cy, polarAngles) => {
|
||||
var path = '';
|
||||
polarAngles.forEach((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 = 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({}, svgPropertiesNoEvents(props));
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-polar-grid-angle"
|
||||
}, polarAngles.map(entry => {
|
||||
var start = polarToCartesian(cx, cy, innerRadius, entry);
|
||||
var end = polarToCartesian(cx, cy, outerRadius, entry);
|
||||
return /*#__PURE__*/React.createElement("line", _extends({
|
||||
key: "line-".concat(entry)
|
||||
}, polarAnglesProps, {
|
||||
x1: start.x,
|
||||
y1: start.y,
|
||||
x2: end.x,
|
||||
y2: end.y
|
||||
}));
|
||||
}));
|
||||
};
|
||||
|
||||
// Draw concentric circles
|
||||
var ConcentricCircle = props => {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
radius = props.radius;
|
||||
var concentricCircleProps = _objectSpread({}, svgPropertiesNoEvents(props));
|
||||
return (
|
||||
/*#__PURE__*/
|
||||
// @ts-expect-error wrong SVG element type
|
||||
React.createElement("circle", _extends({}, concentricCircleProps, {
|
||||
className: clsx('recharts-polar-grid-concentric-circle', props.className),
|
||||
cx: cx,
|
||||
cy: cy,
|
||||
r: radius
|
||||
}))
|
||||
);
|
||||
};
|
||||
|
||||
// Draw concentric polygons
|
||||
var ConcentricPolygon = props => {
|
||||
var radius = props.radius;
|
||||
var concentricPolygonProps = _objectSpread({}, svgPropertiesNoEvents(props));
|
||||
return /*#__PURE__*/React.createElement("path", _extends({}, concentricPolygonProps, {
|
||||
className: clsx('recharts-polar-grid-concentric-polygon', props.className),
|
||||
d: getPolygonPath(radius, props.cx, props.cy, props.polarAngles)
|
||||
}));
|
||||
};
|
||||
|
||||
// Draw concentric axis
|
||||
var ConcentricGridPath = props => {
|
||||
var polarRadius = props.polarRadius,
|
||||
gridType = props.gridType;
|
||||
if (!polarRadius || !polarRadius.length) {
|
||||
return null;
|
||||
}
|
||||
var maxPolarRadius = Math.max(...polarRadius);
|
||||
var renderBackground = props.fill && props.fill !== 'none';
|
||||
return /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-polar-grid-concentric"
|
||||
}, renderBackground && gridType === 'circle' && /*#__PURE__*/React.createElement(ConcentricCircle, _extends({}, props, {
|
||||
radius: maxPolarRadius
|
||||
})), renderBackground && gridType !== 'circle' && /*#__PURE__*/React.createElement(ConcentricPolygon, _extends({}, props, {
|
||||
radius: maxPolarRadius
|
||||
})), polarRadius.map((entry, i) => {
|
||||
var key = i;
|
||||
if (gridType === 'circle') {
|
||||
return /*#__PURE__*/React.createElement(ConcentricCircle, _extends({
|
||||
key: key
|
||||
}, props, {
|
||||
fill: "none",
|
||||
radius: entry
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(ConcentricPolygon, _extends({
|
||||
key: key
|
||||
}, props, {
|
||||
fill: "none",
|
||||
radius: entry
|
||||
}));
|
||||
}));
|
||||
};
|
||||
export var defaultPolarGridProps = {
|
||||
angleAxisId: 0,
|
||||
radiusAxisId: 0,
|
||||
gridType: 'polygon',
|
||||
radialLines: true,
|
||||
zIndex: DefaultZIndexes.grid,
|
||||
stroke: '#ccc',
|
||||
strokeWidth: 1,
|
||||
fill: 'none'
|
||||
};
|
||||
|
||||
/**
|
||||
* @consumes PolarViewBoxContext
|
||||
*/
|
||||
export var PolarGrid = outsideProps => {
|
||||
var _ref, _polarViewBox$cx, _ref2, _polarViewBox$cy, _ref3, _polarViewBox$innerRa, _ref4, _polarViewBox$outerRa;
|
||||
var _resolveDefaultProps = resolveDefaultProps(outsideProps, defaultPolarGridProps),
|
||||
gridType = _resolveDefaultProps.gridType,
|
||||
radialLines = _resolveDefaultProps.radialLines,
|
||||
angleAxisId = _resolveDefaultProps.angleAxisId,
|
||||
radiusAxisId = _resolveDefaultProps.radiusAxisId,
|
||||
cxFromOutside = _resolveDefaultProps.cx,
|
||||
cyFromOutside = _resolveDefaultProps.cy,
|
||||
innerRadiusFromOutside = _resolveDefaultProps.innerRadius,
|
||||
outerRadiusFromOutside = _resolveDefaultProps.outerRadius,
|
||||
polarAnglesInput = _resolveDefaultProps.polarAngles,
|
||||
polarRadiusInput = _resolveDefaultProps.polarRadius,
|
||||
zIndex = _resolveDefaultProps.zIndex,
|
||||
inputs = _objectWithoutProperties(_resolveDefaultProps, _excluded);
|
||||
var polarViewBox = useAppSelector(selectPolarViewBox);
|
||||
var polarAnglesFromRedux = useAppSelector(state => selectPolarGridAngles(state, angleAxisId));
|
||||
var polarRadiiFromRedux = useAppSelector(state => selectPolarGridRadii(state, radiusAxisId));
|
||||
var polarAngles = Array.isArray(polarAnglesInput) ? polarAnglesInput : polarAnglesFromRedux;
|
||||
var polarRadius = Array.isArray(polarRadiusInput) ? polarRadiusInput : polarRadiiFromRedux;
|
||||
if (polarAngles == null || polarRadius == null) {
|
||||
return null;
|
||||
}
|
||||
var props = _objectSpread({
|
||||
cx: (_ref = (_polarViewBox$cx = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.cx) !== null && _polarViewBox$cx !== void 0 ? _polarViewBox$cx : cxFromOutside) !== null && _ref !== void 0 ? _ref : 0,
|
||||
cy: (_ref2 = (_polarViewBox$cy = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.cy) !== null && _polarViewBox$cy !== void 0 ? _polarViewBox$cy : cyFromOutside) !== null && _ref2 !== void 0 ? _ref2 : 0,
|
||||
innerRadius: (_ref3 = (_polarViewBox$innerRa = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.innerRadius) !== null && _polarViewBox$innerRa !== void 0 ? _polarViewBox$innerRa : innerRadiusFromOutside) !== null && _ref3 !== void 0 ? _ref3 : 0,
|
||||
outerRadius: (_ref4 = (_polarViewBox$outerRa = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.outerRadius) !== null && _polarViewBox$outerRa !== void 0 ? _polarViewBox$outerRa : outerRadiusFromOutside) !== null && _ref4 !== void 0 ? _ref4 : 0,
|
||||
polarAngles,
|
||||
polarRadius,
|
||||
zIndex
|
||||
}, inputs);
|
||||
var outerRadius = props.outerRadius;
|
||||
if (outerRadius <= 0) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: props.zIndex
|
||||
}, /*#__PURE__*/React.createElement("g", {
|
||||
className: "recharts-polar-grid"
|
||||
}, /*#__PURE__*/React.createElement(ConcentricGridPath, _extends({
|
||||
gridType: gridType,
|
||||
radialLines: radialLines
|
||||
}, props, {
|
||||
polarAngles: polarAngles,
|
||||
polarRadius: polarRadius
|
||||
})), /*#__PURE__*/React.createElement(PolarAngles, _extends({
|
||||
gridType: gridType,
|
||||
radialLines: radialLines
|
||||
}, props, {
|
||||
polarAngles: polarAngles,
|
||||
polarRadius: polarRadius
|
||||
}))));
|
||||
};
|
||||
PolarGrid.displayName = 'PolarGrid';
|
||||
216
frontend/node_modules/recharts/es6/polar/PolarRadiusAxis.js
generated
vendored
Normal file
216
frontend/node_modules/recharts/es6/polar/PolarRadiusAxis.js
generated
vendored
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
var _excluded = ["type"],
|
||||
_excluded2 = ["cx", "cy", "angle", "axisLine"],
|
||||
_excluded3 = ["angle", "tickFormatter", "stroke", "tick"];
|
||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, 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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
||||
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
||||
import * as React from 'react';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import maxBy from 'es-toolkit/compat/maxBy';
|
||||
import minBy from 'es-toolkit/compat/minBy';
|
||||
import { clsx } from 'clsx';
|
||||
import { Text } from '../component/Text';
|
||||
import { PolarLabelContextProvider, PolarLabelFromLabelProp } from '../component/Label';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { addRadiusAxis, removeRadiusAxis } from '../state/polarAxisSlice';
|
||||
import { useAppDispatch, useAppSelector } from '../state/hooks';
|
||||
import { selectPolarAxisScale, selectPolarAxisTicks } from '../state/selectors/polarScaleSelectors';
|
||||
import { selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
|
||||
import { defaultPolarRadiusAxisProps } from './defaultPolarRadiusAxisProps';
|
||||
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
|
||||
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
||||
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
||||
import { usePolarChartLayout } from '../context/chartLayoutContext';
|
||||
import { noop } from '../util/DataUtils';
|
||||
import { getAxisTypeBasedOnLayout } from '../util/getAxisTypeBasedOnLayout';
|
||||
import { getClassNameFromUnknown } from '../util/getClassNameFromUnknown';
|
||||
var AXIS_TYPE = 'radiusAxis';
|
||||
function SetRadiusAxisSettings(props) {
|
||||
var dispatch = useAppDispatch();
|
||||
var layout = usePolarChartLayout();
|
||||
var settings = useMemo(() => {
|
||||
var typeFromProps = props.type,
|
||||
rest = _objectWithoutProperties(props, _excluded);
|
||||
var evaluatedType = getAxisTypeBasedOnLayout(layout, 'radiusAxis', typeFromProps);
|
||||
if (evaluatedType == null) {
|
||||
return undefined;
|
||||
}
|
||||
return _objectSpread(_objectSpread({}, rest), {}, {
|
||||
type: evaluatedType
|
||||
});
|
||||
}, [props, layout]);
|
||||
useEffect(() => {
|
||||
if (settings == null) {
|
||||
return noop;
|
||||
}
|
||||
dispatch(addRadiusAxis(settings));
|
||||
return () => {
|
||||
dispatch(removeRadiusAxis(settings));
|
||||
};
|
||||
}, [dispatch, settings]);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the coordinate of tick
|
||||
* @param coordinate The radius of tick
|
||||
* @param angle from props
|
||||
* @param cx from chart
|
||||
* @param cy from chart
|
||||
* @return (x, y)
|
||||
*/
|
||||
var getTickValueCoord = (_ref, angle, cx, cy) => {
|
||||
var coordinate = _ref.coordinate;
|
||||
return polarToCartesian(cx, cy, coordinate, angle);
|
||||
};
|
||||
var getTickTextAnchor = orientation => {
|
||||
var textAnchor;
|
||||
switch (orientation) {
|
||||
case 'left':
|
||||
textAnchor = 'end';
|
||||
break;
|
||||
case 'right':
|
||||
textAnchor = 'start';
|
||||
break;
|
||||
default:
|
||||
textAnchor = 'middle';
|
||||
break;
|
||||
}
|
||||
return textAnchor;
|
||||
};
|
||||
var getViewBox = (angle, cx, cy, ticks) => {
|
||||
var maxRadiusTick = maxBy(ticks, entry => entry.coordinate || 0);
|
||||
var minRadiusTick = minBy(ticks, entry => entry.coordinate || 0);
|
||||
return {
|
||||
cx,
|
||||
cy,
|
||||
startAngle: angle,
|
||||
endAngle: angle,
|
||||
innerRadius: (minRadiusTick === null || minRadiusTick === void 0 ? void 0 : minRadiusTick.coordinate) || 0,
|
||||
outerRadius: (maxRadiusTick === null || maxRadiusTick === void 0 ? void 0 : maxRadiusTick.coordinate) || 0,
|
||||
clockWise: false
|
||||
};
|
||||
};
|
||||
var renderAxisLine = (props, ticks) => {
|
||||
var cx = props.cx,
|
||||
cy = props.cy,
|
||||
angle = props.angle,
|
||||
axisLine = props.axisLine,
|
||||
others = _objectWithoutProperties(props, _excluded2);
|
||||
var extent = ticks.reduce((result, entry) => [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 axisLineProps = _objectSpread(_objectSpread(_objectSpread({}, svgPropertiesNoEvents(others)), {}, {
|
||||
fill: 'none'
|
||||
}, svgPropertiesNoEvents(axisLine)), {}, {
|
||||
x1: point0.x,
|
||||
y1: point0.y,
|
||||
x2: point1.x,
|
||||
y2: point1.y
|
||||
});
|
||||
|
||||
// @ts-expect-error wrong SVG element type
|
||||
return /*#__PURE__*/React.createElement("line", _extends({
|
||||
className: "recharts-polar-radius-axis-line"
|
||||
}, axisLineProps));
|
||||
};
|
||||
var renderTickItem = (option, tickProps, value) => {
|
||||
var tickItem;
|
||||
if (/*#__PURE__*/React.isValidElement(option)) {
|
||||
tickItem = /*#__PURE__*/React.cloneElement(option, tickProps);
|
||||
} else if (typeof option === 'function') {
|
||||
tickItem = option(tickProps);
|
||||
} else {
|
||||
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, tickProps, {
|
||||
className: "recharts-polar-radius-axis-tick-value"
|
||||
}), value);
|
||||
}
|
||||
return tickItem;
|
||||
};
|
||||
var renderTicks = (props, ticks) => {
|
||||
var angle = props.angle,
|
||||
tickFormatter = props.tickFormatter,
|
||||
stroke = props.stroke,
|
||||
tick = props.tick,
|
||||
others = _objectWithoutProperties(props, _excluded3);
|
||||
var textAnchor = getTickTextAnchor(props.orientation);
|
||||
var axisProps = svgPropertiesNoEvents(others);
|
||||
var customTickProps = svgPropertiesNoEventsFromUnknown(tick);
|
||||
var items = ticks.map((entry, i) => {
|
||||
var coord = getTickValueCoord(entry, props.angle, props.cx, props.cy);
|
||||
var tickProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
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', getClassNameFromUnknown(tick)),
|
||||
key: "tick-".concat(entry.coordinate)
|
||||
}, adaptEventsOfChild(props, entry, i)), renderTickItem(tick, tickProps, tickFormatter ? tickFormatter(entry.value, i) : entry.value));
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-polar-radius-axis-ticks"
|
||||
}, items);
|
||||
};
|
||||
export var PolarRadiusAxisWrapper = defaultsAndInputs => {
|
||||
var radiusAxisId = defaultsAndInputs.radiusAxisId;
|
||||
var viewBox = useAppSelector(selectPolarViewBox);
|
||||
var scale = useAppSelector(state => selectPolarAxisScale(state, 'radiusAxis', radiusAxisId));
|
||||
var ticks = useAppSelector(state => selectPolarAxisTicks(state, 'radiusAxis', radiusAxisId, false));
|
||||
if (viewBox == null || !ticks || !ticks.length || scale == null) {
|
||||
return null;
|
||||
}
|
||||
var props = _objectSpread(_objectSpread({}, defaultsAndInputs), {}, {
|
||||
scale
|
||||
}, viewBox);
|
||||
var tick = props.tick,
|
||||
axisLine = props.axisLine;
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: props.zIndex
|
||||
}, /*#__PURE__*/React.createElement(Layer, {
|
||||
className: clsx('recharts-polar-radius-axis', AXIS_TYPE, props.className)
|
||||
}, axisLine && renderAxisLine(props, ticks), tick && renderTicks(props, ticks), /*#__PURE__*/React.createElement(PolarLabelContextProvider, getViewBox(props.angle, props.cx, props.cy, ticks), /*#__PURE__*/React.createElement(PolarLabelFromLabelProp, {
|
||||
label: props.label
|
||||
}), props.children)));
|
||||
};
|
||||
|
||||
/**
|
||||
* @provides PolarLabelContext
|
||||
* @consumes PolarViewBoxContext
|
||||
*/
|
||||
export function PolarRadiusAxis(outsideProps) {
|
||||
var _props$niceTicks;
|
||||
var props = resolveDefaultProps(outsideProps, defaultPolarRadiusAxisProps);
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetRadiusAxisSettings, {
|
||||
domain: props.domain,
|
||||
id: props.radiusAxisId,
|
||||
scale: props.scale,
|
||||
type: props.type,
|
||||
dataKey: props.dataKey,
|
||||
unit: undefined,
|
||||
name: props.name,
|
||||
allowDuplicatedCategory: props.allowDuplicatedCategory,
|
||||
allowDataOverflow: props.allowDataOverflow,
|
||||
reversed: props.reversed,
|
||||
includeHidden: props.includeHidden,
|
||||
allowDecimals: props.allowDecimals,
|
||||
niceTicks: (_props$niceTicks = props.niceTicks) !== null && _props$niceTicks !== void 0 ? _props$niceTicks : 'auto',
|
||||
ticks: props.ticks,
|
||||
tickCount: props.tickCount,
|
||||
tick: props.tick
|
||||
}), /*#__PURE__*/React.createElement(PolarRadiusAxisWrapper, props));
|
||||
}
|
||||
PolarRadiusAxis.displayName = 'PolarRadiusAxis';
|
||||
423
frontend/node_modules/recharts/es6/polar/Radar.js
generated
vendored
Normal file
423
frontend/node_modules/recharts/es6/polar/Radar.js
generated
vendored
Normal file
|
|
@ -0,0 +1,423 @@
|
|||
var _excluded = ["id"];
|
||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, 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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
||||
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
||||
import * as React from 'react';
|
||||
import { useRef } from 'react';
|
||||
import last from 'es-toolkit/compat/last';
|
||||
import { clsx } from 'clsx';
|
||||
import { interpolate, isNullish, noop } from '../util/DataUtils';
|
||||
import { polarToCartesian } from '../util/PolarUtils';
|
||||
import { getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
|
||||
import { Polygon } from '../shape/Polygon';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
|
||||
import { Dots } from '../component/Dots';
|
||||
import { ActivePoints } from '../component/ActivePoints';
|
||||
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
|
||||
import { selectRadarPoints } from '../state/selectors/radarSelectors';
|
||||
import { useAppSelector } from '../state/hooks';
|
||||
import { useIsPanorama } from '../context/PanoramaContext';
|
||||
import { SetPolarLegendPayload } from '../state/SetLegendPayload';
|
||||
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
|
||||
import { SetPolarGraphicalItem } from '../state/SetGraphicalItem';
|
||||
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
|
||||
import { AnimatedItems, useAnimationCallbacks } from '../animation/AnimatedItems';
|
||||
import { matchAnimationItems, matchByIndex } from '../animation/matchBy';
|
||||
import { useAnimationStartSnapshot } from '../animation/useAnimationStartSnapshot';
|
||||
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
|
||||
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
||||
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
||||
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
||||
import { usePolarChartLayout } from '../context/chartLayoutContext';
|
||||
function getLegendItemColor(stroke, fill) {
|
||||
return stroke && stroke !== 'none' ? stroke : fill;
|
||||
}
|
||||
var computeLegendPayloadFromRadarSectors = props => {
|
||||
var dataKey = props.dataKey,
|
||||
name = props.name,
|
||||
stroke = props.stroke,
|
||||
fill = props.fill,
|
||||
legendType = props.legendType,
|
||||
hide = props.hide;
|
||||
return [{
|
||||
inactive: hide,
|
||||
dataKey,
|
||||
type: legendType,
|
||||
color: getLegendItemColor(stroke, fill),
|
||||
value: getTooltipNameProp(name, dataKey),
|
||||
payload: props
|
||||
}];
|
||||
};
|
||||
var SetRadarTooltipEntrySettings = /*#__PURE__*/React.memo(_ref => {
|
||||
var dataKey = _ref.dataKey,
|
||||
stroke = _ref.stroke,
|
||||
strokeWidth = _ref.strokeWidth,
|
||||
fill = _ref.fill,
|
||||
name = _ref.name,
|
||||
hide = _ref.hide,
|
||||
tooltipType = _ref.tooltipType,
|
||||
id = _ref.id;
|
||||
var tooltipEntrySettings = {
|
||||
/*
|
||||
* I suppose this here _could_ return props.points
|
||||
* because while Radar does not support item tooltip mode, it _could_ support it.
|
||||
* But when I actually do return the points here, a defaultIndex test starts failing.
|
||||
* So, undefined it is.
|
||||
*/
|
||||
dataDefinedOnItem: undefined,
|
||||
getPosition: noop,
|
||||
settings: {
|
||||
stroke,
|
||||
strokeWidth,
|
||||
fill,
|
||||
nameKey: undefined,
|
||||
// RadarChart does not have nameKey unfortunately
|
||||
dataKey,
|
||||
name: getTooltipNameProp(name, dataKey),
|
||||
hide,
|
||||
type: tooltipType,
|
||||
color: getLegendItemColor(stroke, fill),
|
||||
unit: '',
|
||||
// why doesn't Radar support unit?
|
||||
graphicalItemId: id
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
|
||||
tooltipEntrySettings: tooltipEntrySettings
|
||||
});
|
||||
});
|
||||
function RadarDotsWrapper(_ref2) {
|
||||
var points = _ref2.points,
|
||||
props = _ref2.props;
|
||||
var dot = props.dot,
|
||||
dataKey = props.dataKey;
|
||||
var id = props.id,
|
||||
propsWithoutId = _objectWithoutProperties(props, _excluded);
|
||||
var baseProps = svgPropertiesNoEvents(propsWithoutId);
|
||||
return /*#__PURE__*/React.createElement(Dots, {
|
||||
points: points,
|
||||
dot: dot,
|
||||
className: "recharts-radar-dots",
|
||||
dotClassName: "recharts-radar-dot",
|
||||
dataKey: dataKey,
|
||||
baseProps: baseProps
|
||||
});
|
||||
}
|
||||
export function computeRadarPoints(_ref3) {
|
||||
var radiusAxis = _ref3.radiusAxis,
|
||||
angleAxis = _ref3.angleAxis,
|
||||
displayedData = _ref3.displayedData,
|
||||
dataKey = _ref3.dataKey,
|
||||
bandSize = _ref3.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((entry, i) => {
|
||||
var _angleAxis$scale$map, _radiusAxis$scale$map;
|
||||
var name = getValueByDataKey(entry, angleAxis.dataKey, i);
|
||||
var value = getValueByDataKey(entry, dataKey);
|
||||
var angle = ((_angleAxis$scale$map = angleAxis.scale.map(name)) !== null && _angleAxis$scale$map !== void 0 ? _angleAxis$scale$map : 0) + angleBandSize;
|
||||
var pointValue = Array.isArray(value) ? last(value) : value;
|
||||
var radius = isNullish(pointValue) ? 0 : (_radiusAxis$scale$map = radiusAxis.scale.map(pointValue)) !== null && _radiusAxis$scale$map !== void 0 ? _radiusAxis$scale$map : 0;
|
||||
if (Array.isArray(value) && value.length >= 2) {
|
||||
isRange = true;
|
||||
}
|
||||
points.push(_objectSpread(_objectSpread({}, polarToCartesian(cx, cy, radius, angle)), {}, {
|
||||
// getValueByDataKey does not validate the output type
|
||||
name,
|
||||
// getValueByDataKey does not validate the output type
|
||||
value,
|
||||
cx,
|
||||
cy,
|
||||
radius,
|
||||
angle,
|
||||
payload: entry
|
||||
}));
|
||||
});
|
||||
var baseLinePoints = [];
|
||||
if (isRange) {
|
||||
points.forEach(point => {
|
||||
if (Array.isArray(point.value)) {
|
||||
var _radiusAxis$scale$map2;
|
||||
var baseValue = point.value[0];
|
||||
var radius = isNullish(baseValue) ? 0 : (_radiusAxis$scale$map2 = radiusAxis.scale.map(baseValue)) !== null && _radiusAxis$scale$map2 !== void 0 ? _radiusAxis$scale$map2 : 0;
|
||||
baseLinePoints.push(_objectSpread(_objectSpread({}, point), {}, {
|
||||
radius
|
||||
}, polarToCartesian(cx, cy, radius, point.angle)));
|
||||
} else {
|
||||
baseLinePoints.push(point);
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
points,
|
||||
isRange,
|
||||
baseLinePoints
|
||||
};
|
||||
}
|
||||
function RadarLabelListProvider(_ref4) {
|
||||
var showLabels = _ref4.showLabels,
|
||||
points = _ref4.points,
|
||||
children = _ref4.children;
|
||||
/*
|
||||
* Radar provides a Cartesian label list context. Do we want to also provide a polar label list context?
|
||||
* That way, users can choose to use polar positions for the Radar labels.
|
||||
*/
|
||||
// const labelListEntries: ReadonlyArray<PolarLabelListEntry> = points.map(
|
||||
// (point): PolarLabelListEntry => ({
|
||||
// value: point.value,
|
||||
// payload: point.payload,
|
||||
// parentViewBox: undefined,
|
||||
// clockWise: false,
|
||||
// viewBox: {
|
||||
// cx: point.cx,
|
||||
// cy: point.cy,
|
||||
// innerRadius: point.radius,
|
||||
// outerRadius: point.radius,
|
||||
// startAngle: point.angle,
|
||||
// endAngle: point.angle,
|
||||
// clockWise: false,
|
||||
// },
|
||||
// }),
|
||||
// );
|
||||
|
||||
var labelListEntries = points.map(point => {
|
||||
var _point$value;
|
||||
var viewBox = {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
width: 0,
|
||||
lowerWidth: 0,
|
||||
upperWidth: 0,
|
||||
height: 0
|
||||
};
|
||||
return _objectSpread(_objectSpread({}, viewBox), {}, {
|
||||
value: (_point$value = point.value) !== null && _point$value !== void 0 ? _point$value : '',
|
||||
payload: point.payload,
|
||||
parentViewBox: undefined,
|
||||
viewBox,
|
||||
fill: undefined
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
|
||||
value: showLabels ? labelListEntries : undefined
|
||||
}, children);
|
||||
}
|
||||
function StaticPolygon(_ref5) {
|
||||
var points = _ref5.points,
|
||||
baseLinePoints = _ref5.baseLinePoints,
|
||||
props = _ref5.props;
|
||||
if (points == null) {
|
||||
return null;
|
||||
}
|
||||
var shape = props.shape,
|
||||
isRange = props.isRange,
|
||||
connectNulls = props.connectNulls;
|
||||
var handleMouseEnter = e => {
|
||||
var onMouseEnter = props.onMouseEnter;
|
||||
if (onMouseEnter) {
|
||||
onMouseEnter(props, e);
|
||||
}
|
||||
};
|
||||
var handleMouseLeave = e => {
|
||||
var onMouseLeave = props.onMouseLeave;
|
||||
if (onMouseLeave) {
|
||||
onMouseLeave(props, e);
|
||||
}
|
||||
};
|
||||
var radar;
|
||||
if (/*#__PURE__*/React.isValidElement(shape)) {
|
||||
radar = /*#__PURE__*/React.cloneElement(shape, _objectSpread(_objectSpread({}, props), {}, {
|
||||
points
|
||||
}));
|
||||
} else if (typeof shape === 'function') {
|
||||
radar = shape(_objectSpread(_objectSpread({}, props), {}, {
|
||||
points
|
||||
}));
|
||||
} else {
|
||||
radar = /*#__PURE__*/React.createElement(Polygon, _extends({}, svgPropertiesAndEvents(props), {
|
||||
onMouseEnter: handleMouseEnter,
|
||||
onMouseLeave: handleMouseLeave,
|
||||
points: points,
|
||||
baseLinePoints: isRange ? baseLinePoints : undefined,
|
||||
connectNulls: connectNulls
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radar-polygon"
|
||||
}, radar, /*#__PURE__*/React.createElement(RadarDotsWrapper, {
|
||||
props: props,
|
||||
points: points
|
||||
}));
|
||||
}
|
||||
var defaultRadarAnimateItems = (items, animationElapsedTime) => {
|
||||
if (items == null) return [];
|
||||
if (animationElapsedTime === 1) {
|
||||
return items.flatMap(item => item.status === 'removed' ? [] : [item.next]);
|
||||
}
|
||||
return items.flatMap(item => {
|
||||
if (item.status === 'removed') return [];
|
||||
if (item.status === 'matched') {
|
||||
return [_objectSpread(_objectSpread({}, item.next), {}, {
|
||||
x: interpolate(item.prev.x, item.next.x, animationElapsedTime),
|
||||
y: interpolate(item.prev.y, item.next.y, animationElapsedTime)
|
||||
})];
|
||||
}
|
||||
// added: animate from center
|
||||
return [_objectSpread(_objectSpread({}, item.next), {}, {
|
||||
x: interpolate(item.next.cx, item.next.x, animationElapsedTime),
|
||||
y: interpolate(item.next.cy, item.next.y, animationElapsedTime)
|
||||
})];
|
||||
});
|
||||
};
|
||||
function PolygonWithAnimation(_ref6) {
|
||||
var props = _ref6.props,
|
||||
previousPointsRef = _ref6.previousPointsRef,
|
||||
previousBaseLinePointsRef = _ref6.previousBaseLinePointsRef;
|
||||
var points = props.points,
|
||||
baseLinePoints = props.baseLinePoints,
|
||||
isAnimationActive = props.isAnimationActive,
|
||||
animationBegin = props.animationBegin,
|
||||
animationDuration = props.animationDuration,
|
||||
animationEasing = props.animationEasing,
|
||||
animationMatchBy = props.animationMatchBy,
|
||||
animationInterpolateFn = props.animationInterpolateFn,
|
||||
onAnimationStart = props.onAnimationStart,
|
||||
onAnimationEnd = props.onAnimationEnd;
|
||||
var baseLineAnimationState = useAnimationStartSnapshot(props, previousBaseLinePointsRef);
|
||||
var prevBaseLinePoints = baseLineAnimationState.startValue;
|
||||
var baseLineAnimationItems = matchAnimationItems(prevBaseLinePoints !== null && prevBaseLinePoints !== void 0 ? prevBaseLinePoints : null, baseLinePoints, animationMatchBy);
|
||||
var _useAnimationCallback = useAnimationCallbacks(onAnimationStart, onAnimationEnd),
|
||||
isAnimating = _useAnimationCallback.isAnimating,
|
||||
handleAnimationStart = _useAnimationCallback.handleAnimationStart,
|
||||
handleAnimationEnd = _useAnimationCallback.handleAnimationEnd;
|
||||
var layout = usePolarChartLayout();
|
||||
if (layout == null) return null;
|
||||
return /*#__PURE__*/React.createElement(RadarLabelListProvider, {
|
||||
showLabels: !isAnimating,
|
||||
points: points
|
||||
}, /*#__PURE__*/React.createElement(AnimatedItems, {
|
||||
animationInput: props,
|
||||
animationIdPrefix: "recharts-radar-",
|
||||
items: points,
|
||||
previousItemsRef: previousPointsRef,
|
||||
isAnimationActive: isAnimationActive,
|
||||
animationBegin: animationBegin,
|
||||
animationDuration: animationDuration,
|
||||
animationEasing: animationEasing,
|
||||
onAnimationStart: handleAnimationStart,
|
||||
onAnimationEnd: handleAnimationEnd,
|
||||
animationInterpolateFn: animationInterpolateFn,
|
||||
animationMatchBy: animationMatchBy,
|
||||
layout: layout
|
||||
}, (stepData, animationElapsedTime) => {
|
||||
var stepBaseLinePoints = animationElapsedTime === 1 ? baseLinePoints : animationInterpolateFn(baseLineAnimationItems, animationElapsedTime, layout);
|
||||
baseLineAnimationState.syncStepValue(stepBaseLinePoints, animationElapsedTime);
|
||||
return /*#__PURE__*/React.createElement(StaticPolygon, {
|
||||
points: stepData,
|
||||
baseLinePoints: stepBaseLinePoints,
|
||||
props: props
|
||||
});
|
||||
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
|
||||
label: props.label
|
||||
}), props.children);
|
||||
}
|
||||
function RenderPolygon(props) {
|
||||
var previousPointsRef = useRef(undefined);
|
||||
var previousBaseLinePointsRef = useRef(undefined);
|
||||
return /*#__PURE__*/React.createElement(PolygonWithAnimation, {
|
||||
props: props,
|
||||
previousPointsRef: previousPointsRef,
|
||||
previousBaseLinePointsRef: previousBaseLinePointsRef
|
||||
});
|
||||
}
|
||||
export var defaultRadarProps = {
|
||||
activeDot: true,
|
||||
angleAxisId: 0,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
animationMatchBy: matchByIndex,
|
||||
animationInterpolateFn: defaultRadarAnimateItems,
|
||||
dot: false,
|
||||
hide: false,
|
||||
isAnimationActive: 'auto',
|
||||
label: false,
|
||||
legendType: 'rect',
|
||||
radiusAxisId: 0,
|
||||
zIndex: DefaultZIndexes.area
|
||||
};
|
||||
function RadarWithState(props) {
|
||||
var hide = props.hide,
|
||||
className = props.className,
|
||||
points = props.points;
|
||||
if (hide) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-radar', className);
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: props.zIndex
|
||||
}, /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, /*#__PURE__*/React.createElement(RenderPolygon, props)), /*#__PURE__*/React.createElement(ActivePoints, {
|
||||
points: points,
|
||||
mainColor: getLegendItemColor(props.stroke, props.fill),
|
||||
itemDataKey: props.dataKey,
|
||||
activeDot: props.activeDot
|
||||
}));
|
||||
}
|
||||
function RadarImpl(props) {
|
||||
var isPanorama = useIsPanorama();
|
||||
var radarPoints = useAppSelector(state => selectRadarPoints(state, props.radiusAxisId, props.angleAxisId, isPanorama, props.id));
|
||||
if ((radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.points) == null) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(RadarWithState, _extends({}, props, {
|
||||
points: radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.points,
|
||||
baseLinePoints: radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.baseLinePoints,
|
||||
isRange: radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.isRange
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @consumes PolarChartContext
|
||||
* @provides LabelListContext
|
||||
*/
|
||||
export function Radar(outsideProps) {
|
||||
var props = resolveDefaultProps(outsideProps, defaultRadarProps);
|
||||
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
|
||||
id: props.id,
|
||||
type: "radar"
|
||||
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetPolarGraphicalItem, {
|
||||
type: "radar",
|
||||
id: id,
|
||||
data: undefined // Radar does not have data prop, why?
|
||||
,
|
||||
dataKey: props.dataKey,
|
||||
hide: props.hide,
|
||||
angleAxisId: props.angleAxisId,
|
||||
radiusAxisId: props.radiusAxisId
|
||||
}), /*#__PURE__*/React.createElement(SetPolarLegendPayload, {
|
||||
legendPayload: computeLegendPayloadFromRadarSectors(props)
|
||||
}), /*#__PURE__*/React.createElement(SetRadarTooltipEntrySettings, {
|
||||
dataKey: props.dataKey,
|
||||
stroke: props.stroke,
|
||||
strokeWidth: props.strokeWidth,
|
||||
fill: props.fill,
|
||||
name: props.name,
|
||||
hide: props.hide,
|
||||
tooltipType: props.tooltipType,
|
||||
id: id
|
||||
}), /*#__PURE__*/React.createElement(RadarImpl, _extends({}, props, {
|
||||
id: id
|
||||
}))));
|
||||
}
|
||||
Radar.displayName = 'Radar';
|
||||
464
frontend/node_modules/recharts/es6/polar/RadialBar.js
generated
vendored
Normal file
464
frontend/node_modules/recharts/es6/polar/RadialBar.js
generated
vendored
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
var _excluded = ["shape", "activeShape", "cornerRadius", "id"],
|
||||
_excluded2 = ["onMouseEnter", "onClick", "onMouseLeave"],
|
||||
_excluded3 = ["value", "background"];
|
||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, 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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
||||
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
||||
import * as React from 'react';
|
||||
import { PureComponent, useRef } from 'react';
|
||||
import { clsx } from 'clsx';
|
||||
import { defaultRadialBarShape, parseCornerRadius, RadialBarSector } from '../util/RadialBarUtils';
|
||||
import { Layer } from '../container/Layer';
|
||||
import { findAllByType } from '../util/ReactUtils';
|
||||
import { LabelListFromLabelProp, PolarLabelListContextProvider } from '../component/LabelList';
|
||||
import { Cell } from '../component/Cell';
|
||||
import { interpolate, mathSign, noop } from '../util/DataUtils';
|
||||
import { getCateCoordinateOfBar, getNormalizedStackId, getTooltipNameProp, getValueByDataKey, truncateByDomain } from '../util/ChartUtils';
|
||||
import { adaptEventsOfChild } from '../util/types';
|
||||
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
|
||||
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
|
||||
import { selectRadialBarLegendPayload, selectRadialBarSectors } from '../state/selectors/radialBarSelectors';
|
||||
import { useAppSelector } from '../state/hooks';
|
||||
import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
|
||||
import { SetPolarLegendPayload } from '../state/SetLegendPayload';
|
||||
import { AnimatedItems, useAnimationCallbacks } from '../animation/AnimatedItems';
|
||||
import { matchAppend } from '../animation/matchBy';
|
||||
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
|
||||
import { SetPolarGraphicalItem } from '../state/SetGraphicalItem';
|
||||
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
|
||||
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
||||
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
||||
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
||||
import { getZIndexFromUnknown } from '../zIndex/getZIndexFromUnknown';
|
||||
import { usePolarChartLayout } from '../context/chartLayoutContext';
|
||||
var STABLE_EMPTY_ARRAY = [];
|
||||
function RadialBarLabelListProvider(_ref) {
|
||||
var showLabels = _ref.showLabels,
|
||||
sectors = _ref.sectors,
|
||||
children = _ref.children;
|
||||
var labelListEntries = sectors.map(sector => ({
|
||||
value: sector.value,
|
||||
payload: sector.payload,
|
||||
parentViewBox: undefined,
|
||||
clockWise: false,
|
||||
viewBox: {
|
||||
cx: sector.cx,
|
||||
cy: sector.cy,
|
||||
innerRadius: sector.innerRadius,
|
||||
outerRadius: sector.outerRadius,
|
||||
startAngle: sector.startAngle,
|
||||
endAngle: sector.endAngle,
|
||||
clockWise: false
|
||||
},
|
||||
fill: sector.fill
|
||||
}));
|
||||
return /*#__PURE__*/React.createElement(PolarLabelListContextProvider, {
|
||||
value: showLabels ? labelListEntries : undefined
|
||||
}, children);
|
||||
}
|
||||
function RadialBarSectors(_ref2) {
|
||||
var sectors = _ref2.sectors,
|
||||
allOtherRadialBarProps = _ref2.allOtherRadialBarProps,
|
||||
showLabels = _ref2.showLabels,
|
||||
animationElapsedTime = _ref2.animationElapsedTime,
|
||||
isAnimating = _ref2.isAnimating,
|
||||
isEntrance = _ref2.isEntrance;
|
||||
var shape = allOtherRadialBarProps.shape,
|
||||
activeShape = allOtherRadialBarProps.activeShape,
|
||||
cornerRadius = allOtherRadialBarProps.cornerRadius,
|
||||
id = allOtherRadialBarProps.id,
|
||||
others = _objectWithoutProperties(allOtherRadialBarProps, _excluded);
|
||||
var baseProps = svgPropertiesNoEvents(others);
|
||||
var activeIndex = useAppSelector(selectActiveTooltipIndex);
|
||||
var onMouseEnterFromProps = allOtherRadialBarProps.onMouseEnter,
|
||||
onItemClickFromProps = allOtherRadialBarProps.onClick,
|
||||
onMouseLeaveFromProps = allOtherRadialBarProps.onMouseLeave,
|
||||
restOfAllOtherProps = _objectWithoutProperties(allOtherRadialBarProps, _excluded2);
|
||||
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherRadialBarProps.dataKey, id);
|
||||
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
|
||||
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherRadialBarProps.dataKey, id);
|
||||
if (sectors == null) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(RadialBarLabelListProvider, {
|
||||
showLabels: showLabels,
|
||||
sectors: sectors
|
||||
}, sectors.map((entry, i) => {
|
||||
var isActive = Boolean(activeShape && activeIndex === String(i));
|
||||
var onMouseEnter = onMouseEnterFromContext(entry, i);
|
||||
var onMouseLeave = onMouseLeaveFromContext(entry, i);
|
||||
var onClick = onClickFromContext(entry, i);
|
||||
var radialBarSectorProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseProps), {}, {
|
||||
cornerRadius: parseCornerRadius(cornerRadius)
|
||||
}, entry), adaptEventsOfChild(restOfAllOtherProps, entry, i)), {}, {
|
||||
onMouseEnter,
|
||||
onMouseLeave,
|
||||
onClick,
|
||||
className: "recharts-radial-bar-sector ".concat(entry.className),
|
||||
forceCornerRadius: others.forceCornerRadius,
|
||||
cornerIsExternal: others.cornerIsExternal,
|
||||
animationElapsedTime,
|
||||
isAnimating,
|
||||
isEntrance,
|
||||
isActive,
|
||||
option: isActive && activeShape != null ? activeShape : shape,
|
||||
index: i
|
||||
});
|
||||
if (isActive) {
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: DefaultZIndexes.activeBar,
|
||||
key: "sector-".concat(entry.cx, "-").concat(entry.cy, "-").concat(entry.innerRadius, "-").concat(entry.outerRadius, "-").concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(i)
|
||||
}, /*#__PURE__*/React.createElement(RadialBarSector, radialBarSectorProps));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(RadialBarSector, _extends({
|
||||
key: "sector-".concat(entry.cx, "-").concat(entry.cy, "-").concat(entry.innerRadius, "-").concat(entry.outerRadius, "-").concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(i)
|
||||
}, radialBarSectorProps));
|
||||
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
|
||||
label: allOtherRadialBarProps.label
|
||||
}), allOtherRadialBarProps.children);
|
||||
}
|
||||
var defaultRadialBarAnimateItems = (items, animationElapsedTime) => {
|
||||
if (items == null) return [];
|
||||
if (animationElapsedTime === 1) {
|
||||
return items.flatMap(item => item.status === 'removed' ? [] : [item.next]);
|
||||
}
|
||||
return items.flatMap(item => {
|
||||
if (item.status === 'removed') return [];
|
||||
if (item.status === 'matched') {
|
||||
return [_objectSpread(_objectSpread({}, item.next), {}, {
|
||||
startAngle: interpolate(item.prev.startAngle, item.next.startAngle, animationElapsedTime),
|
||||
endAngle: interpolate(item.prev.endAngle, item.next.endAngle, animationElapsedTime)
|
||||
})];
|
||||
}
|
||||
// added
|
||||
return [_objectSpread(_objectSpread({}, item.next), {}, {
|
||||
endAngle: interpolate(item.next.startAngle, item.next.endAngle, animationElapsedTime)
|
||||
})];
|
||||
});
|
||||
};
|
||||
function SectorsWithAnimation(_ref3) {
|
||||
var props = _ref3.props,
|
||||
previousSectorsRef = _ref3.previousSectorsRef;
|
||||
var sectors = props.sectors,
|
||||
isAnimationActive = props.isAnimationActive,
|
||||
animationBegin = props.animationBegin,
|
||||
animationDuration = props.animationDuration,
|
||||
animationEasing = props.animationEasing,
|
||||
onAnimationStart = props.onAnimationStart,
|
||||
onAnimationEnd = props.onAnimationEnd;
|
||||
var _useAnimationCallback = useAnimationCallbacks(onAnimationStart, onAnimationEnd),
|
||||
isAnimating = _useAnimationCallback.isAnimating,
|
||||
handleAnimationStart = _useAnimationCallback.handleAnimationStart,
|
||||
handleAnimationEnd = _useAnimationCallback.handleAnimationEnd;
|
||||
var layout = usePolarChartLayout();
|
||||
if (layout == null) return null;
|
||||
return /*#__PURE__*/React.createElement(AnimatedItems, {
|
||||
animationInput: props,
|
||||
animationIdPrefix: "recharts-radialbar-",
|
||||
items: sectors,
|
||||
previousItemsRef: previousSectorsRef,
|
||||
isAnimationActive: isAnimationActive,
|
||||
animationBegin: animationBegin,
|
||||
animationDuration: animationDuration,
|
||||
animationEasing: animationEasing,
|
||||
onAnimationStart: handleAnimationStart,
|
||||
onAnimationEnd: handleAnimationEnd,
|
||||
animationInterpolateFn: props.animationInterpolateFn,
|
||||
animationMatchBy: props.animationMatchBy,
|
||||
layout: layout
|
||||
}, (stepData, animationElapsedTime, isEntrance) => /*#__PURE__*/React.createElement(RadialBarSectors, {
|
||||
sectors: stepData,
|
||||
allOtherRadialBarProps: props,
|
||||
showLabels: !isAnimating,
|
||||
animationElapsedTime: animationElapsedTime,
|
||||
isAnimating: isAnimating || animationElapsedTime < 1,
|
||||
isEntrance: isEntrance
|
||||
}));
|
||||
}
|
||||
function RenderSectors(props) {
|
||||
var previousSectorsRef = useRef(null);
|
||||
return /*#__PURE__*/React.createElement(SectorsWithAnimation, {
|
||||
props: props,
|
||||
previousSectorsRef: previousSectorsRef
|
||||
});
|
||||
}
|
||||
function SetRadialBarPayloadLegend(props) {
|
||||
var legendPayload = useAppSelector(state => selectRadialBarLegendPayload(state, props.legendType));
|
||||
return /*#__PURE__*/React.createElement(SetPolarLegendPayload, {
|
||||
legendPayload: legendPayload !== null && legendPayload !== void 0 ? legendPayload : []
|
||||
});
|
||||
}
|
||||
var SetRadialBarTooltipEntrySettings = /*#__PURE__*/React.memo(_ref4 => {
|
||||
var dataKey = _ref4.dataKey,
|
||||
sectors = _ref4.sectors,
|
||||
stroke = _ref4.stroke,
|
||||
strokeWidth = _ref4.strokeWidth,
|
||||
name = _ref4.name,
|
||||
hide = _ref4.hide,
|
||||
fill = _ref4.fill,
|
||||
tooltipType = _ref4.tooltipType,
|
||||
formatter = _ref4.formatter,
|
||||
id = _ref4.id;
|
||||
var tooltipEntrySettings = {
|
||||
dataDefinedOnItem: sectors,
|
||||
getPosition: noop,
|
||||
settings: {
|
||||
graphicalItemId: id,
|
||||
stroke,
|
||||
strokeWidth,
|
||||
fill,
|
||||
nameKey: undefined,
|
||||
// RadialBar does not have nameKey, why?
|
||||
dataKey,
|
||||
name: getTooltipNameProp(name, dataKey),
|
||||
hide,
|
||||
type: tooltipType,
|
||||
color: fill,
|
||||
unit: '',
|
||||
// Why does RadialBar not support unit?
|
||||
formatter
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
|
||||
tooltipEntrySettings: tooltipEntrySettings
|
||||
});
|
||||
});
|
||||
class RadialBarWithState extends PureComponent {
|
||||
renderBackground(sectors) {
|
||||
if (sectors == null) {
|
||||
return null;
|
||||
}
|
||||
var cornerRadius = this.props.cornerRadius;
|
||||
var backgroundProps = svgPropertiesNoEventsFromUnknown(this.props.background);
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: getZIndexFromUnknown(this.props.background, DefaultZIndexes.barBackground)
|
||||
}, sectors.map((entry, i) => {
|
||||
var value = entry.value,
|
||||
background = entry.background,
|
||||
rest = _objectWithoutProperties(entry, _excluded3);
|
||||
if (!background) {
|
||||
return null;
|
||||
}
|
||||
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
cornerRadius: parseCornerRadius(cornerRadius)
|
||||
}, rest), {}, {
|
||||
// @ts-expect-error backgroundProps is contributing unknown props
|
||||
fill: '#eee'
|
||||
}, background), backgroundProps), adaptEventsOfChild(this.props, entry, i)), {}, {
|
||||
index: i,
|
||||
className: clsx('recharts-radial-bar-background-sector', String(backgroundProps === null || backgroundProps === void 0 ? void 0 : backgroundProps.className)),
|
||||
option: background,
|
||||
isActive: false
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(RadialBarSector, _extends({
|
||||
key: "background-".concat(rest.cx, "-").concat(rest.cy, "-").concat(rest.innerRadius, "-").concat(rest.outerRadius, "-").concat(rest.startAngle, "-").concat(rest.endAngle, "-").concat(i)
|
||||
}, props));
|
||||
}));
|
||||
}
|
||||
render() {
|
||||
var _this$props = this.props,
|
||||
hide = _this$props.hide,
|
||||
sectors = _this$props.sectors,
|
||||
className = _this$props.className,
|
||||
background = _this$props.background;
|
||||
if (hide) {
|
||||
return null;
|
||||
}
|
||||
var layerClass = clsx('recharts-area', className);
|
||||
return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
||||
zIndex: this.props.zIndex
|
||||
}, /*#__PURE__*/React.createElement(Layer, {
|
||||
className: layerClass
|
||||
}, background && /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radial-bar-background"
|
||||
}, this.renderBackground(sectors)), /*#__PURE__*/React.createElement(Layer, {
|
||||
className: "recharts-radial-bar-sectors"
|
||||
}, /*#__PURE__*/React.createElement(RenderSectors, this.props))));
|
||||
}
|
||||
}
|
||||
function RadialBarImpl(props) {
|
||||
var _useAppSelector;
|
||||
var cells = React.useMemo(() => findAllByType(props.children, Cell), [props.children]);
|
||||
var radialBarSettings = React.useMemo(() => ({
|
||||
data: undefined,
|
||||
hide: false,
|
||||
id: props.id,
|
||||
dataKey: props.dataKey,
|
||||
minPointSize: props.minPointSize,
|
||||
stackId: getNormalizedStackId(props.stackId),
|
||||
maxBarSize: props.maxBarSize,
|
||||
barSize: props.barSize,
|
||||
type: 'radialBar',
|
||||
angleAxisId: props.angleAxisId,
|
||||
radiusAxisId: props.radiusAxisId
|
||||
}), [props.id, props.dataKey, props.minPointSize, props.stackId, props.maxBarSize, props.barSize, props.angleAxisId, props.radiusAxisId]);
|
||||
var sectors = (_useAppSelector = useAppSelector(state => selectRadialBarSectors(state, props.radiusAxisId, props.angleAxisId, radialBarSettings, cells))) !== null && _useAppSelector !== void 0 ? _useAppSelector : STABLE_EMPTY_ARRAY;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetRadialBarTooltipEntrySettings, {
|
||||
dataKey: props.dataKey,
|
||||
sectors: sectors,
|
||||
stroke: props.stroke,
|
||||
strokeWidth: props.strokeWidth,
|
||||
name: props.name,
|
||||
hide: props.hide,
|
||||
fill: props.fill,
|
||||
tooltipType: props.tooltipType,
|
||||
formatter: props.formatter,
|
||||
id: props.id
|
||||
}), /*#__PURE__*/React.createElement(RadialBarWithState, _extends({}, props, {
|
||||
sectors: sectors
|
||||
})));
|
||||
}
|
||||
export var defaultRadialBarProps = {
|
||||
angleAxisId: 0,
|
||||
animationBegin: 0,
|
||||
animationDuration: 1500,
|
||||
animationEasing: 'ease',
|
||||
animationMatchBy: matchAppend,
|
||||
animationInterpolateFn: defaultRadialBarAnimateItems,
|
||||
background: false,
|
||||
cornerIsExternal: false,
|
||||
cornerRadius: 0,
|
||||
forceCornerRadius: false,
|
||||
hide: false,
|
||||
isAnimationActive: 'auto',
|
||||
label: false,
|
||||
legendType: 'rect',
|
||||
minPointSize: 0,
|
||||
radiusAxisId: 0,
|
||||
shape: defaultRadialBarShape,
|
||||
zIndex: DefaultZIndexes.bar
|
||||
};
|
||||
export function computeRadialBarDataItems(_ref5) {
|
||||
var displayedData = _ref5.displayedData,
|
||||
stackedData = _ref5.stackedData,
|
||||
dataStartIndex = _ref5.dataStartIndex,
|
||||
stackedDomain = _ref5.stackedDomain,
|
||||
dataKey = _ref5.dataKey,
|
||||
baseValue = _ref5.baseValue,
|
||||
layout = _ref5.layout,
|
||||
radiusAxis = _ref5.radiusAxis,
|
||||
radiusAxisTicks = _ref5.radiusAxisTicks,
|
||||
bandSize = _ref5.bandSize,
|
||||
pos = _ref5.pos,
|
||||
angleAxis = _ref5.angleAxis,
|
||||
minPointSize = _ref5.minPointSize,
|
||||
cx = _ref5.cx,
|
||||
cy = _ref5.cy,
|
||||
angleAxisTicks = _ref5.angleAxisTicks,
|
||||
cells = _ref5.cells,
|
||||
rootStartAngle = _ref5.startAngle,
|
||||
rootEndAngle = _ref5.endAngle;
|
||||
if (angleAxisTicks == null || radiusAxisTicks == null) {
|
||||
return STABLE_EMPTY_ARRAY;
|
||||
}
|
||||
return (displayedData !== null && displayedData !== void 0 ? displayedData : []).map((entry, index) => {
|
||||
var value, innerRadius, outerRadius, startAngle, endAngle, backgroundSector;
|
||||
if (stackedData) {
|
||||
// @ts-expect-error truncateByDomain expects only numerical domain, but it can received categorical domain too
|
||||
value = truncateByDomain(stackedData[dataStartIndex + index], stackedDomain);
|
||||
} else {
|
||||
value = getValueByDataKey(entry, dataKey);
|
||||
if (!Array.isArray(value)) {
|
||||
value = [baseValue, value];
|
||||
}
|
||||
}
|
||||
if (layout === 'radial') {
|
||||
var _angleAxis$scale$map, _angleAxis$scale$map2;
|
||||
startAngle = (_angleAxis$scale$map = angleAxis.scale.map(value[0])) !== null && _angleAxis$scale$map !== void 0 ? _angleAxis$scale$map : rootStartAngle;
|
||||
endAngle = (_angleAxis$scale$map2 = angleAxis.scale.map(value[1])) !== null && _angleAxis$scale$map2 !== void 0 ? _angleAxis$scale$map2 : rootEndAngle;
|
||||
innerRadius = getCateCoordinateOfBar({
|
||||
axis: radiusAxis,
|
||||
ticks: radiusAxisTicks,
|
||||
bandSize,
|
||||
offset: pos.offset,
|
||||
entry,
|
||||
index
|
||||
});
|
||||
if (innerRadius != null && endAngle != null && startAngle != null) {
|
||||
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,
|
||||
cy,
|
||||
innerRadius,
|
||||
outerRadius,
|
||||
startAngle: rootStartAngle,
|
||||
endAngle: rootEndAngle
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
innerRadius = radiusAxis.scale.map(value[0]);
|
||||
outerRadius = radiusAxis.scale.map(value[1]);
|
||||
startAngle = getCateCoordinateOfBar({
|
||||
axis: angleAxis,
|
||||
ticks: angleAxisTicks,
|
||||
bandSize,
|
||||
offset: pos.offset,
|
||||
entry,
|
||||
index
|
||||
});
|
||||
if (innerRadius != null && outerRadius != null && startAngle != null) {
|
||||
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({}, entry), backgroundSector), {}, {
|
||||
payload: entry,
|
||||
value: stackedData ? value : value[1],
|
||||
cx,
|
||||
cy,
|
||||
innerRadius,
|
||||
outerRadius,
|
||||
startAngle,
|
||||
// @ts-expect-error endAngle is used before assigned (?)
|
||||
endAngle
|
||||
}, cells && cells[index] && cells[index].props);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @consumes PolarChartContext
|
||||
* @provides LabelListContext
|
||||
* @provides CellReader
|
||||
*/
|
||||
export function RadialBar(outsideProps) {
|
||||
var props = resolveDefaultProps(outsideProps, defaultRadialBarProps);
|
||||
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
|
||||
id: props.id,
|
||||
type: "radialBar"
|
||||
}, id => {
|
||||
var _props$hide, _props$angleAxisId, _props$radiusAxisId;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetPolarGraphicalItem, {
|
||||
type: "radialBar",
|
||||
id: id,
|
||||
data: undefined // why does RadialBar not allow data defined on the item?
|
||||
,
|
||||
dataKey: props.dataKey,
|
||||
hide: (_props$hide = props.hide) !== null && _props$hide !== void 0 ? _props$hide : defaultRadialBarProps.hide,
|
||||
angleAxisId: (_props$angleAxisId = props.angleAxisId) !== null && _props$angleAxisId !== void 0 ? _props$angleAxisId : defaultRadialBarProps.angleAxisId,
|
||||
radiusAxisId: (_props$radiusAxisId = props.radiusAxisId) !== null && _props$radiusAxisId !== void 0 ? _props$radiusAxisId : defaultRadialBarProps.radiusAxisId,
|
||||
stackId: getNormalizedStackId(props.stackId),
|
||||
barSize: props.barSize,
|
||||
minPointSize: props.minPointSize,
|
||||
maxBarSize: props.maxBarSize
|
||||
}), /*#__PURE__*/React.createElement(SetRadialBarPayloadLegend, props), /*#__PURE__*/React.createElement(RadialBarImpl, _extends({}, props, {
|
||||
id: id
|
||||
})));
|
||||
});
|
||||
}
|
||||
RadialBar.displayName = 'RadialBar';
|
||||
25
frontend/node_modules/recharts/es6/polar/defaultPolarAngleAxisProps.js
generated
vendored
Normal file
25
frontend/node_modules/recharts/es6/polar/defaultPolarAngleAxisProps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
||||
export var defaultPolarAngleAxisProps = {
|
||||
allowDecimals: false,
|
||||
allowDuplicatedCategory: true,
|
||||
// if I set this to false then Tooltip synchronisation stops working in Radar, wtf
|
||||
allowDataOverflow: false,
|
||||
angle: 0,
|
||||
angleAxisId: 0,
|
||||
axisLine: true,
|
||||
axisLineType: 'polygon',
|
||||
cx: 0,
|
||||
cy: 0,
|
||||
hide: false,
|
||||
includeHidden: false,
|
||||
label: false,
|
||||
niceTicks: 'auto',
|
||||
orientation: 'outer',
|
||||
reversed: false,
|
||||
scale: 'auto',
|
||||
tick: true,
|
||||
tickLine: true,
|
||||
tickSize: 8,
|
||||
type: 'auto',
|
||||
zIndex: DefaultZIndexes.axis
|
||||
};
|
||||
22
frontend/node_modules/recharts/es6/polar/defaultPolarRadiusAxisProps.js
generated
vendored
Normal file
22
frontend/node_modules/recharts/es6/polar/defaultPolarRadiusAxisProps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
||||
export var defaultPolarRadiusAxisProps = {
|
||||
allowDataOverflow: false,
|
||||
allowDecimals: false,
|
||||
allowDuplicatedCategory: true,
|
||||
angle: 0,
|
||||
axisLine: true,
|
||||
includeHidden: false,
|
||||
hide: false,
|
||||
niceTicks: 'auto',
|
||||
label: false,
|
||||
orientation: 'right',
|
||||
radiusAxisId: 0,
|
||||
reversed: false,
|
||||
scale: 'auto',
|
||||
stroke: '#ccc',
|
||||
tick: true,
|
||||
tickCount: 5,
|
||||
tickLine: true,
|
||||
type: 'auto',
|
||||
zIndex: DefaultZIndexes.axis
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue