Skip to content

Commit 9128e13

Browse files
committed
add 'blend' setBackground value
- which is currently used in the image server
1 parent dd003ce commit 9128e13

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/plot_api/plot_api.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ function opaqueSetBackground(gd, bgColor) {
404404
setBackground(gd, bgColor);
405405
}
406406

407+
function blendSetBackground(gd, bgColor) {
408+
var blend = Color.combine(bgColor, 'white');
409+
setBackground(gd, blend);
410+
}
411+
407412
function setPlotContext(gd, config) {
408413
if(!gd._context) gd._context = Lib.extendDeep({}, Plotly.defaultConfig);
409414
var context = gd._context;
@@ -416,10 +421,15 @@ function setPlotContext(gd, config) {
416421
key = keys[i];
417422
if(key === 'editable' || key === 'edits') continue;
418423
if(key in context) {
419-
if(key === 'setBackground' && config[key] === 'opaque') {
420-
context[key] = opaqueSetBackground;
424+
if(key === 'setBackground') {
425+
if(config[key] === 'opaque') {
426+
context[key] = opaqueSetBackground;
427+
} else if(config[key] === 'blend') {
428+
context[key] = blendSetBackground;
429+
}
430+
} else {
431+
context[key] = config[key];
421432
}
422-
else context[key] = config[key];
423433
}
424434
}
425435

src/plot_api/plot_config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ module.exports = {
108108

109109
// function to add the background color to a different container
110110
// or 'opaque' to ensure there's white behind it,
111+
// or 'blend' to blend bg color with white,
111112
// or any other custom function of gd
112113
setBackground: 'transparent',
113114

0 commit comments

Comments
 (0)