Skip to content

Fix logging and notifyOnLogging to work with Plotly.newPlot calls #4994

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/annotations/common_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Lib = require('../../lib');
var Color = require('../color');

// defaults common to 'annotations' and 'annotations3d'
module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayout, coerce) {
module.exports = function handleAnnotationCommonDefaults(gd, annIn, annOut, fullLayout, coerce) {
coerce('opacity');
var bgColor = coerce('bgcolor');

Expand Down
8 changes: 4 additions & 4 deletions src/components/annotations/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ var handleAnnotationCommonDefaults = require('./common_defaults');
var attributes = require('./attributes');


module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
handleArrayContainerDefaults(layoutIn, layoutOut, {
module.exports = function supplyLayoutDefaults(gd, layoutIn, layoutOut) {
handleArrayContainerDefaults(gd, layoutIn, layoutOut, {
name: 'annotations',
handleItemDefaults: handleAnnotationDefaults
});
};

function handleAnnotationDefaults(annIn, annOut, fullLayout) {
function handleAnnotationDefaults(gd, annIn, annOut, fullLayout) {
function coerce(attr, dflt) {
return Lib.coerce(annIn, annOut, attributes, attr, dflt);
}
Expand All @@ -34,7 +34,7 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) {

if(!(visible || clickToShow)) return;

handleAnnotationCommonDefaults(annIn, annOut, fullLayout, coerce);
handleAnnotationCommonDefaults(gd, annIn, annOut, fullLayout, coerce);

var showArrow = annOut.showarrow;

Expand Down
8 changes: 4 additions & 4 deletions src/components/annotations3d/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ var handleArrayContainerDefaults = require('../../plots/array_container_defaults
var handleAnnotationCommonDefaults = require('../annotations/common_defaults');
var attributes = require('./attributes');

module.exports = function handleDefaults(sceneLayoutIn, sceneLayoutOut, opts) {
handleArrayContainerDefaults(sceneLayoutIn, sceneLayoutOut, {
module.exports = function handleDefaults(gd, sceneLayoutIn, sceneLayoutOut, opts) {
handleArrayContainerDefaults(gd, sceneLayoutIn, sceneLayoutOut, {
name: 'annotations',
handleItemDefaults: handleAnnotationDefaults,
fullLayout: opts.fullLayout
});
};

function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) {
function handleAnnotationDefaults(gd, annIn, annOut, sceneLayout, opts) {
function coerce(attr, dflt) {
return Lib.coerce(annIn, annOut, attributes, attr, dflt);
}
Expand All @@ -41,7 +41,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) {
var visible = coerce('visible');
if(!visible) return;

handleAnnotationCommonDefaults(annIn, annOut, opts.fullLayout, coerce);
handleAnnotationCommonDefaults(gd, annIn, annOut, opts.fullLayout, coerce);

coercePosition('x');
coercePosition('y');
Expand Down
6 changes: 3 additions & 3 deletions src/components/calendars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ var attributes = {
dflt: 'gregorian'
};

var handleDefaults = function(contIn, contOut, attr, dflt) {
var handleDefaults = function(gd, contIn, contOut, attr, dflt) {
var attrs = {};
attrs[attr] = attributes;

return Lib.coerce(contIn, contOut, attrs, attr, dflt);
};

var handleTraceDefaults = function(traceIn, traceOut, coords, layout) {
var handleTraceDefaults = function(gd, traceIn, traceOut, coords, layout) {
for(var i = 0; i < coords.length; i++) {
handleDefaults(traceIn, traceOut, coords[i] + 'calendar', layout.calendar);
handleDefaults(gd, traceIn, traceOut, coords[i] + 'calendar', layout.calendar);
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/components/colorbar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var handleTickLabelDefaults = require('../../plots/cartesian/tick_label_defaults

var attributes = require('./attributes');

module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
module.exports = function colorbarDefaults(gd, containerIn, containerOut, layout) {
var colorbarOut = Template.newContainer(containerOut, 'colorbar');
var colorbarIn = containerIn.colorbar || {};

Expand Down Expand Up @@ -52,11 +52,11 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
coerce('borderwidth');
coerce('bgcolor');

handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear');
handleTickValueDefaults(gd, colorbarIn, colorbarOut, coerce, 'linear');

var opts = {outerTicks: false, font: layout.font};
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
handleTickLabelDefaults(gd, colorbarIn, colorbarOut, coerce, 'linear', opts);
handleTickMarkDefaults(gd, colorbarIn, colorbarOut, coerce, 'linear', opts);

coerce('title.text', layout._dfltTitle.colorbar);
Lib.coerceFont(coerce, 'title.font', layout.font);
Expand Down
4 changes: 2 additions & 2 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ function mockColorBarAxis(gd, opts, zrange) {
return Lib.coerce(cbAxisIn, cbAxisOut, axisLayoutAttrs, attr, dflt);
}

handleAxisDefaults(cbAxisIn, cbAxisOut, coerce, axisOptions, fullLayout);
handleAxisPositionDefaults(cbAxisIn, cbAxisOut, coerce, axisOptions);
handleAxisDefaults(gd, cbAxisIn, cbAxisOut, coerce, axisOptions, fullLayout);
handleAxisPositionDefaults(gd, cbAxisIn, cbAxisOut, coerce, axisOptions);

return cbAxisOut;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorscale/cross_trace_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Lib = require('../../lib');
var hasColorscale = require('./helpers').hasColorscale;
var extractOpts = require('./helpers').extractOpts;

module.exports = function crossTraceDefaults(fullData, fullLayout) {
module.exports = function crossTraceDefaults(gd, fullData, fullLayout) {
function replace(cont, k) {
var val = cont['_' + k];
if(val !== undefined) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/colorscale/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function npMaybe(parentCont, prefix) {
* - prefix {string} : attr string prefix to colorscale container from parent root
* - cLetter {string} : 'c or 'z' color letter
*/
module.exports = function colorScaleDefaults(parentContIn, parentContOut, layout, coerce, opts) {
module.exports = function colorScaleDefaults(gd, parentContIn, parentContOut, layout, coerce, opts) {
var prefix = opts.prefix;
var cLetter = opts.cLetter;
var inTrace = '_module' in parentContOut;
Expand All @@ -48,7 +48,7 @@ module.exports = function colorScaleDefaults(parentContIn, parentContOut, layout
var thisFn = function() {
delete parentContIn.coloraxis;
delete parentContOut.coloraxis;
return colorScaleDefaults(parentContIn, parentContOut, layout, coerce, opts);
return colorScaleDefaults(gd, parentContIn, parentContOut, layout, coerce, opts);
};

if(inTrace) {
Expand All @@ -68,7 +68,7 @@ module.exports = function colorScaleDefaults(parentContIn, parentContOut, layout

if(stash[0] !== colorbarVisuals) {
stash[0] = false;
Lib.warn([
Lib.warn(gd, [
'Ignoring coloraxis:', colorAx, 'setting',
'as it is linked to incompatible colorscales.'
].join(' '));
Expand Down Expand Up @@ -117,7 +117,7 @@ module.exports = function colorScaleDefaults(parentContIn, parentContOut, layout
var showScale = coerce(prefix + 'showscale', showScaleDflt);
if(showScale) {
if(prefix && template) containerOut._template = template;
colorbarDefaults(containerIn, containerOut, layout);
colorbarDefaults(gd, containerIn, containerOut, layout);
}
}
};
4 changes: 2 additions & 2 deletions src/components/colorscale/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var Template = require('../../plot_api/plot_template');
var colorScaleAttrs = require('./layout_attributes');
var colorScaleDefaults = require('./defaults');

module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
module.exports = function supplyLayoutDefaults(gd, layoutIn, layoutOut) {
function coerce(attr, dflt) {
return Lib.coerce(layoutIn, layoutOut, colorScaleAttrs, attr, dflt);
}
Expand All @@ -37,7 +37,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
colorAxIn = layoutIn[k] || {};
colorAxOut = Template.newContainer(layoutOut, k, 'coloraxis');
colorAxOut._name = k;
colorScaleDefaults(colorAxIn, colorAxOut, layoutOut, coerceAx, {prefix: '', cLetter: 'c'});
colorScaleDefaults(gd, colorAxIn, colorAxOut, layoutOut, coerceAx, {prefix: '', cLetter: 'c'});
} else {
// re-coerce colorscale attributes w/o coloraxis
for(var i = 0; i < stash[2].length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ drawing.textPointStyle = function(s, trace, gd) {
var pointValues = {};
appendArrayPointValue(pointValues, trace, d.i);
var meta = trace._meta || {};
text = Lib.texttemplateString(text, labels, fullLayout._d3locale, pointValues, d, meta);
text = Lib.texttemplateString(gd, text, labels, fullLayout._d3locale, pointValues, d, meta);
}

var pos = d.tp || trace.textposition;
Expand Down
2 changes: 1 addition & 1 deletion src/components/errorbars/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var Template = require('../../plot_api/plot_template');
var attributes = require('./attributes');


module.exports = function(traceIn, traceOut, defaultColor, opts) {
module.exports = function supplyLayoutDefault(gd, traceIn, traceOut, defaultColor, opts) {
var objName = 'error_' + opts.axis;
var containerOut = Template.newContainer(traceOut, objName);
var containerIn = traceIn[objName] || {};
Expand Down
4 changes: 2 additions & 2 deletions src/components/fx/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ var Lib = require('../../lib');
var attributes = require('./attributes');
var handleHoverLabelDefaults = require('./hoverlabel_defaults');

module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
module.exports = function supplyDefaults(gd, traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}

var opts = Lib.extendFlat({}, layout.hoverlabel);
if(traceOut.hovertemplate) opts.namelength = -1;

handleHoverLabelDefaults(traceIn, traceOut, coerce, opts);
handleHoverLabelDefaults(gd, traceIn, traceOut, coerce, opts);
};
19 changes: 10 additions & 9 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
xaArray[i] = _subplot.xaxis;
yaArray[i] = _subplot.yaxis;
} else {
Lib.warn('Unrecognized subplot: ' + spId);
Lib.warn(gd, 'Unrecognized subplot: ' + spId);
return;
}
}
Expand Down Expand Up @@ -353,7 +353,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
else yvalArray = helpers.p2c(yaArray, ypx);

if(!isNumeric(xvalArray[0]) || !isNumeric(yvalArray[0])) {
Lib.warn('Fx.hover failed', evt, gd);
Lib.warn(gd, 'Fx.hover failed', evt, gd);
return dragElement.unhoverRaw(gd, evt);
}
}
Expand Down Expand Up @@ -478,7 +478,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
// Now if there is range to look in, find the points to hover.
if(hoverdistance !== 0) {
if(trace._module && trace._module.hoverPoints) {
var newPoints = trace._module.hoverPoints(pointData, xval, yval, mode, fullLayout._hoverlayer);
var newPoints = trace._module.hoverPoints(gd, pointData, xval, yval, mode, fullLayout._hoverlayer);
if(newPoints) {
var newPoint;
for(var newPointNum = 0; newPointNum < newPoints.length; newPointNum++) {
Expand All @@ -489,7 +489,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
}
}
} else {
Lib.log('Unrecognized trace type in hover:', trace);
Lib.log(gd, 'Unrecognized trace type in hover:', trace);
}
}

Expand All @@ -507,7 +507,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
if(hoverData.length === 0) {
pointData.distance = spikedistance;
pointData.index = false;
var closestPoints = trace._module.hoverPoints(pointData, xval, yval, 'closest', fullLayout._hoverlayer);
var closestPoints = trace._module.hoverPoints(gd, pointData, xval, yval, 'closest', fullLayout._hoverlayer);
if(closestPoints) {
closestPoints = closestPoints.filter(function(point) {
// some hover points, like scatter fills, do not allow spikes,
Expand Down Expand Up @@ -1000,13 +1000,13 @@ function createHoverText(hoverData, opts, gd) {
}
};
var mockLayoutOut = {};
legendSupplyDefaults(mockLayoutIn, mockLayoutOut, gd._fullData);
legendSupplyDefaults(gd, mockLayoutIn, mockLayoutOut, gd._fullData);
var legendOpts = mockLayoutOut.legend;

// prepare items for the legend
legendOpts.entries = [];
for(var j = 0; j < hoverData.length; j++) {
var texts = getHoverLabelText(hoverData[j], true, hovermode, fullLayout, t0);
var texts = getHoverLabelText(gd, hoverData[j], true, hovermode, fullLayout, t0);
var text = texts[0];
var name = texts[1];
var pt = hoverData[j];
Expand Down Expand Up @@ -1118,7 +1118,7 @@ function createHoverText(hoverData, opts, gd) {
// find a contrasting color for border and text
var contrastColor = d.borderColor || Color.contrast(numsColor);

var texts = getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g);
var texts = getHoverLabelText(gd, d, showCommonLabel, hovermode, fullLayout, t0, g);
var text = texts[0];
var name = texts[1];

Expand Down Expand Up @@ -1219,7 +1219,7 @@ function createHoverText(hoverData, opts, gd) {
return hoverLabels;
}

function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) {
function getHoverLabelText(gd, d, showCommonLabel, hovermode, fullLayout, t0, g) {
var name = '';
var text = '';
// to get custom 'name' labels pass cleanPoint
Expand Down Expand Up @@ -1274,6 +1274,7 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) {
var eventData = d.eventData[0] || {};
if(hovertemplate) {
text = Lib.hovertemplateString(
gd,
hovertemplate,
hovertemplateLabels,
d3locale,
Expand Down
2 changes: 1 addition & 1 deletion src/components/fx/hoverlabel_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Lib = require('../../lib');
var Color = require('../color');
var isUnifiedHover = require('./helpers').isUnifiedHover;

module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts) {
module.exports = function handleHoverLabelDefaults(gd, contIn, contOut, coerce, opts) {
opts = opts || {};

function inheritFontAttr(attr) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/fx/hovermode_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var Lib = require('../../lib');
var layoutAttributes = require('./layout_attributes');

module.exports = function handleHoverModeDefaults(layoutIn, layoutOut, fullData) {
module.exports = function handleHoverModeDefaults(gd, layoutIn, layoutOut, fullData) {
function coerce(attr, dflt) {
// don't coerce if it is already coerced in other place e.g. in cartesian defaults
if(layoutOut[attr] !== undefined) return layoutOut[attr];
Expand Down
6 changes: 3 additions & 3 deletions src/components/fx/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var layoutAttributes = require('./layout_attributes');
var handleHoverModeDefaults = require('./hovermode_defaults');
var handleHoverLabelDefaults = require('./hoverlabel_defaults');

module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
module.exports = function supplyLayoutDefaults(gd, layoutIn, layoutOut, fullData) {
function coerce(attr, dflt) {
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
}

var hoverMode = handleHoverModeDefaults(layoutIn, layoutOut, fullData);
var hoverMode = handleHoverModeDefaults(gd, layoutIn, layoutOut, fullData);
if(hoverMode) {
coerce('hoverdistance');
coerce('spikedistance', isUnifiedHover(hoverMode) ? -1 : undefined);
Expand All @@ -42,5 +42,5 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
layoutOut.dragmode = 'pan';
}

handleHoverLabelDefaults(layoutIn, layoutOut, coerce);
handleHoverLabelDefaults(gd, layoutIn, layoutOut, coerce);
};
4 changes: 2 additions & 2 deletions src/components/fx/layout_global_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var Lib = require('../../lib');
var handleHoverLabelDefaults = require('./hoverlabel_defaults');
var layoutAttributes = require('./layout_attributes');

module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) {
module.exports = function supplyLayoutGlobalDefaults(gd, layoutIn, layoutOut) {
function coerce(attr, dflt) {
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
}

handleHoverLabelDefaults(layoutIn, layoutOut, coerce);
handleHoverLabelDefaults(gd, layoutIn, layoutOut, coerce);
};
4 changes: 2 additions & 2 deletions src/components/grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function getAxes(layout, grid, axLetter) {

// the shape of the grid - this needs to be done BEFORE supplyDataDefaults
// so that non-subplot traces can place themselves in the grid
function sizeDefaults(layoutIn, layoutOut) {
function sizeDefaults(gd, layoutIn, layoutOut) {
var gridIn = layoutIn.grid || {};
var xAxes = getAxes(layoutOut, gridIn, 'x');
var yAxes = getAxes(layoutOut, gridIn, 'y');
Expand Down Expand Up @@ -258,7 +258,7 @@ function fillGridPositions(axLetter, coerce, dfltGap, dfltSide, len, reversed) {

// the (cartesian) contents of the grid - this needs to happen AFTER supplyDataDefaults
// so that we know what cartesian subplots are available
function contentDefaults(layoutIn, layoutOut) {
function contentDefaults(gd, layoutIn, layoutOut) {
var gridOut = layoutOut.grid;
// make sure we got to the end of handleGridSizing
if(!gridOut || !gridOut._domains) return;
Expand Down
6 changes: 3 additions & 3 deletions src/components/images/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ var handleArrayContainerDefaults = require('../../plots/array_container_defaults
var attributes = require('./attributes');
var name = 'images';

module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
module.exports = function supplyLayoutDefaults(gd, layoutIn, layoutOut) {
var opts = {
name: name,
handleItemDefaults: imageDefaults
};

handleArrayContainerDefaults(layoutIn, layoutOut, opts);
handleArrayContainerDefaults(gd, layoutIn, layoutOut, opts);
};


function imageDefaults(imageIn, imageOut, fullLayout) {
function imageDefaults(gd, imageIn, imageOut, fullLayout) {
function coerce(attr, dflt) {
return Lib.coerce(imageIn, imageOut, attributes, attr, dflt);
}
Expand Down
Loading