@fluentui/react-charts 0.0.0-nightly-20260112-0407.1 → 0.0.0-nightly-20260114-0406.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -13
- package/dist/index.d.ts +360 -0
- package/lib/PolarChart.js +1 -0
- package/lib/PolarChart.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.js +21 -7
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +24 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +14 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +5 -3
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +33 -29
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +250 -153
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +14 -4
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +25 -5
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +16 -5
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +13 -4
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +26 -4
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +15 -3
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +6 -5
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +31 -19
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +23 -18
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/PolarChart/PolarChart.js +576 -0
- package/lib/components/PolarChart/PolarChart.js.map +1 -0
- package/lib/components/PolarChart/PolarChart.types.js +1 -0
- package/lib/components/PolarChart/PolarChart.types.js.map +1 -0
- package/lib/components/PolarChart/PolarChart.utils.js +174 -0
- package/lib/components/PolarChart/PolarChart.utils.js.map +1 -0
- package/lib/components/PolarChart/index.js +2 -0
- package/lib/components/PolarChart/index.js.map +1 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.js +72 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.js.map +1 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.raw.js +61 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.raw.js.map +1 -0
- package/lib/components/SankeyChart/SankeyChart.js +13 -3
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +23 -6
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +15 -5
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/ChartTitle.js +33 -0
- package/lib/utilities/ChartTitle.js.map +1 -0
- package/lib/utilities/Common.styles.js +73 -1
- package/lib/utilities/Common.styles.js.map +1 -1
- package/lib/utilities/Common.styles.raw.js +70 -0
- package/lib/utilities/Common.styles.raw.js.map +1 -1
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/index.js.map +1 -1
- package/lib/utilities/utilities.js +2 -2
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/PolarChart.js +6 -0
- package/lib-commonjs/PolarChart.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js +21 -7
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +34 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +4 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +59 -56
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +256 -156
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +13 -3
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +31 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +15 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +12 -3
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +36 -4
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +15 -3
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +5 -4
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +39 -18
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +23 -18
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/PolarChart/PolarChart.js +586 -0
- package/lib-commonjs/components/PolarChart/PolarChart.js.map +1 -0
- package/lib-commonjs/components/PolarChart/PolarChart.types.js +6 -0
- package/lib-commonjs/components/PolarChart/PolarChart.types.js.map +1 -0
- package/lib-commonjs/components/PolarChart/PolarChart.utils.js +204 -0
- package/lib-commonjs/components/PolarChart/PolarChart.utils.js.map +1 -0
- package/lib-commonjs/components/PolarChart/index.js +7 -0
- package/lib-commonjs/components/PolarChart/index.js.map +1 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.js +107 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.raw.js +75 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +13 -3
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +28 -4
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +14 -3
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/ChartTitle.js +41 -0
- package/lib-commonjs/utilities/ChartTitle.js.map +1 -0
- package/lib-commonjs/utilities/Common.styles.js +69 -0
- package/lib-commonjs/utilities/Common.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.raw.js +69 -0
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +6 -0
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "PolarChart", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return PolarChart;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
+
const _usePolarChartStylesstyles = require("./usePolarChartStyles.styles");
|
|
15
|
+
const _hooks = require("../../utilities/hooks");
|
|
16
|
+
const _d3shape = require("d3-shape");
|
|
17
|
+
const _reacttheme = require("@fluentui/react-theme");
|
|
18
|
+
const _index = require("../Legends/index");
|
|
19
|
+
const _PolarChartutils = require("./PolarChart.utils");
|
|
20
|
+
const _ChartPopover = require("../CommonComponents/ChartPopover");
|
|
21
|
+
const _index1 = require("../../utilities/index");
|
|
22
|
+
const _d3array = require("d3-array");
|
|
23
|
+
const _reacttabster = require("@fluentui/react-tabster");
|
|
24
|
+
const _chartutilities = require("@fluentui/chart-utilities");
|
|
25
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
26
|
+
const DEFAULT_LEGEND_HEIGHT = 32;
|
|
27
|
+
const LABEL_WIDTH = 36;
|
|
28
|
+
const LABEL_HEIGHT = 16;
|
|
29
|
+
const LABEL_OFFSET = 10;
|
|
30
|
+
const TICK_SIZE = 6;
|
|
31
|
+
const MIN_MARKER_SIZE_PX = 2;
|
|
32
|
+
const MAX_MARKER_SIZE_PX = 16;
|
|
33
|
+
const MIN_MARKER_SIZE_PX_MARKERS_ONLY = 4;
|
|
34
|
+
const PolarChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
35
|
+
var _props_legendProps, _props_legendProps1, _props_radialAxis, _props_angularAxis, _props_radialAxis1, _props_radialAxis2, _props_radialAxis3, _props_radialAxis4, _props_radialAxis5, _props_radialAxis6, _props_radialAxis7, _props_radialAxis8, _props_radialAxis9, _props_angularAxis1, _props_angularAxis2, _props_angularAxis3, _props_angularAxis4, _props_angularAxis5, _props_angularAxis6, _props_angularAxis7, _props_angularAxis8, _props_angularAxis9, _props_angularAxis10;
|
|
36
|
+
const { chartContainerRef, legendsRef } = (0, _hooks.useImageExport)(props.componentRef, props.hideLegend, false);
|
|
37
|
+
const legendContainerRef = _react.useRef(null);
|
|
38
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
39
|
+
const _window = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
40
|
+
const [containerWidth, setContainerWidth] = _react.useState(200);
|
|
41
|
+
const [containerHeight, setContainerHeight] = _react.useState(200);
|
|
42
|
+
const [legendContainerHeight, setLegendContainerHeight] = _react.useState(props.hideLegend ? 0 : DEFAULT_LEGEND_HEIGHT);
|
|
43
|
+
const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
|
|
44
|
+
const [popoverTarget, setPopoverTarget] = _react.useState(null);
|
|
45
|
+
const [popoverXValue, setPopoverXValue] = _react.useState('');
|
|
46
|
+
const [popoverLegend, setPopoverLegend] = _react.useState('');
|
|
47
|
+
const [popoverColor, setPopoverColor] = _react.useState('');
|
|
48
|
+
const [popoverYValue, setPopoverYValue] = _react.useState('');
|
|
49
|
+
const [hoveredLegend, setHoveredLegend] = _react.useState('');
|
|
50
|
+
const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
51
|
+
const [activePoint, setActivePoint] = _react.useState('');
|
|
52
|
+
_react.useEffect(()=>{
|
|
53
|
+
if (chartContainerRef.current) {
|
|
54
|
+
const { width, height } = chartContainerRef.current.getBoundingClientRect();
|
|
55
|
+
setContainerWidth(width);
|
|
56
|
+
setContainerHeight(height);
|
|
57
|
+
}
|
|
58
|
+
}, [
|
|
59
|
+
chartContainerRef
|
|
60
|
+
]);
|
|
61
|
+
_react.useEffect(()=>{
|
|
62
|
+
if (props.hideLegend) {
|
|
63
|
+
setLegendContainerHeight(0);
|
|
64
|
+
} else if (legendContainerRef.current) {
|
|
65
|
+
const { height } = legendContainerRef.current.getBoundingClientRect();
|
|
66
|
+
const marginTop = (_window === null || _window === void 0 ? void 0 : _window.getComputedStyle(legendContainerRef.current).marginTop) || '0px';
|
|
67
|
+
setLegendContainerHeight(Math.max(height, DEFAULT_LEGEND_HEIGHT) + parseFloat(marginTop));
|
|
68
|
+
}
|
|
69
|
+
}, [
|
|
70
|
+
props.hideLegend,
|
|
71
|
+
_window
|
|
72
|
+
]);
|
|
73
|
+
_react.useEffect(()=>{
|
|
74
|
+
var _props_legendProps;
|
|
75
|
+
setSelectedLegends(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
76
|
+
}, [
|
|
77
|
+
(_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends
|
|
78
|
+
]);
|
|
79
|
+
const margins = _react.useMemo(()=>({
|
|
80
|
+
left: LABEL_OFFSET + LABEL_WIDTH,
|
|
81
|
+
right: LABEL_OFFSET + LABEL_WIDTH,
|
|
82
|
+
top: LABEL_OFFSET + LABEL_HEIGHT,
|
|
83
|
+
bottom: LABEL_OFFSET + LABEL_HEIGHT,
|
|
84
|
+
...props.margins
|
|
85
|
+
}), [
|
|
86
|
+
props.margins
|
|
87
|
+
]);
|
|
88
|
+
const svgWidth = _react.useMemo(()=>props.width || containerWidth, [
|
|
89
|
+
props.width,
|
|
90
|
+
containerWidth
|
|
91
|
+
]);
|
|
92
|
+
const svgHeight = _react.useMemo(()=>(props.height || containerHeight) - legendContainerHeight, [
|
|
93
|
+
props.height,
|
|
94
|
+
containerHeight,
|
|
95
|
+
legendContainerHeight
|
|
96
|
+
]);
|
|
97
|
+
const outerRadius = _react.useMemo(()=>Math.min(svgWidth - (margins.left + margins.right), svgHeight - (margins.top + margins.bottom)) / 2, [
|
|
98
|
+
svgWidth,
|
|
99
|
+
svgHeight,
|
|
100
|
+
margins
|
|
101
|
+
]);
|
|
102
|
+
const innerRadius = _react.useMemo(()=>Math.max(0, Math.min(Math.abs(props.hole || 0), 1)) * outerRadius, [
|
|
103
|
+
props.hole,
|
|
104
|
+
outerRadius
|
|
105
|
+
]);
|
|
106
|
+
const legendColorMap = _react.useRef({});
|
|
107
|
+
const chartData = _react.useMemo(()=>{
|
|
108
|
+
legendColorMap.current = {};
|
|
109
|
+
let colorIndex = 0;
|
|
110
|
+
const renderingOrder = [
|
|
111
|
+
'areapolar',
|
|
112
|
+
'linepolar',
|
|
113
|
+
'scatterpolar'
|
|
114
|
+
];
|
|
115
|
+
return props.data.map((series)=>{
|
|
116
|
+
const seriesColor = series.color ? (0, _index1.getColorFromToken)(series.color) : (0, _index1.getNextColor)(colorIndex++, 0);
|
|
117
|
+
if (!(series.legend in legendColorMap.current)) {
|
|
118
|
+
legendColorMap.current[series.legend] = seriesColor;
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
...series,
|
|
122
|
+
color: seriesColor,
|
|
123
|
+
data: series.data.map((point)=>{
|
|
124
|
+
return {
|
|
125
|
+
...point,
|
|
126
|
+
color: point.color ? (0, _index1.getColorFromToken)(point.color) : seriesColor
|
|
127
|
+
};
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
}).sort((a, b)=>{
|
|
131
|
+
return renderingOrder.indexOf(a.type) - renderingOrder.indexOf(b.type);
|
|
132
|
+
});
|
|
133
|
+
}, [
|
|
134
|
+
props.data
|
|
135
|
+
]);
|
|
136
|
+
const mapCategoryToValues = _react.useCallback((isAngularAxis)=>{
|
|
137
|
+
const categoryToValues = {};
|
|
138
|
+
chartData.forEach((series)=>{
|
|
139
|
+
series.data.forEach((point)=>{
|
|
140
|
+
const category = isAngularAxis ? point.theta : point.r;
|
|
141
|
+
if (!categoryToValues[category]) {
|
|
142
|
+
categoryToValues[category] = [];
|
|
143
|
+
}
|
|
144
|
+
const value = isAngularAxis ? point.r : point.theta;
|
|
145
|
+
if (typeof value === 'number') {
|
|
146
|
+
categoryToValues[category].push(value);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
return categoryToValues;
|
|
151
|
+
}, [
|
|
152
|
+
chartData
|
|
153
|
+
]);
|
|
154
|
+
const getOrderedRCategories = _react.useCallback(()=>{
|
|
155
|
+
var _props_radialAxis;
|
|
156
|
+
return (0, _index1.sortAxisCategories)(mapCategoryToValues(), (_props_radialAxis = props.radialAxis) === null || _props_radialAxis === void 0 ? void 0 : _props_radialAxis.categoryOrder);
|
|
157
|
+
}, [
|
|
158
|
+
mapCategoryToValues,
|
|
159
|
+
(_props_radialAxis = props.radialAxis) === null || _props_radialAxis === void 0 ? void 0 : _props_radialAxis.categoryOrder
|
|
160
|
+
]);
|
|
161
|
+
const getOrderedACategories = _react.useCallback(()=>{
|
|
162
|
+
var _props_angularAxis;
|
|
163
|
+
return (0, _index1.sortAxisCategories)(mapCategoryToValues(true), (_props_angularAxis = props.angularAxis) === null || _props_angularAxis === void 0 ? void 0 : _props_angularAxis.categoryOrder);
|
|
164
|
+
}, [
|
|
165
|
+
mapCategoryToValues,
|
|
166
|
+
(_props_angularAxis = props.angularAxis) === null || _props_angularAxis === void 0 ? void 0 : _props_angularAxis.categoryOrder
|
|
167
|
+
]);
|
|
168
|
+
const rValues = _react.useMemo(()=>chartData.flatMap((series)=>series.data.map((point)=>point.r)), [
|
|
169
|
+
chartData
|
|
170
|
+
]);
|
|
171
|
+
const rScaleType = _react.useMemo(()=>{
|
|
172
|
+
var _props_radialAxis;
|
|
173
|
+
return (0, _PolarChartutils.getScaleType)(rValues, {
|
|
174
|
+
scaleType: (_props_radialAxis = props.radialAxis) === null || _props_radialAxis === void 0 ? void 0 : _props_radialAxis.scaleType,
|
|
175
|
+
supportsLog: true
|
|
176
|
+
});
|
|
177
|
+
}, [
|
|
178
|
+
rValues,
|
|
179
|
+
(_props_radialAxis1 = props.radialAxis) === null || _props_radialAxis1 === void 0 ? void 0 : _props_radialAxis1.scaleType
|
|
180
|
+
]);
|
|
181
|
+
const rScaleDomain = _react.useMemo(()=>{
|
|
182
|
+
var _props_radialAxis, _props_radialAxis1;
|
|
183
|
+
return rScaleType === 'category' ? getOrderedRCategories() : (0, _PolarChartutils.getContinuousScaleDomain)(rScaleType, rValues, {
|
|
184
|
+
rangeStart: (_props_radialAxis = props.radialAxis) === null || _props_radialAxis === void 0 ? void 0 : _props_radialAxis.rangeStart,
|
|
185
|
+
rangeEnd: (_props_radialAxis1 = props.radialAxis) === null || _props_radialAxis1 === void 0 ? void 0 : _props_radialAxis1.rangeEnd
|
|
186
|
+
});
|
|
187
|
+
}, [
|
|
188
|
+
getOrderedRCategories,
|
|
189
|
+
rScaleType,
|
|
190
|
+
rValues,
|
|
191
|
+
(_props_radialAxis2 = props.radialAxis) === null || _props_radialAxis2 === void 0 ? void 0 : _props_radialAxis2.rangeStart,
|
|
192
|
+
(_props_radialAxis3 = props.radialAxis) === null || _props_radialAxis3 === void 0 ? void 0 : _props_radialAxis3.rangeEnd
|
|
193
|
+
]);
|
|
194
|
+
const { scale: rScale, tickValues: rTickValues, tickLabels: rTickLabels } = _react.useMemo(()=>{
|
|
195
|
+
var _props_radialAxis, _props_radialAxis1, _props_radialAxis2, _props_radialAxis3, _props_radialAxis4, _props_radialAxis5;
|
|
196
|
+
return (0, _PolarChartutils.createRadialScale)(rScaleType, rScaleDomain, [
|
|
197
|
+
innerRadius,
|
|
198
|
+
outerRadius
|
|
199
|
+
], {
|
|
200
|
+
useUTC: props.useUTC,
|
|
201
|
+
tickCount: (_props_radialAxis = props.radialAxis) === null || _props_radialAxis === void 0 ? void 0 : _props_radialAxis.tickCount,
|
|
202
|
+
tickValues: (_props_radialAxis1 = props.radialAxis) === null || _props_radialAxis1 === void 0 ? void 0 : _props_radialAxis1.tickValues,
|
|
203
|
+
tickText: (_props_radialAxis2 = props.radialAxis) === null || _props_radialAxis2 === void 0 ? void 0 : _props_radialAxis2.tickText,
|
|
204
|
+
tickFormat: (_props_radialAxis3 = props.radialAxis) === null || _props_radialAxis3 === void 0 ? void 0 : _props_radialAxis3.tickFormat,
|
|
205
|
+
culture: props.culture,
|
|
206
|
+
tickStep: (_props_radialAxis4 = props.radialAxis) === null || _props_radialAxis4 === void 0 ? void 0 : _props_radialAxis4.tickStep,
|
|
207
|
+
tick0: (_props_radialAxis5 = props.radialAxis) === null || _props_radialAxis5 === void 0 ? void 0 : _props_radialAxis5.tick0,
|
|
208
|
+
dateLocalizeOptions: props.dateLocalizeOptions
|
|
209
|
+
});
|
|
210
|
+
}, [
|
|
211
|
+
rScaleType,
|
|
212
|
+
rScaleDomain,
|
|
213
|
+
innerRadius,
|
|
214
|
+
outerRadius,
|
|
215
|
+
props.culture,
|
|
216
|
+
props.dateLocalizeOptions,
|
|
217
|
+
(_props_radialAxis4 = props.radialAxis) === null || _props_radialAxis4 === void 0 ? void 0 : _props_radialAxis4.tick0,
|
|
218
|
+
(_props_radialAxis5 = props.radialAxis) === null || _props_radialAxis5 === void 0 ? void 0 : _props_radialAxis5.tickCount,
|
|
219
|
+
(_props_radialAxis6 = props.radialAxis) === null || _props_radialAxis6 === void 0 ? void 0 : _props_radialAxis6.tickFormat,
|
|
220
|
+
(_props_radialAxis7 = props.radialAxis) === null || _props_radialAxis7 === void 0 ? void 0 : _props_radialAxis7.tickStep,
|
|
221
|
+
(_props_radialAxis8 = props.radialAxis) === null || _props_radialAxis8 === void 0 ? void 0 : _props_radialAxis8.tickText,
|
|
222
|
+
(_props_radialAxis9 = props.radialAxis) === null || _props_radialAxis9 === void 0 ? void 0 : _props_radialAxis9.tickValues,
|
|
223
|
+
props.useUTC
|
|
224
|
+
]);
|
|
225
|
+
const aValues = _react.useMemo(()=>chartData.flatMap((series)=>series.data.map((point)=>point.theta)), [
|
|
226
|
+
chartData
|
|
227
|
+
]);
|
|
228
|
+
const aScaleType = _react.useMemo(()=>{
|
|
229
|
+
var _props_angularAxis;
|
|
230
|
+
return (0, _PolarChartutils.getScaleType)(aValues, {
|
|
231
|
+
scaleType: (_props_angularAxis = props.angularAxis) === null || _props_angularAxis === void 0 ? void 0 : _props_angularAxis.scaleType
|
|
232
|
+
});
|
|
233
|
+
}, [
|
|
234
|
+
aValues,
|
|
235
|
+
(_props_angularAxis1 = props.angularAxis) === null || _props_angularAxis1 === void 0 ? void 0 : _props_angularAxis1.scaleType
|
|
236
|
+
]);
|
|
237
|
+
const aDomain = _react.useMemo(()=>aScaleType === 'category' ? getOrderedACategories() : (0, _PolarChartutils.getContinuousScaleDomain)(aScaleType, aValues), [
|
|
238
|
+
getOrderedACategories,
|
|
239
|
+
aScaleType,
|
|
240
|
+
aValues
|
|
241
|
+
]);
|
|
242
|
+
const { scale: aScale, tickValues: aTickValues, tickLabels: aTickLabels } = _react.useMemo(()=>{
|
|
243
|
+
var _props_angularAxis, _props_angularAxis1, _props_angularAxis2, _props_angularAxis3, _props_angularAxis4, _props_angularAxis5, _props_angularAxis6;
|
|
244
|
+
return (0, _PolarChartutils.createAngularScale)(aScaleType, aDomain, {
|
|
245
|
+
tickCount: (_props_angularAxis = props.angularAxis) === null || _props_angularAxis === void 0 ? void 0 : _props_angularAxis.tickCount,
|
|
246
|
+
tickValues: (_props_angularAxis1 = props.angularAxis) === null || _props_angularAxis1 === void 0 ? void 0 : _props_angularAxis1.tickValues,
|
|
247
|
+
tickText: (_props_angularAxis2 = props.angularAxis) === null || _props_angularAxis2 === void 0 ? void 0 : _props_angularAxis2.tickText,
|
|
248
|
+
tickFormat: (_props_angularAxis3 = props.angularAxis) === null || _props_angularAxis3 === void 0 ? void 0 : _props_angularAxis3.tickFormat,
|
|
249
|
+
culture: props.culture,
|
|
250
|
+
tickStep: (_props_angularAxis4 = props.angularAxis) === null || _props_angularAxis4 === void 0 ? void 0 : _props_angularAxis4.tickStep,
|
|
251
|
+
tick0: (_props_angularAxis5 = props.angularAxis) === null || _props_angularAxis5 === void 0 ? void 0 : _props_angularAxis5.tick0,
|
|
252
|
+
direction: props.direction,
|
|
253
|
+
unit: (_props_angularAxis6 = props.angularAxis) === null || _props_angularAxis6 === void 0 ? void 0 : _props_angularAxis6.unit
|
|
254
|
+
});
|
|
255
|
+
}, [
|
|
256
|
+
aScaleType,
|
|
257
|
+
aDomain,
|
|
258
|
+
(_props_angularAxis2 = props.angularAxis) === null || _props_angularAxis2 === void 0 ? void 0 : _props_angularAxis2.tick0,
|
|
259
|
+
(_props_angularAxis3 = props.angularAxis) === null || _props_angularAxis3 === void 0 ? void 0 : _props_angularAxis3.tickCount,
|
|
260
|
+
(_props_angularAxis4 = props.angularAxis) === null || _props_angularAxis4 === void 0 ? void 0 : _props_angularAxis4.tickFormat,
|
|
261
|
+
(_props_angularAxis5 = props.angularAxis) === null || _props_angularAxis5 === void 0 ? void 0 : _props_angularAxis5.tickStep,
|
|
262
|
+
(_props_angularAxis6 = props.angularAxis) === null || _props_angularAxis6 === void 0 ? void 0 : _props_angularAxis6.tickText,
|
|
263
|
+
(_props_angularAxis7 = props.angularAxis) === null || _props_angularAxis7 === void 0 ? void 0 : _props_angularAxis7.tickValues,
|
|
264
|
+
(_props_angularAxis8 = props.angularAxis) === null || _props_angularAxis8 === void 0 ? void 0 : _props_angularAxis8.unit,
|
|
265
|
+
props.culture,
|
|
266
|
+
props.direction
|
|
267
|
+
]);
|
|
268
|
+
const classes = (0, _usePolarChartStylesstyles.usePolarChartStyles)(props);
|
|
269
|
+
const renderPolarGrid = _react.useCallback(()=>{
|
|
270
|
+
const extRTickValues = [];
|
|
271
|
+
const rDomain = rScale.domain();
|
|
272
|
+
if (innerRadius > 0 && rDomain[0] !== rTickValues[0]) {
|
|
273
|
+
extRTickValues.push(rDomain[0]);
|
|
274
|
+
}
|
|
275
|
+
extRTickValues.push(...rTickValues);
|
|
276
|
+
if (rDomain[rDomain.length - 1] !== rTickValues[rTickValues.length - 1]) {
|
|
277
|
+
extRTickValues.push(rDomain[rDomain.length - 1]);
|
|
278
|
+
}
|
|
279
|
+
return /*#__PURE__*/ _react.createElement("g", null, /*#__PURE__*/ _react.createElement("g", null, extRTickValues.map((r, rIndex)=>{
|
|
280
|
+
const className = rIndex === extRTickValues.length - 1 ? classes.gridLineOuter : classes.gridLineInner;
|
|
281
|
+
if (props.shape === 'polygon') {
|
|
282
|
+
let d = '';
|
|
283
|
+
aTickValues.forEach((a, aIndex)=>{
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
const radialPoint = (0, _d3shape.pointRadial)(aScale(a), rScale(r));
|
|
286
|
+
d += (aIndex === 0 ? 'M' : 'L') + radialPoint.join(',') + ' ';
|
|
287
|
+
});
|
|
288
|
+
d += 'Z';
|
|
289
|
+
return /*#__PURE__*/ _react.createElement("path", {
|
|
290
|
+
key: rIndex,
|
|
291
|
+
d: d,
|
|
292
|
+
className: className
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
296
|
+
return /*#__PURE__*/ _react.createElement("circle", {
|
|
297
|
+
key: rIndex,
|
|
298
|
+
cx: 0,
|
|
299
|
+
cy: 0,
|
|
300
|
+
r: rScale(r),
|
|
301
|
+
className: className
|
|
302
|
+
});
|
|
303
|
+
})), /*#__PURE__*/ _react.createElement("g", null, aTickValues.map((a, aIndex)=>{
|
|
304
|
+
const radialPoint1 = (0, _d3shape.pointRadial)(aScale(a), innerRadius);
|
|
305
|
+
const radialPoint2 = (0, _d3shape.pointRadial)(aScale(a), outerRadius);
|
|
306
|
+
return /*#__PURE__*/ _react.createElement("path", {
|
|
307
|
+
key: aIndex,
|
|
308
|
+
d: `M${radialPoint1.join(',')} L${radialPoint2.join(',')}`,
|
|
309
|
+
className: classes.gridLineInner
|
|
310
|
+
});
|
|
311
|
+
})));
|
|
312
|
+
}, [
|
|
313
|
+
innerRadius,
|
|
314
|
+
outerRadius,
|
|
315
|
+
rTickValues,
|
|
316
|
+
aTickValues,
|
|
317
|
+
rScale,
|
|
318
|
+
aScale,
|
|
319
|
+
props.shape,
|
|
320
|
+
classes.gridLineInner,
|
|
321
|
+
classes.gridLineOuter
|
|
322
|
+
]);
|
|
323
|
+
const renderPolarTicks = _react.useCallback(()=>{
|
|
324
|
+
const radialAxisAngle = props.direction === 'clockwise' ? 0 : Math.PI / 2;
|
|
325
|
+
const radialAxisStartPoint = (0, _d3shape.pointRadial)(radialAxisAngle, innerRadius);
|
|
326
|
+
const radialAxisEndPoint = (0, _d3shape.pointRadial)(radialAxisAngle, outerRadius);
|
|
327
|
+
// (0, pi]
|
|
328
|
+
const sign = radialAxisAngle > _PolarChartutils.EPSILON && radialAxisAngle - Math.PI < _PolarChartutils.EPSILON ? 1 : -1;
|
|
329
|
+
return /*#__PURE__*/ _react.createElement("g", null, /*#__PURE__*/ _react.createElement("g", null, /*#__PURE__*/ _react.createElement("path", {
|
|
330
|
+
d: `M${radialAxisStartPoint.join(',')} L${radialAxisEndPoint.join(',')}`,
|
|
331
|
+
className: classes.gridLineOuter
|
|
332
|
+
}), rTickValues.map((r, rIndex)=>{
|
|
333
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
334
|
+
const [pointX, pointY] = (0, _d3shape.pointRadial)(radialAxisAngle, rScale(r));
|
|
335
|
+
return /*#__PURE__*/ _react.createElement("g", {
|
|
336
|
+
key: rIndex
|
|
337
|
+
}, /*#__PURE__*/ _react.createElement("path", {
|
|
338
|
+
d: `M${pointX},${pointY} L${pointX + TICK_SIZE * Math.cos(radialAxisAngle) * sign},${pointY + TICK_SIZE * Math.sin(radialAxisAngle) * sign}`,
|
|
339
|
+
className: classes.gridLineOuter
|
|
340
|
+
}), /*#__PURE__*/ _react.createElement("text", {
|
|
341
|
+
x: pointX + (TICK_SIZE + LABEL_OFFSET) * Math.cos(radialAxisAngle) * sign,
|
|
342
|
+
y: pointY + (TICK_SIZE + LABEL_OFFSET) * Math.sin(radialAxisAngle) * sign,
|
|
343
|
+
textAnchor: Math.abs(radialAxisAngle - Math.PI / 2) < _PolarChartutils.EPSILON || Math.abs(radialAxisAngle - 3 * Math.PI / 2) < _PolarChartutils.EPSILON ? 'middle' : radialAxisAngle > _PolarChartutils.EPSILON && radialAxisAngle - Math.PI / 2 < -_PolarChartutils.EPSILON || radialAxisAngle - Math.PI > _PolarChartutils.EPSILON && radialAxisAngle - 3 * Math.PI / 2 < -_PolarChartutils.EPSILON ? 'start' : 'end',
|
|
344
|
+
dominantBaseline: "middle",
|
|
345
|
+
"aria-hidden": true,
|
|
346
|
+
className: classes.tickLabel
|
|
347
|
+
}, rTickLabels[rIndex]));
|
|
348
|
+
})), /*#__PURE__*/ _react.createElement("g", null, aTickValues.map((a, aIndex)=>{
|
|
349
|
+
const angle = aScale(a);
|
|
350
|
+
const [pointX, pointY] = (0, _d3shape.pointRadial)(angle, outerRadius + LABEL_OFFSET);
|
|
351
|
+
return /*#__PURE__*/ _react.createElement("text", {
|
|
352
|
+
key: aIndex,
|
|
353
|
+
x: pointX,
|
|
354
|
+
y: pointY,
|
|
355
|
+
textAnchor: Math.abs(angle) < _PolarChartutils.EPSILON || Math.abs(angle - Math.PI) < _PolarChartutils.EPSILON ? 'middle' : angle > Math.PI ? 'end' : 'start',
|
|
356
|
+
dominantBaseline: "middle",
|
|
357
|
+
"aria-hidden": true,
|
|
358
|
+
className: classes.tickLabel
|
|
359
|
+
}, aTickLabels[aIndex]);
|
|
360
|
+
})));
|
|
361
|
+
}, [
|
|
362
|
+
rTickValues,
|
|
363
|
+
aTickValues,
|
|
364
|
+
rScale,
|
|
365
|
+
aScale,
|
|
366
|
+
outerRadius,
|
|
367
|
+
classes.gridLineOuter,
|
|
368
|
+
classes.tickLabel,
|
|
369
|
+
aTickLabels,
|
|
370
|
+
innerRadius,
|
|
371
|
+
rTickLabels,
|
|
372
|
+
props.direction
|
|
373
|
+
]);
|
|
374
|
+
const getActiveLegends = _react.useCallback(()=>{
|
|
375
|
+
return selectedLegends.length > 0 ? selectedLegends : hoveredLegend ? [
|
|
376
|
+
hoveredLegend
|
|
377
|
+
] : [];
|
|
378
|
+
}, [
|
|
379
|
+
selectedLegends,
|
|
380
|
+
hoveredLegend
|
|
381
|
+
]);
|
|
382
|
+
const legendHighlighted = _react.useCallback((legendTitle)=>{
|
|
383
|
+
const activeLegends = getActiveLegends();
|
|
384
|
+
return activeLegends.includes(legendTitle) || activeLegends.length === 0;
|
|
385
|
+
}, [
|
|
386
|
+
getActiveLegends
|
|
387
|
+
]);
|
|
388
|
+
const renderRadialArea = _react.useCallback((series)=>{
|
|
389
|
+
var _series_lineOptions;
|
|
390
|
+
const radialArea = (0, _d3shape.areaRadial)().angle((d)=>aScale(d.theta)).innerRadius(innerRadius) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
391
|
+
.outerRadius((d)=>rScale(d.r)).curve((0, _index1.getCurveFactory)((_series_lineOptions = series.lineOptions) === null || _series_lineOptions === void 0 ? void 0 : _series_lineOptions.curve, _d3shape.curveLinearClosed)) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
392
|
+
.defined((d)=>(0, _index1.isPlottable)(aScale(d.theta), rScale(d.r)));
|
|
393
|
+
const shouldHighlight = legendHighlighted(series.legend);
|
|
394
|
+
return /*#__PURE__*/ _react.createElement("path", {
|
|
395
|
+
d: radialArea(series.data),
|
|
396
|
+
fill: series.color,
|
|
397
|
+
fillOpacity: shouldHighlight ? 0.7 : 0.1,
|
|
398
|
+
pointerEvents: "none"
|
|
399
|
+
});
|
|
400
|
+
}, [
|
|
401
|
+
innerRadius,
|
|
402
|
+
rScale,
|
|
403
|
+
aScale,
|
|
404
|
+
legendHighlighted
|
|
405
|
+
]);
|
|
406
|
+
const renderRadialLine = _react.useCallback((series)=>{
|
|
407
|
+
var _series_lineOptions, _series_lineOptions1, _series_lineOptions2, _series_lineOptions3, _series_lineOptions4;
|
|
408
|
+
const radialLine = (0, _d3shape.lineRadial)().angle((d)=>aScale(d.theta)) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
409
|
+
.radius((d)=>rScale(d.r)).curve((0, _index1.getCurveFactory)((_series_lineOptions = series.lineOptions) === null || _series_lineOptions === void 0 ? void 0 : _series_lineOptions.curve)) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
|
+
.defined((d)=>(0, _index1.isPlottable)(aScale(d.theta), rScale(d.r)));
|
|
411
|
+
var _series_lineOptions_strokeWidth;
|
|
412
|
+
return /*#__PURE__*/ _react.createElement("path", {
|
|
413
|
+
d: radialLine(series.data),
|
|
414
|
+
fill: "none",
|
|
415
|
+
stroke: series.color,
|
|
416
|
+
strokeOpacity: legendHighlighted(series.legend) ? 1 : 0.1,
|
|
417
|
+
strokeWidth: (_series_lineOptions_strokeWidth = (_series_lineOptions1 = series.lineOptions) === null || _series_lineOptions1 === void 0 ? void 0 : _series_lineOptions1.strokeWidth) !== null && _series_lineOptions_strokeWidth !== void 0 ? _series_lineOptions_strokeWidth : 3,
|
|
418
|
+
strokeDasharray: (_series_lineOptions2 = series.lineOptions) === null || _series_lineOptions2 === void 0 ? void 0 : _series_lineOptions2.strokeDasharray,
|
|
419
|
+
strokeDashoffset: (_series_lineOptions3 = series.lineOptions) === null || _series_lineOptions3 === void 0 ? void 0 : _series_lineOptions3.strokeDashoffset,
|
|
420
|
+
strokeLinecap: (_series_lineOptions4 = series.lineOptions) === null || _series_lineOptions4 === void 0 ? void 0 : _series_lineOptions4.strokeLinecap,
|
|
421
|
+
pointerEvents: "none"
|
|
422
|
+
});
|
|
423
|
+
}, [
|
|
424
|
+
rScale,
|
|
425
|
+
aScale,
|
|
426
|
+
legendHighlighted
|
|
427
|
+
]);
|
|
428
|
+
const [minMarkerSize, maxMarkerSize] = _react.useMemo(()=>(0, _d3array.extent)(chartData.flatMap((series)=>series.data.map((point)=>point.markerSize))), [
|
|
429
|
+
chartData
|
|
430
|
+
]);
|
|
431
|
+
const showPopover = _react.useCallback((event, point, pointId, legend)=>{
|
|
432
|
+
var _props_angularAxis;
|
|
433
|
+
setPopoverTarget(event.currentTarget);
|
|
434
|
+
setPopoverOpen(legendHighlighted(legend));
|
|
435
|
+
var _point_angularAxisCalloutData;
|
|
436
|
+
setPopoverXValue((_point_angularAxisCalloutData = point.angularAxisCalloutData) !== null && _point_angularAxisCalloutData !== void 0 ? _point_angularAxisCalloutData : (0, _PolarChartutils.formatAngle)(point.theta, (_props_angularAxis = props.angularAxis) === null || _props_angularAxis === void 0 ? void 0 : _props_angularAxis.unit));
|
|
437
|
+
setPopoverLegend(legend);
|
|
438
|
+
setPopoverColor(point.color);
|
|
439
|
+
var _point_radialAxisCalloutData;
|
|
440
|
+
setPopoverYValue((_point_radialAxisCalloutData = point.radialAxisCalloutData) !== null && _point_radialAxisCalloutData !== void 0 ? _point_radialAxisCalloutData : (0, _chartutilities.formatToLocaleString)(point.r, props.culture, props.useUTC));
|
|
441
|
+
setActivePoint(pointId);
|
|
442
|
+
}, [
|
|
443
|
+
legendHighlighted,
|
|
444
|
+
(_props_angularAxis9 = props.angularAxis) === null || _props_angularAxis9 === void 0 ? void 0 : _props_angularAxis9.unit,
|
|
445
|
+
props.culture,
|
|
446
|
+
props.useUTC
|
|
447
|
+
]);
|
|
448
|
+
const hidePopover = _react.useCallback(()=>{
|
|
449
|
+
setPopoverOpen(false);
|
|
450
|
+
setActivePoint('');
|
|
451
|
+
}, []);
|
|
452
|
+
const markersOnlyMode = _react.useMemo(()=>chartData.filter((s)=>s.type === 'areapolar' || s.type === 'linepolar').length === 0, [
|
|
453
|
+
chartData
|
|
454
|
+
]);
|
|
455
|
+
const renderRadialPoints = _react.useCallback((series, seriesIndex)=>{
|
|
456
|
+
const shouldHighlight = legendHighlighted(series.legend);
|
|
457
|
+
return /*#__PURE__*/ _react.createElement("g", null, series.data.map((point, pointIndex)=>{
|
|
458
|
+
var _props_angularAxis, _point_callOutAccessibilityData;
|
|
459
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
460
|
+
if (!(0, _index1.isPlottable)(aScale(point.theta), rScale(point.r))) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
464
|
+
const [x, y] = (0, _d3shape.pointRadial)(aScale(point.theta), rScale(point.r));
|
|
465
|
+
const id = `${seriesIndex}-${pointIndex}`;
|
|
466
|
+
const isActive = activePoint === id;
|
|
467
|
+
const minPx = markersOnlyMode ? MIN_MARKER_SIZE_PX_MARKERS_ONLY : MIN_MARKER_SIZE_PX;
|
|
468
|
+
let radius = minPx;
|
|
469
|
+
if (typeof point.markerSize !== 'undefined' && minMarkerSize !== maxMarkerSize) {
|
|
470
|
+
radius = minPx + (point.markerSize - minMarkerSize) / (maxMarkerSize - minMarkerSize) * (MAX_MARKER_SIZE_PX - minPx);
|
|
471
|
+
}
|
|
472
|
+
const xValue = point.radialAxisCalloutData || (0, _chartutilities.formatToLocaleString)(point.r, props.culture, props.useUTC);
|
|
473
|
+
const legend = series.legend;
|
|
474
|
+
const yValue = point.angularAxisCalloutData || (0, _PolarChartutils.formatAngle)(point.theta, (_props_angularAxis = props.angularAxis) === null || _props_angularAxis === void 0 ? void 0 : _props_angularAxis.unit);
|
|
475
|
+
const ariaLabel = ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
|
|
476
|
+
return /*#__PURE__*/ _react.createElement("circle", {
|
|
477
|
+
key: pointIndex,
|
|
478
|
+
cx: x,
|
|
479
|
+
cy: y,
|
|
480
|
+
r: radius,
|
|
481
|
+
fill: isActive ? _reacttheme.tokens.colorNeutralBackground1 : point.color,
|
|
482
|
+
stroke: isActive ? point.color : 'none',
|
|
483
|
+
strokeWidth: isActive ? 2 : 0,
|
|
484
|
+
opacity: shouldHighlight ? 1 : 0.1,
|
|
485
|
+
tabIndex: shouldHighlight ? 0 : -1,
|
|
486
|
+
onMouseOver: (e)=>showPopover(e, point, id, series.legend),
|
|
487
|
+
onFocus: (e)=>showPopover(e, point, id, series.legend),
|
|
488
|
+
role: "img",
|
|
489
|
+
"aria-label": ariaLabel
|
|
490
|
+
});
|
|
491
|
+
}));
|
|
492
|
+
}, [
|
|
493
|
+
legendHighlighted,
|
|
494
|
+
rScale,
|
|
495
|
+
aScale,
|
|
496
|
+
activePoint,
|
|
497
|
+
showPopover,
|
|
498
|
+
minMarkerSize,
|
|
499
|
+
maxMarkerSize,
|
|
500
|
+
markersOnlyMode,
|
|
501
|
+
(_props_angularAxis10 = props.angularAxis) === null || _props_angularAxis10 === void 0 ? void 0 : _props_angularAxis10.unit,
|
|
502
|
+
props.culture,
|
|
503
|
+
props.useUTC
|
|
504
|
+
]);
|
|
505
|
+
const onLegendSelectionChange = _react.useCallback((_selectedLegends, event, currentLegend)=>{
|
|
506
|
+
var _props_legendProps, _props_legendProps1;
|
|
507
|
+
if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
|
|
508
|
+
setSelectedLegends(_selectedLegends);
|
|
509
|
+
} else {
|
|
510
|
+
setSelectedLegends(_selectedLegends.slice(-1));
|
|
511
|
+
}
|
|
512
|
+
if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
|
|
513
|
+
props.legendProps.onChange(_selectedLegends, event, currentLegend);
|
|
514
|
+
}
|
|
515
|
+
}, [
|
|
516
|
+
props.legendProps
|
|
517
|
+
]);
|
|
518
|
+
const renderLegends = _react.useCallback(()=>{
|
|
519
|
+
if (props.hideLegend) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
const legends = Object.keys(legendColorMap.current).map((legendTitle)=>{
|
|
523
|
+
return {
|
|
524
|
+
title: legendTitle,
|
|
525
|
+
color: legendColorMap.current[legendTitle],
|
|
526
|
+
hoverAction: ()=>{
|
|
527
|
+
setHoveredLegend(legendTitle);
|
|
528
|
+
},
|
|
529
|
+
onMouseOutAction: ()=>{
|
|
530
|
+
setHoveredLegend('');
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
});
|
|
534
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
535
|
+
ref: legendContainerRef,
|
|
536
|
+
className: classes.legendContainer
|
|
537
|
+
}, /*#__PURE__*/ _react.createElement(_index.Legends, {
|
|
538
|
+
legends: legends,
|
|
539
|
+
centerLegends: true,
|
|
540
|
+
onChange: onLegendSelectionChange,
|
|
541
|
+
legendRef: legendsRef,
|
|
542
|
+
...props.legendProps
|
|
543
|
+
}));
|
|
544
|
+
}, [
|
|
545
|
+
props.hideLegend,
|
|
546
|
+
props.legendProps,
|
|
547
|
+
legendsRef,
|
|
548
|
+
onLegendSelectionChange,
|
|
549
|
+
classes.legendContainer
|
|
550
|
+
]);
|
|
551
|
+
const focusAttributes = (0, _reacttabster.useArrowNavigationGroup)({
|
|
552
|
+
axis: 'horizontal'
|
|
553
|
+
});
|
|
554
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
555
|
+
className: classes.root,
|
|
556
|
+
ref: chartContainerRef,
|
|
557
|
+
onMouseLeave: hidePopover,
|
|
558
|
+
onBlur: hidePopover
|
|
559
|
+
}, /*#__PURE__*/ _react.createElement("div", {
|
|
560
|
+
className: classes.chartWrapper,
|
|
561
|
+
...focusAttributes
|
|
562
|
+
}, /*#__PURE__*/ _react.createElement("svg", {
|
|
563
|
+
className: classes.chart,
|
|
564
|
+
width: svgWidth,
|
|
565
|
+
height: svgHeight,
|
|
566
|
+
viewBox: `${-svgWidth / 2} ${-svgHeight / 2} ${svgWidth} ${svgHeight}`,
|
|
567
|
+
role: "region",
|
|
568
|
+
"aria-label": (props.chartTitle ? `${props.chartTitle}. ` : '') + `Polar chart with ${chartData.length} data series.`
|
|
569
|
+
}, renderPolarGrid(), /*#__PURE__*/ _react.createElement("g", null, chartData.map((series, seriesIndex)=>{
|
|
570
|
+
return /*#__PURE__*/ _react.createElement("g", {
|
|
571
|
+
key: seriesIndex,
|
|
572
|
+
role: "region",
|
|
573
|
+
"aria-label": `${series.legend}, series ${seriesIndex + 1} of ${chartData.length} with ${series.data.length} data points.`
|
|
574
|
+
}, series.type === 'areapolar' && renderRadialArea(series), (series.type === 'areapolar' || series.type === 'linepolar') && renderRadialLine(series), renderRadialPoints(series, seriesIndex));
|
|
575
|
+
})), renderPolarTicks())), renderLegends(), !props.hideTooltip && /*#__PURE__*/ _react.createElement(_ChartPopover.ChartPopover, {
|
|
576
|
+
isPopoverOpen: isPopoverOpen,
|
|
577
|
+
positioning: {
|
|
578
|
+
target: popoverTarget
|
|
579
|
+
},
|
|
580
|
+
XValue: popoverXValue,
|
|
581
|
+
legend: popoverLegend,
|
|
582
|
+
color: popoverColor,
|
|
583
|
+
YValue: popoverYValue
|
|
584
|
+
}));
|
|
585
|
+
});
|
|
586
|
+
PolarChart.displayName = 'PolarChart';
|