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