Skip to content

fix: hide axis ticks from aria since they are just adding noise #2018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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