diff --git a/src/lib/gl_format_color.js b/src/lib/gl_format_color.js index 36cd70d5ba7..41b95484306 100644 --- a/src/lib/gl_format_color.js +++ b/src/lib/gl_format_color.js @@ -41,11 +41,12 @@ function formatColor(containerIn, opacityIn, len) { var colorIn = containerIn.color; var isArrayColorIn = isArrayOrTypedArray(colorIn); var isArrayOpacityIn = isArrayOrTypedArray(opacityIn); + var cOpts = Colorscale.extractOpts(containerIn); var colorOut = []; var sclFunc, getColor, getOpacity, colori, opacityi; - if(containerIn.colorscale !== undefined) { + if(cOpts.colorscale !== undefined) { sclFunc = Colorscale.makeColorScaleFuncFromTrace(containerIn); } else { sclFunc = validateColor; diff --git a/test/image/baselines/gl2d_marker_coloraxis.png b/test/image/baselines/gl2d_marker_coloraxis.png new file mode 100644 index 00000000000..e1ec515186a Binary files /dev/null and b/test/image/baselines/gl2d_marker_coloraxis.png differ diff --git a/test/image/mocks/gl2d_marker_coloraxis.json b/test/image/mocks/gl2d_marker_coloraxis.json new file mode 100644 index 00000000000..4feddd96ab4 --- /dev/null +++ b/test/image/mocks/gl2d_marker_coloraxis.json @@ -0,0 +1,911 @@ +{ + "data": [ + { + "hoverlabel": { + "namelength": 0 + }, + "hovertemplate": "sex=Female
total_bill=%{x}
tip=%{y}
size=%{marker.color}", + "legendgroup": "", + "marker": { + "color": [ + 2, + 4, + 4, + 2, + 3, + 3, + 2, + 2, + 2, + 2, + 4, + 3, + 2, + 4, + 2, + 2, + 1, + 3, + 2, + 2, + 2, + 1, + 4, + 2, + 2, + 2, + 2, + 2, + 3, + 2, + 2, + 2, + 1, + 3, + 2, + 2, + 2, + 4, + 2, + 2, + 6, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 6, + 2, + 2, + 3, + 2, + 5, + 4, + 2, + 3, + 2, + 2, + 2, + 2, + 3, + 3, + 2, + 4, + 2, + 2, + 2, + 2, + 3, + 2, + 2, + 3, + 2, + 4, + 2, + 3, + 2, + 2, + 2, + 3, + 2, + 2 + ], + "coloraxis": "coloraxis", + "symbol": "circle" + }, + "mode": "markers", + "name": "", + "showlegend": false, + "type": "scattergl", + "x": [ + 16.99, + 24.59, + 35.26, + 14.83, + 10.33, + 16.97, + 20.29, + 15.77, + 19.65, + 15.06, + 20.69, + 16.93, + 10.29, + 34.81, + 26.41, + 16.45, + 3.07, + 17.07, + 26.86, + 25.28, + 14.73, + 10.07, + 34.83, + 5.75, + 16.32, + 22.75, + 11.35, + 15.38, + 44.3, + 22.42, + 20.92, + 14.31, + 7.25, + 25.71, + 17.31, + 10.65, + 12.43, + 24.08, + 13.42, + 12.48, + 29.8, + 14.52, + 11.38, + 20.27, + 11.17, + 12.26, + 18.26, + 8.51, + 10.33, + 14.15, + 13.16, + 17.47, + 27.05, + 16.43, + 8.35, + 18.64, + 11.87, + 29.85, + 25, + 13.39, + 16.21, + 17.51, + 10.59, + 10.63, + 9.6, + 20.9, + 18.15, + 19.81, + 43.11, + 13, + 12.74, + 13, + 16.4, + 16.47, + 12.76, + 13.27, + 28.17, + 12.9, + 30.14, + 13.42, + 15.98, + 16.27, + 10.09, + 22.12, + 35.83, + 27.18, + 18.78 + ], + "xaxis": "x", + "y": [ + 1.01, + 3.61, + 5, + 3.02, + 1.67, + 3.5, + 2.75, + 2.23, + 3, + 3, + 2.45, + 3.07, + 2.6, + 5.2, + 1.5, + 2.47, + 1, + 3, + 3.14, + 5, + 2.2, + 1.83, + 5.17, + 1, + 4.3, + 3.25, + 2.5, + 3, + 2.5, + 3.48, + 4.08, + 4, + 1, + 4, + 3.5, + 1.5, + 1.8, + 2.92, + 1.68, + 2.52, + 4.2, + 2, + 2, + 2.83, + 1.5, + 2, + 3.25, + 1.25, + 2, + 2, + 2.75, + 3.5, + 5, + 2.3, + 1.5, + 1.36, + 1.63, + 5.14, + 3.75, + 2.61, + 2, + 3, + 1.61, + 2, + 4, + 3.5, + 3.5, + 4.19, + 5, + 2, + 2.01, + 2, + 2.5, + 3.23, + 2.23, + 2.5, + 6.5, + 1.1, + 3.09, + 3.48, + 3, + 2.5, + 2, + 2.88, + 4.67, + 2, + 3 + ], + "yaxis": "y" + }, + { + "hoverlabel": { + "namelength": 0 + }, + "hovertemplate": "sex=Male
total_bill=%{x}
tip=%{y}
size=%{marker.color}", + "legendgroup": "", + "marker": { + "color": [ + 3, + 3, + 2, + 4, + 2, + 4, + 2, + 2, + 2, + 2, + 4, + 2, + 3, + 3, + 2, + 4, + 2, + 4, + 2, + 2, + 2, + 2, + 4, + 2, + 3, + 3, + 3, + 3, + 3, + 2, + 2, + 2, + 4, + 2, + 2, + 4, + 3, + 2, + 2, + 2, + 4, + 2, + 4, + 2, + 4, + 2, + 2, + 2, + 4, + 3, + 3, + 2, + 2, + 2, + 2, + 2, + 4, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 4, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 3, + 2, + 4, + 2, + 2, + 2, + 2, + 3, + 2, + 2, + 6, + 5, + 2, + 2, + 2, + 2, + 3, + 4, + 4, + 6, + 4, + 4, + 2, + 2, + 3, + 2, + 4, + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 4, + 2, + 3, + 4, + 2, + 5, + 5, + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 3, + 4, + 3, + 4, + 2, + 3, + 4, + 4, + 5, + 2, + 2, + 2, + 1, + 2, + 4, + 2, + 4, + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 3, + 2, + 2 + ], + "coloraxis": "coloraxis", + "symbol": "circle" + }, + "mode": "markers", + "name": "", + "showlegend": false, + "type": "scattergl", + "x": [ + 10.34, + 21.01, + 23.68, + 25.29, + 8.77, + 26.88, + 15.04, + 14.78, + 10.27, + 15.42, + 18.43, + 21.58, + 16.29, + 20.65, + 17.92, + 39.42, + 19.82, + 17.81, + 13.37, + 12.69, + 21.7, + 9.55, + 18.35, + 17.78, + 24.06, + 16.31, + 18.69, + 31.27, + 16.04, + 17.46, + 13.94, + 9.68, + 30.4, + 18.29, + 22.23, + 32.4, + 28.55, + 18.04, + 12.54, + 9.94, + 25.56, + 19.49, + 38.01, + 11.24, + 48.27, + 20.29, + 13.81, + 11.02, + 18.29, + 17.59, + 20.08, + 20.23, + 15.01, + 12.02, + 10.51, + 17.92, + 27.2, + 22.76, + 17.29, + 19.44, + 16.66, + 32.68, + 15.98, + 13.03, + 18.28, + 24.71, + 21.16, + 28.97, + 22.49, + 40.17, + 27.28, + 12.03, + 21.01, + 12.46, + 15.36, + 20.49, + 25.21, + 18.24, + 14, + 38.07, + 23.95, + 29.93, + 11.69, + 14.26, + 15.95, + 8.52, + 22.82, + 19.08, + 16, + 34.3, + 41.19, + 9.78, + 7.51, + 14.07, + 13.13, + 17.26, + 24.55, + 19.77, + 48.17, + 16.49, + 21.5, + 12.66, + 13.81, + 24.52, + 20.76, + 31.71, + 50.81, + 15.81, + 7.25, + 31.85, + 16.82, + 32.9, + 17.89, + 14.48, + 34.63, + 34.65, + 23.33, + 45.35, + 23.17, + 40.55, + 20.69, + 30.46, + 23.1, + 15.69, + 28.44, + 15.48, + 16.58, + 7.56, + 10.34, + 13.51, + 18.71, + 20.53, + 26.59, + 38.73, + 24.27, + 30.06, + 25.89, + 48.33, + 28.15, + 11.59, + 7.74, + 12.16, + 8.58, + 13.42, + 20.45, + 13.28, + 24.01, + 15.69, + 11.61, + 10.77, + 15.53, + 10.07, + 12.6, + 32.83, + 29.03, + 22.67, + 17.82 + ], + "xaxis": "x2", + "y": [ + 1.66, + 3.5, + 3.31, + 4.71, + 2, + 3.12, + 1.96, + 3.23, + 1.71, + 1.57, + 3, + 3.92, + 3.71, + 3.35, + 4.08, + 7.58, + 3.18, + 2.34, + 2, + 2, + 4.3, + 1.45, + 2.5, + 3.27, + 3.6, + 2, + 2.31, + 5, + 2.24, + 2.54, + 3.06, + 1.32, + 5.6, + 3, + 5, + 6, + 2.05, + 3, + 2.5, + 1.56, + 4.34, + 3.51, + 3, + 1.76, + 6.73, + 3.21, + 2, + 1.98, + 3.76, + 2.64, + 3.15, + 2.01, + 2.09, + 1.97, + 1.25, + 3.08, + 4, + 3, + 2.71, + 3, + 3.4, + 5, + 2.03, + 2, + 4, + 5.85, + 3, + 3, + 3.5, + 4.73, + 4, + 1.5, + 3, + 1.5, + 1.64, + 4.06, + 4.29, + 3.76, + 3, + 4, + 2.55, + 5.07, + 2.31, + 2.5, + 2, + 1.48, + 2.18, + 1.5, + 2, + 6.7, + 5, + 1.73, + 2, + 2.5, + 2, + 2.74, + 2, + 2, + 5, + 2, + 3.5, + 2.5, + 2, + 3.48, + 2.24, + 4.5, + 10, + 3.16, + 5.15, + 3.18, + 4, + 3.11, + 2, + 2, + 3.55, + 3.68, + 5.65, + 3.5, + 6.5, + 3, + 5, + 2, + 4, + 1.5, + 2.56, + 2.02, + 4, + 1.44, + 2, + 2, + 4, + 4, + 3.41, + 3, + 2.03, + 2, + 5.16, + 9, + 3, + 1.5, + 1.44, + 2.2, + 1.92, + 1.58, + 3, + 2.72, + 2, + 3, + 3.39, + 1.47, + 3, + 1.25, + 1, + 1.17, + 5.92, + 2, + 1.75 + ], + "yaxis": "y" + } + ], + "layout": { + "annotations": [ + { + "showarrow": false, + "text": "sex=Female", + "textangle": 0, + "x": 0.23684210526315788, + "xanchor": "center", + "xref": "paper", + "y": 1.02, + "yanchor": "middle", + "yref": "paper" + }, + { + "showarrow": false, + "text": "sex=Male", + "textangle": 0, + "x": 0.763157894736842, + "xanchor": "center", + "xref": "paper", + "y": 1.02, + "yanchor": "middle", + "yref": "paper" + } + ], + "coloraxis": { + "colorbar": { + "title": { + "text": "size" + } + }, + "colorscale": [ + [ + 0, + "#440154" + ], + [ + 0.1111111111111111, + "#482878" + ], + [ + 0.2222222222222222, + "#3e4989" + ], + [ + 0.3333333333333333, + "#31688e" + ], + [ + 0.4444444444444444, + "#26828e" + ], + [ + 0.5555555555555556, + "#1f9e89" + ], + [ + 0.6666666666666666, + "#35b779" + ], + [ + 0.7777777777777778, + "#6ece58" + ], + [ + 0.8888888888888888, + "#b5de2b" + ], + [ + 1, + "#fde725" + ] + ] + }, + "grid": { + "xaxes": [ + "x", + "x2" + ], + "xgap": 0.1, + "xside": "bottom", + "yaxes": [ + "y" + ], + "ygap": 0.1, + "yside": "left" + }, + "height": 600, + "legend": { + "tracegroupgap": 0 + }, + "margin": { + "t": 60 + }, + "xaxis": { + "title": { + "text": "total_bill" + }, + "type": "linear", + "range": [ + 0.00511244751263229, + 54.04809123905772 + ], + "autorange": true + }, + "xaxis2": { + "matches": "x", + "title": { + "text": "total_bill" + }, + "type": "linear", + "range": [ + 0.00511244751263229, + 54.04809123905772 + ], + "autorange": true + }, + "yaxis": { + "title": { + "text": "tip" + }, + "type": "linear", + "range": [ + 0.40774907749077494, + 10.592250922509225 + ], + "autorange": true + } + } +}