From a2400f16ac2645222aa83cbcb532dbe626ede1d3 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Tue, 5 Mar 2024 14:15:54 -0500 Subject: [PATCH] add moduleHasFillgradient option to fillColorDefaults --- src/traces/scatter/defaults.js | 4 +++- src/traces/scatter/fillcolor_defaults.js | 30 ++++++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/traces/scatter/defaults.js b/src/traces/scatter/defaults.js index ce6a5fab07f..31cae6f285c 100644 --- a/src/traces/scatter/defaults.js +++ b/src/traces/scatter/defaults.js @@ -72,7 +72,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout // We handle that case in some hacky code inside handleStackDefaults. coerce('fill', stackGroupOpts ? stackGroupOpts.fillDflt : 'none'); if(traceOut.fill !== 'none') { - handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce); + handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce, { + moduleHasFillgradient: true + }); if(!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce); coercePattern(coerce, 'fillpattern', traceOut.fillcolor, false); } diff --git a/src/traces/scatter/fillcolor_defaults.js b/src/traces/scatter/fillcolor_defaults.js index 535e605be2f..0822ae8aad6 100644 --- a/src/traces/scatter/fillcolor_defaults.js +++ b/src/traces/scatter/fillcolor_defaults.js @@ -12,7 +12,9 @@ function averageColors(colorscale) { return color; } -module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coerce) { +module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coerce, opts) { + if(!opts) opts = {}; + var inheritColorFromMarker = false; if(traceOut.marker) { @@ -28,18 +30,20 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe } var averageGradientColor; - var gradientOrientation = coerce('fillgradient.type'); - if(gradientOrientation !== 'none') { - coerce('fillgradient.start'); - coerce('fillgradient.stop'); - var gradientColorscale = coerce('fillgradient.colorscale'); - - // if a fillgradient is specified, we use the average gradient color - // to specify fillcolor after all other more specific candidates - // are considered, but before the global default color. - // fillcolor affects the background color of the hoverlabel in this case. - if(gradientColorscale) { - averageGradientColor = averageColors(gradientColorscale); + if(opts.moduleHasFillgradient) { + var gradientOrientation = coerce('fillgradient.type'); + if(gradientOrientation !== 'none') { + coerce('fillgradient.start'); + coerce('fillgradient.stop'); + var gradientColorscale = coerce('fillgradient.colorscale'); + + // if a fillgradient is specified, we use the average gradient color + // to specify fillcolor after all other more specific candidates + // are considered, but before the global default color. + // fillcolor affects the background color of the hoverlabel in this case. + if(gradientColorscale) { + averageGradientColor = averageColors(gradientColorscale); + } } }