Skip to content

Commit

Permalink
Merge pull request #477 from adobe/nli1/chart-aria-label-fix
Browse files Browse the repository at this point in the history
Fix accessibility issue: <svg> elements with an img role must have an alternative text
  • Loading branch information
marshallpete authored Dec 11, 2024
2 parents c989800 + 0ec4604 commit b690296
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/specBuilder/area/areaSpecBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const defaultSpec = initializeSpec({
interactive: false,
from: { data: 'area0_facet' },
name: 'area0',
description: 'area0',
type: 'area',
},
],
Expand Down
4 changes: 4 additions & 0 deletions src/specBuilder/area/areaUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('getAreaMark', () => {
})
).toStrictEqual({
name: 'area0',
description: 'area0',
type: 'area',
from: {
data: 'area0_facet',
Expand Down Expand Up @@ -90,6 +91,7 @@ describe('getAreaMark', () => {
})
).toStrictEqual({
name: 'area0',
description: 'area0',
type: 'area',
from: {
data: 'area0_facet',
Expand Down Expand Up @@ -151,6 +153,7 @@ describe('getAreaMark', () => {
})
).toStrictEqual({
name: 'area0',
description: 'area0',
type: 'area',
from: {
data: 'area0_facet',
Expand Down Expand Up @@ -204,6 +207,7 @@ describe('getAreaMark', () => {
})
).toStrictEqual({
name: 'area0',
description: 'area0',
type: 'area',
from: {
data: 'area0_facet',
Expand Down
1 change: 1 addition & 0 deletions src/specBuilder/area/areaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const getAreaMark = (areaProps: AreaMarkProps, dataSource: string = `${ar
areaProps;
return {
name,
description: name,
type: 'area',
from: { data: dataSource },
interactive: getInteractive(children),
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/axis/axisTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { AxisSpecProps } from '../../types';

export const defaultXBaselineMark: Mark = {
name: 'xBaseline',
description: 'xBaseline',
type: 'rule',
interactive: false,
encode: {
Expand All @@ -35,6 +36,7 @@ export const defaultXBaselineMark: Mark = {

export const defaultYBaselineMark: Mark = {
name: 'yBaseline',
description: 'yBaseline',
type: 'rule',
interactive: false,
encode: {
Expand Down
1 change: 1 addition & 0 deletions src/specBuilder/axis/axisUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ export const getBaselineRule = (baselineOffset: number, position: Position): Mar

return {
name: `${orientation}Baseline`,
description: `${orientation}Baseline`,
type: 'rule',
interactive: false,
encode: {
Expand Down
1 change: 1 addition & 0 deletions src/specBuilder/bar/barAnnotationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const getAnnotationBackgroundMark = ({
style,
}: AnnotationSpecProps): RectMark => ({
name: `${barProps.name}_annotationBackground`,
description: `${barProps.name}_annotationBackground`,
type: 'rect',
from: { data: `${barProps.name}_annotationText` },
interactive: false,
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/bar/barSpecBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const defaultSelectedGroupIdTransform: Transforms[] = [

const defaultBackgroundStackedMark: Mark = {
name: 'bar0_background',
description: 'bar0_background',
type: 'rect',
from: { data: FILTERED_TABLE },
interactive: false,
Expand All @@ -169,6 +170,7 @@ const defaultBackgroundStackedMark: Mark = {
};
const defaultStackedMark: Mark = {
name: 'bar0',
description: 'bar0',
type: 'rect',
from: { data: FILTERED_TABLE },
interactive: false,
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/bar/stackedBarUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const defaultBackgroundMark: Mark = {
from: { data: FILTERED_TABLE },
interactive: false,
name: 'bar0_background',
description: 'bar0_background',
type: 'rect',
};

Expand All @@ -63,6 +64,7 @@ const defaultMark = {
from: { data: FILTERED_TABLE },
interactive: false,
name: 'bar0',
description: 'bar0',
type: 'rect',
};

Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/bar/stackedBarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const getStackedBackgroundBar = (props: BarSpecProps): RectMark => {

return {
name: `${name}_background`,
description:`${name}_background`,
type: 'rect',
from: { data: isDodgedAndStacked(props) ? `${name}_facet` : getBaseDataSourceName(props) },
interactive: false,
Expand All @@ -88,6 +89,7 @@ export const getStackedBar = (props: BarSpecProps): RectMark => {
const { children, name } = props;
return {
name,
description: name,
type: 'rect',
from: { data: isDodgedAndStacked(props) ? `${name}_facet` : getBaseDataSourceName(props) },
interactive: getInteractive(children, props),
Expand Down
1 change: 1 addition & 0 deletions src/specBuilder/donut/donutUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const getArcMark = (props: DonutSpecProps): ArcMark => {
return {
type: 'arc',
name,
description: name,
from: { data: FILTERED_TABLE },
encode: {
enter: {
Expand Down
1 change: 1 addition & 0 deletions src/specBuilder/line/lineMarkUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('getLineMark()', () => {
const lineMark = getLineMark(defaultLineMarkProps, 'line0_facet');
expect(lineMark).toEqual({
name: 'line0',
description: 'line0',
type: 'line',
from: { data: 'line0_facet' },
interactive: false,
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/line/lineMarkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const getLineMark = (lineMarkProps: LineMarkProps, dataSource: string): L

return {
name,
description: name,
type: 'line',
from: { data: dataSource },
interactive: false,
Expand Down Expand Up @@ -152,6 +153,7 @@ export const getLineHoverMarks = (
const getHoverRule = (dimension: string, name: string, scaleType: ScaleType): RuleMark => {
return {
name: `${name}_hoverRule`,
description: `${name}_hoverRule`,
type: 'rule',
from: { data: `${name}_highlightedData` },
interactive: false,
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/line/linePointUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const getLineStaticPoint = ({
}: LineSpecProps): SymbolMark => {
return {
name: `${name}_staticPoints`,
description: `${name}_staticPoints`,
type: 'symbol',
from: { data: `${name}_staticPointData` },
interactive: false,
Expand All @@ -78,6 +79,7 @@ export const getHighlightBackgroundPoint = (lineProps: LineMarkProps): SymbolMar
const { dimension, metric, metricAxis, name, scaleType } = lineProps;
return {
name: `${name}_pointBackground`,
description: `${name}_pointBackground`,
type: 'symbol',
from: { data: `${name}_highlightedData` },
interactive: false,
Expand Down
7 changes: 7 additions & 0 deletions src/specBuilder/line/lineSpecBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const defaultSpec = initializeSpec({
},
from: { data: 'line0_facet' },
name: 'line0',
description: 'line0',
type: 'line',
interactive: false,
},
Expand Down Expand Up @@ -171,6 +172,7 @@ const line0_groupMark = {
marks: [
{
name: 'line0',
description: 'line0',
type: 'line',
from: {
data: 'line0_facet',
Expand Down Expand Up @@ -207,6 +209,7 @@ const metricRangeGroupMark = {
marks: [
{
name: 'line0MetricRange0_line',
description: 'line0MetricRange0_line',
type: 'line',
from: {
data: 'line0MetricRange0_facet',
Expand Down Expand Up @@ -241,6 +244,7 @@ const metricRangeGroupMark = {
},
{
name: 'line0MetricRange0_area',
description: 'line0MetricRange0_area',
type: 'area',
from: {
data: 'line0MetricRange0_facet',
Expand Down Expand Up @@ -282,6 +286,7 @@ const metricRangeWithDisplayPointMarks = [
line0_groupMark,
{
name: 'line0_staticPoints',
description: 'line0_staticPoints',
type: 'symbol',
from: {
data: 'line0_staticPointData',
Expand Down Expand Up @@ -319,6 +324,7 @@ const displayPointMarks = [
line0_groupMark,
{
name: 'line0_staticPoints',
description: 'line0_staticPoints',
type: 'symbol',
from: {
data: 'line0_staticPointData',
Expand Down Expand Up @@ -481,6 +487,7 @@ describe('lineSpecBuilder', () => {
},
from: { data: 'line0_facet' },
name: 'line0',
description: 'line0',
type: 'line',
interactive: false,
},
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/marks/markUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const getPointsForVoronoi = (
): SymbolMark => {
return {
name: `${name}_pointsForVoronoi`,
description: `${name}_pointsForVoronoi`,
type: 'symbol',
from: { data: dataSource },
interactive: false,
Expand All @@ -329,6 +330,7 @@ export const getPointsForVoronoi = (
*/
export const getVoronoiPath = (children: MarkChildElement[], dataSource: string, markName: string): PathMark => ({
name: `${markName}_voronoi`,
description: `${markName}_voronoi`,
type: 'path',
from: { data: dataSource },
encode: {
Expand Down
2 changes: 2 additions & 0 deletions src/specBuilder/metricRange/metricRangeUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const defaultLineProps: LineSpecProps = {
const basicMetricRangeMarks = [
{
name: 'line0MetricRange0_line',
description: 'line0MetricRange0_line',
type: 'line',
from: {
data: 'line0MetricRange0_facet',
Expand All @@ -97,6 +98,7 @@ const basicMetricRangeMarks = [
},
{
name: 'line0MetricRange0_area',
description: 'line0MetricRange0_area',
type: 'area',
from: {
data: 'line0MetricRange0_facet',
Expand Down
1 change: 1 addition & 0 deletions src/specBuilder/scatter/scatterMarkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const getScatterMark = (props: ScatterSpecProps): SymbolMark => {
} = props;
return {
name,
description: name,
type: 'symbol',
from: {
data: FILTERED_TABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export const getTrendlineAnnotationBadgeMark = ({
return [
{
name: `${name}_badge`,
description: `${name}_badge`,
type: 'rect',
from: { data: `${name}` },
interactive: false,
Expand Down

0 comments on commit b690296

Please sign in to comment.