@fluentui/react-charting 5.24.10 → 5.24.12
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.json +69 -1
- package/CHANGELOG.md +25 -2
- package/dist/react-charting.d.ts +18 -3
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +7 -3
- package/lib/components/AreaChart/AreaChart.base.js +4 -0
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.base.js +2 -1
- package/lib/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.types.d.ts +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.js +4 -2
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +4 -0
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +14 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +112 -12
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +1 -0
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.base.js +5 -6
- package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.styles.js +2 -4
- package/lib/components/DonutChart/DonutChart.styles.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.d.ts +4 -0
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js +2 -0
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.base.js +2 -0
- package/lib/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.base.js +3 -5
- package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.styles.js +2 -4
- package/lib/components/GaugeChart/GaugeChart.styles.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.d.ts +4 -0
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +5 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js +3 -0
- package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +4 -0
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +6 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/Legends/Legends.base.js +5 -1
- package/lib/components/Legends/Legends.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.d.ts +1 -0
- package/lib/components/LineChart/LineChart.base.js +53 -12
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/PieChart/Arc/Arc.js +2 -0
- package/lib/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib/components/PieChart/Pie/Pie.js +2 -0
- package/lib/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib/components/PieChart/PieChart.base.js +1 -0
- package/lib/components/PieChart/PieChart.base.js.map +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js +13 -5
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.types.d.ts +2 -4
- package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.base.js +4 -6
- package/lib/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.styles.js +3 -0
- package/lib/components/SankeyChart/SankeyChart.styles.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.d.ts +4 -0
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +41 -8
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.base.d.ts +2 -2
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +6 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.js +5 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib/components/TreeChart/TreeChart.base.js +17 -2
- package/lib/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +11 -0
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
- package/lib/utilities/scatterpolar-utils.d.ts +22 -0
- package/lib/utilities/scatterpolar-utils.js +38 -0
- package/lib/utilities/scatterpolar-utils.js.map +1 -0
- package/lib/utilities/utilities.d.ts +6 -0
- package/lib/utilities/utilities.js +16 -4
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js +4 -0
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/ChartTable/ChartTable.base.js +2 -1
- package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib-amd/components/ChartTable/ChartTable.types.d.ts +1 -0
- package/lib-amd/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +4 -2
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +4 -0
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +14 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +111 -11
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.js +1 -0
- package/lib-amd/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.base.js +5 -6
- package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.styles.js +2 -4
- package/lib-amd/components/DonutChart/DonutChart.styles.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.types.d.ts +4 -0
- package/lib-amd/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-amd/components/DonutChart/Pie/Pie.js +2 -0
- package/lib-amd/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-amd/components/FunnelChart/FunnelChart.base.js +2 -0
- package/lib-amd/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.js +3 -5
- package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.styles.js +2 -4
- package/lib-amd/components/GaugeChart/GaugeChart.styles.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.types.d.ts +4 -0
- package/lib-amd/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +5 -0
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +3 -0
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +4 -0
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +6 -0
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/Legends/Legends.base.js +5 -1
- package/lib-amd/components/Legends/Legends.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.d.ts +1 -0
- package/lib-amd/components/LineChart/LineChart.base.js +52 -12
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/PieChart/Arc/Arc.js +2 -0
- package/lib-amd/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-amd/components/PieChart/Pie/Pie.js +2 -0
- package/lib-amd/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib-amd/components/PieChart/PieChart.base.js +1 -0
- package/lib-amd/components/PieChart/PieChart.base.js.map +1 -1
- package/lib-amd/components/ResponsiveContainer/ResponsiveContainer.js +13 -5
- package/lib-amd/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib-amd/components/ResponsiveContainer/ResponsiveContainer.types.d.ts +2 -4
- package/lib-amd/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.base.js +4 -6
- package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.styles.js +3 -0
- package/lib-amd/components/SankeyChart/SankeyChart.styles.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.types.d.ts +4 -0
- package/lib-amd/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +40 -8
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/Sparkline/Sparkline.base.d.ts +2 -2
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +6 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js +5 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-amd/components/TreeChart/TreeChart.base.js +17 -2
- package/lib-amd/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +11 -0
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
- package/lib-amd/utilities/scatterpolar-utils.d.ts +22 -0
- package/lib-amd/utilities/scatterpolar-utils.js +43 -0
- package/lib-amd/utilities/scatterpolar-utils.js.map +1 -0
- package/lib-amd/utilities/utilities.d.ts +6 -0
- package/lib-amd/utilities/utilities.js +18 -5
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +4 -0
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.base.js +2 -1
- package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.types.d.ts +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +4 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +4 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +14 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +111 -11
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -0
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.js +5 -6
- package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.styles.js +2 -4
- package/lib-commonjs/components/DonutChart/DonutChart.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.d.ts +4 -0
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js +2 -0
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.base.js +2 -0
- package/lib-commonjs/components/FunnelChart/FunnelChart.base.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js +3 -5
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.styles.js +2 -4
- package/lib-commonjs/components/GaugeChart/GaugeChart.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.d.ts +4 -0
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +5 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +3 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +4 -0
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +6 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.base.js +5 -1
- package/lib-commonjs/components/Legends/Legends.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.d.ts +1 -0
- package/lib-commonjs/components/LineChart/LineChart.base.js +52 -11
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/PieChart/Arc/Arc.js +2 -0
- package/lib-commonjs/components/PieChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/PieChart/Pie/Pie.js +2 -0
- package/lib-commonjs/components/PieChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/PieChart/PieChart.base.js +1 -0
- package/lib-commonjs/components/PieChart/PieChart.base.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +13 -5
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.d.ts +2 -4
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js +4 -6
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js +3 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.d.ts +4 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +40 -7
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.base.d.ts +2 -2
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +6 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js +5 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.base.js +17 -2
- package/lib-commonjs/components/TreeChart/TreeChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +11 -0
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/ChartHoverCard/ChartHoverCard.base.js.map +1 -1
- package/lib-commonjs/utilities/scatterpolar-utils.d.ts +22 -0
- package/lib-commonjs/utilities/scatterpolar-utils.js +42 -0
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
- package/lib-commonjs/utilities/utilities.d.ts +6 -0
- package/lib-commonjs/utilities/utilities.js +18 -5
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ChartTable/ChartTable.types.ts +1 -0
- package/src/components/CommonComponents/CartesianChart.types.ts +6 -0
- package/src/components/DonutChart/DonutChart.types.ts +5 -0
- package/src/components/GaugeChart/GaugeChart.types.ts +5 -0
- package/src/components/ResponsiveContainer/ResponsiveContainer.types.ts +3 -2
- package/src/components/SankeyChart/SankeyChart.types.ts +5 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to render categorical labels for scatterpolar charts with improved overlap logic across all series
|
|
4
|
+
* Now places labels at equal angles for all unique texts, regardless of data positions.
|
|
5
|
+
*/
|
|
6
|
+
export function renderScatterPolarCategoryLabels(_a) {
|
|
7
|
+
var allSeriesData = _a.allSeriesData, xAxisScale = _a.xAxisScale, yAxisScale = _a.yAxisScale, className = _a.className, maybeLineOptions = _a.maybeLineOptions, _b = _a.minPixelGap, minPixelGap = _b === void 0 ? 40 : _b;
|
|
8
|
+
// 1. Aggregate all data points from all series
|
|
9
|
+
var allLabels = [];
|
|
10
|
+
allSeriesData.forEach(function (series) {
|
|
11
|
+
series.data.forEach(function (pt) {
|
|
12
|
+
if (pt.text) {
|
|
13
|
+
allLabels.push({ x: pt.x, y: pt.y, text: pt.text });
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
// 2. Deduplicate by text (angle label)
|
|
18
|
+
var uniqueTexts = Array.from(new Set(allLabels.map(function (l) { return l.text; })));
|
|
19
|
+
// 3. Place labels at equal angles
|
|
20
|
+
var renderedLabels = [];
|
|
21
|
+
var placedPositions = [];
|
|
22
|
+
var labelRadius = 0.7; // You can adjust this value for more/less offset
|
|
23
|
+
var numLabels = uniqueTexts.length;
|
|
24
|
+
uniqueTexts.forEach(function (text, i) {
|
|
25
|
+
var angle = ((2 * Math.PI) / numLabels) * i;
|
|
26
|
+
var originXOffset = (maybeLineOptions === null || maybeLineOptions === void 0 ? void 0 : maybeLineOptions.originXOffset) || 0;
|
|
27
|
+
var x = xAxisScale(labelRadius * Math.cos(angle) - originXOffset / 2);
|
|
28
|
+
var y = yAxisScale(labelRadius * Math.sin(angle));
|
|
29
|
+
// Check distance from all previously placed labels
|
|
30
|
+
var isFarEnough = placedPositions.every(function (pos) { return Math.sqrt(Math.pow((x - pos.x), 2) + Math.pow((y - pos.y), 2)) >= minPixelGap; });
|
|
31
|
+
if (renderedLabels.length === 0 || isFarEnough) {
|
|
32
|
+
renderedLabels.push(React.createElement("text", { key: "scatterpolar-label-".concat(text), x: x, y: y, className: className, textAnchor: "middle", alignmentBaseline: "middle", opacity: 1 }, text));
|
|
33
|
+
placedPositions.push({ x: x, y: y });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return renderedLabels;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=scatterpolar-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scatterpolar-utils.js","sourceRoot":"../src/","sources":["utilities/scatterpolar-utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,EAchD;QAbC,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,gBAAgB,sBAAA,EAChB,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,KAAA;IAShB,+CAA+C;IAC/C,IAAM,SAAS,GAA6C,EAAE,CAAC;IAC/D,aAAa,CAAC,OAAO,CAAC,UAAA,MAAM;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,EAAE;YACpB,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;gBACZ,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,uCAAuC;IACvC,IAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,EAAN,CAAM,CAAC,CAAC,CAAC,CAAC;IAEpE,kCAAkC;IAClC,IAAM,cAAc,GAAwB,EAAE,CAAC;IAC/C,IAAM,eAAe,GAA+B,EAAE,CAAC;IACvD,IAAM,WAAW,GAAG,GAAG,CAAC,CAAC,iDAAiD;IAC1E,IAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC;IAErC,WAAW,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,CAAC;QAC1B,IAAM,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAM,aAAa,GAAG,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,aAAa,KAAI,CAAC,CAAC;QAC3D,IAAM,CAAC,GAAG,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,aAAa,GAAG,CAAC,CAAC,CAAC;QACxE,IAAM,CAAC,GAAG,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QAEpD,mDAAmD;QACnD,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,IAAI,CAAC,IAAI,CAAC,SAAA,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAI,CAAC,CAAA,GAAG,SAAA,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAI,CAAC,CAAA,CAAC,IAAI,WAAW,EAA7D,CAA6D,CAAC,CAAC;QAEhH,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YAC/C,cAAc,CAAC,IAAI,CACjB,8BACE,GAAG,EAAE,6BAAsB,IAAI,CAAE,EACjC,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,SAAS,EAAE,SAAS,EACpB,UAAU,EAAC,QAAQ,EACnB,iBAAiB,EAAC,QAAQ,EAC1B,OAAO,EAAE,CAAC,IAET,IAAI,CACA,CACR,CAAC;YACF,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import * as React from 'react';\nimport { ScaleLinear } from 'd3-scale';\n\n/**\n * Helper to render categorical labels for scatterpolar charts with improved overlap logic across all series\n * Now places labels at equal angles for all unique texts, regardless of data positions.\n */\nexport function renderScatterPolarCategoryLabels({\n allSeriesData,\n xAxisScale,\n yAxisScale,\n className,\n maybeLineOptions,\n minPixelGap = 40,\n}: {\n allSeriesData: { data: { x: number; y: number; text?: string }[] }[];\n xAxisScale: ScaleLinear<number, number>;\n yAxisScale: ScaleLinear<number, number>;\n className: string;\n maybeLineOptions?: { originXOffset?: number };\n minPixelGap?: number;\n}): React.JSX.Element[] {\n // 1. Aggregate all data points from all series\n const allLabels: { x: number; y: number; text: string }[] = [];\n allSeriesData.forEach(series => {\n series.data.forEach(pt => {\n if (pt.text) {\n allLabels.push({ x: pt.x, y: pt.y, text: pt.text });\n }\n });\n });\n\n // 2. Deduplicate by text (angle label)\n const uniqueTexts = Array.from(new Set(allLabels.map(l => l.text)));\n\n // 3. Place labels at equal angles\n const renderedLabels: React.JSX.Element[] = [];\n const placedPositions: { x: number; y: number }[] = [];\n const labelRadius = 0.7; // You can adjust this value for more/less offset\n const numLabels = uniqueTexts.length;\n\n uniqueTexts.forEach((text, i) => {\n const angle = ((2 * Math.PI) / numLabels) * i;\n const originXOffset = maybeLineOptions?.originXOffset || 0;\n const x = xAxisScale(labelRadius * Math.cos(angle) - originXOffset / 2);\n const y = yAxisScale(labelRadius * Math.sin(angle));\n\n // Check distance from all previously placed labels\n const isFarEnough = placedPositions.every(pos => Math.sqrt((x - pos.x) ** 2 + (y - pos.y) ** 2) >= minPixelGap);\n\n if (renderedLabels.length === 0 || isFarEnough) {\n renderedLabels.push(\n <text\n key={`scatterpolar-label-${text}`}\n x={x}\n y={y}\n className={className}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n opacity={1}\n >\n {text}\n </text>,\n );\n placedPositions.push({ x, y });\n }\n });\n\n return renderedLabels;\n}\n"]}
|
|
@@ -473,3 +473,9 @@ export declare const truncateString: (str: string, maxLength: number, ellipsis?:
|
|
|
473
473
|
export declare const sortAxisCategories: (categoryToValues: Record<string, number[]>, categoryOrder: AxisCategoryOrder | undefined) => string[];
|
|
474
474
|
export declare const getInvertedTextColor: (color: string, theme: ITheme | undefined) => string;
|
|
475
475
|
export declare function getContrastTextColor(backgroundColor: string, theme: ITheme): string;
|
|
476
|
+
/**
|
|
477
|
+
* Utility function to check if an array of points is scatterpolar
|
|
478
|
+
* @param points - Array of chart points
|
|
479
|
+
* @returns true if any point has lineOptions.mode as 'scatterpolar'
|
|
480
|
+
*/
|
|
481
|
+
export declare function isScatterPolarSeries(points: (ILineChartPoints | IScatterChartPoints)[]): boolean;
|
|
@@ -801,6 +801,7 @@ export function getXAxisType(points) {
|
|
|
801
801
|
* @returns {IDomainNRange}
|
|
802
802
|
*/
|
|
803
803
|
export function domainRangeOfNumericForAreaChart(points, margins, width, isRTL) {
|
|
804
|
+
var isScatterPolar = isScatterPolarSeries(points);
|
|
804
805
|
var xMin = d3Min(points, function (point) {
|
|
805
806
|
return d3Min(point.data, function (item) { return item.x; });
|
|
806
807
|
});
|
|
@@ -812,8 +813,8 @@ export function domainRangeOfNumericForAreaChart(points, margins, width, isRTL)
|
|
|
812
813
|
var rStartValue = margins.left;
|
|
813
814
|
var rEndValue = width - margins.right;
|
|
814
815
|
return isRTL
|
|
815
|
-
? { dStartValue: xMax, dEndValue: xMin, rStartValue: rStartValue, rEndValue: rEndValue }
|
|
816
|
-
: { dStartValue: xMin, dEndValue: xMax, rStartValue: rStartValue, rEndValue: rEndValue };
|
|
816
|
+
? { dStartValue: isScatterPolar ? 1 : xMax, dEndValue: isScatterPolar ? -1 : xMin, rStartValue: rStartValue, rEndValue: rEndValue }
|
|
817
|
+
: { dStartValue: isScatterPolar ? -1 : xMin, dEndValue: isScatterPolar ? 1 : xMax, rStartValue: rStartValue, rEndValue: rEndValue };
|
|
817
818
|
}
|
|
818
819
|
/**
|
|
819
820
|
* Groups HorizontalBarChart With Axis data based on YValue
|
|
@@ -1383,6 +1384,7 @@ export function domainRangeOfDateForScatterChart(points, margins, width, isRTL,
|
|
|
1383
1384
|
* @returns {IDomainNRange}
|
|
1384
1385
|
*/
|
|
1385
1386
|
export function domainRangeOfNumericForScatterChart(points, margins, width, isRTL) {
|
|
1387
|
+
var isScatterPolar = isScatterPolarSeries(points);
|
|
1386
1388
|
var xMin = d3Min(points, function (point) {
|
|
1387
1389
|
return d3Min(point.data, function (item) { return item.x; });
|
|
1388
1390
|
});
|
|
@@ -1397,8 +1399,8 @@ export function domainRangeOfNumericForScatterChart(points, margins, width, isRT
|
|
|
1397
1399
|
var rStartValue = margins.left;
|
|
1398
1400
|
var rEndValue = width - margins.right;
|
|
1399
1401
|
return isRTL
|
|
1400
|
-
? { dStartValue: xMax, dEndValue: xMin, rStartValue: rStartValue, rEndValue: rEndValue }
|
|
1401
|
-
: { dStartValue: xMin, dEndValue: xMax, rStartValue: rStartValue, rEndValue: rEndValue };
|
|
1402
|
+
? { dStartValue: isScatterPolar ? 1 : xMax, dEndValue: isScatterPolar ? -1 : xMin, rStartValue: rStartValue, rEndValue: rEndValue }
|
|
1403
|
+
: { dStartValue: isScatterPolar ? -1 : xMin, dEndValue: isScatterPolar ? 1 : xMax, rStartValue: rStartValue, rEndValue: rEndValue };
|
|
1402
1404
|
}
|
|
1403
1405
|
export var truncateString = function (str, maxLength, ellipsis) {
|
|
1404
1406
|
if (ellipsis === void 0) { ellipsis = '...'; }
|
|
@@ -1477,4 +1479,14 @@ export function getContrastTextColor(backgroundColor, theme) {
|
|
|
1477
1479
|
}
|
|
1478
1480
|
return textColor;
|
|
1479
1481
|
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Utility function to check if an array of points is scatterpolar
|
|
1484
|
+
* @param points - Array of chart points
|
|
1485
|
+
* @returns true if any point has lineOptions.mode as 'scatterpolar'
|
|
1486
|
+
*/
|
|
1487
|
+
export function isScatterPolarSeries(points) {
|
|
1488
|
+
return points.some(
|
|
1489
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1490
|
+
function (item) { var _a; return typeof ((_a = item.lineOptions) === null || _a === void 0 ? void 0 : _a.mode) === 'string' && item.lineOptions.mode === 'scatterpolar'; });
|
|
1491
|
+
}
|
|
1480
1492
|
//# sourceMappingURL=utilities.js.map
|