-
Notifications
You must be signed in to change notification settings - Fork 122
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
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
91bb738
feat: initial commit
rshen91 c63b88b
test: update snapshot
rshen91 a105604
fix: merge changes
rshen91 6245b05
feat: add goal chart data and labels
rshen91 0dc89a6
test: add test
rshen91 ebd8af7
fix: remove min max target value from not goal types
rshen91 9d5bc31
fix: clean up code
rshen91 44b9eb5
fix: code review changes
rshen91 c65eb86
Merge remote-tracking branch 'upstream/master' into a11y-goal
rshen91 9216fc8
Merge remote-tracking branch 'upstream/master' into a11y-goal
rshen91 4f8e86c
fix: fix code review
rshen91 9b4d573
test: update goal test
rshen91 eb6918c
Merge remote-tracking branch 'upstream/master' into a11y-goal
rshen91 16fe794
Merge remote-tracking branch 'upstream/master' into a11y-goal
rshen91 08c9c0b
Merge remote-tracking branch 'upstream/master' into a11y-goal
rshen91 7ad9893
fix: remove unnecessary code
rshen91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
packages/charts/src/chart_types/goal_chart/state/selectors/get_goal_chart_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { createCustomCachedSelector } from '../../../../state/create_selector'; | ||
import { geometries } from './geometries'; | ||
|
||
/** @internal */ | ||
export type GoalChartData = { | ||
maximum: number; | ||
minimum: number; | ||
target: number; | ||
value: number; | ||
}; | ||
|
||
/** @internal */ | ||
export type GoalChartLabels = { | ||
minorLabel: string; | ||
majorLabel: string; | ||
}; | ||
|
||
/** @internal */ | ||
export const getGoalChartDataSelector = createCustomCachedSelector( | ||
[geometries], | ||
(geoms): GoalChartData => { | ||
const goalChartData: GoalChartData = { | ||
maximum: geoms.bulletViewModel.highestValue, | ||
minimum: geoms.bulletViewModel.lowestValue, | ||
target: geoms.bulletViewModel.target, | ||
value: geoms.bulletViewModel.actual, | ||
}; | ||
return goalChartData; | ||
}, | ||
); | ||
|
||
/** @internal */ | ||
export const getGoalChartLabelsSelector = createCustomCachedSelector([geometries], (geoms) => { | ||
return { majorLabel: geoms.bulletViewModel.labelMajor, minorLabel: geoms.bulletViewModel.labelMinor }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,41 @@ | |
|
||
import React from 'react'; | ||
|
||
import { GoalChartData } from '../../chart_types/goal_chart/state/selectors/get_goal_chart_data'; | ||
import { A11ySettings } from '../../state/selectors/get_accessibility_config'; | ||
|
||
interface ScreenReaderTypesProps { | ||
chartTypeDescription: string; | ||
goalChartData?: GoalChartData; | ||
} | ||
|
||
/** @internal */ | ||
export function ScreenReaderTypes(props: A11ySettings & ScreenReaderTypesProps) { | ||
if (!props.defaultSummaryId) return null; | ||
export function ScreenReaderTypes({ | ||
goalChartData, | ||
defaultSummaryId, | ||
chartTypeDescription, | ||
}: A11ySettings & ScreenReaderTypesProps) { | ||
if (!defaultSummaryId && !goalChartData) return null; | ||
const validGoalChart = | ||
chartTypeDescription === 'goal chart' || | ||
chartTypeDescription === 'horizontalBullet chart' || | ||
chartTypeDescription === 'verticalBullet chart'; | ||
return ( | ||
<dl> | ||
<dt>Chart type:</dt> | ||
<dd id={props.defaultSummaryId}>{props.chartTypeDescription}</dd> | ||
<dd id={defaultSummaryId}>{chartTypeDescription}</dd> | ||
{validGoalChart && goalChartData ? ( | ||
<> | ||
<dt>{'Minimum: '}</dt> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good catch thank you 4f8e86c |
||
<dd>{goalChartData.minimum}</dd> | ||
<dt>{'Maximum: '}</dt> | ||
<dd>{goalChartData.maximum}</dd> | ||
<dt>{'Target: '}</dt> | ||
<dd>${goalChartData.target}</dd> | ||
<dd>{'Value: '}</dd> | ||
<dt>{goalChartData.value}</dt> | ||
</> | ||
) : null} | ||
</dl> | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can delete, the
unifiedLabel
includes itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!! Good catch 7ad9893