Skip to content

Commit

Permalink
feat: add alt-text for maidr plot (#568)
Browse files Browse the repository at this point in the history
Co-authored-by: ellvix <[email protected]>
  • Loading branch information
jooyoungseo and ellvix authored Oct 11, 2024
1 parent 4ccca0e commit 7752123
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,18 @@ function InitMaidr(thisMaidr) {
// actually do eventlisteners for all events
this.SetEvents();

// Set img role for chart
constants.chart.setAttribute('role', 'img');

// once everything is set up, announce the chart name (or title as a backup) to the user
setTimeout(function () {
if ('name' in singleMaidr) {
display.announceText(singleMaidr.name);
// setTimeout(function () {
if ('name' in singleMaidr) {

// Add the aria-label and title attributes to the chart
constants.chart.setAttribute('aria-label', announceText);
constants.chart.setAttribute('title', announceText);

// display.announceText(singleMaidr.name);
} else if (
'title' in singleMaidr ||
('labels' in singleMaidr && 'title' in singleMaidr.labels)
Expand Down Expand Up @@ -143,10 +151,16 @@ function InitMaidr(thisMaidr) {
isMultiLayered ? multiLayerInstruction : ' '
}Toggle B for Braille, T for Text, S for Sonification, and R for Review mode. Use H for Help.`;

// Add the aria-label and title attributes to the chart
constants.chart.setAttribute('aria-label', announceText);
constants.chart.setAttribute('title', announceText);



// Display the announcement text
display.announceText(announceText);
// display.announceText(announceText);
}
}, 100);
// }, 100);
}
}

Expand Down

0 comments on commit 7752123

Please sign in to comment.