@@ -31,11 +31,7 @@ function initC2M(gd, defaultConfig) {
31
31
// I'd rather the callback be given its c2m handler which
32
32
// could store extra data. Or bind c2mContext as `this`.
33
33
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' ;
39
35
var ccElement = initClosedCaptionDiv ( gd , c2mContext . ccOptions ) ;
40
36
41
37
// TODO:
@@ -44,19 +40,8 @@ function initC2M(gd, defaultConfig) {
44
40
// Furthermore, I think that the traces would have to point to their axis,
45
41
// since it might not be x1, could be x2, etc
46
42
// 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' ;
60
45
61
46
var c2mData = { } ;
62
47
var types = [ ] ;
@@ -67,12 +52,12 @@ function initC2M(gd, defaultConfig) {
67
52
// TODO: what happens if this doesn't run, weird c2m errors
68
53
for ( var codecI = 0 ; codecI < codecs . length ; codecI ++ ) {
69
54
var test = codecs [ codecI ] . test ( trace ) ;
70
- if ( ! test ) continue ;
55
+ if ( ! test ) continue ;
71
56
var label = test . name ? test . name : i . toString ( ) + ' ' ;
72
57
73
58
var labelCount = 0 ;
74
59
var originalLabel = label ;
75
- while ( label in c2mData ) {
60
+ while ( label in c2mData ) {
76
61
labelCount ++ ;
77
62
label = originalLabel + labelCount . toString ( ) ;
78
63
}
0 commit comments