@@ -1168,7 +1168,9 @@ <h1 class="brand-header">
11681168 backgroundColor : 'rgba(31,119,180,0.15)' ,
11691169 pointRadius : 0 , borderWidth : 2
11701170 } ] ;
1171- if ( p2 . length ) {
1171+ const hasSecondary = p2 . length > 0 ;
1172+
1173+ if ( hasSecondary ) {
11721174 ds . push ( {
11731175 label : label2 || 'Series 2' ,
11741176 data : p2 ,
@@ -1179,17 +1181,21 @@ <h1 class="brand-header">
11791181 } ) ;
11801182 }
11811183
1184+ const scales = {
1185+ x : { type : 'time' , time : { unit : chooseTimeUnit ( all ) } } ,
1186+ y : { type : 'linear' , position : 'left' }
1187+ } ;
1188+ if ( hasSecondary ) {
1189+ scales . y1 = { type : 'linear' , position : 'right' , grid : { drawOnChartArea : false } } ;
1190+ }
1191+
11821192 chartRef = new Chart ( ctx , {
11831193 type : 'line' ,
11841194 data : { datasets : ds } ,
11851195 options : {
11861196 parsing : false , responsive : true , maintainAspectRatio : false ,
11871197 interaction : { mode : 'nearest' , intersect : false } ,
1188- scales : {
1189- x : { type : 'time' , time : { unit : chooseTimeUnit ( all ) } } ,
1190- y : { type : 'linear' , position : 'left' } ,
1191- y1 : { type : 'linear' , position : 'right' , grid : { drawOnChartArea : false } }
1192- } ,
1198+ scales,
11931199 plugins : {
11941200 legend : { display : true , position : 'top' } ,
11951201 tooltip : {
0 commit comments