Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
fontColor: hoverFont.color
}, {
container: fullLayout._hoverlayer.node(),
outerContainer: fullLayout._paper.node()
outerContainer: fullLayout._paper.node(),
gd: gd
});
})
.on('mouseout', function() {
Expand Down Expand Up @@ -214,7 +215,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
}[options.align] || 'middle'
});

svgTextUtils.convertToTspans(s, drawGraphicalElements);
svgTextUtils.convertToTspans(s, gd, drawGraphicalElements);
return s;
}

Expand Down Expand Up @@ -554,6 +555,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
// (head/tail/text) all together
dragElement.init({
element: arrowDrag.node(),
gd: gd,
prepFn: function() {
var pos = Drawing.getTranslate(annTextGroupInner);

Expand Down Expand Up @@ -616,6 +618,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
// textbox and tail, leave the head untouched
dragElement.init({
element: annTextGroupInner.node(),
gd: gd,
prepFn: function() {
baseTextTransform = annTextGroup.attr('transform');
update = {};
Expand Down Expand Up @@ -686,7 +689,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
}

if(gd._context.editable) {
annText.call(svgTextUtils.makeEditable, annTextGroupInner)
annText.call(svgTextUtils.makeEditable, {delegate: annTextGroupInner, gd: gd})
.call(textLayout)
.on('edit', function(_text) {
options.text = _text;
Expand Down
1 change: 1 addition & 0 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ module.exports = function draw(gd, id) {

dragElement.init({
element: container.node(),
gd: gd,
prepFn: function() {
t0 = container.attr('transform');
setCursor(container);
Expand Down
2 changes: 1 addition & 1 deletion src/components/dragelement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dragElement.unhoverRaw = unhover.raw;
* the click & drag interaction has been initiated
*/
dragElement.init = function init(options) {
var gd = Lib.getPlotDiv(options.element) || {},
var gd = options.gd,
numClicks = 1,
DBLCLICKDELAY = interactConstants.DBLCLICKDELAY,
startX,
Expand Down
7 changes: 3 additions & 4 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,14 @@ drawing.singlePointStyle = function(d, sel, trace, markerScale, lineScale, gd) {

};

drawing.pointStyle = function(s, trace) {
drawing.pointStyle = function(s, trace, gd) {
if(!s.size()) return;

// allow array marker and marker line colors to be
// scaled by given max and min to colorscales
var marker = trace.marker;
var markerScale = drawing.tryColorscale(marker, '');
var lineScale = drawing.tryColorscale(marker, 'line');
var gd = Lib.getPlotDiv(s.node());

s.each(function(d) {
drawing.singlePointStyle(d, d3.select(this), trace, markerScale, lineScale, gd);
Expand All @@ -423,7 +422,7 @@ drawing.tryColorscale = function(marker, prefix) {
// draw text at points
var TEXTOFFSETSIGN = {start: 1, end: -1, middle: 0, bottom: 1, top: -1},
LINEEXPAND = 1.3;
drawing.textPointStyle = function(s, trace) {
drawing.textPointStyle = function(s, trace, gd) {
s.each(function(d) {
var p = d3.select(this),
text = d.tx || trace.text;
Expand Down Expand Up @@ -454,7 +453,7 @@ drawing.textPointStyle = function(s, trace) {
d.tc || trace.textfont.color)
.attr('text-anchor', h)
.text(text)
.call(svgTextUtils.convertToTspans);
.call(svgTextUtils.convertToTspans, gd);
var pgroup = d3.select(this.parentNode),
tspans = p.selectAll('tspan.line'),
numLines = ((tspans[0].length || 1) - 1) * LINEEXPAND + 1,
Expand Down
12 changes: 6 additions & 6 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ exports.loneHover = function loneHover(hoverItem, opts) {
outerContainer: outerContainer3
};

var hoverLabel = createHoverText([pointData], fullOpts);
var hoverLabel = createHoverText([pointData], fullOpts, opts.gd);
alignHoverText(hoverLabel, fullOpts.rotateLabels);

return hoverLabel.node();
Expand Down Expand Up @@ -490,7 +490,7 @@ function _hover(gd, evt, subplot) {
commonLabelOpts: fullLayout.hoverlabel
};

var hoverLabels = createHoverText(hoverData, labelOpts);
var hoverLabels = createHoverText(hoverData, labelOpts, gd);

hoverAvoidOverlaps(hoverData, rotateLabels ? 'xa' : 'ya');

Expand Down Expand Up @@ -523,7 +523,7 @@ function _hover(gd, evt, subplot) {
});
}

function createHoverText(hoverData, opts) {
function createHoverText(hoverData, opts, gd) {
var hovermode = opts.hovermode;
var rotateLabels = opts.rotateLabels;
var bgColor = opts.bgColor;
Expand Down Expand Up @@ -595,7 +595,7 @@ function createHoverText(hoverData, opts) {
.attr('data-notex', 1);

ltext.text(t0)
.call(svgTextUtils.convertToTspans)
.call(svgTextUtils.convertToTspans, gd)
.call(Drawing.setPosition, 0, 0)
.selectAll('tspan.line')
.call(Drawing.setPosition, 0, 0);
Expand Down Expand Up @@ -745,7 +745,7 @@ function createHoverText(hoverData, opts) {
.call(Drawing.setPosition, 0, 0)
.text(text)
.attr('data-notex', 1)
.call(svgTextUtils.convertToTspans);
.call(svgTextUtils.convertToTspans, gd);
tx.selectAll('tspan.line')
.call(Drawing.setPosition, 0, 0);

Expand All @@ -761,7 +761,7 @@ function createHoverText(hoverData, opts) {
.text(name)
.call(Drawing.setPosition, 0, 0)
.attr('data-notex', 1)
.call(svgTextUtils.convertToTspans);
.call(svgTextUtils.convertToTspans, gd);
tx2.selectAll('tspan.line')
.call(Drawing.setPosition, 0, 0);
tx2width = tx2.node().getBoundingClientRect().width + 2 * HOVERTEXTPAD;
Expand Down
7 changes: 4 additions & 3 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = function draw(gd) {
traces.enter().append('g').attr('class', 'traces');
traces.exit().remove();

traces.call(style)
traces.call(style, gd)
.style('opacity', function(d) {
var trace = d[0].trace;
if(Registry.traceIs(trace, 'pie')) {
Expand Down Expand Up @@ -317,6 +317,7 @@ module.exports = function draw(gd) {

dragElement.init({
element: legend.node(),
gd: gd,
prepFn: function() {
var transform = Drawing.getTranslate(legend);

Expand Down Expand Up @@ -380,14 +381,14 @@ function drawTexts(g, gd) {
.text(name);

function textLayout(s) {
svgTextUtils.convertToTspans(s, function() {
svgTextUtils.convertToTspans(s, gd, function() {
s.selectAll('tspan.line').attr({x: s.attr('x')});
g.call(computeTextDimensions, gd);
});
}

if(gd._context.editable && !isPie) {
text.call(svgTextUtils.makeEditable)
text.call(svgTextUtils.makeEditable, {gd: gd})
.call(textLayout)
.on('edit', function(text) {
this.attr({'data-unformatted': text});
Expand Down
Loading