@@ -16,216 +16,43 @@ The examples below are based on the [Victory](https://formidable.com/open-source
16
16
17
17
## Examples
18
18
### Basic
19
- ``` js
20
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
21
-
22
- < div style= {{ height: ' 230px' , width: ' 230px' }}>
23
- < ChartDonut
24
- ariaDesc= " Average number of pets"
25
- ariaTitle= " Donut chart example"
26
- constrainToVisibleArea
27
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
28
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
29
- name= " chart1"
30
- subTitle= " Pets"
31
- title= " 100"
32
- / >
33
- < / div>
19
+ ``` ts file = "ChartDonutBasic.tsx"
20
+
34
21
```
35
22
36
23
### Right aligned legend
37
- ``` js
38
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
39
-
40
- < div style= {{ height: ' 230px' , width: ' 350px' }}>
41
- < ChartDonut
42
- ariaDesc= " Average number of pets"
43
- ariaTitle= " Donut chart example"
44
- constrainToVisibleArea
45
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
46
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
47
- legendData= {[{ name: ' Cats: 35' }, { name: ' Dogs: 55' }, { name: ' Birds: 10' }]}
48
- legendOrientation= " vertical"
49
- legendPosition= " right"
50
- name= " chart2"
51
- padding= {{
52
- bottom: 20 ,
53
- left: 20 ,
54
- right: 140 , // Adjusted to accommodate legend
55
- top: 20
56
- }}
57
- subTitle= " Pets"
58
- title= " 100"
59
- width= {350 }
60
- / >
61
- < / div>
24
+ ``` ts file = "ChartDonutRightAlignedLegend.tsx"
25
+
62
26
```
63
27
64
28
### Multi-color (ordered) with right aligned legend
65
- ``` js
66
- import { ChartDonut , ChartThemeColor } from ' @patternfly/react-charts/victory' ;
29
+ ``` ts file = "ChartDonutMultiColor.tsx"
67
30
68
- < div style= {{ height: ' 230px' , width: ' 350px' }}>
69
- < ChartDonut
70
- ariaDesc= " Average number of pets"
71
- ariaTitle= " Donut chart example"
72
- constrainToVisibleArea
73
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
74
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
75
- legendData= {[{ name: ' Cats: 35' }, { name: ' Dogs: 55' }, { name: ' Birds: 10' }]}
76
- legendOrientation= " vertical"
77
- legendPosition= " right"
78
- name= " chart3"
79
- padding= {{
80
- bottom: 20 ,
81
- left: 20 ,
82
- right: 140 , // Adjusted to accommodate legend
83
- top: 20
84
- }}
85
- subTitle= " Pets"
86
- title= " 100"
87
- themeColor= {ChartThemeColor .multiOrdered }
88
- width= {350 }
89
- / >
90
- < / div>
91
31
```
92
32
93
33
### Bottom aligned legend
94
- ``` js
95
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
96
-
97
- < div style= {{ height: ' 275px' , width: ' 300px' }}>
98
- < ChartDonut
99
- ariaDesc= " Average number of pets"
100
- ariaTitle= " Donut chart example"
101
- constrainToVisibleArea
102
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
103
- donutOrientation= " top"
104
- height= {275 }
105
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
106
- legendData= {[{ name: ' Cats: 35' }, { name: ' Dogs: 55' }, { name: ' Birds: 10' }]}
107
- legendPosition= " bottom"
108
- legendWidth= {225 }
109
- name= " chart4"
110
- padding= {{
111
- bottom: 65 , // Adjusted to accommodate legend
112
- left: 20 ,
113
- right: 20 ,
114
- top: 20
115
- }}
116
- subTitle= " Pets"
117
- title= " 100"
118
- width= {300 }
119
- / >
120
- < / div>
34
+ ``` ts file = "ChartDonutBottomAlignedLegend.tsx"
35
+
121
36
```
122
37
123
38
### Small
124
- ``` js
125
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
126
-
127
- < div style= {{ height: ' 150px' , width: ' 150px' }}>
128
- < ChartDonut
129
- ariaDesc= " Average number of pets"
130
- ariaTitle= " Donut chart example"
131
- constrainToVisibleArea
132
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
133
- height= {150 }
134
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
135
- name= " chart5"
136
- subTitle= " Pets"
137
- title= " 100"
138
- width= {150 }
139
- / >
140
- < / div>
39
+ ``` ts file = "ChartDonutSmall.tsx"
40
+
141
41
```
142
42
143
43
### Small with right aligned legend
144
- ``` js
145
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
146
-
147
- < div style= {{ height: ' 150px' , width: ' 275px' }}>
148
- < ChartDonut
149
- ariaDesc= " Average number of pets"
150
- ariaTitle= " Donut chart example"
151
- constrainToVisibleArea
152
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
153
- height= {150 }
154
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
155
- legendData= {[{ name: ' Cats: 35' }, { name: ' Dogs: 55' }, { name: ' Birds: 10' }]}
156
- legendOrientation= " vertical"
157
- legendPosition= " right"
158
- name= " chart6"
159
- padding= {{
160
- bottom: 20 ,
161
- left: 20 ,
162
- right: 145 , // Adjusted to accommodate legend
163
- top: 20
164
- }}
165
- subTitle= " Pets"
166
- title= " 100"
167
- width= {275 }
168
- / >
169
- < / div>
44
+ ``` ts file = "ChartDonutSmallRightLegend.tsx"
45
+
170
46
```
171
47
172
48
### Small with bottom aligned subtitle
173
- ``` js
174
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
175
-
176
- < div style= {{ height: ' 165px' , width: ' 275px' }}>
177
- < ChartDonut
178
- ariaDesc= " Average number of pets"
179
- ariaTitle= " Donut chart example"
180
- constrainToVisibleArea
181
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
182
- height= {165 }
183
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
184
- legendData= {[{ name: ' Cats: 35' }, { name: ' Dogs: 55' }, { name: ' Birds: 10' }]}
185
- legendOrientation= " vertical"
186
- legendPosition= " right"
187
- name= " chart7"
188
- padding= {{
189
- bottom: 25 , // Adjusted to accommodate subTitle
190
- left: 20 ,
191
- right: 145 , // Adjusted to accommodate legend
192
- top: 20
193
- }}
194
- subTitle= " Pets"
195
- subTitlePosition= " bottom"
196
- title= " 100"
197
- width= {275 }
198
- / >
199
- < / div>
49
+ ``` ts file = "ChartDonutSmallBottomSubtitle.tsx"
50
+
200
51
```
201
52
202
53
### Small with right aligned subtitle
203
- ``` js
204
- import { ChartDonut } from ' @patternfly/react-charts/victory' ;
205
-
206
- < div style= {{ height: ' 200px' , width: ' 300px' }}>
207
- < ChartDonut
208
- ariaDesc= " Average number of pets"
209
- ariaTitle= " Donut chart example"
210
- constrainToVisibleArea
211
- data= {[{ x: ' Cats' , y: 35 }, { x: ' Dogs' , y: 55 }, { x: ' Birds' , y: 10 }]}
212
- height= {200 }
213
- labels= {({ datum }) => ` ${ datum .x } : ${ datum .y } %` }
214
- legendData= {[{ name: ' Cats: 35' }, { name: ' Dogs: 55' }, { name: ' Birds: 10' }]}
215
- legendPosition= " bottom"
216
- name= " chart8"
217
- padding= {{
218
- bottom: 70 , // Adjusted to accommodate legend
219
- left: 20 ,
220
- right: 50 , // Adjusted to accommodate subTitle
221
- top: 20
222
- }}
223
- subTitle= " Pets"
224
- subTitlePosition= " right"
225
- title= " 100"
226
- width= {300 }
227
- / >
228
- < / div>
54
+ ``` ts file = "ChartDonutSmallRightSubtitle.tsx"
55
+
229
56
```
230
57
231
58
## Documentation
0 commit comments