Skip to content

Commit 129eb3b

Browse files
committed
Code readability improvements
1 parent 043d408 commit 129eb3b

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/accessibility/sonification/index.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ function initC2M(gd, defaultConfig) {
3131
// I'd rather the callback be given its c2m handler which
3232
// could store extra data. Or bind c2mContext as `this`.
3333

34-
var titleText = 'Chart';
35-
if((gd._fullLayout.title !== undefined) && (gd._fullLayout.title.text !== undefined)) {
36-
titleText = gd._fullLayout.title.text;
37-
}
38-
34+
var titleText = gd._fullLayout.title?.text ?? 'Chart';
3935
var ccElement = initClosedCaptionDiv(gd, c2mContext.ccOptions);
4036

4137
// TODO:
@@ -44,19 +40,8 @@ function initC2M(gd, defaultConfig) {
4440
// Furthermore, I think that the traces would have to point to their axis,
4541
// since it might not be x1, could be x2, etc
4642
// So this really needs to be part of process()
47-
var xAxisText = 'X Axis';
48-
if((gd._fullLayout.xaxis !== undefined) &&
49-
(gd._fullLayout.xaxis.title !== undefined) &&
50-
(gd._fullLayout.xaxis.title.text !== undefined)) {
51-
xAxisText = gd._fullLayout.xaxis.title.text;
52-
}
53-
var yAxisText = 'Y Axis';
54-
if((gd._fullLayout.yaxis !== undefined) &&
55-
(gd._fullLayout.yaxis.title !== undefined) &&
56-
(gd._fullLayout.yaxis.title.text !== undefined)) {
57-
yAxisText = gd._fullLayout.yaxis.title.text;
58-
}
59-
43+
var xAxisText = gd._fullLayout.xaxis?.title?.text ?? 'X Axis';
44+
var yAxisText = gd._fullLayout.yaxis?.title?.text ?? 'Y Axis';
6045

6146
var c2mData = {};
6247
var types = [];
@@ -67,12 +52,12 @@ function initC2M(gd, defaultConfig) {
6752
// TODO: what happens if this doesn't run, weird c2m errors
6853
for(var codecI = 0; codecI < codecs.length; codecI++) {
6954
var test = codecs[codecI].test(trace);
70-
if(!test) continue;
55+
if (!test) continue;
7156
var label = test.name ? test.name : i.toString() + ' ';
7257

7358
var labelCount = 0;
7459
var originalLabel = label;
75-
while(label in c2mData) {
60+
while (label in c2mData) {
7661
labelCount++;
7762
label = originalLabel + labelCount.toString();
7863
}

0 commit comments

Comments
 (0)