@@ -44,10 +44,10 @@ function mergeScaleConfig(config, options) {
4444
4545 // First figure out first scale id's per axis.
4646 // Note: for now, axis is determined from first letter of scale id!
47- Object . entries ( configScales ) . forEach ( ( [ id , scale ] ) => {
47+ Object . keys ( configScales ) . forEach ( id => {
4848 const axis = id [ 0 ] ;
4949 firstIDs [ axis ] = firstIDs [ axis ] || id ;
50- scales [ id ] = helpers . mergeIf ( { } , [ scale , chartDefaults . scales [ axis ] ] ) ;
50+ scales [ id ] = helpers . mergeIf ( { } , [ configScales [ id ] , chartDefaults . scales [ axis ] ] ) ;
5151 } ) ;
5252
5353 // Backward compatibility
@@ -59,12 +59,13 @@ function mergeScaleConfig(config, options) {
5959 // Then merge dataset defaults to scale configs
6060 config . data . datasets . forEach ( dataset => {
6161 const datasetDefaults = defaults [ dataset . type || config . type ] || { scales : { } } ;
62- Object . entries ( datasetDefaults . scales || { } ) . forEach ( ( [ defaultID , defaultScaleOptions ] ) => {
62+ const defaultScaleOptions = datasetDefaults . scales || { } ;
63+ Object . keys ( defaultScaleOptions ) . forEach ( defaultID => {
6364 const id = dataset [ defaultID + 'AxisID' ] || firstIDs [ defaultID ] || defaultID ;
6465 scales [ id ] = scales [ id ] || { } ;
6566 helpers . mergeIf ( scales [ id ] , [
6667 configScales [ id ] ,
67- defaultScaleOptions
68+ defaultScaleOptions [ defaultID ]
6869 ] ) ;
6970 } ) ;
7071 } ) ;
@@ -312,22 +313,22 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
312313 * Builds a map of scale ID to scale object for future lookup.
313314 */
314315 buildOrUpdateScales : function ( ) {
315- var me = this ;
316- var options = me . options ;
317- var scales = me . scales || { } ;
318- var items = [ ] ;
319- var updated = Object . keys ( scales ) . reduce ( function ( obj , id ) {
316+ const me = this ;
317+ const options = me . options ;
318+ const scaleOpts = options . scales ;
319+ const scales = me . scales || { } ;
320+ const updated = Object . keys ( scales ) . reduce ( function ( obj , id ) {
320321 obj [ id ] = false ;
321322 return obj ;
322323 } , { } ) ;
324+ let items = [ ] ;
323325
324- if ( options . scales ) {
326+ if ( scaleOpts ) {
325327 items = items . concat (
326- Object . entries ( options . scales ) . map ( function ( entry ) {
327- var axisID = entry [ 0 ] ;
328- var axisOptions = entry [ 1 ] ;
329- var isRadial = axisID . charAt ( 0 ) . toLowerCase === 'r' ;
330- var isHorizontal = axisID . charAt ( 0 ) . toLowerCase ( ) === 'x' ;
328+ Object . keys ( scaleOpts ) . map ( function ( axisID ) {
329+ const axisOptions = scaleOpts [ axisID ] ;
330+ const isRadial = axisID . charAt ( 0 ) . toLowerCase === 'r' ;
331+ const isHorizontal = axisID . charAt ( 0 ) . toLowerCase ( ) === 'x' ;
331332 return {
332333 options : axisOptions ,
333334 dposition : isRadial ? 'chartArea' : isHorizontal ? 'bottom' : 'left' ,
@@ -338,23 +339,23 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
338339 }
339340
340341 helpers . each ( items , function ( item ) {
341- var scaleOptions = item . options ;
342- var id = scaleOptions . id ;
343- var scaleType = valueOrDefault ( scaleOptions . type , item . dtype ) ;
342+ const scaleOptions = item . options ;
343+ const id = scaleOptions . id ;
344+ const scaleType = valueOrDefault ( scaleOptions . type , item . dtype ) ;
344345
345346 if ( scaleOptions . position === undefined || positionIsHorizontal ( scaleOptions . position , scaleOptions . axis || id [ 0 ] ) !== positionIsHorizontal ( item . dposition ) ) {
346347 scaleOptions . position = item . dposition ;
347348 }
348349
349350 updated [ id ] = true ;
350- var scale = null ;
351+ let scale = null ;
351352 if ( id in scales && scales [ id ] . type === scaleType ) {
352353 scale = scales [ id ] ;
353354 scale . options = scaleOptions ;
354355 scale . ctx = me . ctx ;
355356 scale . chart = me ;
356357 } else {
357- var scaleClass = scaleService . getScaleConstructor ( scaleType ) ;
358+ const scaleClass = scaleService . getScaleConstructor ( scaleType ) ;
358359 if ( ! scaleClass ) {
359360 return ;
360361 }
0 commit comments