@@ -139,6 +139,206 @@ const chartPoints = [
139
139
} ,
140
140
] ;
141
141
142
+ const dataGVBC = [
143
+ {
144
+ name : 'Jan - Mar' ,
145
+ series : [
146
+ {
147
+ key : 'series1' ,
148
+ data : 33000 ,
149
+ color : DefaultPalette . blue ,
150
+ legend : '2022' ,
151
+ xAxisCalloutData : '2022/04/30' ,
152
+ yAxisCalloutData : '29%' ,
153
+ callOutAccessibilityData : {
154
+ ariaLabel : 'Group Jan - Mar 1 of 4, Bar series 1 of 2 2022, x value 2022/04/30, y value 29%' ,
155
+ } ,
156
+ } ,
157
+ {
158
+ key : 'series2' ,
159
+ data : 44000 ,
160
+ color : DefaultPalette . green ,
161
+ legend : '2023' ,
162
+ xAxisCalloutData : '2023/04/30' ,
163
+ yAxisCalloutData : '44%' ,
164
+ callOutAccessibilityData : {
165
+ ariaLabel : 'Group Jan - Mar 1 of 4, Bar series 2 of 2 2023, x value 2023/04/30, y value 44%' ,
166
+ } ,
167
+ } ,
168
+ {
169
+ key : 'series3' ,
170
+ data : 54000 ,
171
+ color : DefaultPalette . red ,
172
+ legend : '2024' ,
173
+ xAxisCalloutData : '2024/04/30' ,
174
+ yAxisCalloutData : '44%' ,
175
+ callOutAccessibilityData : {
176
+ ariaLabel : 'Group Jan - Mar 1 of 4, Bar series 3 of 4 2022, x value 2024/04/30, y value 44%' ,
177
+ } ,
178
+ } ,
179
+ {
180
+ key : 'series4' ,
181
+ data : 24000 ,
182
+ color : DefaultPalette . yellow ,
183
+ legend : '2021' ,
184
+ xAxisCalloutData : '2021/04/30' ,
185
+ yAxisCalloutData : '44%' ,
186
+ callOutAccessibilityData : {
187
+ ariaLabel : 'Group Jan - Mar 1 of 4, Bar series 4 of 4 2021, x value 2021/04/30, y value 44%' ,
188
+ } ,
189
+ } ,
190
+ ] ,
191
+ } ,
192
+ {
193
+ name : 'Apr - Jun' ,
194
+ series : [
195
+ {
196
+ key : 'series1' ,
197
+ data : 33000 ,
198
+ color : DefaultPalette . blue ,
199
+ legend : '2022' ,
200
+ xAxisCalloutData : '2022/05/30' ,
201
+ yAxisCalloutData : '29%' ,
202
+ callOutAccessibilityData : {
203
+ ariaLabel : 'Group Apr - Jun 2 of 4, Bar series 1 of 2 2022, x value 2022/05/30, y value 29%' ,
204
+ } ,
205
+ } ,
206
+ {
207
+ key : 'series2' ,
208
+ data : 3000 ,
209
+ color : DefaultPalette . green ,
210
+ legend : '2023' ,
211
+ xAxisCalloutData : '2023/05/30' ,
212
+ yAxisCalloutData : '3%' ,
213
+ callOutAccessibilityData : {
214
+ ariaLabel : 'Group Apr - Jun 2 of 4, Bar series 2 of 2 2023, x value 2023/05/30, y value 3%' ,
215
+ } ,
216
+ } ,
217
+ {
218
+ key : 'series3' ,
219
+ data : 9000 ,
220
+ color : DefaultPalette . red ,
221
+ legend : '2024' ,
222
+ xAxisCalloutData : '2024/05/30' ,
223
+ yAxisCalloutData : '3%' ,
224
+ callOutAccessibilityData : {
225
+ ariaLabel : 'Group Apr - Jun 2 of 4, Bar series 3 of 4 2024, x value 2024/05/30, y value 3%' ,
226
+ } ,
227
+ } ,
228
+ {
229
+ key : 'series4' ,
230
+ data : 12000 ,
231
+ color : DefaultPalette . yellow ,
232
+ legend : '2021' ,
233
+ xAxisCalloutData : '2021/05/30' ,
234
+ yAxisCalloutData : '3%' ,
235
+ callOutAccessibilityData : {
236
+ ariaLabel : 'Group Apr - Jun 2 of 4, Bar series 4 of 4 2021, x value 2021/05/30, y value 3%' ,
237
+ } ,
238
+ } ,
239
+ ] ,
240
+ } ,
241
+
242
+ {
243
+ name : 'Jul - Sep' ,
244
+ series : [
245
+ {
246
+ key : 'series1' ,
247
+ data : 14000 ,
248
+ color : DefaultPalette . blue ,
249
+ legend : '2022' ,
250
+ xAxisCalloutData : '2022/06/30' ,
251
+ yAxisCalloutData : '13%' ,
252
+ callOutAccessibilityData : {
253
+ ariaLabel : 'Group Jul - Sep 3 of 4, Bar series 1 of 2 2022, x value 2022/06/30, y value 13%' ,
254
+ } ,
255
+ } ,
256
+ {
257
+ key : 'series2' ,
258
+ data : 50000 ,
259
+ color : DefaultPalette . green ,
260
+ legend : '2023' ,
261
+ xAxisCalloutData : '2023/06/30' ,
262
+ yAxisCalloutData : '50%' ,
263
+ callOutAccessibilityData : {
264
+ ariaLabel : 'Group Jul - Sep 3 of 4, Bar series 2 of 2 2023, x value 2023/06/30, y value 50%' ,
265
+ } ,
266
+ } ,
267
+ {
268
+ key : 'series3' ,
269
+ data : 60000 ,
270
+ color : DefaultPalette . red ,
271
+ legend : '2024' ,
272
+ xAxisCalloutData : '2024/06/30' ,
273
+ yAxisCalloutData : '50%' ,
274
+ callOutAccessibilityData : {
275
+ ariaLabel : 'Group Jul - Sep 3 of 4, Bar series 3 of 4 2024, x value 2024/06/30, y value 50%' ,
276
+ } ,
277
+ } ,
278
+ {
279
+ key : 'series4' ,
280
+ data : 10000 ,
281
+ color : DefaultPalette . yellow ,
282
+ legend : '2021' ,
283
+ xAxisCalloutData : '2021/06/30' ,
284
+ yAxisCalloutData : '50%' ,
285
+ callOutAccessibilityData : {
286
+ ariaLabel : 'Group Jul - Sep 3 of 4, Bar series 4 of 4 2021, x value 2021/06/30, y value 50%' ,
287
+ } ,
288
+ } ,
289
+ ] ,
290
+ } ,
291
+ {
292
+ name : 'Oct - Dec' ,
293
+ series : [
294
+ {
295
+ key : 'series1' ,
296
+ data : 33000 ,
297
+ color : DefaultPalette . blue ,
298
+ legend : '2022' ,
299
+ xAxisCalloutData : '2022/07/30' ,
300
+ yAxisCalloutData : '29%' ,
301
+ callOutAccessibilityData : {
302
+ ariaLabel : 'Group Oct - Dec 4 of 4, Bar series 1 of 2 2022, x value 2022/07/30, y value 29%' ,
303
+ } ,
304
+ } ,
305
+ {
306
+ key : 'series2' ,
307
+ data : 3000 ,
308
+ color : DefaultPalette . green ,
309
+ legend : '2023' ,
310
+ xAxisCalloutData : '2023/07/30' ,
311
+ yAxisCalloutData : '3%' ,
312
+ callOutAccessibilityData : {
313
+ ariaLabel : 'Group Oct - Dec 4 of 4, Bar series 2 of 2 2023, x value 2023/07/30, y value 3%' ,
314
+ } ,
315
+ } ,
316
+ {
317
+ key : 'series3' ,
318
+ data : 6000 ,
319
+ color : DefaultPalette . red ,
320
+ legend : '2024' ,
321
+ xAxisCalloutData : '2024/07/30' ,
322
+ yAxisCalloutData : '3%' ,
323
+ callOutAccessibilityData : {
324
+ ariaLabel : 'Group Oct - Dec 4 of 4, Bar series 3 of 4 2024, x value 2024/07/30, y value 3%' ,
325
+ } ,
326
+ } ,
327
+ {
328
+ key : 'series4' ,
329
+ data : 15000 ,
330
+ color : DefaultPalette . yellow ,
331
+ legend : '2021' ,
332
+ xAxisCalloutData : '2021/07/30' ,
333
+ yAxisCalloutData : '3%' ,
334
+ callOutAccessibilityData : {
335
+ ariaLabel : 'Group Oct - Dec 4 of 4, Bar series 4 of 4 2021, x value 2021/07/30, y value 3%' ,
336
+ } ,
337
+ } ,
338
+ ] ,
339
+ } ,
340
+ ] ;
341
+
142
342
describe ( 'Grouped Vertical bar chart rendering' , ( ) => {
143
343
beforeEach ( updateChartWidthAndHeight ) ;
144
344
afterEach ( sharedAfterEach ) ;
@@ -350,6 +550,40 @@ describe('Grouped vertical bar chart - Subcomponent Legends', () => {
350
550
expect ( bars [ 5 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
351
551
} ,
352
552
) ;
553
+
554
+ testWithoutWait (
555
+ 'Should select multiple legends on click' ,
556
+ GroupedVerticalBarChart ,
557
+ { data : dataGVBC , legendProps : { canSelectMultipleLegends : true } } ,
558
+ container => {
559
+ const firstLegend = screen . queryByText ( '2023' ) ?. closest ( 'button' ) ;
560
+ const secondLegend = screen . queryByText ( '2024' ) ?. closest ( 'button' ) ;
561
+
562
+ expect ( firstLegend ) . toBeDefined ( ) ;
563
+ expect ( secondLegend ) . toBeDefined ( ) ;
564
+
565
+ fireEvent . click ( firstLegend ! ) ;
566
+ fireEvent . click ( secondLegend ! ) ;
567
+
568
+ // Assert
569
+ expect ( firstLegend ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
570
+ expect ( secondLegend ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
571
+
572
+ const bars = screen . getAllByText ( ( content , element ) => element ! . tagName . toLowerCase ( ) === 'rect' ) ;
573
+ expect ( bars [ 0 ] ) . toHaveAttribute ( 'opacity' , '0.1' ) ;
574
+ expect ( bars [ 1 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
575
+ expect ( bars [ 2 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
576
+ expect ( bars [ 3 ] ) . toHaveAttribute ( 'opacity' , '0.1' ) ;
577
+ expect ( bars [ 4 ] ) . toHaveAttribute ( 'opacity' , '0.1' ) ;
578
+ expect ( bars [ 5 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
579
+ expect ( bars [ 6 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
580
+ expect ( bars [ 7 ] ) . toHaveAttribute ( 'opacity' , '0.1' ) ;
581
+ expect ( bars [ 8 ] ) . toHaveAttribute ( 'opacity' , '0.1' ) ;
582
+ expect ( bars [ 9 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
583
+ expect ( bars [ 10 ] ) . toHaveAttribute ( 'opacity' , '' ) ;
584
+ expect ( bars [ 11 ] ) . toHaveAttribute ( 'opacity' , '0.1' ) ;
585
+ } ,
586
+ ) ;
353
587
} ) ;
354
588
355
589
describe ( 'Grouped vertical bar chart - Subcomponent callout' , ( ) => {
0 commit comments