Skip to content

Commit

Permalink
add moduleHasFillgradient option to fillColorDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Mar 5, 2024
1 parent d9bd365 commit a2400f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/traces/scatter/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
30 changes: 17 additions & 13 deletions src/traces/scatter/fillcolor_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit a2400f1

Please sign in to comment.