-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: master
Are you sure you want to change the base?
Changes from 13 commits
6fb9c65
87b4c5c
64ae505
d37d24f
d0467bb
3a73776
b4df959
97b608f
6205d62
7e40cde
6d9185b
935cf54
44deae2
c38ab67
c6a27be
cac174c
159ca1b
7467a47
08b820b
41b0fb9
94e25c3
61ea8ce
c9a0b91
cc92639
7baa0d3
3127dee
2429e55
00572e8
30f4e11
247b301
d08adfb
dbce5da
e1f9563
3f4ab54
92d97b7
6b2dcc9
b5bb517
25ca44a
7328324
00b2750
b04bb17
d4bd71b
af2ff80
80b4cf3
ee99f35
3841640
d84d108
0c43407
4c75035
3c49ed6
f7be666
4a260af
f67c513
41baab9
26754b7
ed18907
1e4bcef
2c1abf4
614fb8b
5f5e599
fe9736e
59ad5c6
d18c584
043d408
129eb3b
acc8517
c5ad240
0113d90
771029e
bfbbbf1
cadfd7f
56e582d
8e55f98
86d75d8
15671b0
057e067
44f7ad3
8e3b62b
aed1e02
1777fba
3a0384f
dba0b53
56f2ebc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"use strict"; | ||
import c2mChart from "chart2music"; | ||
|
||
|
||
export function enable (gd) { | ||
|
||
const c2mData = {}; | ||
const labels = []; | ||
|
||
const fullData = gd._fullData; | ||
|
||
for(var i = 0; i < fullData.length; i++) { | ||
var trace = fullData[i] ?? {}; | ||
var {type, x = [], y = [], name = i, text = []} = trace; | ||
if(type === 'scatter') { | ||
var traceData = []; | ||
if ('y' in trace) { | ||
|
||
for(var p = 0; p < y.length; p++) { | ||
traceData.push( | ||
{ | ||
x: x.length > 0 ? x[p] : p, | ||
y: y[p], | ||
label: text[p] ?? p | ||
}) | ||
} | ||
c2mData[name] = traceData; | ||
labels.push(name); | ||
} | ||
} | ||
else { | ||
// 'Accessibility not implemented for trace type: ' + trace.type | ||
return; | ||
|
||
} | ||
} | ||
|
||
var closed_captions = document.createElement('div'); | ||
closed_captions.id = 'cc'; | ||
closed_captions.className = 'closed_captions'; | ||
gd.appendChild(closed_captions); | ||
|
||
const { | ||
title: {text: title_text = ''} = {}, | ||
xaxis: {title: {text: xaxis_text = ''} = {}} = {}, | ||
yaxis: {title: {text: yaxis_text = ''} = {}} = {}, | ||
} = gd._fullLayout; | ||
|
||
c2mChart({ | ||
title: title_text, | ||
type: "line", | ||
|
||
axes: { | ||
x: { | ||
label: xaxis_text | ||
}, | ||
y: { | ||
label: yaxis_text | ||
} | ||
}, | ||
element: gd, | ||
cc: closed_captions, | ||
data: c2mData, | ||
options: { | ||
onFocusCallback: ({slice, index}) => { | ||
Plotly.Fx.hover(gd, [{ | ||
curveNumber: labels.indexOf(slice), | ||
pointNumber: index | ||
}]) | ||
}, | ||
...gd._context.chart2musicOptions | ||
}, | ||
info: gd._context.chart2musicInfo | ||
aliwelchoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
}); | ||
}; |
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.
Nice MIT library.
To transpile it to es5, please add it to
plotly.js/webpack.config.js
Line 25 in 149c895
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.
Thank you! Knew there'd be something simple I was missing so I could get this into the same style