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

feat(a11y): accessible goal and gauge chart #1174

Merged
merged 16 commits into from
Jun 30, 2021
Merged

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented May 27, 2021

Summary

Goal chart are more accessible! By default, users of assistive technologies will be able to learn more about goal charts such as the minimum, maximum, target, current value, and label major and minor.

Details

Fixes #1160

Checklist

  • Unit tests were updated or added to match the most common scenarios

@rshen91 rshen91 changed the title (a11y) Accessible goal chart feat(a11y): Accessible goal chart May 27, 2021
@rshen91 rshen91 added :accessibility Accessibility related issue :goal/gauge (old) Old Goal/Gauge chart related issues labels May 27, 2021
@rshen91 rshen91 added the enhancement New feature or request label Jun 22, 2021
@rshen91 rshen91 marked this pull request as ready for review June 22, 2021 16:54
@rshen91 rshen91 requested a review from myasonik June 22, 2021 16:54
@rshen91 rshen91 changed the title feat(a11y): Accessible goal chart feat(a11y): accessible goal chart Jun 23, 2021
@rshen91 rshen91 changed the title feat(a11y): accessible goal chart feat(a11y): accessible goal and gauge chart Jun 23, 2021
Copy link

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏

Comment on lines 45 to 48
{validGoalChart && goalChartData && <dd>{`Minimum: ${goalChartData.minimum}`}</dd>}
{validGoalChart && goalChartData && <dd>{`Maximum: ${goalChartData.maximum}`}</dd>}
{validGoalChart && goalChartData && <dd>{`Target: ${goalChartData.target}`}</dd>}
{validGoalChart && goalChartData && <dd>{`Value: ${goalChartData.value}`}</dd>}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow the same DOM structure for all the items on in the list: <dt>{category}</dt><dd>{dataPoint}</dd>. We can also probably simplify it so there's only one conditional at the same time.

Not tested but something like this should work:

Suggested change
{validGoalChart && goalChartData && <dd>{`Minimum: ${goalChartData.minimum}`}</dd>}
{validGoalChart && goalChartData && <dd>{`Maximum: ${goalChartData.maximum}`}</dd>}
{validGoalChart && goalChartData && <dd>{`Target: ${goalChartData.target}`}</dd>}
{validGoalChart && goalChartData && <dd>{`Value: ${goalChartData.value}`}</dd>}
{validGoalChart && goalChartData && <>
<dt>Minimum:</dt>
<dd>${goalChartData.minimum}</dd>
<dt>Maximum:</dt>
<dd>${goalChartData.maximum}</dd>
<dt>Target:</dt>
<dd>${goalChartData.target}</dd>
<dt>Value:</dt>
<dd>${goalChartData.}}</dd>
</>}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this makes sense! 44b9eb5

labelId,
goalChartLabels,
}: A11ySettings & ScreenReaderLabelProps) {
if (!label && !goalChartLabels?.majorLabel) return null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do a goalChartLabels.minorLabel check here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yas - 44b9eb5 thanks!!

Comment on lines 38 to 46
const goalChartLabelsSection = !goalChartLabels?.majorLabel
? null
: `Goal chart label: ${goalChartLabels.majorLabel} ${goalChartLabels.minorLabel}`;

return (
<Heading id={labelId}>
{label}
{goalChartLabelsSection}
</Heading>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole "while label to render" thing is, unfortunately, going to be more complicated...

So, first, the easy change:
The minorLabel we can just render as a <p> under the heading as there isn't a great semantic way to to signify a subheading but also shoving it all into a heading seems incorrect. So the DOM will look something like this:

return <>
	{unifedLabel && 
	      <Heading id={labelId}>
	        {unifiedLabel}
	      </Heading>
	}
    {goalChartLabels.minorLabel && <p>{goalChartLabels.minorLabel}</p>}
</>;

Now we've got the more difficult change that I hid under a new variable I made up called unifiedLabel.

  1. Goal charts are kind of great in that they're one of the few that have a visible label built in. I imagine a separate accessible label doesn't need to actually be passed in very often so let's hide that bit of indirection from users.

  2. If both an accessible label and a chart label are passed in, just from what I see users doing a lot, I'd bet they will often be identical so let's check for that too before printing both.

  3. Finally, only if both are supplied and are different should we print both and make clear what's what.

let unifiedLabel = '';

if (!label && goalChartLabels?.majorLabel) unifiedLabel = goalChartLabels?.majorLabel;
else if (label && !goalChartLabels?.majorLabel) unifiedLabel = label;
else if (label && goalChartLabels?.majorLabel && label !== goalChartLabels.majorLabel) {
	unifiedLabel = `${label}; Chart visible label: ${goalChartLabels.majorLabel}`;
}

👆 I also changed the string a little bit. Because we don't know what the user might be passing in, and it seems a little strange to pass in both, I'm being super explicit about it but also trying not to duplicate info (we elsewhere say it's a goal chart).

Hope this all makes sense! Happy to zoom about it too!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm following!! 44b9eb5 for changes, thank you!

@rshen91 rshen91 requested a review from myasonik June 24, 2021 13:40
Copy link

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, will test this next week before giving it a green light

<dd id={defaultSummaryId}>{chartTypeDescription}</dd>
{validGoalChart && goalChartData ? (
<>
<dt>{'Minimum: '}</dt>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the extra space at the end here? I don't think screen readers need it and I think this is hidden visually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch thank you 4f8e86c

@rshen91 rshen91 requested a review from myasonik June 28, 2021 13:44
Copy link

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

<>
{unifiedLabel && (
<Heading id={labelId}>
{label}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{label}

Can delete, the unifiedLabel includes it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!! Good catch 7ad9893

Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rshen91 rshen91 merged commit ffa8822 into elastic:master Jun 30, 2021
@rshen91 rshen91 deleted the a11y-goal branch June 30, 2021 13:07
nickofthyme pushed a commit that referenced this pull request Jul 6, 2021
# [31.1.0](v31.0.0...v31.1.0) (2021-07-06)

### Bug Fixes

* **heatmap:** pick correct brush end value ([#1230](#1230)) ([57678fe](57678fe)), closes [#1229](#1229)

### Features

* **a11y:** accessible goal and gauge chart ([#1174](#1174)) ([ffa8822](ffa8822)), closes [#1160](#1160)
@nickofthyme
Copy link
Collaborator

🎉 This PR is included in version 31.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nickofthyme nickofthyme added the released Issue released publicly label Jul 6, 2021
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:accessibility Accessibility related issue enhancement New feature or request :goal/gauge (old) Old Goal/Gauge chart related issues released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accessible goal chart (numbers and strings)
3 participants