MCPcopy Index your code
hub / github.com/plotly/plotly.js / plotConnectors

Function plotConnectors

src/traces/waterfall/plot.js:25–102  ·  view source on GitHub ↗
(gd, plotinfo, cdModule, traceLayer)

Source from the content-addressed store, hash-verified

23};
24
25function plotConnectors(gd, plotinfo, cdModule, traceLayer) {
26 var xa = plotinfo.xaxis;
27 var ya = plotinfo.yaxis;
28
29 Lib.makeTraceGroups(traceLayer, cdModule, 'trace bars').each(function(cd) {
30 var plotGroup = d3.select(this);
31 var trace = cd[0].trace;
32
33 var group = Lib.ensureSingle(plotGroup, 'g', 'lines');
34
35 if(!trace.connector || !trace.connector.visible) {
36 group.remove();
37 return;
38 }
39
40 var isHorizontal = (trace.orientation === 'h');
41 var mode = trace.connector.mode;
42
43 var connectors = group.selectAll('g.line').data(Lib.identity);
44
45 connectors.enter().append('g')
46 .classed('line', true);
47
48 connectors.exit().remove();
49
50 var len = connectors.size();
51
52 connectors.each(function(di, i) {
53 // don't draw lines between nulls
54 if(i !== len - 1 && !di.cNext) return;
55
56 var xy = getXY(di, xa, ya, isHorizontal);
57 var x = xy[0];
58 var y = xy[1];
59
60 var shape = '';
61
62 if(
63 x[0] !== BADNUM && y[0] !== BADNUM &&
64 x[1] !== BADNUM && y[1] !== BADNUM
65 ) {
66 if(mode === 'spanning') {
67 if(!di.isSum && i > 0) {
68 if(isHorizontal) {
69 shape += 'M' + x[0] + ',' + y[1] + 'V' + y[0];
70 } else {
71 shape += 'M' + x[1] + ',' + y[0] + 'H' + x[0];
72 }
73 }
74 }
75
76 if(mode !== 'between') {
77 if(di.isSum || i < len - 1) {
78 if(isHorizontal) {
79 shape += 'M' + x[1] + ',' + y[0] + 'V' + y[1];
80 } else {
81 shape += 'M' + x[0] + ',' + y[1] + 'H' + x[1];
82 }

Callers 1

plot.jsFile · 0.85

Calls 1

getXYFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…