Skip to content

Commit 21bfe7f

Browse files
domoritzmbostock
andauthored
fix: hide axis ticks from aria since they are just adding noise (#2018)
* fix: hide axis ticks from aria since they are just adding noise * plumbing; update test snapshots --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent 5e65ac6 commit 21bfe7f

File tree

535 files changed

+1309
-1293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+1309
-1293
lines changed

src/marks/axis.js

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,28 @@ function axisTickKy(
278278
...options
279279
}
280280
) {
281-
return axisMark(vectorY, k, anchor, `${k}-axis tick`, data, {
282-
strokeWidth,
283-
strokeLinecap,
284-
strokeLinejoin,
285-
facetAnchor,
286-
frameAnchor,
287-
y,
288-
...options,
289-
dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
290-
anchor: "start",
291-
length: tickSize,
292-
shape: anchor === "left" ? shapeTickLeft : shapeTickRight
293-
});
281+
return axisMark(
282+
vectorY,
283+
k,
284+
data,
285+
{
286+
ariaLabel: `${k}-axis tick`,
287+
ariaHidden: true
288+
},
289+
{
290+
strokeWidth,
291+
strokeLinecap,
292+
strokeLinejoin,
293+
facetAnchor,
294+
frameAnchor,
295+
y,
296+
...options,
297+
dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
298+
anchor: "start",
299+
length: tickSize,
300+
shape: anchor === "left" ? shapeTickLeft : shapeTickRight
301+
}
302+
);
294303
}
295304

296305
function axisTickKx(
@@ -312,19 +321,28 @@ function axisTickKx(
312321
...options
313322
}
314323
) {
315-
return axisMark(vectorX, k, anchor, `${k}-axis tick`, data, {
316-
strokeWidth,
317-
strokeLinejoin,
318-
strokeLinecap,
319-
facetAnchor,
320-
frameAnchor,
321-
x,
322-
...options,
323-
dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
324-
anchor: "start",
325-
length: tickSize,
326-
shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
327-
});
324+
return axisMark(
325+
vectorX,
326+
k,
327+
data,
328+
{
329+
ariaLabel: `${k}-axis tick`,
330+
ariaHidden: true
331+
},
332+
{
333+
strokeWidth,
334+
strokeLinejoin,
335+
strokeLinecap,
336+
facetAnchor,
337+
frameAnchor,
338+
x,
339+
...options,
340+
dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
341+
anchor: "start",
342+
length: tickSize,
343+
shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
344+
}
345+
);
328346
}
329347

330348
function axisTextKy(
@@ -352,9 +370,8 @@ function axisTextKy(
352370
return axisMark(
353371
textY,
354372
k,
355-
anchor,
356-
`${k}-axis tick label`,
357373
data,
374+
{ariaLabel: `${k}-axis tick label`},
358375
{
359376
facetAnchor,
360377
frameAnchor,
@@ -399,9 +416,8 @@ function axisTextKx(
399416
return axisMark(
400417
textX,
401418
k,
402-
anchor,
403-
`${k}-axis tick label`,
404419
data,
420+
{ariaLabel: `${k}-axis tick label`},
405421
{
406422
facetAnchor,
407423
frameAnchor,
@@ -453,7 +469,7 @@ function gridKy(
453469
...options
454470
}
455471
) {
456-
return axisMark(ruleY, k, anchor, `${k}-grid`, data, {y, x1, x2, ...gridDefaults(options)});
472+
return axisMark(ruleY, k, data, {ariaLabel: `${k}-grid`, ariaHidden: true}, {y, x1, x2, ...gridDefaults(options)});
457473
}
458474

459475
function gridKx(
@@ -468,7 +484,7 @@ function gridKx(
468484
...options
469485
}
470486
) {
471-
return axisMark(ruleX, k, anchor, `${k}-grid`, data, {x, y1, y2, ...gridDefaults(options)});
487+
return axisMark(ruleX, k, data, {ariaLabel: `${k}-grid`, ariaHidden: true}, {x, y1, y2, ...gridDefaults(options)});
472488
}
473489

474490
function gridDefaults({
@@ -520,7 +536,7 @@ function labelOptions(
520536
};
521537
}
522538

523-
function axisMark(mark, k, anchor, ariaLabel, data, options, initialize) {
539+
function axisMark(mark, k, data, properties, options, initialize) {
524540
let channels;
525541

526542
function axisInitializer(data, facets, _channels, scales, dimensions, context) {
@@ -615,7 +631,7 @@ function axisMark(mark, k, anchor, ariaLabel, data, options, initialize) {
615631
} else {
616632
channels = {};
617633
}
618-
m.ariaLabel = ariaLabel;
634+
if (properties !== undefined) Object.assign(m, properties);
619635
if (m.clip === undefined) m.clip = false; // don’t clip axes by default
620636
return m;
621637
}

test/output/aaplBollinger.svg

Lines changed: 3 additions & 3 deletions
Loading

test/output/aaplBollingerCandlestick.svg

Lines changed: 3 additions & 3 deletions
Loading

test/output/aaplBollingerGridInterval.svg

Lines changed: 6 additions & 6 deletions
Loading

test/output/aaplBollingerGridSpacing.svg

Lines changed: 6 additions & 6 deletions
Loading

test/output/aaplCandlestick.svg

Lines changed: 4 additions & 4 deletions
Loading

test/output/aaplChangeVolume.svg

Lines changed: 4 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)