@ssa-ui-kit/core 1.0.11 → 1.0.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/dist/components/PieChart/types.d.ts +3 -3
- package/dist/components/SegmentedPieChart/SegmentedPieChart.d.ts +1 -1
- package/dist/components/SegmentedPieChart/components/ChartTitle.d.ts +4 -0
- package/dist/components/SegmentedPieChart/components/ChartTooltip.d.ts +5 -0
- package/dist/components/SegmentedPieChart/components/LegendItem.d.ts +2 -0
- package/dist/components/SegmentedPieChart/components/index.d.ts +3 -0
- package/dist/components/SegmentedPieChart/hooks/index.d.ts +1 -0
- package/dist/components/SegmentedPieChart/hooks/useData.d.ts +5 -0
- package/dist/components/SegmentedPieChart/stories/fixtures.d.ts +5 -3
- package/dist/components/SegmentedPieChart/types.d.ts +29 -16
- package/dist/components/SegmentedPieChart/utils.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/PieChart/PieChart.stories.tsx +2 -2
- package/src/components/PieChart/types.ts +3 -3
- package/src/components/SegmentedPieChart/SegmentedPieChart.spec.tsx +11 -9
- package/src/components/SegmentedPieChart/SegmentedPieChart.tsx +38 -103
- package/src/components/SegmentedPieChart/components/ChartTitle.tsx +34 -0
- package/src/components/SegmentedPieChart/components/ChartTooltip.tsx +85 -0
- package/src/components/SegmentedPieChart/components/LegendItem.tsx +36 -0
- package/src/components/SegmentedPieChart/components/index.ts +3 -0
- package/src/components/SegmentedPieChart/hooks/index.ts +1 -0
- package/src/components/SegmentedPieChart/hooks/useData.ts +71 -0
- package/src/components/SegmentedPieChart/stories/SegmentedPieChart.stories.tsx +44 -7
- package/src/components/SegmentedPieChart/stories/fixtures.ts +72 -45
- package/src/components/SegmentedPieChart/types.ts +37 -16
- package/src/components/SegmentedPieChart/utils.ts +2 -0
- package/tsbuildcache +1 -1
|
@@ -1,147 +1,174 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SegmentedDataSet } from '../types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const RATE = {
|
|
4
|
+
BTC: 63972.97,
|
|
5
|
+
ETH: 2649.84,
|
|
6
|
+
FDUSD: 0.9991,
|
|
7
|
+
USDT: 1,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const balanceData: SegmentedDataSet = [
|
|
4
11
|
{
|
|
5
12
|
id: 1,
|
|
6
13
|
value: 5843.37,
|
|
14
|
+
legendValue: 5843.37 / RATE.BTC,
|
|
15
|
+
legendLabel: 'BTC',
|
|
7
16
|
label: 'BTC',
|
|
8
|
-
|
|
17
|
+
legendValueRoundingDigits: 6,
|
|
9
18
|
parts: [
|
|
10
19
|
{
|
|
11
|
-
label: '
|
|
12
|
-
percentage: 13,
|
|
20
|
+
label: 'Option 1',
|
|
13
21
|
value: 2300,
|
|
22
|
+
legendValue: 2300 / RATE.BTC,
|
|
14
23
|
},
|
|
15
24
|
{
|
|
16
|
-
label: '
|
|
17
|
-
percentage: 10,
|
|
25
|
+
label: 'Option 2',
|
|
18
26
|
value: 1800,
|
|
27
|
+
legendValue: 1800 / RATE.BTC,
|
|
19
28
|
},
|
|
20
29
|
{
|
|
21
|
-
label: '
|
|
22
|
-
percentage: 10,
|
|
30
|
+
label: 'Option 3',
|
|
23
31
|
value: 1743.37,
|
|
32
|
+
legendValue: 1743.37 / RATE.BTC,
|
|
24
33
|
},
|
|
25
34
|
],
|
|
26
35
|
},
|
|
27
36
|
{
|
|
28
37
|
id: 2,
|
|
29
38
|
value: 5249.25,
|
|
39
|
+
legendValue: 5249.25 / RATE.ETH,
|
|
40
|
+
legendLabel: 'ETH',
|
|
30
41
|
label: 'ETH',
|
|
31
|
-
|
|
42
|
+
legendValueRoundingDigits: 2,
|
|
32
43
|
parts: [
|
|
33
44
|
{
|
|
34
|
-
label: '
|
|
35
|
-
percentage: 17,
|
|
45
|
+
label: 'Option 1',
|
|
36
46
|
value: 2800,
|
|
47
|
+
legendValue: 2800 / RATE.ETH,
|
|
37
48
|
},
|
|
38
49
|
{
|
|
39
|
-
label: '
|
|
40
|
-
percentage: 13,
|
|
50
|
+
label: 'Option 2',
|
|
41
51
|
value: 2449.25,
|
|
52
|
+
legendValue: 2449.25 / RATE.ETH,
|
|
42
53
|
},
|
|
43
54
|
],
|
|
44
55
|
},
|
|
45
56
|
{
|
|
46
57
|
id: 3,
|
|
47
58
|
value: 3825.55,
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
legendValue: 3825.55 / RATE.FDUSD,
|
|
60
|
+
legendLabel: 'FDUSD',
|
|
61
|
+
label: 'FDUSD',
|
|
62
|
+
legendValueRoundingDigits: 2,
|
|
50
63
|
parts: [
|
|
51
64
|
{
|
|
52
|
-
label: '
|
|
53
|
-
percentage: 5,
|
|
65
|
+
label: 'Option 1',
|
|
54
66
|
value: 1000,
|
|
67
|
+
legendValue: 1000 / RATE.FDUSD,
|
|
55
68
|
},
|
|
56
69
|
{
|
|
57
|
-
label: '
|
|
58
|
-
percentage: 12,
|
|
70
|
+
label: 'Option 2',
|
|
59
71
|
value: 1840,
|
|
72
|
+
legendValue: 1840 / RATE.FDUSD,
|
|
60
73
|
},
|
|
61
74
|
{
|
|
62
|
-
label: '
|
|
63
|
-
percentage: 5,
|
|
75
|
+
label: 'Option 3',
|
|
64
76
|
value: 985.55,
|
|
77
|
+
legendValue: 985.55 / RATE.FDUSD,
|
|
65
78
|
},
|
|
66
79
|
],
|
|
67
80
|
},
|
|
68
81
|
{
|
|
69
82
|
id: 4,
|
|
70
83
|
value: 2818.83,
|
|
84
|
+
legendValue: 2818.83 / RATE.USDT,
|
|
71
85
|
label: 'Other',
|
|
72
|
-
|
|
86
|
+
legendLabel: 'USDT',
|
|
87
|
+
legendValueRoundingDigits: 0,
|
|
73
88
|
parts: [
|
|
74
89
|
{
|
|
75
|
-
label: '
|
|
76
|
-
percentage: 7,
|
|
90
|
+
label: 'Option 1',
|
|
77
91
|
value: 1400,
|
|
92
|
+
legendValue: 1400 / RATE.USDT,
|
|
78
93
|
},
|
|
79
94
|
{
|
|
80
|
-
label: '
|
|
81
|
-
percentage: 8,
|
|
95
|
+
label: 'Option 2',
|
|
82
96
|
value: 1418.83,
|
|
97
|
+
legendValue: 1418.83 / RATE.USDT,
|
|
83
98
|
},
|
|
84
99
|
],
|
|
85
100
|
},
|
|
86
101
|
];
|
|
87
102
|
|
|
88
|
-
export const
|
|
103
|
+
export const balanceTotalAmount = balanceData
|
|
104
|
+
.map((item) => Number(item.value))
|
|
105
|
+
.reduce((acc, currentValue) => acc + currentValue, 0);
|
|
106
|
+
|
|
107
|
+
export const balanceMissedPartsData: SegmentedDataSet = [
|
|
89
108
|
{
|
|
90
109
|
id: 1,
|
|
91
110
|
value: 5843.37,
|
|
111
|
+
legendValue: 5843.37 / RATE.BTC,
|
|
92
112
|
label: 'BTC',
|
|
93
|
-
|
|
113
|
+
legendValueRoundingDigits: 6,
|
|
94
114
|
parts: [
|
|
95
115
|
{
|
|
96
|
-
label: '
|
|
97
|
-
percentage: 13,
|
|
116
|
+
label: 'Option 1',
|
|
98
117
|
value: 2300,
|
|
118
|
+
legendValue: 2300 / RATE.BTC,
|
|
99
119
|
},
|
|
100
120
|
{
|
|
101
|
-
label: '
|
|
102
|
-
percentage: 10,
|
|
121
|
+
label: 'Option 2',
|
|
103
122
|
value: 1800,
|
|
123
|
+
legendValue: 1800 / RATE.BTC,
|
|
104
124
|
},
|
|
105
125
|
{
|
|
106
|
-
label: '
|
|
107
|
-
percentage: 10,
|
|
126
|
+
label: 'Option 3',
|
|
108
127
|
value: 1743.37,
|
|
128
|
+
legendValue: 1743.37 / RATE.BTC,
|
|
109
129
|
},
|
|
110
130
|
],
|
|
111
131
|
},
|
|
112
132
|
{
|
|
113
133
|
id: 2,
|
|
114
134
|
value: 5249.25,
|
|
135
|
+
legendValue: 5249.25 / RATE.ETH,
|
|
115
136
|
label: 'ETH',
|
|
116
|
-
|
|
137
|
+
legendValueRoundingDigits: 2,
|
|
117
138
|
},
|
|
118
139
|
{
|
|
119
140
|
id: 3,
|
|
120
141
|
value: 3825.55,
|
|
121
|
-
|
|
122
|
-
|
|
142
|
+
legendValue: 3825.55 / RATE.FDUSD,
|
|
143
|
+
label: 'FDUSD',
|
|
144
|
+
legendValueRoundingDigits: 2,
|
|
123
145
|
parts: [
|
|
124
146
|
{
|
|
125
|
-
label: '
|
|
126
|
-
percentage: 5,
|
|
147
|
+
label: 'Option 1',
|
|
127
148
|
value: 1000,
|
|
149
|
+
legendValue: 1000 / RATE.FDUSD,
|
|
128
150
|
},
|
|
129
151
|
{
|
|
130
|
-
label: '
|
|
131
|
-
percentage: 12,
|
|
152
|
+
label: 'Option 2',
|
|
132
153
|
value: 1840,
|
|
154
|
+
legendValue: 1840 / RATE.FDUSD,
|
|
133
155
|
},
|
|
134
156
|
{
|
|
135
|
-
label: '
|
|
136
|
-
percentage: 5,
|
|
157
|
+
label: 'Option 3',
|
|
137
158
|
value: 985.55,
|
|
159
|
+
legendValue: 985.55 / RATE.FDUSD,
|
|
138
160
|
},
|
|
139
161
|
],
|
|
140
162
|
},
|
|
141
163
|
{
|
|
142
164
|
id: 4,
|
|
143
165
|
value: 2818.83,
|
|
166
|
+
legendValue: 2818.83 / RATE.USDT,
|
|
144
167
|
label: 'Other',
|
|
145
|
-
|
|
168
|
+
legendValueRoundingDigits: 0,
|
|
146
169
|
},
|
|
147
170
|
];
|
|
171
|
+
|
|
172
|
+
export const balanceMissedPartsDataTotalAmount = balanceMissedPartsData
|
|
173
|
+
.map((item) => Number(item.value))
|
|
174
|
+
.reduce((acc, currentValue) => acc + currentValue, 0);
|
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import { CommonProps } from '@global-types/emotion';
|
|
2
|
-
import {
|
|
3
|
-
import { PieChartLegend, PieChartProps } from '@components';
|
|
2
|
+
import { PieChartLegend, PieChartLegendItem, PieChartProps } from '@components';
|
|
4
3
|
|
|
5
|
-
type
|
|
4
|
+
type SegmentedDataMainInfo = {
|
|
6
5
|
label: string;
|
|
7
|
-
percentage: number;
|
|
8
6
|
value: number;
|
|
7
|
+
legendValue: number;
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
parts?: BalanceDataPartsItem[];
|
|
17
|
-
};
|
|
10
|
+
export interface SegmentedDataItem extends PieChartLegendItem {
|
|
11
|
+
legendValue: number;
|
|
12
|
+
legendLabel?: string;
|
|
13
|
+
parts?: SegmentedDataMainInfo[];
|
|
14
|
+
}
|
|
18
15
|
|
|
19
|
-
export type
|
|
16
|
+
export type SegmentedDataSet = Array<SegmentedDataItem>;
|
|
20
17
|
|
|
21
18
|
export interface SegmentedPieChartProps extends CommonProps {
|
|
22
|
-
data:
|
|
19
|
+
data: SegmentedDataSet;
|
|
20
|
+
totalAmount: number;
|
|
21
|
+
totalDimension: string;
|
|
23
22
|
pieChartProps?: Partial<PieChartProps>;
|
|
24
23
|
pieChartLegendProps?: Partial<React.ComponentProps<typeof PieChartLegend>>;
|
|
25
24
|
legendBackgrounds?: string[];
|
|
26
25
|
pieChartColors?: string[][];
|
|
27
26
|
currency?: string;
|
|
28
27
|
otherLabel?: string;
|
|
28
|
+
legendValueRoundingDigits?: number;
|
|
29
|
+
legendPercentageRoundingDigits?: number;
|
|
30
|
+
showDimensions?: boolean;
|
|
31
|
+
showPercentage?: boolean;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
export interface BalanceDataForGraph extends
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
export interface BalanceDataForGraph extends PieChartLegendItem {
|
|
35
|
+
label: string;
|
|
36
|
+
legendLabel?: string;
|
|
37
|
+
legendValueRoundingDigits: number;
|
|
38
|
+
percentage: number;
|
|
39
|
+
partIndex?: number;
|
|
34
40
|
partLabel?: string;
|
|
35
41
|
partPercentage?: number;
|
|
36
42
|
id: number | string;
|
|
@@ -38,3 +44,18 @@ export interface BalanceDataForGraph extends MayHaveLabel {
|
|
|
38
44
|
value: number | string;
|
|
39
45
|
color: string;
|
|
40
46
|
}
|
|
47
|
+
|
|
48
|
+
export type LegendItemProps = {
|
|
49
|
+
label: string;
|
|
50
|
+
legendLabel?: string;
|
|
51
|
+
percentage?: number;
|
|
52
|
+
legendValue?: number;
|
|
53
|
+
legendValueRoundingDigits: number;
|
|
54
|
+
} & Pick<
|
|
55
|
+
SegmentedPieChartProps,
|
|
56
|
+
| 'showDimensions'
|
|
57
|
+
| 'legendPercentageRoundingDigits'
|
|
58
|
+
| 'otherLabel'
|
|
59
|
+
| 'currency'
|
|
60
|
+
| 'showPercentage'
|
|
61
|
+
>;
|