@redsift/charts 9.2.3 → 9.2.4
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/{dist/index.js → index.js} +2 -1
- package/index.js.map +1 -0
- package/package.json +3 -2
- package/coverage/clover.xml +0 -1096
- package/coverage/coverage-final.json +0 -60
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/components/Arc/Arc.tsx.html +0 -304
- package/coverage/lcov-report/components/Arc/index.html +0 -146
- package/coverage/lcov-report/components/Arc/index.ts.html +0 -94
- package/coverage/lcov-report/components/Arc/styles.ts.html +0 -208
- package/coverage/lcov-report/components/Arcs/Arcs.tsx.html +0 -409
- package/coverage/lcov-report/components/Arcs/index.html +0 -146
- package/coverage/lcov-report/components/Arcs/index.ts.html +0 -94
- package/coverage/lcov-report/components/Arcs/styles.ts.html +0 -106
- package/coverage/lcov-report/components/Axis/Axis.tsx.html +0 -754
- package/coverage/lcov-report/components/Axis/computeTicks.ts.html +0 -481
- package/coverage/lcov-report/components/Axis/index.html +0 -176
- package/coverage/lcov-report/components/Axis/index.ts.html +0 -94
- package/coverage/lcov-report/components/Axis/styles.ts.html +0 -148
- package/coverage/lcov-report/components/Axis/types.ts.html +0 -253
- package/coverage/lcov-report/components/Bar/Bar.tsx.html +0 -421
- package/coverage/lcov-report/components/Bar/index.html +0 -161
- package/coverage/lcov-report/components/Bar/index.ts.html +0 -94
- package/coverage/lcov-report/components/Bar/styles.ts.html +0 -247
- package/coverage/lcov-report/components/Bar/types.ts.html +0 -178
- package/coverage/lcov-report/components/BarChart/BarChart.tsx.html +0 -352
- package/coverage/lcov-report/components/BarChart/EmptyBarChart.tsx.html +0 -259
- package/coverage/lcov-report/components/BarChart/LoadingBarChart.tsx.html +0 -145
- package/coverage/lcov-report/components/BarChart/RenderedBarChart.tsx.html +0 -430
- package/coverage/lcov-report/components/BarChart/index.html +0 -206
- package/coverage/lcov-report/components/BarChart/index.ts.html +0 -94
- package/coverage/lcov-report/components/BarChart/styles.ts.html +0 -190
- package/coverage/lcov-report/components/BarChart/utils.ts.html +0 -145
- package/coverage/lcov-report/components/BottomAxis/BottomAxis.tsx.html +0 -247
- package/coverage/lcov-report/components/BottomAxis/index.html +0 -146
- package/coverage/lcov-report/components/BottomAxis/index.ts.html +0 -94
- package/coverage/lcov-report/components/BottomAxis/styles.ts.html +0 -139
- package/coverage/lcov-report/components/ChartContainer/ChartContainer.tsx.html +0 -361
- package/coverage/lcov-report/components/ChartContainer/index.html +0 -146
- package/coverage/lcov-report/components/ChartContainer/index.ts.html +0 -94
- package/coverage/lcov-report/components/ChartContainer/intl/index.html +0 -116
- package/coverage/lcov-report/components/ChartContainer/intl/index.ts.html +0 -106
- package/coverage/lcov-report/components/ChartContainer/styles.ts.html +0 -208
- package/coverage/lcov-report/components/DataPoint/DataPoint.tsx.html +0 -391
- package/coverage/lcov-report/components/DataPoint/index.html +0 -146
- package/coverage/lcov-report/components/DataPoint/index.ts.html +0 -94
- package/coverage/lcov-report/components/DataPoint/styles.ts.html +0 -109
- package/coverage/lcov-report/components/Dot/Dot.tsx.html +0 -232
- package/coverage/lcov-report/components/Dot/index.html +0 -146
- package/coverage/lcov-report/components/Dot/index.ts.html +0 -94
- package/coverage/lcov-report/components/Dot/styles.ts.html +0 -184
- package/coverage/lcov-report/components/HorizontalBar/HorizontalBar.tsx.html +0 -541
- package/coverage/lcov-report/components/HorizontalBar/index.html +0 -161
- package/coverage/lcov-report/components/HorizontalBar/index.ts.html +0 -94
- package/coverage/lcov-report/components/HorizontalBar/styles.ts.html +0 -187
- package/coverage/lcov-report/components/HorizontalBar/types.ts.html +0 -301
- package/coverage/lcov-report/components/HorizontalBarChart/HorizontalBarChart.tsx.html +0 -691
- package/coverage/lcov-report/components/HorizontalBarChart/index.html +0 -146
- package/coverage/lcov-report/components/HorizontalBarChart/index.ts.html +0 -94
- package/coverage/lcov-report/components/HorizontalBarChart/styles.ts.html +0 -196
- package/coverage/lcov-report/components/HorizontalBarChart/types.ts.html +0 -301
- package/coverage/lcov-report/components/Legend/Legend.tsx.html +0 -268
- package/coverage/lcov-report/components/Legend/index.html +0 -146
- package/coverage/lcov-report/components/Legend/index.ts.html +0 -94
- package/coverage/lcov-report/components/Legend/styles.ts.html +0 -130
- package/coverage/lcov-report/components/LegendItem/LegendItem.tsx.html +0 -325
- package/coverage/lcov-report/components/LegendItem/index.html +0 -146
- package/coverage/lcov-report/components/LegendItem/index.ts.html +0 -94
- package/coverage/lcov-report/components/LegendItem/styles.ts.html +0 -205
- package/coverage/lcov-report/components/PieChart/EmptyPieChart.tsx.html +0 -343
- package/coverage/lcov-report/components/PieChart/LoadingPieChart.tsx.html +0 -145
- package/coverage/lcov-report/components/PieChart/PieChart.tsx.html +0 -385
- package/coverage/lcov-report/components/PieChart/RenderedPieChart.tsx.html +0 -607
- package/coverage/lcov-report/components/PieChart/index.html +0 -221
- package/coverage/lcov-report/components/PieChart/index.ts.html +0 -94
- package/coverage/lcov-report/components/PieChart/styles.ts.html +0 -370
- package/coverage/lcov-report/components/PieChart/types.ts.html +0 -367
- package/coverage/lcov-report/components/PieChart/utils.ts.html +0 -199
- package/coverage/lcov-report/components/ScatterPlot/EmptyScatterPlot.tsx.html +0 -295
- package/coverage/lcov-report/components/ScatterPlot/LoadingScatterPlot.tsx.html +0 -145
- package/coverage/lcov-report/components/ScatterPlot/RenderedScatterPlot.tsx.html +0 -1048
- package/coverage/lcov-report/components/ScatterPlot/ScatterPlot.tsx.html +0 -367
- package/coverage/lcov-report/components/ScatterPlot/index.html +0 -221
- package/coverage/lcov-report/components/ScatterPlot/index.ts.html +0 -94
- package/coverage/lcov-report/components/ScatterPlot/styles.ts.html +0 -190
- package/coverage/lcov-report/components/ScatterPlot/types.ts.html +0 -394
- package/coverage/lcov-report/components/ScatterPlot/utils.ts.html +0 -388
- package/coverage/lcov-report/core/Arc/Arc.tsx.html +0 -304
- package/coverage/lcov-report/core/Arc/index.html +0 -146
- package/coverage/lcov-report/core/Arc/index.ts.html +0 -94
- package/coverage/lcov-report/core/Arc/styles.ts.html +0 -202
- package/coverage/lcov-report/core/Arcs/Arcs.tsx.html +0 -421
- package/coverage/lcov-report/core/Arcs/index.html +0 -146
- package/coverage/lcov-report/core/Arcs/index.ts.html +0 -94
- package/coverage/lcov-report/core/Arcs/styles.ts.html +0 -106
- package/coverage/lcov-report/core/Axis/Axis.tsx.html +0 -754
- package/coverage/lcov-report/core/Axis/computeTicks.ts.html +0 -481
- package/coverage/lcov-report/core/Axis/index.html +0 -176
- package/coverage/lcov-report/core/Axis/index.ts.html +0 -94
- package/coverage/lcov-report/core/Axis/styles.ts.html +0 -145
- package/coverage/lcov-report/core/Axis/types.ts.html +0 -253
- package/coverage/lcov-report/core/Bar/Bar.tsx.html +0 -421
- package/coverage/lcov-report/core/Bar/index.html +0 -161
- package/coverage/lcov-report/core/Bar/index.ts.html +0 -94
- package/coverage/lcov-report/core/Bar/styles.ts.html +0 -190
- package/coverage/lcov-report/core/Bar/types.ts.html +0 -178
- package/coverage/lcov-report/core/BottomAxis/BottomAxis.tsx.html +0 -277
- package/coverage/lcov-report/core/BottomAxis/index.html +0 -146
- package/coverage/lcov-report/core/BottomAxis/index.ts.html +0 -94
- package/coverage/lcov-report/core/BottomAxis/styles.ts.html +0 -139
- package/coverage/lcov-report/core/ChartConfig/ChartConfig.ts.html +0 -97
- package/coverage/lcov-report/core/ChartConfig/index.html +0 -131
- package/coverage/lcov-report/core/ChartConfig/index.ts.html +0 -88
- package/coverage/lcov-report/core/ChartContainer/ChartContainer.tsx.html +0 -421
- package/coverage/lcov-report/core/ChartContainer/index.html +0 -146
- package/coverage/lcov-report/core/ChartContainer/index.ts.html +0 -94
- package/coverage/lcov-report/core/ChartContainer/intl/index.html +0 -116
- package/coverage/lcov-report/core/ChartContainer/intl/index.ts.html +0 -106
- package/coverage/lcov-report/core/ChartContainer/styles.ts.html +0 -205
- package/coverage/lcov-report/core/DataPoint/DataPoint.tsx.html +0 -442
- package/coverage/lcov-report/core/DataPoint/index.html +0 -146
- package/coverage/lcov-report/core/DataPoint/index.ts.html +0 -94
- package/coverage/lcov-report/core/DataPoint/styles.ts.html +0 -109
- package/coverage/lcov-report/core/Dot/Dot.tsx.html +0 -232
- package/coverage/lcov-report/core/Dot/index.html +0 -146
- package/coverage/lcov-report/core/Dot/index.ts.html +0 -94
- package/coverage/lcov-report/core/Dot/styles.ts.html +0 -184
- package/coverage/lcov-report/core/Legend/Legend.tsx.html +0 -277
- package/coverage/lcov-report/core/Legend/index.html +0 -146
- package/coverage/lcov-report/core/Legend/index.ts.html +0 -94
- package/coverage/lcov-report/core/Legend/styles.ts.html +0 -172
- package/coverage/lcov-report/core/Point/Point.tsx.html +0 -484
- package/coverage/lcov-report/core/Point/index.html +0 -146
- package/coverage/lcov-report/core/Point/index.ts.html +0 -94
- package/coverage/lcov-report/core/Point/styles.ts.html +0 -169
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/gallery/HorizontalBarChart/HorizontalBarChart.tsx.html +0 -706
- package/coverage/lcov-report/gallery/HorizontalBarChart/index.html +0 -161
- package/coverage/lcov-report/gallery/HorizontalBarChart/index.ts.html +0 -94
- package/coverage/lcov-report/gallery/HorizontalBarChart/styles.ts.html +0 -316
- package/coverage/lcov-report/gallery/HorizontalBarChart/types.ts.html +0 -310
- package/coverage/lcov-report/gallery/PieChart/PieChart.tsx.html +0 -1252
- package/coverage/lcov-report/gallery/PieChart/index.html +0 -161
- package/coverage/lcov-report/gallery/PieChart/index.ts.html +0 -94
- package/coverage/lcov-report/gallery/PieChart/styles.ts.html +0 -517
- package/coverage/lcov-report/gallery/PieChart/types.ts.html +0 -388
- package/coverage/lcov-report/gallery/ScatterPlot/index.html +0 -146
- package/coverage/lcov-report/gallery/ScatterPlot/index.ts.html +0 -94
- package/coverage/lcov-report/gallery/ScatterPlot/styles.ts.html +0 -343
- package/coverage/lcov-report/gallery/ScatterPlot/types.ts.html +0 -433
- package/coverage/lcov-report/hooks/index.html +0 -176
- package/coverage/lcov-report/hooks/index.ts.html +0 -97
- package/coverage/lcov-report/hooks/useBrush.tsx.html +0 -430
- package/coverage/lcov-report/hooks/useColor.tsx.html +0 -163
- package/coverage/lcov-report/hooks/useFormatCategoricalData.tsx.html +0 -289
- package/coverage/lcov-report/hooks/useIsEmpty.tsx.html +0 -118
- package/coverage/lcov-report/hooks/useZoom.tsx.html +0 -235
- package/coverage/lcov-report/index.html +0 -311
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -2345
- package/coverage/storybook/coverage-storybook.json +0 -79382
- package/dist/index.js.map +0 -1
- package/dist/package.json +0 -98
- package/index.ts +0 -1
- package/jest.config.js +0 -3
- package/rollup.config.js +0 -13
- package/src/components/Arc/Arc.test.tsx +0 -80
- package/src/components/Arc/Arc.tsx +0 -73
- package/src/components/Arc/index.ts +0 -3
- package/src/components/Arc/styles.ts +0 -41
- package/src/components/Arc/types.ts +0 -18
- package/src/components/Arcs/Arcs.stories.tsx +0 -177
- package/src/components/Arcs/Arcs.tsx +0 -108
- package/src/components/Arcs/index.ts +0 -3
- package/src/components/Arcs/styles.ts +0 -7
- package/src/components/Arcs/types.ts +0 -26
- package/src/components/Axis/Axis.stories.tsx +0 -297
- package/src/components/Axis/Axis.tsx +0 -223
- package/src/components/Axis/computeTicks.ts +0 -132
- package/src/components/Axis/index.ts +0 -3
- package/src/components/Axis/styles.ts +0 -21
- package/src/components/Axis/types.ts +0 -56
- package/src/components/Bar/Bar.stories.tsx +0 -152
- package/src/components/Bar/Bar.test.tsx +0 -156
- package/src/components/Bar/Bar.tsx +0 -112
- package/src/components/Bar/index.ts +0 -3
- package/src/components/Bar/styles.ts +0 -54
- package/src/components/Bar/types.ts +0 -31
- package/src/components/BarChart/BarChart.stories.tsx +0 -74
- package/src/components/BarChart/BarChart.test.tsx +0 -178
- package/src/components/BarChart/BarChart.tsx +0 -89
- package/src/components/BarChart/EmptyBarChart.tsx +0 -58
- package/src/components/BarChart/LoadingBarChart.tsx +0 -20
- package/src/components/BarChart/RenderedBarChart.tsx +0 -115
- package/src/components/BarChart/__snapshots__/BarChart.test.tsx.snap +0 -7028
- package/src/components/BarChart/index.ts +0 -3
- package/src/components/BarChart/styles.ts +0 -35
- package/src/components/BarChart/types.ts +0 -58
- package/src/components/BarChart/utils.ts +0 -20
- package/src/components/ChartContainer/ChartContainer.stories.tsx +0 -81
- package/src/components/ChartContainer/ChartContainer.test.tsx +0 -71
- package/src/components/ChartContainer/ChartContainer.tsx +0 -92
- package/src/components/ChartContainer/index.ts +0 -3
- package/src/components/ChartContainer/intl/en-US.json +0 -3
- package/src/components/ChartContainer/intl/fr-FR.json +0 -3
- package/src/components/ChartContainer/intl/index.ts +0 -7
- package/src/components/ChartContainer/styles.ts +0 -41
- package/src/components/ChartContainer/types.ts +0 -26
- package/src/components/DataPoint/DataPoint.tsx +0 -102
- package/src/components/DataPoint/index.ts +0 -3
- package/src/components/DataPoint/styles.ts +0 -8
- package/src/components/DataPoint/types.ts +0 -33
- package/src/components/Dot/Dot.stories.tsx +0 -157
- package/src/components/Dot/Dot.test.tsx +0 -136
- package/src/components/Dot/Dot.tsx +0 -49
- package/src/components/Dot/index.ts +0 -3
- package/src/components/Dot/styles.ts +0 -33
- package/src/components/Dot/types.ts +0 -16
- package/src/components/Legend/Legend.stories.tsx +0 -108
- package/src/components/Legend/Legend.tsx +0 -61
- package/src/components/Legend/index.ts +0 -3
- package/src/components/Legend/styles.ts +0 -15
- package/src/components/Legend/types.ts +0 -27
- package/src/components/LegendItem/LegendItem.test.tsx +0 -69
- package/src/components/LegendItem/LegendItem.tsx +0 -80
- package/src/components/LegendItem/index.ts +0 -3
- package/src/components/LegendItem/styles.ts +0 -40
- package/src/components/LegendItem/types.ts +0 -30
- package/src/components/PieChart/EmptyPieChart.tsx +0 -86
- package/src/components/PieChart/LoadingPieChart.tsx +0 -20
- package/src/components/PieChart/PieChart.stories.tsx +0 -85
- package/src/components/PieChart/PieChart.test.tsx +0 -183
- package/src/components/PieChart/PieChart.tsx +0 -100
- package/src/components/PieChart/RenderedPieChart.tsx +0 -174
- package/src/components/PieChart/__snapshots__/PieChart.test.tsx.snap +0 -21020
- package/src/components/PieChart/index.ts +0 -3
- package/src/components/PieChart/styles.ts +0 -95
- package/src/components/PieChart/types.ts +0 -94
- package/src/components/PieChart/utils.ts +0 -38
- package/src/components/ScatterPlot/EmptyScatterPlot.tsx +0 -70
- package/src/components/ScatterPlot/LoadingScatterPlot.tsx +0 -20
- package/src/components/ScatterPlot/RenderedScatterPlot.tsx +0 -321
- package/src/components/ScatterPlot/ScatterPlot.stories.tsx +0 -101
- package/src/components/ScatterPlot/ScatterPlot.test.tsx +0 -61
- package/src/components/ScatterPlot/ScatterPlot.tsx +0 -94
- package/src/components/ScatterPlot/__snapshots__/ScatterPlot.test.tsx.snap +0 -91712
- package/src/components/ScatterPlot/index.ts +0 -3
- package/src/components/ScatterPlot/styles.ts +0 -35
- package/src/components/ScatterPlot/types.ts +0 -103
- package/src/components/ScatterPlot/utils.ts +0 -101
- package/src/config.ts +0 -10
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useBrush.tsx +0 -115
- package/src/hooks/useColor.tsx +0 -26
- package/src/hooks/useFormatCategoricalData.tsx +0 -68
- package/src/hooks/useZoom.tsx +0 -50
- package/src/index.ts +0 -15
- package/src/scheme.ts +0 -213
- package/src/types/data.ts +0 -52
- package/src/types/index.ts +0 -5
- package/src/types/legend.ts +0 -19
- package/src/types/scale.ts +0 -79
- package/src/types/size.ts +0 -17
- package/src/types/theme.ts +0 -27
- package/tsconfig.json +0 -3
- /package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, RefObject, useEffect, useRef } from 'react';
|
|
2
|
-
import { arc as d3arc, pie as d3pie, sum as d3sum } from 'd3';
|
|
3
|
-
|
|
4
|
-
import { LabelVariant, ArcDatum, CategoryData, CategoryDatum } from '../../types';
|
|
5
|
-
import { PieChartLabelVariant, PieChartProps, PieChartVariant } from './types';
|
|
6
|
-
import { StyledPieChartCenterText, StyledPieChart } from './styles';
|
|
7
|
-
import { Arcs } from '../Arcs';
|
|
8
|
-
import { useFormatCategoricalData } from '../../hooks';
|
|
9
|
-
import { Legend } from '../Legend';
|
|
10
|
-
import { sizeToDimension } from './utils';
|
|
11
|
-
import { PieChart } from './PieChart';
|
|
12
|
-
|
|
13
|
-
interface RenderedPieChartProps extends Required<Pick<PieChartProps, 'data'>>, Omit<PieChartProps, 'data'> {}
|
|
14
|
-
|
|
15
|
-
export const RenderedPieChart = forwardRef<HTMLDivElement, RenderedPieChartProps>((props, ref) => {
|
|
16
|
-
const {
|
|
17
|
-
caping,
|
|
18
|
-
className,
|
|
19
|
-
data: propsData,
|
|
20
|
-
id,
|
|
21
|
-
isSliceSelected,
|
|
22
|
-
labelDecorator,
|
|
23
|
-
labelVariant,
|
|
24
|
-
legendProps,
|
|
25
|
-
middleText: propsMiddleText,
|
|
26
|
-
onSliceClick,
|
|
27
|
-
others,
|
|
28
|
-
size,
|
|
29
|
-
sliceProps,
|
|
30
|
-
sliceRole,
|
|
31
|
-
subtext: propsSubtext,
|
|
32
|
-
text: propsText,
|
|
33
|
-
theme,
|
|
34
|
-
tooltipVariant,
|
|
35
|
-
variant,
|
|
36
|
-
...forwardedProps
|
|
37
|
-
} = props;
|
|
38
|
-
|
|
39
|
-
const cache = useRef<CategoryData>();
|
|
40
|
-
|
|
41
|
-
const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
|
|
42
|
-
|
|
43
|
-
const { data, colorScale } = useFormatCategoricalData({
|
|
44
|
-
data: propsData,
|
|
45
|
-
theme: theme!,
|
|
46
|
-
caping,
|
|
47
|
-
others,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
cache.current = data;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const { width, height, smallFontSize, fontSize, innerRadius } = sizeToDimension(size!);
|
|
55
|
-
const externalRadiusPadding = 8;
|
|
56
|
-
|
|
57
|
-
const createPie = d3pie<CategoryDatum>()
|
|
58
|
-
.value((d) => d.value)
|
|
59
|
-
.sort(null);
|
|
60
|
-
const createArc = d3arc<ArcDatum>()
|
|
61
|
-
.innerRadius(isDonut ? innerRadius : 0)
|
|
62
|
-
.outerRadius(width / 2 - externalRadiusPadding);
|
|
63
|
-
const pieData = createPie(data);
|
|
64
|
-
const previousPieData = cache.current ? createPie(cache.current) : undefined;
|
|
65
|
-
const total = d3sum(data, (d) => d.value);
|
|
66
|
-
const legendWidth = useRef<string>();
|
|
67
|
-
if (data && !legendWidth.current) {
|
|
68
|
-
legendWidth.current = `${Math.max(...data.map((d) => d.key.length + String(d.value).length)) * 8 + 32}px`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const text =
|
|
72
|
-
typeof propsText === 'function'
|
|
73
|
-
? propsText(
|
|
74
|
-
pieData.map((datum) => {
|
|
75
|
-
const percent = datum.data.value / total;
|
|
76
|
-
return { ...datum, data: { ...datum.data, percent } };
|
|
77
|
-
}),
|
|
78
|
-
total
|
|
79
|
-
)
|
|
80
|
-
: propsText;
|
|
81
|
-
const subtext =
|
|
82
|
-
typeof propsSubtext === 'function'
|
|
83
|
-
? propsSubtext(
|
|
84
|
-
pieData.map((datum) => {
|
|
85
|
-
const percent = datum.data.value / total;
|
|
86
|
-
return { ...datum, data: { ...datum.data, percent } };
|
|
87
|
-
}),
|
|
88
|
-
total
|
|
89
|
-
)
|
|
90
|
-
: propsSubtext;
|
|
91
|
-
const middleText =
|
|
92
|
-
typeof propsMiddleText === 'function'
|
|
93
|
-
? propsMiddleText(
|
|
94
|
-
pieData.map((datum) => {
|
|
95
|
-
const percent = datum.data.value / total;
|
|
96
|
-
return { ...datum, data: { ...datum.data, percent } };
|
|
97
|
-
}),
|
|
98
|
-
total
|
|
99
|
-
)
|
|
100
|
-
: propsMiddleText;
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<StyledPieChart {...forwardedProps} className={className} id={id} ref={ref as RefObject<HTMLDivElement>}>
|
|
104
|
-
<div className={`${PieChart.className}__chart-wrapper`}>
|
|
105
|
-
{text ? (
|
|
106
|
-
<StyledPieChartCenterText $maxWidth={innerRadius * 2} $textSize={fontSize} $smallTextSize={smallFontSize}>
|
|
107
|
-
{subtext ? <b>{text}</b> : <span>{text}</span>}
|
|
108
|
-
{middleText ? <b>{middleText}</b> : null}
|
|
109
|
-
<span>{subtext}</span>
|
|
110
|
-
</StyledPieChartCenterText>
|
|
111
|
-
) : null}
|
|
112
|
-
<svg width={width} height={height}>
|
|
113
|
-
<Arcs
|
|
114
|
-
arcs={pieData
|
|
115
|
-
.filter((datum) => datum.data.value)
|
|
116
|
-
.map((datum, index) => {
|
|
117
|
-
const percent = datum.data.value / total;
|
|
118
|
-
const from = previousPieData
|
|
119
|
-
? previousPieData[index]
|
|
120
|
-
: {
|
|
121
|
-
data: {
|
|
122
|
-
key: '',
|
|
123
|
-
value: 0,
|
|
124
|
-
},
|
|
125
|
-
startAngle: 0,
|
|
126
|
-
endAngle: 0,
|
|
127
|
-
padAngle: 0,
|
|
128
|
-
value: 0,
|
|
129
|
-
index: index,
|
|
130
|
-
};
|
|
131
|
-
const to = { ...datum, data: { ...datum.data, percent } };
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
color: colorScale?.(to.data.key),
|
|
135
|
-
createArc,
|
|
136
|
-
previousData: from,
|
|
137
|
-
id: `id${id}__bar-${index}`,
|
|
138
|
-
index,
|
|
139
|
-
isSelected: isSliceSelected!(to),
|
|
140
|
-
key: `id${id}__bar-${index}`,
|
|
141
|
-
data: to,
|
|
142
|
-
};
|
|
143
|
-
})}
|
|
144
|
-
hasLabels={labelVariant === PieChartLabelVariant.internal}
|
|
145
|
-
hasStroke={variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut}
|
|
146
|
-
labelDecorator={labelDecorator}
|
|
147
|
-
onClick={onSliceClick}
|
|
148
|
-
role={sliceRole}
|
|
149
|
-
sliceProps={sliceProps}
|
|
150
|
-
tooltipVariant={tooltipVariant}
|
|
151
|
-
transform={`translate(${width / 2} ${height / 2})`}
|
|
152
|
-
/>
|
|
153
|
-
</svg>
|
|
154
|
-
</div>
|
|
155
|
-
{labelVariant !== PieChartLabelVariant.none && labelVariant !== PieChartLabelVariant.internal ? (
|
|
156
|
-
<Legend
|
|
157
|
-
data={data.map((d) => ({
|
|
158
|
-
...d,
|
|
159
|
-
color: colorScale?.(d.key)!,
|
|
160
|
-
}))}
|
|
161
|
-
variant={
|
|
162
|
-
labelVariant === PieChartLabelVariant.externalLabelValue
|
|
163
|
-
? LabelVariant.value
|
|
164
|
-
: labelVariant === PieChartLabelVariant.externalLabelPercent
|
|
165
|
-
? LabelVariant.percent
|
|
166
|
-
: LabelVariant.label
|
|
167
|
-
}
|
|
168
|
-
width={legendWidth.current}
|
|
169
|
-
{...legendProps}
|
|
170
|
-
/>
|
|
171
|
-
) : null}
|
|
172
|
-
</StyledPieChart>
|
|
173
|
-
);
|
|
174
|
-
});
|