8000 Add fill gradients for scatter traces by lumip · Pull Request #6905 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Add fill gradients for scatter traces #6905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 6, 2024
Prev Previous commit
add moduleHasFillgradient option to fillColorDefaults
  • Loading branch information
archmoj committed Mar 5, 2024
commit a2400f16ac2645222aa83cbcb532dbe626ede1d3
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