Skip to content
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

refactor: make instruction message audible and visible for BLV and sighted users when focused in the maidr plot area #562

Merged
merged 1 commit into from
Sep 20, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion galleries/bar_plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,6 @@
id: 'barplot1',
title: 'The Number of Diamonds by Cut.',
selector: 'g[id^="geom_rect"] > rect',
name: 'test test test',
axes: {
x: {
label: 'Cut',
Expand Down
1 change: 0 additions & 1 deletion galleries/scatterplot.html
Original file line number Diff line number Diff line change
Expand Up @@ -4594,7 +4594,6 @@
type: ['point', 'smooth'],
id: 'scatter1',
title: 'Highway Mileage by Engine Displacement.',
name: 'Tutorial 4: Scatterplot',
selector: [
'g[id^="geom_point"] > use',
'g[id^="geom_smooth.gTree"] > g[id^="GRID.polyline"] > polyline[id^="GRID.polyline"]',
Expand Down
23 changes: 20 additions & 3 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,27 @@ function InitMaidr(thisMaidr) {
// this is hacky, but we delay just a tick so that the chart has time to load
if ('name' in singleMaidr) {
display.announceText(singleMaidr.name);
} else if ('title' in singleMaidr) {
display.announceText(singleMaidr.title);
} else if ('title' in singleMaidr || 'labels' in singleMaidr && 'title' in singleMaidr.labels) {
let title = 'title' in singleMaidr ? singleMaidr.title : singleMaidr.labels.title;

// Determine whether type is multiple or single. If multiple, put commas and "and" in between. If single, just put the type.
let plotTypeString = Array.isArray(singleMaidr.type)
? singleMaidr.type.slice(0, -1).join(', ') + ' and ' + singleMaidr.type.slice(-1)
: singleMaidr.type;

// Prepare the instruction text for multi-layered plot
let multiLayerInstruction = 'This is a multi-layered plot. Use PageUp and PageDown to switch between layers.';

// Check if plotTypeString has multiple types
let isMultiLayered = Array.isArray(singleMaidr.type) && singleMaidr.type.length > 1;

// Construct the final announceText string
let announceText = `${plotTypeString} plot of ${title}: Use Arrows to navigate data points. ${isMultiLayered ? multiLayerInstruction : ' '}Toggle B for Braille, T for Text, S for Sonification, and R for Review mode. Use H for Help.`;

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

Expand Down
Loading