diff --git a/src/components/fields/MarkerColor.js b/src/components/fields/MarkerColor.js index 96d3ce230..c982f06f8 100644 --- a/src/components/fields/MarkerColor.js +++ b/src/components/fields/MarkerColor.js @@ -106,14 +106,19 @@ class UnconnectedMarkerColor extends Component { let adjustedColors = colors; if (colorscaleType !== 'categorical') { - adjustedColors = adjustColorscale(colors, numberOfTraces); + adjustedColors = adjustColorscale(colors, numberOfTraces, colorscaleType); } if ( adjustedColors.every(c => c === adjustedColors[0]) || colorscaleType === 'categorical' ) { - adjustedColors = adjustColorscale(colors, numberOfTraces, {repeat: true}); + adjustedColors = adjustColorscale( + colors, + numberOfTraces, + colorscaleType, + {repeat: true} + ); } const updates = adjustedColors.map(color => ({ diff --git a/src/lib/index.js b/src/lib/index.js index f6612c629..9402208a2 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -182,7 +182,11 @@ function adjustColorscale( colorscaleType, config ) { - if (config.repeat) { + if (config && config.repeat) { + if (numberOfNeededColors < colorscale.length) { + return colorscale.slice(0, numberOfNeededColors); + } + const repetitions = Math.ceil(numberOfNeededColors / colorscale.length); const newArray = new Array(repetitions).fill(colorscale); return newArray