Repository navigation
Expand file tree
/
Copy pathGroupedVerticalBarChart.CustomAccessibility.Example.tsx
More file actions
235 lines (225 loc) · 7.74 KB
/
Copy pathGroupedVerticalBarChart.CustomAccessibility.Example.tsx
File metadata and controls
235 lines (225 loc) · 7.74 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import * as React from 'react';
import {
GroupedVerticalBarChart,
IGroupedVerticalBarChartProps,
IGroupedVerticalBarChartData,
DataVizPalette,
getColorFromToken,
} from '@fluentui/react-charting';
import { ChoiceGroup, IChoiceGroupOption } from '@fluentui/react/lib/ChoiceGroup';
import { Toggle } from '@fluentui/react/lib/Toggle';
interface IGroupedBarChartState {
width: number;
height: number;
selectedCallout: 'singleCallout' | 'StackCallout';
enableGradient: boolean;
roundCorners: boolean;
}
export class GroupedVerticalBarChartCustomAccessibilityExample extends React.Component<{}, IGroupedBarChartState> {
constructor(props: IGroupedVerticalBarChartProps) {
super(props);
this.state = {
width: 700,
height: 400,
selectedCallout: 'singleCallout',
enableGradient: false,
roundCorners: false,
};
}
public render(): JSX.Element {
return <div>{this._basicExample()}</div>;
}
private _onWidthChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({ width: parseInt(e.target.value, 10) });
};
private _onHeightChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({ height: parseInt(e.target.value, 10) });
};
private _onChange = (ev: React.FormEvent<HTMLInputElement>, option: IChoiceGroupOption): void => {
this.setState({ selectedCallout: option.key as IGroupedBarChartState['selectedCallout'] });
};
private _onEnableGradientChange = (ev: React.MouseEvent<HTMLElement>, checked: boolean) => {
this.setState({ enableGradient: checked });
};
private _onRoundCornersChange = (ev: React.MouseEvent<HTMLElement>, checked: boolean) => {
this.setState({ roundCorners: checked });
};
private _basicExample(): JSX.Element {
const data: IGroupedVerticalBarChartData[] = [
{
name: 'Metadata info multi lines text Completed',
series: [
{
key: 'series1',
data: 33000,
color: getColorFromToken(DataVizPalette.color1),
legend: 'MetaData1',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '29%',
callOutAccessibilityData: {
ariaLabel: 'Group series 1 of 4, Bar series 1 of 2 x-Axis 2020/04/30 MetaData1 29%',
},
},
{
key: 'series2',
data: 44000,
color: getColorFromToken(DataVizPalette.color2),
legend: 'MetaData4',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '44%',
callOutAccessibilityData: {
ariaLabel: 'Bar series 2 of 2 x-Axis 2020/04/30 MetaData4 44%',
},
},
],
stackCallOutAccessibilityData: {
ariaLabel: 'Group series 1 of 4 x-Axis 2020/04/30 MetaData1 33% MetaData4 44%',
},
},
{
name: 'Data Point2',
series: [
{
key: 'series1',
data: 33000,
color: getColorFromToken(DataVizPalette.color1),
legend: 'MetaData1',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '29%',
callOutAccessibilityData: {
ariaLabel: 'Group series 2 of 4, Bar series 1 of 2 x-Axis 2020/04/30 MetaData1 29%',
},
},
{
key: 'series2',
data: 3000,
color: getColorFromToken(DataVizPalette.color2),
legend: 'MetaData4',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '3%',
callOutAccessibilityData: {
ariaLabel: 'Bar series 2 of 2 x-Axis 2020/04/30 MetaData4 3%',
},
},
],
stackCallOutAccessibilityData: {
ariaLabel: 'Group series 2 of 4 x-Axis 2020/04/30 MetaData1 33% MetaData4 3%',
},
},
{
name: 'Single line text ',
series: [
{
key: 'series1',
data: 14000,
color: getColorFromToken(DataVizPalette.color1),
legend: 'MetaData1',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '13%',
callOutAccessibilityData: {
ariaLabel: 'Group series 3 of 4, Bar series 1 of 2 x-Axis 2020/04/30 MetaData1 13%',
},
},
{
key: 'series2',
data: 50000,
color: getColorFromToken(DataVizPalette.color2),
legend: 'MetaData4',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '50%',
callOutAccessibilityData: {
ariaLabel: 'Bar series 2 of 2 x-Axis 2020/04/30 MetaData4 50%',
},
},
],
stackCallOutAccessibilityData: {
ariaLabel: 'Group series 3 of 4 x-Axis 2020/04/30 MetaData1 14% MetaData4 50%',
},
},
{
name: 'Hello World!!!',
series: [
{
key: 'series1',
data: 33000,
color: getColorFromToken(DataVizPalette.color1),
legend: 'MetaData1',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '29%',
callOutAccessibilityData: {
ariaLabel: 'Group series 4 of 4, Bar series 1 of 2 x-Axis 2020/04/30 MetaData1 29%',
},
},
{
key: 'series2',
data: 3000,
color: getColorFromToken(DataVizPalette.color2),
legend: 'MetaData4',
xAxisCalloutData: '2020/04/30',
yAxisCalloutData: '3%',
callOutAccessibilityData: {
ariaLabel: 'Bar series 2 of 2 x-Axis 2020/04/30 MetaData4 3%',
},
},
],
stackCallOutAccessibilityData: {
ariaLabel: 'Group series 4 of 4 x-Axis 2020/04/30 MetaData1 33% MetaData4 3%',
},
},
];
const rootStyle = { width: `${this.state.width}px`, height: `${this.state.height}px` };
const options: IChoiceGroupOption[] = [
{ key: 'singleCallout', text: 'Single callout' },
{ key: 'StackCallout', text: 'Stack callout' },
];
return (
<div className="containerDiv">
<label htmlFor="changeWidth_Custom">Change Width:</label>
<input
type="range"
value={this.state.width}
min={200}
max={1000}
id="changeWidth_Custom"
onChange={this._onWidthChange}
aria-valuetext={`ChangeWidthSlider${this.state.width}`}
/>
<label htmlFor="changeHeight_Custom">Change Height:</label>
<input
type="range"
value={this.state.height}
min={200}
max={1000}
id="changeHeight_Custom"
onChange={this._onHeightChange}
aria-valuetext={`ChangeHeightslider${this.state.height}`}
/>
<ChoiceGroup
options={options}
selectedKey={this.state.selectedCallout}
onChange={this._onChange}
label="Pick one"
/>
<div style={{ display: 'flex' }}>
<Toggle label="Enable Gradient" onText="ON" offText="OFF" onChange={this._onEnableGradientChange} />
<Toggle label="Rounded Corners" onText="ON" offText="OFF" onChange={this._onRoundCornersChange} />
</div>
<div style={rootStyle}>
<GroupedVerticalBarChart
chartTitle="Grouped Vertical Bar chart custom accessibility example"
data={data}
height={this.state.height}
width={this.state.width}
showYAxisGridLines
wrapXAxisLables
isCalloutForStack={this.state.selectedCallout === 'StackCallout'}
enableReflow={true}
enableGradient={this.state.enableGradient}
roundCorners={this.state.roundCorners}
/>
</div>
</div>
);
}
}