-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
add Chart2Music keyboard and sound accessibility features #6680
Open
aliwelchoo
wants to merge
82
commits into
plotly:master
Choose a base branch
from
aliwelchoo:chart2music
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
6fb9c65
initial commit, single scatter plot
87b4c5c
single scatter plot
64ae505
options and info
d37d24f
data and trace labels
d0467bb
false default
3a73776
remove debugging prints
b4df959
use index if no x provided
97b608f
Lib requirement
6205d62
layout destructuring
7e40cde
layout defaults
6d9185b
destructure trace
935cf54
test sourcetype module
44deae2
remove sourcetype
c38ab67
into es5
c6a27be
include mjs files
cac174c
transpile accessibility
159ca1b
accessibility in config
7467a47
Merge branch 'master' into chart2music
ayjayt 08b820b
Remove special rules from webpack.config:
ayjayt 41b0fb9
Reorder declarations to make a bit more readable
ayjayt 94e25c3
Lint
ayjayt 61ea8ce
Change import/export scheme to promise
ayjayt c9a0b91
Remove a console.log
ayjayt cc92639
Limit chunks to 1
ayjayt 7baa0d3
Upgrade chart2music to support commonjs
ayjayt 3127dee
Rewrite accessibility in es5
ayjayt 2429e55
Merge pull request #1 from geopozo/pikul-music-import-promise
aliwelchoo 00572e8
Fix some undef errors in accessibility
ayjayt 30f4e11
update plot-schema diff
ayjayt 247b301
Merge branch 'master' into pikul-music-import-promise
ayjayt d08adfb
Add config so dev can place closed captions:
ayjayt dbce5da
Merge branch 'chart2music' of https://github.com/aliwelchoo/plotly.js…
ayjayt e1f9563
Add more default assurance in accessibility
ayjayt 3f4ab54
Lint
ayjayt 92d97b7
Skip empty trace data in accessibility.enable:
ayjayt 6b2dcc9
update plot-schema diff
ayjayt b5bb517
Modify how accessibility treats config vars:
ayjayt 25ca44a
Remove jasmine ftest focus
ayjayt 7328324
Run schema plot diff
ayjayt 00b2750
Test if previous commits deprecate hack-fix
ayjayt b04bb17
Set c2music default to not make its caption div:
ayjayt d4bd71b
update plot-scheme diff
ayjayt af2ff80
Add closed captions to dev dashboard
ayjayt 80b4cf3
Merge pull request #2 from geopozo/pikul-music-import-promise
aliwelchoo ee99f35
Merge branch 'master' into chart2music
ayjayt 3841640
Merge branch 'master' into chart2music
ayjayt d84d108
Merge branch 'master' into chart2music
ayjayt 0c43407
Refactor accessibility/c2m:
ayjayt 4c75035
Lint
ayjayt 3c49ed6
Fix import path
ayjayt f7be666
Merge remote-tracking branch 'origin/build-with-esbuild' into chart2m…
archmoj 4a260af
Merge branch 'master' into chart2music
ayjayt f67c513
Merge branch 'master' into chart2music
ayjayt 41baab9
Merge branch 'master' into chart2music
ayjayt 26754b7
Merge with master
marthacryan ed18907
Change name of config to sonification, clean up directory
marthacryan 1e4bcef
Spelling
marthacryan 2c1abf4
fix directory name
marthacryan 614fb8b
Reset package-lock
marthacryan 5f5e599
Update package-lock.json
marthacryan fe9736e
Reset tests
marthacryan 59ad5c6
Update auto-generated schema
marthacryan d18c584
Rename more stuff to sonification and clean up contributing
marthacryan 043d408
Update filepath for new location of enable_sonification.js
marthacryan 129eb3b
Code readability improvements
marthacryan acc8517
Add baseline for new mock
marthacryan c5ad240
Remove changes in existing mock
marthacryan 0113d90
Update baseline
marthacryan 771029e
Remove function that was introduced through incorrect merge
marthacryan bfbbbf1
Undo changes to jasmine tests
marthacryan cadfd7f
Revert "Code readability improvements"
marthacryan 56e582d
Fix syntax
marthacryan 8e55f98
remove comment
marthacryan 86d75d8
Remove todo
marthacryan 15671b0
Schema update
marthacryan 057e067
Merge branch 'master' of github.com:plotly/plotly.js into chart2music
marthacryan 44f7ad3
Remove accessibility wrapper directory
marthacryan 8e3b62b
Fix filepaths
marthacryan aed1e02
Code cleanup
marthacryan 1777fba
Code cleanup
marthacryan 3a0384f
Code cleanup
marthacryan dba0b53
Fix trace bug
marthacryan 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# `plotly.js` wrapper for `chart2music`, sonified charts | ||
|
||
This wrapper attaches a context object to `gd._context._c2m` with the following properties: | ||
|
||
* `.options`: the options object as required by c2m | ||
* `.info`: the info object as required by c2m | ||
* `.ccOptions`: information about where to place the closed caption div | ||
* `.c2mHandler`: the object returned by calling the c2m library's initializer | ||
|
||
The first three have most of their values set by the defaults in *src/plot_api/plot_config.js*. | ||
|
||
|
||
### index.js | ||
|
||
**index.js** exposes the following api: | ||
|
||
* `initC2M(gd, defaultConfig)` full resets the `c2mChart` object. | ||
* `defaultConfig` is equal to `gd._context.sonification`, as defined in *src/plot_api/plot_config.js*. | ||
|
||
### all_codecs.js | ||
**all_codecs.js** agregates all the individual **_codec.js* files, all are expect to export exactly two functions: `test` and `process`. | ||
|
||
I chose to aggregate all codecs in a separate file because it will ultimately be a 1-1 conversion if `plotly.js` adopts ES modules. | ||
|
||
## Writing a Codec | ||
|
||
This section is TODO | ||
|
||
chart2music supports N types of graphs. We should figure out how how to convert as many plotly types to chart2music types. I will write descriptions for each type in the folder, if not the actual code, along with what `test` must return and what `process` must return. |
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,5 @@ | ||
'use strict'; | ||
|
||
var scatterXY = require('./xy_scatter_codec'); | ||
|
||
exports.codecs = [ scatterXY ]; |
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,10 @@ | ||
'use strict'; | ||
|
||
var c2mPlotly = require('.'); | ||
|
||
function enable_sonification(gd) { | ||
// Collecting defaults | ||
var defaultConfig = gd._context.sonification; | ||
c2mPlotly.initC2M(gd, defaultConfig); | ||
} | ||
exports.enable_sonification = enable_sonification; |
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,96 @@ | ||||||||||||
'use strict'; | ||||||||||||
|
||||||||||||
var c2m = require('chart2music'); | ||||||||||||
var Fx = require('../components/fx'); | ||||||||||||
var Lib = require('../lib'); | ||||||||||||
|
||||||||||||
var codecs = require('./all_codecs').codecs; | ||||||||||||
|
||||||||||||
/* initClosedCaptionDiv: Initialize the closed caption div with the given configuration. | ||||||||||||
* This function works by either creating a new div or returning the existing div | ||||||||||||
*/ | ||||||||||||
function initClosedCaptionDiv(gd, config) { | ||||||||||||
if(config.generate) { | ||||||||||||
var closedCaptions = document.createElement('div'); | ||||||||||||
closedCaptions.id = config.elId; | ||||||||||||
closedCaptions.className = config.elClassname; | ||||||||||||
gd.parentNode.insertBefore(closedCaptions, gd.nextSibling); // this really might not work | ||||||||||||
return closedCaptions; | ||||||||||||
} else { | ||||||||||||
return document.getElementById(config.elId); | ||||||||||||
} | ||||||||||||
Comment on lines
+19
to
+21
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. We could simply return and drop else.
Suggested change
|
||||||||||||
} | ||||||||||||
|
||||||||||||
/* initC2M: Initialize the chart2music library with the given configuration. | ||||||||||||
* This function works by resetting the c2m context of the given graph div | ||||||||||||
*/ | ||||||||||||
function initC2M(gd, defaultConfig) { | ||||||||||||
var c2mContext = gd._context._c2m = {}; | ||||||||||||
c2mContext.options = Lib.extendDeepAll({}, defaultConfig.options); | ||||||||||||
c2mContext.info = Lib.extendDeepAll({}, defaultConfig.info); | ||||||||||||
c2mContext.ccOptions = Lib.extendDeepAll({}, defaultConfig.closedCaptions); | ||||||||||||
|
||||||||||||
var labels = []; | ||||||||||||
// Set the onFocusCallback to highlight the hovered point | ||||||||||||
c2mContext.options.onFocusCallback = function(dataInfo) { | ||||||||||||
Fx.hover(gd, [{ | ||||||||||||
curveNumber: labels.indexOf(dataInfo.slice), | ||||||||||||
pointNumber: dataInfo.index | ||||||||||||
}]); | ||||||||||||
}; | ||||||||||||
|
||||||||||||
var ccElement = initClosedCaptionDiv(gd, c2mContext.ccOptions); | ||||||||||||
|
||||||||||||
// Get the chart, x, and y axis titles from the layout. | ||||||||||||
// This will be used for the closed captions. | ||||||||||||
var titleText = 'Chart'; | ||||||||||||
if((gd._fullLayout.title !== undefined) && (gd._fullLayout.title.text !== undefined)) { | ||||||||||||
titleText = gd._fullLayout.title.text; | ||||||||||||
} | ||||||||||||
var xAxisText = 'X Axis'; | ||||||||||||
if((gd._fullLayout.xaxis !== undefined) && | ||||||||||||
(gd._fullLayout.xaxis.title !== undefined) && | ||||||||||||
(gd._fullLayout.xaxis.title.text !== undefined)) { | ||||||||||||
xAxisText = gd._fullLayout.xaxis.title.text; | ||||||||||||
} | ||||||||||||
var yAxisText = 'Y Axis'; | ||||||||||||
if((gd._fullLayout.yaxis !== undefined) && | ||||||||||||
(gd._fullLayout.yaxis.title !== undefined) && | ||||||||||||
(gd._fullLayout.yaxis.title.text !== undefined)) { | ||||||||||||
yAxisText = gd._fullLayout.yaxis.title.text; | ||||||||||||
} | ||||||||||||
|
||||||||||||
// Convert the data to the format that c2m expects | ||||||||||||
var c2mData = {}; | ||||||||||||
var types = []; | ||||||||||||
var fullData = gd._fullData; | ||||||||||||
|
||||||||||||
// Iterate through the traces and find the codec that matches the trace | ||||||||||||
for (var trace of fullData) { | ||||||||||||
for (var codec of codecs) { | ||||||||||||
var test = codec.test(trace); | ||||||||||||
if (!test) continue; | ||||||||||||
|
||||||||||||
// Generate a unique label for the trace | ||||||||||||
var label = test.name; | ||||||||||||
labels.push(label); | ||||||||||||
types.push(test.type); | ||||||||||||
c2mData[label] = codec.process(trace); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
c2mContext.c2mHandler = c2m.c2mChart({ | ||||||||||||
title: titleText, | ||||||||||||
type: types, | ||||||||||||
axes: { | ||||||||||||
x: { label: xAxisText }, | ||||||||||||
y: { label: yAxisText }, | ||||||||||||
}, | ||||||||||||
element: gd, | ||||||||||||
cc: ccElement, | ||||||||||||
data: c2mData, | ||||||||||||
options: c2mContext.options, | ||||||||||||
info: c2mContext.info | ||||||||||||
}); | ||||||||||||
} | ||||||||||||
exports.initC2M = initC2M; |
Oops, something went wrong.
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.
IS
sonification
key always present?