forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(a11y): improve chart figure (opensearch-project#1104)
- Loading branch information
Showing
7 changed files
with
148 additions
and
32 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
packages/osd-charts/integration/tests/accessibility.test.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,45 @@ | ||
/* | ||
* 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 { common } from '../page_objects/common'; | ||
|
||
describe('Accessibility tree', () => { | ||
it('should include the series types if one type of series', async () => { | ||
const tree = await common.testAccessibilityTree( | ||
'http://localhost:9001/iframe.html?id=annotations-lines--x-continuous-domain', | ||
'.echCanvasRenderer', | ||
); | ||
// the legend has bars and lines as value.descriptions not value.name | ||
const hasTextOfChartTypes = tree.children.filter((value) => { | ||
return value.name === 'bar chart'; | ||
}); | ||
expect(hasTextOfChartTypes[0].name).toBe('bar chart'); | ||
}); | ||
it('should include the series types if multiple types of series', async () => { | ||
const tree = await common.testAccessibilityTree( | ||
'http://localhost:9001/iframe.html?id=mixed-charts--bars-and-lines', | ||
'.echCanvasRenderer', | ||
); | ||
// the legend has bars and lines as value.descriptions not value.name | ||
const hasTextOfChartTypes = tree.children.filter((value) => { | ||
return value.name === 'Mixed chart: bar and line chart'; | ||
}); | ||
expect(hasTextOfChartTypes[0].name).toBe('Mixed chart: bar and line chart'); | ||
}); | ||
}); |
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
1 change: 1 addition & 0 deletions
1
packages/osd-charts/src/chart_types/xy_chart/renderer/dom/_index.scss
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@import 'highlighter'; | ||
@import 'crosshair'; | ||
@import 'screen_reader'; | ||
@import 'annotations/index'; |
8 changes: 8 additions & 0 deletions
8
packages/osd-charts/src/chart_types/xy_chart/renderer/dom/_screen_reader.scss
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,8 @@ | ||
.echScreenReaderOnly { | ||
position: absolute; | ||
left: -10000px; | ||
top: auto; | ||
width: 1px; | ||
height: 1px; | ||
overflow: hidden; | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/osd-charts/src/chart_types/xy_chart/state/selectors/get_series_types.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,34 @@ | ||
/* | ||
* 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 createCachedSelector from 're-reselect'; | ||
|
||
import { getChartIdSelector } from '../../../../state/selectors/get_chart_id'; | ||
import { SeriesType } from '../../utils/specs'; | ||
import { getSeriesSpecsSelector } from './get_specs'; | ||
|
||
/** @internal */ | ||
export const getSeriesTypes = createCachedSelector( | ||
[getSeriesSpecsSelector], | ||
(specs): Set<SeriesType> => { | ||
const seriesTypes = new Set<SeriesType>(); | ||
specs.forEach((value) => seriesTypes.add(value.seriesType)); | ||
return seriesTypes; | ||
}, | ||
)(getChartIdSelector); |
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