@redsift/charts 8.0.1 → 8.0.2
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.d.ts → index.d.ts} +8 -0
- package/{dist/index.js → index.js} +97 -25
- package/index.js.map +1 -0
- package/package.json +3 -2
- package/coverage/clover.xml +0 -1070
- package/coverage/coverage-final.json +0 -60
- package/coverage/lcov-report/ChartEmptyState/ChartEmptyState.tsx.html +0 -679
- package/coverage/lcov-report/ChartEmptyState/index.html +0 -146
- package/coverage/lcov-report/ChartEmptyState/index.ts.html +0 -91
- package/coverage/lcov-report/ChartEmptyState/styles.ts.html +0 -184
- package/coverage/lcov-report/HorizontalBarChart/HorizontalBarChart.tsx.html +0 -775
- package/coverage/lcov-report/HorizontalBarChart/HorizontalBarChartAxisBottom.tsx.html +0 -259
- package/coverage/lcov-report/HorizontalBarChart/HorizontalBarChartBar.tsx.html +0 -421
- package/coverage/lcov-report/HorizontalBarChart/index.html +0 -191
- package/coverage/lcov-report/HorizontalBarChart/index.ts.html +0 -94
- package/coverage/lcov-report/HorizontalBarChart/styles.ts.html +0 -451
- package/coverage/lcov-report/HorizontalBarChart/types.ts.html +0 -433
- package/coverage/lcov-report/PieChart/PieChart.tsx.html +0 -1105
- package/coverage/lcov-report/PieChart/PieChartArc.tsx.html +0 -412
- package/coverage/lcov-report/PieChart/index.html +0 -176
- package/coverage/lcov-report/PieChart/index.ts.html +0 -94
- package/coverage/lcov-report/PieChart/styles.ts.html +0 -616
- package/coverage/lcov-report/PieChart/types.ts.html +0 -472
- package/coverage/lcov-report/PieChart.tsx.html +0 -1045
- package/coverage/lcov-report/PieChartArc.tsx.html +0 -271
- package/coverage/lcov-report/StaticPieChart.tsx.html +0 -286
- 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 -427
- 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 -355
- 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 -496
- 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/ChartContainer/ChartContainer.tsx.html +0 -433
- 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 -211
- package/coverage/lcov-report/components/DataPoint/DataPoint.tsx.html +0 -442
- 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/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 -403
- 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 -388
- package/coverage/lcov-report/components/PieChart/RenderedPieChart.tsx.html +0 -571
- 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 -376
- package/coverage/lcov-report/components/PieChart/types.ts.html +0 -352
- 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 -910
- package/coverage/lcov-report/components/ScatterPlot/ScatterPlot.tsx.html +0 -379
- 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 -196
- package/coverage/lcov-report/components/ScatterPlot/types.ts.html +0 -376
- package/coverage/lcov-report/components/ScatterPlot/utils.ts.html +0 -388
- package/coverage/lcov-report/favicon.png +0 -0
- 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/useZoom.tsx.html +0 -235
- package/coverage/lcov-report/index.html +0 -311
- package/coverage/lcov-report/index.ts.html +0 -94
- 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-report/styles.ts.html +0 -631
- package/coverage/lcov-report/types.ts.html +0 -457
- package/coverage/lcov.info +0 -2272
- 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 -92
- 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 -114
- 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 -158
- 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 -80
- package/src/components/BarChart/BarChart.test.tsx +0 -189
- package/src/components/BarChart/BarChart.tsx +0 -90
- package/src/components/BarChart/EmptyBarChart.tsx +0 -58
- package/src/components/BarChart/LoadingBarChart.tsx +0 -20
- package/src/components/BarChart/RenderedBarChart.tsx +0 -137
- package/src/components/BarChart/__snapshots__/BarChart.test.tsx.snap +0 -6932
- 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 -75
- package/src/components/ChartContainer/ChartContainer.tsx +0 -116
- 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 -42
- package/src/components/ChartContainer/types.ts +0 -24
- package/src/components/DataPoint/DataPoint.tsx +0 -119
- 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 -106
- 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 -91
- package/src/components/PieChart/PieChart.test.tsx +0 -201
- package/src/components/PieChart/PieChart.tsx +0 -101
- package/src/components/PieChart/RenderedPieChart.tsx +0 -162
- package/src/components/PieChart/__snapshots__/PieChart.stories.storyshot +0 -7843
- package/src/components/PieChart/__snapshots__/PieChart.test.tsx.snap +0 -20540
- package/src/components/PieChart/index.ts +0 -3
- package/src/components/PieChart/styles.ts +0 -97
- package/src/components/PieChart/types.ts +0 -89
- 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 -275
- package/src/components/ScatterPlot/ScatterPlot.stories.tsx +0 -95
- package/src/components/ScatterPlot/ScatterPlot.test.tsx +0 -44
- package/src/components/ScatterPlot/ScatterPlot.tsx +0 -98
- package/src/components/ScatterPlot/__snapshots__/ScatterPlot.test.tsx.snap +0 -88352
- package/src/components/ScatterPlot/index.ts +0 -3
- package/src/components/ScatterPlot/styles.ts +0 -37
- package/src/components/ScatterPlot/types.ts +0 -97
- 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 -221
- 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
|
@@ -1,162 +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 {
|
|
5
|
-
LabelVariant,
|
|
6
|
-
ArcDatum,
|
|
7
|
-
CategoryData,
|
|
8
|
-
CategoryDatum,
|
|
9
|
-
} from '../../types';
|
|
10
|
-
import { PieChartLabelVariant, PieChartProps, PieChartVariant } from './types';
|
|
11
|
-
import { StyledPieChartCenterText, StyledPieChart } from './styles';
|
|
12
|
-
import { Arcs } from '../Arcs';
|
|
13
|
-
import { useFormatCategoricalData } from '../../hooks';
|
|
14
|
-
import { Legend } from '../Legend';
|
|
15
|
-
import { sizeToDimension } from './utils';
|
|
16
|
-
import { PieChart } from './PieChart';
|
|
17
|
-
|
|
18
|
-
interface RenderedPieChartProps
|
|
19
|
-
extends Required<Pick<PieChartProps, 'data'>>,
|
|
20
|
-
Omit<PieChartProps, 'data'> {}
|
|
21
|
-
|
|
22
|
-
export const RenderedPieChart = forwardRef<
|
|
23
|
-
HTMLDivElement,
|
|
24
|
-
RenderedPieChartProps
|
|
25
|
-
>((props, ref) => {
|
|
26
|
-
const {
|
|
27
|
-
caping,
|
|
28
|
-
className,
|
|
29
|
-
data: propsData,
|
|
30
|
-
id,
|
|
31
|
-
isSliceSelected,
|
|
32
|
-
labelDecorator,
|
|
33
|
-
labelVariant,
|
|
34
|
-
middleText,
|
|
35
|
-
onSliceClick,
|
|
36
|
-
others,
|
|
37
|
-
size,
|
|
38
|
-
sliceProps,
|
|
39
|
-
sliceRole,
|
|
40
|
-
subtext,
|
|
41
|
-
text,
|
|
42
|
-
theme,
|
|
43
|
-
tooltipVariant,
|
|
44
|
-
variant,
|
|
45
|
-
...forwardedProps
|
|
46
|
-
} = props;
|
|
47
|
-
|
|
48
|
-
const cache = useRef<CategoryData>();
|
|
49
|
-
|
|
50
|
-
const isDonut =
|
|
51
|
-
variant === PieChartVariant.donut ||
|
|
52
|
-
variant === PieChartVariant.spacedDonut;
|
|
53
|
-
|
|
54
|
-
const { data, colorScale } = useFormatCategoricalData({
|
|
55
|
-
data: propsData,
|
|
56
|
-
theme: theme!,
|
|
57
|
-
caping,
|
|
58
|
-
others,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
cache.current = data;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const { width, height, smallFontSize, fontSize, innerRadius } =
|
|
66
|
-
sizeToDimension(size!);
|
|
67
|
-
const externalRadiusPadding = 8;
|
|
68
|
-
|
|
69
|
-
const createPie = d3pie<CategoryDatum>()
|
|
70
|
-
.value((d) => d.value)
|
|
71
|
-
.sort(null);
|
|
72
|
-
const createArc = d3arc<ArcDatum>()
|
|
73
|
-
.innerRadius(isDonut ? innerRadius : 0)
|
|
74
|
-
.outerRadius(width / 2 - externalRadiusPadding);
|
|
75
|
-
const pieData = createPie(data);
|
|
76
|
-
const previousPieData = cache.current ? createPie(cache.current) : undefined;
|
|
77
|
-
const total = d3sum(data, (d) => d.value);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<StyledPieChart
|
|
81
|
-
{...forwardedProps}
|
|
82
|
-
className={className}
|
|
83
|
-
id={id}
|
|
84
|
-
ref={ref as RefObject<HTMLDivElement>}
|
|
85
|
-
>
|
|
86
|
-
<div className={`${PieChart.className}__chart-wrapper`}>
|
|
87
|
-
{text ? (
|
|
88
|
-
<StyledPieChartCenterText
|
|
89
|
-
$maxWidth={innerRadius * 2}
|
|
90
|
-
$textSize={fontSize}
|
|
91
|
-
$smallTextSize={smallFontSize}
|
|
92
|
-
>
|
|
93
|
-
{subtext ? <b>{text}</b> : <span>{text}</span>}
|
|
94
|
-
{middleText ? <b>{middleText}</b> : null}
|
|
95
|
-
<span>{subtext}</span>
|
|
96
|
-
</StyledPieChartCenterText>
|
|
97
|
-
) : null}
|
|
98
|
-
<svg width={width} height={height}>
|
|
99
|
-
<Arcs
|
|
100
|
-
arcs={pieData
|
|
101
|
-
.filter((datum) => datum.data.value)
|
|
102
|
-
.map((datum, index) => {
|
|
103
|
-
const percent = datum.data.value / total;
|
|
104
|
-
const from = previousPieData
|
|
105
|
-
? previousPieData[index]
|
|
106
|
-
: {
|
|
107
|
-
data: {
|
|
108
|
-
key: '',
|
|
109
|
-
value: 0,
|
|
110
|
-
},
|
|
111
|
-
startAngle: 0,
|
|
112
|
-
endAngle: 0,
|
|
113
|
-
padAngle: 0,
|
|
114
|
-
value: 0,
|
|
115
|
-
index: index,
|
|
116
|
-
};
|
|
117
|
-
const to = { ...datum, data: { ...datum.data, percent } };
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
color: colorScale?.(to.data.key),
|
|
121
|
-
createArc,
|
|
122
|
-
previousData: from,
|
|
123
|
-
id: `id${id}__bar-${index}`,
|
|
124
|
-
index,
|
|
125
|
-
isSelected: isSliceSelected!(to),
|
|
126
|
-
key: `id${id}__bar-${index}`,
|
|
127
|
-
data: to,
|
|
128
|
-
};
|
|
129
|
-
})}
|
|
130
|
-
hasLabels={labelVariant === PieChartLabelVariant.internal}
|
|
131
|
-
hasStroke={
|
|
132
|
-
variant === PieChartVariant.spaced ||
|
|
133
|
-
variant === PieChartVariant.spacedDonut
|
|
134
|
-
}
|
|
135
|
-
labelDecorator={labelDecorator}
|
|
136
|
-
onClick={onSliceClick}
|
|
137
|
-
role={sliceRole}
|
|
138
|
-
sliceProps={sliceProps}
|
|
139
|
-
tooltipVariant={tooltipVariant}
|
|
140
|
-
transform={`translate(${width / 2} ${height / 2})`}
|
|
141
|
-
/>
|
|
142
|
-
</svg>
|
|
143
|
-
</div>
|
|
144
|
-
{labelVariant !== PieChartLabelVariant.none &&
|
|
145
|
-
labelVariant !== PieChartLabelVariant.internal ? (
|
|
146
|
-
<Legend
|
|
147
|
-
data={data.map((d) => ({
|
|
148
|
-
...d,
|
|
149
|
-
color: colorScale?.(d.key)!,
|
|
150
|
-
}))}
|
|
151
|
-
variant={
|
|
152
|
-
labelVariant === PieChartLabelVariant.externalLabelValue
|
|
153
|
-
? LabelVariant.value
|
|
154
|
-
: labelVariant === PieChartLabelVariant.externalLabelPercent
|
|
155
|
-
? LabelVariant.percent
|
|
156
|
-
: LabelVariant.label
|
|
157
|
-
}
|
|
158
|
-
/>
|
|
159
|
-
) : null}
|
|
160
|
-
</StyledPieChart>
|
|
161
|
-
);
|
|
162
|
-
});
|