Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 032cf7c

Browse filesBrowse files
committed
get rid of Lib.getPlotDiv
1 parent 2b831a0 commit 032cf7c
Copy full SHA for 032cf7c

File tree

28 files changed

+287
-272
lines changed
Filter options

28 files changed

+287
-272
lines changed

‎src/components/annotations/draw.js

Copy file name to clipboardExpand all lines: src/components/annotations/draw.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
168168
fontColor: hoverFont.color
169169
}, {
170170
container: fullLayout._hoverlayer.node(),
171-
outerContainer: fullLayout._paper.node()
171+
outerContainer: fullLayout._paper.node(),
172+
gd: gd
172173
});
173174
})
174175
.on('mouseout', function() {
@@ -214,7 +215,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
214215
}[options.align] || 'middle'
215216
});
216217

217-
svgTextUtils.convertToTspans(s, drawGraphicalElements);
218+
svgTextUtils.convertToTspans(s, gd, drawGraphicalElements);
218219
return s;
219220
}
220221

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

@@ -616,6 +618,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
616618
// textbox and tail, leave the head untouched
617619
dragElement.init({
618620
element: annTextGroupInner.node(),
621+
gd: gd,
619622
prepFn: function() {
620623
baseTextTransform = annTextGroup.attr('transform');
621624
update = {};
@@ -686,7 +689,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
686689
}
687690

688691
if(gd._context.editable) {
689-
annText.call(svgTextUtils.makeEditable, annTextGroupInner)
692+
annText.call(svgTextUtils.makeEditable, {delegate: annTextGroupInner, gd: gd})
690693
.call(textLayout)
691694
.on('edit', function(_text) {
692695
options.text = _text;

‎src/components/colorbar/draw.js

Copy file name to clipboardExpand all lines: src/components/colorbar/draw.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ module.exports = function draw(gd, id) {
556556

557557
dragElement.init({
558558
element: container.node(),
559+
gd: gd,
559560
prepFn: function() {
560561
t0 = container.attr('transform');
561562
setCursor(container);

‎src/components/dragelement/index.js

Copy file name to clipboardExpand all lines: src/components/dragelement/index.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dragElement.unhoverRaw = unhover.raw;
5050
* the click & drag interaction has been initiated
5151
*/
5252
dragElement.init = function init(options) {
53-
var gd = Lib.getPlotDiv(options.element) || {},
53+
var gd = options.gd,
5454
numClicks = 1,
5555
DBLCLICKDELAY = interactConstants.DBLCLICKDELAY,
5656
startX,

‎src/components/drawing/index.js

Copy file name to clipboardExpand all lines: src/components/drawing/index.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,14 @@ drawing.singlePointStyle = function(d, sel, trace, markerScale, lineScale, gd) {
392392

393393
};
394394

395-
drawing.pointStyle = function(s, trace) {
395+
drawing.pointStyle = function(s, trace, gd) {
396396
if(!s.size()) return;
397397

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

405404
s.each(function(d) {
406405
drawing.singlePointStyle(d, d3.select(this), trace, markerScale, lineScale, gd);
@@ -423,7 +422,7 @@ drawing.tryColorscale = function(marker, prefix) {
423422
// draw text at points
424423
var TEXTOFFSETSIGN = {start: 1, end: -1, middle: 0, bottom: 1, top: -1},
425424
LINEEXPAND = 1.3;
426-
drawing.textPointStyle = function(s, trace) {
425+
drawing.textPointStyle = function(s, trace, gd) {
427426
s.each(function(d) {
428427
var p = d3.select(this),
429428
text = d.tx || trace.text;
@@ -454,7 +453,7 @@ drawing.textPointStyle = function(s, trace) {
454453
d.tc || trace.textfont.color)
455454
.attr('text-anchor', h)
456455
.text(text)
457-
.call(svgTextUtils.convertToTspans);
456+
.call(svgTextUtils.convertToTspans, gd);
458457
var pgroup = d3.select(this.parentNode),
459458
tspans = p.selectAll('tspan.line'),
460459
numLines = ((tspans[0].length || 1) - 1) * LINEEXPAND + 1,

‎src/components/fx/hover.js

Copy file name to clipboardExpand all lines: src/components/fx/hover.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ exports.loneHover = function loneHover(hoverItem, opts) {
161161
outerContainer: outerContainer3
162162
};
163163

164-
var hoverLabel = createHoverText([pointData], fullOpts);
164+
var hoverLabel = createHoverText([pointData], fullOpts, opts.gd);
165165
alignHoverText(hoverLabel, fullOpts.rotateLabels);
166166

167167
return hoverLabel.node();
@@ -490,7 +490,7 @@ function _hover(gd, evt, subplot) {
490490
commonLabelOpts: fullLayout.hoverlabel
491491
};
492492

493-
var hoverLabels = createHoverText(hoverData, labelOpts);
493+
var hoverLabels = createHoverText(hoverData, labelOpts, gd);
494494

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

@@ -523,7 +523,7 @@ function _hover(gd, evt, subplot) {
523523
});
524524
}
525525

526-
function createHoverText(hoverData, opts) {
526+
function createHoverText(hoverData, opts, gd) {
527527
var hovermode = opts.hovermode;
528528
var rotateLabels = opts.rotateLabels;
529529
var bgColor = opts.bgColor;
@@ -595,7 +595,7 @@ function createHoverText(hoverData, opts) {
595595
.attr('data-notex', 1);
596596

597597
ltext.text(t0)
598-
.call(svgTextUtils.convertToTspans)
598+
.call(svgTextUtils.convertToTspans, gd)
599599
.call(Drawing.setPosition, 0, 0)
600600
.selectAll('tspan.line')
601601
.call(Drawing.setPosition, 0, 0);
@@ -745,7 +745,7 @@ function createHoverText(hoverData, opts) {
745745
.call(Drawing.setPosition, 0, 0)
746746
.text(text)
747747
.attr('data-notex', 1)
748-
.call(svgTextUtils.convertToTspans);
748+
.call(svgTextUtils.convertToTspans, gd);
749749
tx.selectAll('tspan.line')
750750
.call(Drawing.setPosition, 0, 0);
751751

@@ -761,7 +761,7 @@ function createHoverText(hoverData, opts) {
761761
.text(name)
762762
.call(Drawing.setPosition, 0, 0)
763763
.attr('data-notex', 1)
764-
.call(svgTextUtils.convertToTspans);
764+
.call(svgTextUtils.convertToTspans, gd);
765765
tx2.selectAll('tspan.line')
766766
.call(Drawing.setPosition, 0, 0);
767767
tx2width = tx2.node().getBoundingClientRect().width + 2 * HOVERTEXTPAD;

‎src/components/legend/draw.js

Copy file name to clipboardExpand all lines: src/components/legend/draw.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = function draw(gd) {
111111
traces.enter().append('g').attr('class', 'traces');
112112
traces.exit().remove();
113113

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

318318
dragElement.init({
319319
element: legend.node(),
320+
gd: gd,
320321
prepFn: function() {
321322
var transform = Drawing.getTranslate(legend);
322323

@@ -380,14 +381,14 @@ function drawTexts(g, gd) {
380381
.text(name);
381382

382383
function textLayout(s) {
383-
svgTextUtils.convertToTspans(s, function() {
384+
svgTextUtils.convertToTspans(s, gd, function() {
384385
s.selectAll('tspan.line').attr({x: s.attr('x')});
385386
g.call(computeTextDimensions, gd);
386387
});
387388
}
388389

389390
if(gd._context.editable && !isPie) {
390-
text.call(svgTextUtils.makeEditable)
391+
text.call(svgTextUtils.makeEditable, {gd: gd})
391392
.call(textLayout)
392393
.on('edit', function(text) {
393394
this.attr({'data-unformatted': text});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.