Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

add Chart2Music keyboard and sound accessibility features #6680

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

Open
wants to merge 83 commits into
base: master
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
6fb9c65
initial commit, single scatter plot
Jul 21, 2023
87b4c5c
single scatter plot
Jul 21, 2023
64ae505
options and info
Jul 21, 2023
d37d24f
data and trace labels
Jul 21, 2023
d0467bb
false default
Jul 21, 2023
3a73776
remove debugging prints
Jul 21, 2023
b4df959
use index if no x provided
Jul 21, 2023
97b608f
Lib requirement
Jul 22, 2023
6205d62
layout destructuring
Jul 22, 2023
7e40cde
layout defaults
Jul 22, 2023
6d9185b
destructure trace
Jul 22, 2023
935cf54
test sourcetype module
Jul 22, 2023
44deae2
remove sourcetype
Jul 22, 2023
c38ab67
into es5
Jul 28, 2023
c6a27be
include mjs files
Jul 28, 2023
cac174c
transpile accessibility
Jul 30, 2023
159ca1b
accessibility in config
Jul 30, 2023
7467a47
Merge branch 'master' into chart2music
ayjayt Jan 12, 2024
08b820b
Remove special rules from webpack.config:
ayjayt Jan 12, 2024
41b0fb9
Reorder declarations to make a bit more readable
ayjayt Jan 12, 2024
94e25c3
Lint
ayjayt Jan 13, 2024
61ea8ce
Change import/export scheme to promise
ayjayt Jan 17, 2024
c9a0b91
Remove a console.log
ayjayt Jan 17, 2024
cc92639
Limit chunks to 1
ayjayt Jan 17, 2024
7baa0d3
Upgrade chart2music to support commonjs
ayjayt Jan 17, 2024
3127dee
Rewrite accessibility in es5
ayjayt Jan 17, 2024
2429e55
Merge pull request #1 from geopozo/pikul-music-import-promise
aliwelchoo Jan 17, 2024
00572e8
Fix some undef errors in accessibility
ayjayt Jan 17, 2024
30f4e11
update plot-schema diff
ayjayt Jan 17, 2024
247b301
Merge branch 'master' into pikul-music-import-promise
ayjayt Jan 25, 2024
d08adfb
Add config so dev can place closed captions:
ayjayt Jan 25, 2024
dbce5da
Merge branch 'chart2music' of https://github.com/aliwelchoo/plotly.js…
ayjayt Jan 25, 2024
e1f9563
Add more default assurance in accessibility
ayjayt Jan 25, 2024
3f4ab54
Lint
ayjayt Jan 25, 2024
92d97b7
Skip empty trace data in accessibility.enable:
ayjayt Jan 25, 2024
6b2dcc9
update plot-schema diff
ayjayt Jan 25, 2024
b5bb517
Modify how accessibility treats config vars:
ayjayt Jan 26, 2024
25ca44a
Remove jasmine ftest focus
ayjayt Jan 26, 2024
7328324
Run schema plot diff
ayjayt Jan 26, 2024
00b2750
Test if previous commits deprecate hack-fix
ayjayt Jan 26, 2024
b04bb17
Set c2music default to not make its caption div:
ayjayt Jan 26, 2024
d4bd71b
update plot-scheme diff
ayjayt Jan 26, 2024
af2ff80
Add closed captions to dev dashboard
ayjayt Jan 26, 2024
80b4cf3
Merge pull request #2 from geopozo/pikul-music-import-promise
aliwelchoo Jan 28, 2024
ee99f35
Merge branch 'master' into chart2music
ayjayt Jan 29, 2024
3841640
Merge branch 'master' into chart2music
ayjayt Feb 9, 2024
d84d108
Merge branch 'master' into chart2music
ayjayt Feb 28, 2024
0c43407
Refactor accessibility/c2m:
ayjayt Feb 28, 2024
4c75035
Lint
ayjayt Feb 28, 2024
3c49ed6
Fix import path
ayjayt Feb 28, 2024
f7be666
Merge remote-tracking branch 'origin/build-with-esbuild' into chart2m…
archmoj Feb 28, 2024
4a260af
Merge branch 'master' into chart2music
ayjayt Mar 10, 2024
f67c513
Merge branch 'master' into chart2music
ayjayt Mar 20, 2024
41baab9
Merge branch 'master' into chart2music
ayjayt Mar 27, 2024
26754b7
Merge with master
marthacryan Sep 16, 2024
ed18907
Change name of config to sonification, clean up directory
marthacryan Sep 23, 2024
1e4bcef
Spelling
marthacryan Sep 23, 2024
2c1abf4
fix directory name
marthacryan Sep 23, 2024
614fb8b
Reset package-lock
marthacryan Sep 23, 2024
5f5e599
Update package-lock.json
marthacryan Sep 23, 2024
fe9736e
Reset tests
marthacryan Sep 23, 2024
59ad5c6
Update auto-generated schema
marthacryan Sep 23, 2024
d18c584
Rename more stuff to sonification and clean up contributing
marthacryan Sep 24, 2024
043d408
Update filepath for new location of enable_sonification.js
marthacryan Sep 24, 2024
129eb3b
Code readability improvements
marthacryan Sep 24, 2024
acc8517
Add baseline for new mock
marthacryan Sep 24, 2024
c5ad240
Remove changes in existing mock
marthacryan Sep 24, 2024
0113d90
Update baseline
marthacryan Sep 24, 2024
771029e
Remove function that was introduced through incorrect merge
marthacryan Sep 24, 2024
bfbbbf1
Undo changes to jasmine tests
marthacryan Sep 25, 2024
cadfd7f
Revert "Code readability improvements"
marthacryan Sep 25, 2024
56e582d
Fix syntax
marthacryan Sep 25, 2024
8e55f98
remove comment
marthacryan Sep 25, 2024
86d75d8
Remove todo
marthacryan Sep 25, 2024
15671b0
Schema update
marthacryan Oct 1, 2024
057e067
Merge branch 'master' of github.com:plotly/plotly.js into chart2music
marthacryan Oct 1, 2024
44f7ad3
Remove accessibility wrapper directory
marthacryan Oct 1, 2024
8e3b62b
Fix filepaths
marthacryan Oct 1, 2024
aed1e02
Code cleanup
marthacryan Oct 1, 2024
1777fba
Code cleanup
marthacryan Oct 1, 2024
3a0384f
Code cleanup
marthacryan Oct 1, 2024
dba0b53
Fix trace bug
marthacryan Oct 4, 2024
56f2ebc
Merge branch 'master' into chart2music
ayjayt May 22, 2025
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
4 changes: 4 additions & 0 deletions 4 devtools/test_dashboard/index-mathjax3.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ <h4>no MathJax: Apple: $2, Orange: $3</h4>
<div id="graph"></div>
</div>
<div id="snapshot"></div>
<div style="position:absolute; border-top: .3em solid #eee; bottom: 0px; left: 0; width: 100%">
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if we want this to be included in every test dashboard by default. Maybe we could add a special flag for that?

<div style="margin-top: -1.2em; padding-left: 3px; font-weight: bold; color: #555; width:100%;">Closed Captions</div>
<div id="c2m-plotly-cc" style="width: 100%; height: 40px; padding: 18px 0 0 15px; color: #333">Test</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could have something more informative than "Test" here as the default value.

</div>

<script>
window.MathJax = {
Expand Down
4 changes: 4 additions & 0 deletions 4 devtools/test_dashboard/index-mathjax3chtml.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<div id="graph"></div>
</div>
<div id="snapshot"></div>
<div style="position:absolute; border-top: .3em solid #eee; bottom: 0px; left: 0; width: 100%">
<div style="margin-top: -1.2em; padding-left: 3px; font-weight: bold; color: #555; width:100%;">Closed Captions</div>
<div id="c2m-plotly-cc" style="width: 100%; height: 40px; padding: 18px 0 0 15px; color: #333">Test</div>
</div>

<script>
window.MathJax = window.MathJax || {
Expand Down
4 changes: 4 additions & 0 deletions 4 devtools/test_dashboard/index-strict.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<div id="graph"></div>
</div>
<div id="snapshot"></div>
<div style="position:absolute; border-top: .3em solid #eee; bottom: 0px; left: 0; width: 100%">
<div style="margin-top: -1.2em; padding-left: 3px; font-weight: bold; color: #555; width:100%;">Closed Captions</div>
<div id="c2m-plotly-cc" style="width: 100%; height: 40px; padding: 18px 0 0 15px; color: #333">Test</div>
</div>

<script src="../../node_modules/mathjax-v2/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
Expand Down
5 changes: 4 additions & 1 deletion 5 devtools/test_dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
<div id="graph"></div>
</div>
<div id="snapshot"></div>

<div style="position:absolute; border-top: .3em solid #eee; bottom: 0px; left: 0; width: 100%">
<div style="margin-top: -1.2em; padding-left: 3px; font-weight: bold; color: #555; width:100%;">Closed Captions</div>
<div id="c2m-plotly-cc" style="width: 100%; height: 40px; padding: 18px 0 0 15px; color: #333">Test</div>
</div>
<script src="../../node_modules/mathjax-v2/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script charset="utf-8" id="source" src="../../build/plotly.js" type="module"></script>
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
Expand Down
64 changes: 46 additions & 18 deletions 64 src/plot_api/accessibility.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

var Lib = require('../lib');
var c2m = require('chart2music');
var Fx = require('../components/fx');

Expand All @@ -9,24 +10,23 @@ function enable(gd) {
var accessibilityVars = gd._context.accessibility;
var library = accessibilityVars.library;
var options = accessibilityVars.options;
var info = accessibilityVars.info;
var closedCaptionsOptions = accessibilityVars.closedCaptions;
if(!supportedAccessibilityLibraries.includes(library)) {
// 'Accessibility not implemented for library: ' + library
return;
}
if(library === 'chart2music') {
var c2mData = {};
var labels = [];
var info = options.info;
delete options.info;
var fullData = gd._fullData;

for(var i = 0; i < fullData.length; i++) {
var trace = fullData[i] ? fullData[i] : {};
var type = trace.type;
var x = trace.x ? trace.x : [];
var y = trace.y ? trace.y : [];
var name = trace.name ? trace.name : i;
var text = trace.text ? trace.text : [];
var x = trace.x !== undefined ? trace.x : [];
var y = trace.y !== undefined ? trace.y : [];
var name = trace.name !== undefined ? trace.name : i;
var text = trace.text !== undefined ? trace.text : [];
if(type === 'scatter') {
var traceData = [];
if('y' in trace) {
Expand All @@ -38,6 +38,7 @@ function enable(gd) {
label: text[p] ? text[p] : p
});
}
if(traceData.length === 0) continue;
c2mData[name] = traceData;
labels.push(name);
}
Expand All @@ -46,16 +47,43 @@ function enable(gd) {
return;
}
}
var closedCaptions;
if(closedCaptionsOptions.generate) {
closedCaptions = document.createElement('div'); // should this be Lib.getGraphDiv()?
closedCaptions.id = closedCaptionsOptions.elId;
closedCaptions.className = closedCaptionsOptions.elClassname;
gd.parentNode.insertBefore(closedCaptions, gd.nextSibling); // this does get generated
// TODO we need a better generator
} else {
closedCaptions = document.getElementById(closedCaptionsOptions.elId);
if(closedCaptions === null) {
// TODO maybe handle this better for the developer?
return;
}
}

var closedCaptions = document.createElement('div');
closedCaptions.id = 'cc';
closedCaptions.className = 'closed_captions';
gd.appendChild(closedCaptions); // this does get generated
var titleText = 'Chart';
if((gd._fullLayout.title !== undefined) && (gd._fullLayout.title.text !== undefined)) {
titleText = gd._fullLayout.title.text;
}

var titleText = gd._fullLayout.title.text ? gd._fullLayout.title.text : 'Chart';
var xaxisText = gd._fullLayout.xaxis.title.text ? gd._fullLayout.xaxis.title.text : 'X Axis';
var yaxisText = gd._fullLayout.yaxis.title.text ? gd._fullLayout.yaxis.title.text : 'Y Axis';
options.onFocusCallback = function(dataInfo) {
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;
}
// Arguably should pass all config as copy to C2M
// If C2M eventually modifies them in any way (minus w/ _ prefix)
// It will always break transition/redraw logic in react
var options2 = Lib.extendDeepAll({}, options);
options2.onFocusCallback = function(dataInfo) {
Fx.hover(gd, [{
curveNumber: labels.indexOf(dataInfo.slice),
pointNumber: dataInfo.index
Expand All @@ -66,16 +94,16 @@ function enable(gd) {
type: 'line',
axes: {
x: {
label: xaxisText
label: xAxisText
},
y: {
label: yaxisText
label: yAxisText
},
},
element: gd,
cc: closedCaptions,
data: c2mData,
options: options,
options2: options,
info: info
});
}
Expand Down
4 changes: 0 additions & 4 deletions 4 src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2676,7 +2676,6 @@ function react(gd, data, layout, config) {
setPlotContext(gd, config);
configChanged = diffConfig(oldConfig, gd._context);
}

gd.data = data || [];
helpers.cleanData(gd.data);
gd.layout = layout || {};
Expand Down Expand Up @@ -2747,7 +2746,6 @@ function react(gd, data, layout, config) {

Plots.doCalcdata(gd);
subroutines.doAutoRangeAndConstraints(gd);

seq.push(function() {
return Plots.transitionFromReact(gd, restyleFlags, relayoutFlags, oldFullLayout);
});
Expand Down Expand Up @@ -3663,7 +3661,6 @@ function deleteFrames(gd, frameList) {
*/
function purge(gd) {
gd = Lib.getGraphDiv(gd);

var fullLayout = gd._fullLayout || {};
var fullData = gd._fullData || [];

Expand All @@ -3681,7 +3678,6 @@ function purge(gd) {

// in contrast to _doPlots.purge which does NOT clear _context!
delete gd._context;

return gd;
}

Expand Down
6 changes: 4 additions & 2 deletions 6 src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ var configAttributes = {
dflt: {
library: 'chart2music',
enabled: true,
options: {info: {}}
options: {},
info: {},
closedCaptions: {generate: false, elId: 'c2m-plotly-cc', elClassname: 'c2m-plotly-closed_captions'}
marthacryan marked this conversation as resolved.
Show resolved Hide resolved
},
description: ['Accessibility options: which library to use; whether to enable and the options to pass to the library.',
description: ['Accessibility options: which library to use; whether to enable, options to pass to the library, info to pass to the library, closedCaptions to control how plotly renders the closed-captions element.',
'chart2music is supported and options here include Options and Info from https://www.chart2music.com/docs/API/Config. '
].join(' ')
},
Expand Down
5 changes: 5 additions & 0 deletions 5 test/jasmine/assets/create_graph_div.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module.exports = function createGraphDiv() {
gd.id = 'graph';
document.body.appendChild(gd);

var closedCaptions = document.createElement('div');
marthacryan marked this conversation as resolved.
Show resolved Hide resolved
closedCaptions.id = 'c2m-plotly-cc';
closedCaptions.className = 'c2m-plotly-closed_captions';
document.body.appendChild(closedCaptions); // this does get generated

// force the graph to be at position 0,0 no matter what
gd.style.position = 'fixed';
gd.style.left = 0;
Expand Down
5 changes: 2 additions & 3 deletions 5 test/jasmine/tests/transition_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,10 @@ describe('Plotly.react transitions:', function() {
var data = [{y: [1, 2, 1]}];
var layout = {transition: {duration: 10}};
var config = {scrollZoom: true};

Plotly.react(gd, data, layout, config)
.then(function() {
assertSpies('first draw', [
[Plots, 'transitionFromReact', 0]
[Plots, 'transitionFromReact', 0] // so Plots.transitionFromReact should equal 0, ie didn't get called
]);
})
.then(function() {
Expand All @@ -581,7 +580,7 @@ describe('Plotly.react transitions:', function() {
})
.then(function() {
assertSpies('no config change', [
[Plots, 'transitionFromReact', 1]
[Plots, 'transitionFromReact', 1] // react is not calling transitionFromReact, why?
]);
})
.then(done, done.fail);
Expand Down
15 changes: 15 additions & 0 deletions 15 test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@
}
},
"config": {
"accessibility": {
marthacryan marked this conversation as resolved.
Show resolved Hide resolved
"description": "Accessibility options: which library to use; whether to enable, options to pass to the library, info to pass to the library, closedCaptions to control how plotly renders the closed-captions element. chart2music is supported and options here include Options and Info from https://www.chart2music.com/docs/API/Config. ",
"dflt": {
"closedCaptions": {
"elClassname": "c2m-plotly-closed_captions",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might want to discuss whether we want to use the name of the tool in the schema.

"elId": "c2m-plotly-cc",
"generate": false
},
"enabled": true,
"info": {},
"library": "chart2music",
"options": {}
},
"valType": "any"
},
"autosizable": {
"description": "Determines whether the graphs are plotted with respect to layout.autosize:true and infer its container size.",
"dflt": false,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.