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

Function plotConnectorRegions

src/traces/funnel/plot.js:26–82  ·  view source on GitHub ↗
(gd, plotinfo, cdModule, traceLayer)

Source from the content-addressed store, hash-verified

24};
25
26function plotConnectorRegions(gd, plotinfo, cdModule, traceLayer) {
27 var xa = plotinfo.xaxis;
28 var ya = plotinfo.yaxis;
29
30 Lib.makeTraceGroups(traceLayer, cdModule, 'trace bars').each(function(cd) {
31 var plotGroup = d3.select(this);
32 var trace = cd[0].trace;
33
34 var group = Lib.ensureSingle(plotGroup, 'g', 'regions');
35
36 if(!trace.connector || !trace.connector.visible) {
37 group.remove();
38 return;
39 }
40
41 var isHorizontal = (trace.orientation === 'h');
42
43 var connectors = group.selectAll('g.region').data(Lib.identity);
44
45 connectors.enter().append('g')
46 .classed('region', 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 x[2] !== BADNUM && y[2] !== BADNUM &&
66 x[3] !== BADNUM && y[3] !== BADNUM
67 ) {
68 if(isHorizontal) {
69 shape += 'M' + x[0] + ',' + y[1] + 'L' + x[2] + ',' + y[2] + 'H' + x[3] + 'L' + x[1] + ',' + y[1] + 'Z';
70 } else {
71 shape += 'M' + x[1] + ',' + y[1] + 'L' + x[2] + ',' + y[3] + 'V' + y[2] + 'L' + x[1] + ',' + y[0] + 'Z';
72 }
73 }
74
75 if(shape === '') shape = 'M0,0Z';
76
77 Lib.ensureSingle(d3.select(this), 'path')
78 .attr('d', shape)
79 .call(Drawing.setClipUrl, plotinfo.layerClipId, gd);
80 });
81 });
82}
83

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…