Skip to content

Commit 90e99f4

Browse files
committed
stash node3 on calcdata[i][0] of SVG during makeTraceGroup
- which is a more centralised DRY place - use nodeRangePlot3 for range-plot trace, that way we don't override node3 when plotting a trace in a range-plot
1 parent c1ef691 commit 90e99f4

File tree

10 files changed

+14
-12
lines changed

10 files changed

+14
-12
lines changed

src/lib/make_trace_groups.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

11+
var d3 = require('d3');
12+
1213
/**
1314
* General helper to manage trace groups based on calcdata
1415
*
@@ -31,5 +32,10 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) {
3132

3233
traces.order();
3334

35+
// stash ref node to trace group in calcdata,
36+
// useful for (fast) styleOnSelect
37+
var k = traceLayer.classed('rangeplot') ? 'nodeRangePlot3' : 'node3';
38+
traces.each(function(cd) { cd[0][k] = d3.select(this); });
39+
3440
return traces;
3541
};

src/plots/cartesian/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
239239

240240
layers.enter().append('g')
241241
.attr('class', function(d) { return d.className; })
242-
.classed('mlayer', true);
242+
.classed('mlayer', true)
243+
.classed('rangeplot', plotinfo.isRangePlot);
243244

244245
layers.exit().remove();
245246

src/traces/bar/plot.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts) {
7878

7979
var isHorizontal = (trace.orientation === 'h');
8080

81-
if(!plotinfo.isRangePlot) cd[0].node3 = plotGroup;
82-
8381
var pointGroup = Lib.ensureSingle(plotGroup, 'g', 'points');
8482

8583
var bars = pointGroup.selectAll('g.point').data(Lib.identity);

src/traces/barpolar/plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ module.exports = function plot(gd, subplot, cdbar) {
2323
var pathFn = makePathFn(subplot);
2424
var barLayer = subplot.layers.frontplot.select('g.barlayer');
2525

26-
Lib.makeTraceGroups(barLayer, cdbar, 'trace bars').each(function(cd) {
27-
var plotGroup = cd[0].node3 = d3.select(this);
26+
Lib.makeTraceGroups(barLayer, cdbar, 'trace bars').each(function() {
27+
var plotGroup = d3.select(this);
2828
var pointGroup = Lib.ensureSingle(plotGroup, 'g', 'points');
2929
var bars = pointGroup.selectAll('g.point').data(Lib.identity);
3030

src/traces/box/plot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function plot(gd, plotinfo, cdbox, boxLayer) {
2626
var cd0 = cd[0];
2727
var t = cd0.t;
2828
var trace = cd0.trace;
29-
if(!plotinfo.isRangePlot) cd0.node3 = plotGroup;
3029

3130
// whisker width
3231
t.wdPos = t.bdPos * trace.whiskerwidth;

src/traces/choropleth/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function plot(gd, geo, calcData) {
2424

2525
var choroplethLayer = geo.layers.backplot.select('.choroplethlayer');
2626
Lib.makeTraceGroups(choroplethLayer, calcData, 'trace choropleth').each(function(calcTrace) {
27-
var sel = calcTrace[0].node3 = d3.select(this);
27+
var sel = d3.select(this);
2828

2929
var paths = sel.selectAll('path.choroplethlocation')
3030
.data(Lib.identity);

src/traces/ohlc/plot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = function plot(gd, plotinfo, cdOHLC, ohlcLayer) {
2121
var cd0 = cd[0];
2222
var t = cd0.t;
2323
var trace = cd0.trace;
24-
if(!plotinfo.isRangePlot) cd0.node3 = plotGroup;
2524

2625
if(trace.visible !== true || t.empty) {
2726
plotGroup.remove();

src/traces/scatter/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
152152
if(ownFillDir !== 'x' && ownFillDir !== 'y') ownFillDir = '';
153153

154154
// store node for tweaking by selectPoints
155-
if(!plotinfo.isRangePlot) cdscatter[0].node3 = tr;
155+
cdscatter[0][plotinfo.isRangePlot ? 'nodeRangePlot3' : 'node3'] = tr;
156156

157157
var prevRevpath = '';
158158
var prevPolygons = [];

src/traces/scattergeo/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = function plot(gd, geo, calcData) {
3737
gTraces.selectAll('*').remove();
3838

3939
gTraces.each(function(calcTrace) {
40-
var s = calcTrace[0].node3 = d3.select(this);
40+
var s = d3.select(this);
4141
var trace = calcTrace[0].trace;
4242

4343
if(subTypes.hasLines(trace) || trace.fill !== 'none') {

src/traces/violin/plot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
3838
var cd0 = cd[0];
3939
var t = cd0.t;
4040
var trace = cd0.trace;
41-
if(!plotinfo.isRangePlot) cd0.node3 = plotGroup;
4241

4342
if(trace.visible !== true || t.empty) {
4443
plotGroup.remove();

0 commit comments

Comments
 (0)