/
Pie.stories.js
162 lines (149 loc) · 3.69 KB
/
Pie.stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Pie from './Pie';
export default {
title: 'Pie',
component: Pie,
parameters: {
controls: {
hideNoControlsWarning: true,
},
},
};
export const Simple = () => {
const data = [{ value: 10 }, { value: 35 }, { value: 19 }, { value: 27 }, { value: 6 }];
return <Pie data={data} lineHeight={50} />;
};
export const OneSegment = () => {
const data = [{ value: 10 }];
return <Pie data={data} lineHeight={50} />;
};
export const TwoSegments = () => {
const data = [{ value: 10 }, { value: 35 }];
return <Pie data={data} lineHeight={50} />;
};
export const ThreeSegments = () => {
const data = [{ value: 10 }, { value: 35 }, { value: 19 }, ];
return <Pie data={data} lineHeight={50} />;
};
export const WithCaptions = () => {
const data = [
{ value: 35, title: 'USA $35M' },
{ value: 19, title: 'Canada $19M' },
{ value: 10, title: 'China $10M' },
{ value: 27, title: 'Europe $27M' },
{ value: 12, title: 'Other $12M' },
];
return <Pie data={data} lineHeight={20} centerRadius={3} />;
};
export const CustomStyling = () => {
const highlightStyles = makeStyles((theme) => ({
text: {
stroke: 'Red',
},
wedge: {
fill: 'PapayaWhip',
stroke: 'Red',
},
}));
const regularStyles = makeStyles((theme) => ({
text: {
stroke: 'none',
fill: 'White',
},
wedge: {
fill: 'CornflowerBlue',
},
}));
const highlightClasses = highlightStyles();
const regularClasses = regularStyles();
const data = [
{ value: 35, title: 'USA $35M', classes: regularClasses },
{ value: 27, title: 'Europe $27M', classes: regularClasses },
{ value: 19, title: 'Canada $19M', classes: regularClasses },
{ value: 12, title: 'Other $12M', classes: regularClasses },
{ value: 10, title: 'China $10M', explode: 10, classes: highlightClasses },
];
return <Pie data={data} radius={150} width={330} height={330} centerRadius={20} lineHeight={20} transform={'translate(15 15)'} />;
};
export const PieChart = () => {
const classes = makeStyles((theme) => ({
root: {
stroke: 'Blue',
},
text: {
fontSize: '17px',
},
wedge: {
fill: 'LemonChiffon',
},
}))();
const data = [
{ value: 35, title: 'USA $35M', classes },
{ value: 19, title: 'Canada $19M', classes },
{ value: 10, title: 'China $10M', classes },
{ value: 27, title: 'Europe $27M', classes },
{ value: 12, title: 'Other $12M', classes },
];
return <Pie data={data} lineHeight={20} centerRadius={0} margin={0} />;
};
export const PieMenu = () => {
const classes = makeStyles((theme) => ({
root: {
stroke: 'Blue',
},
text: {
fontSize: '17px',
},
wedge: {
fill: 'CornflowerBlue',
opacity: 0.2,
'&:hover': {
opacity: 0.5,
},
},
}))();
const data = [
{
value: 1,
title: 'Go to some other page',
classes,
onClick: () => {
alert('Go to other page clicked');
},
},
{
value: 1,
title: 'Expand this node in the graph',
classes,
onClick: () => {
alert('Expand clicked');
},
},
{
value: 1,
title: 'Hide this node',
classes,
onClick: () => {
alert('Hide clicked');
},
},
{
value: 1,
title: 'Give me more like this',
classes,
onClick: () => {
alert('More clicked');
},
},
{
value: 1,
title: 'Hide all other nodes except this one',
classes,
onClick: () => {
alert('Hide others clicked');
},
},
];
return <Pie data={data} centerRadius={40} />;
};