Skip to content

Commit

Permalink
fix: hide axis ticks from aria since they are just adding noise (#2018)
Browse files Browse the repository at this point in the history
* fix: hide axis ticks from aria since they are just adding noise

* plumbing; update test snapshots

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
  • Loading branch information
domoritz and mbostock authored Mar 13, 2024
1 parent 5e65ac6 commit 21bfe7f
Show file tree
Hide file tree
Showing 535 changed files with 1,309 additions and 1,293 deletions.
84 changes: 50 additions & 34 deletions src/marks/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,28 @@ function axisTickKy(
...options
}
) {
return axisMark(vectorY, k, anchor, `${k}-axis tick`, data, {
strokeWidth,
strokeLinecap,
strokeLinejoin,
facetAnchor,
frameAnchor,
y,
...options,
dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
anchor: "start",
length: tickSize,
shape: anchor === "left" ? shapeTickLeft : shapeTickRight
});
return axisMark(
vectorY,
k,
data,
{
ariaLabel: `${k}-axis tick`,
ariaHidden: true
},
{
strokeWidth,
strokeLinecap,
strokeLinejoin,
facetAnchor,
frameAnchor,
y,
...options,
dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
anchor: "start",
length: tickSize,
shape: anchor === "left" ? shapeTickLeft : shapeTickRight
}
);
}

function axisTickKx(
Expand All @@ -312,19 +321,28 @@ function axisTickKx(
...options
}
) {
return axisMark(vectorX, k, anchor, `${k}-axis tick`, data, {
strokeWidth,
strokeLinejoin,
strokeLinecap,
facetAnchor,
frameAnchor,
x,
...options,
dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
anchor: "start",
length: tickSize,
shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
});
return axisMark(
vectorX,
k,
data,
{
ariaLabel: `${k}-axis tick`,
ariaHidden: true
},
{
strokeWidth,
strokeLinejoin,
strokeLinecap,
facetAnchor,
frameAnchor,
x,
...options,
dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
anchor: "start",
length: tickSize,
shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
}
);
}

function axisTextKy(
Expand Down Expand Up @@ -352,9 +370,8 @@ function axisTextKy(
return axisMark(
textY,
k,
anchor,
`${k}-axis tick label`,
data,
{ariaLabel: `${k}-axis tick label`},
{
facetAnchor,
frameAnchor,
Expand Down Expand Up @@ -399,9 +416,8 @@ function axisTextKx(
return axisMark(
textX,
k,
anchor,
`${k}-axis tick label`,
data,
{ariaLabel: `${k}-axis tick label`},
{
facetAnchor,
frameAnchor,
Expand Down Expand Up @@ -453,7 +469,7 @@ function gridKy(
...options
}
) {
return axisMark(ruleY, k, anchor, `${k}-grid`, data, {y, x1, x2, ...gridDefaults(options)});
return axisMark(ruleY, k, data, {ariaLabel: `${k}-grid`, ariaHidden: true}, {y, x1, x2, ...gridDefaults(options)});
}

function gridKx(
Expand All @@ -468,7 +484,7 @@ function gridKx(
...options
}
) {
return axisMark(ruleX, k, anchor, `${k}-grid`, data, {x, y1, y2, ...gridDefaults(options)});
return axisMark(ruleX, k, data, {ariaLabel: `${k}-grid`, ariaHidden: true}, {x, y1, y2, ...gridDefaults(options)});
}

function gridDefaults({
Expand Down Expand Up @@ -520,7 +536,7 @@ function labelOptions(
};
}

function axisMark(mark, k, anchor, ariaLabel, data, options, initialize) {
function axisMark(mark, k, data, properties, options, initialize) {
let channels;

function axisInitializer(data, facets, _channels, scales, dimensions, context) {
Expand Down Expand Up @@ -615,7 +631,7 @@ function axisMark(mark, k, anchor, ariaLabel, data, options, initialize) {
} else {
channels = {};
}
m.ariaLabel = ariaLabel;
if (properties !== undefined) Object.assign(m, properties);
if (m.clip === undefined) m.clip = false; // don’t clip axes by default
return m;
}
Expand Down
6 changes: 3 additions & 3 deletions test/output/aaplBollinger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions test/output/aaplBollingerCandlestick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions test/output/aaplBollingerGridInterval.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions test/output/aaplBollingerGridSpacing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions test/output/aaplCandlestick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions test/output/aaplChangeVolume.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 21bfe7f

Please sign in to comment.