Skip to content

Commit cb9f9b0

Browse files
authored
Merge pull request #3376 from plotly/config-opts-in-plot-schema
Add config options in plot schema
2 parents 7c52051 + e7f1478 commit cb9f9b0

19 files changed

+672
-250
lines changed

src/lib/loggers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/* eslint-disable no-console */
1212

13-
var config = require('../plot_api/plot_config');
13+
var dfltConfig = require('../plot_api/plot_config').dfltConfig;
1414

1515
var loggers = module.exports = {};
1616

@@ -21,7 +21,7 @@ var loggers = module.exports = {};
2121
*/
2222

2323
loggers.log = function() {
24-
if(config.logging > 1) {
24+
if(dfltConfig.logging > 1) {
2525
var messages = ['LOG:'];
2626

2727
for(var i = 0; i < arguments.length; i++) {
@@ -33,7 +33,7 @@ loggers.log = function() {
3333
};
3434

3535
loggers.warn = function() {
36-
if(config.logging > 0) {
36+
if(dfltConfig.logging > 0) {
3737
var messages = ['WARN:'];
3838

3939
for(var i = 0; i < arguments.length; i++) {
@@ -45,7 +45,7 @@ loggers.warn = function() {
4545
};
4646

4747
loggers.error = function() {
48-
if(config.logging > 0) {
48+
if(dfltConfig.logging > 0) {
4949
var messages = ['ERROR:'];
5050

5151
for(var i = 0; i < arguments.length; i++) {

src/lib/queue.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var Lib = require('../lib');
13-
var config = require('../plot_api/plot_config');
14-
12+
var dfltConfig = require('../plot_api/plot_config').dfltConfig;
1513

1614
/**
1715
* Copy arg array *without* removing `undefined` values from objects.
@@ -91,7 +89,7 @@ queue.add = function(gd, undoFunc, undoArgs, redoFunc, redoArgs) {
9189
queueObj.redo.args.push(redoArgs);
9290
}
9391

94-
if(gd.undoQueue.queue.length > config.queueLength) {
92+
if(gd.undoQueue.queue.length > dfltConfig.queueLength) {
9593
gd.undoQueue.queue.shift();
9694
gd.undoQueue.index--;
9795
}

src/plot_api/plot_api.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var initInteractions = require('../plots/cartesian/graph_interact').initInteract
3333
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
3434
var svgTextUtils = require('../lib/svg_text_utils');
3535

36-
var defaultConfig = require('./plot_config');
36+
var dfltConfig = require('./plot_config').dfltConfig;
3737
var manageArrays = require('./manage_arrays');
3838
var helpers = require('./helpers');
3939
var subroutines = require('./subroutines');
@@ -405,7 +405,7 @@ function emitAfterPlot(gd) {
405405
}
406406

407407
exports.setPlotConfig = function setPlotConfig(obj) {
408-
return Lib.extendFlat(defaultConfig, obj);
408+
return Lib.extendFlat(dfltConfig, obj);
409409
};
410410

411411
function setBackground(gd, bgColor) {
@@ -423,7 +423,7 @@ function opaqueSetBackground(gd, bgColor) {
423423

424424
function setPlotContext(gd, config) {
425425
if(!gd._context) {
426-
gd._context = Lib.extendDeep({}, defaultConfig);
426+
gd._context = Lib.extendDeep({}, dfltConfig);
427427

428428
// stash <base> href, used to make robust clipPath URLs
429429
var base = d3.select('base');
@@ -507,6 +507,25 @@ function setPlotContext(gd, config) {
507507
// Check if gd has a specified widht/height to begin with
508508
context._hasZeroHeight = context._hasZeroHeight || gd.clientHeight === 0;
509509
context._hasZeroWidth = context._hasZeroWidth || gd.clientWidth === 0;
510+
511+
// fill context._scrollZoom helper to help manage scrollZoom flaglist
512+
var szIn = context.scrollZoom;
513+
var szOut = context._scrollZoom = {};
514+
if(szIn === true) {
515+
szOut.cartesian = 1;
516+
szOut.gl3d = 1;
517+
szOut.geo = 1;
518+
szOut.mapbox = 1;
519+
} else if(typeof szIn === 'string') {
520+
var parts = szIn.split('+');
521+
for(i = 0; i < parts.length; i++) {
522+
szOut[parts[i]] = 1;
523+
}
524+
} else if(szIn !== false) {
525+
szOut.gl3d = 1;
526+
szOut.geo = 1;
527+
szOut.mapbox = 1;
528+
}
510529
}
511530

512531
function plotLegacyPolar(gd, data, layout) {

0 commit comments

Comments
 (0)