| 82 | } |
| 83 | |
| 84 | function plotConnectorLines(gd, plotinfo, cdModule, traceLayer) { |
| 85 | var xa = plotinfo.xaxis; |
| 86 | var ya = plotinfo.yaxis; |
| 87 | |
| 88 | Lib.makeTraceGroups(traceLayer, cdModule, 'trace bars').each(function(cd) { |
| 89 | var plotGroup = d3.select(this); |
| 90 | var trace = cd[0].trace; |
| 91 | |
| 92 | var group = Lib.ensureSingle(plotGroup, 'g', 'lines'); |
| 93 | |
| 94 | if(!trace.connector || !trace.connector.visible || !trace.connector.line.width) { |
| 95 | group.remove(); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | var isHorizontal = (trace.orientation === 'h'); |
| 100 | |
| 101 | var connectors = group.selectAll('g.line').data(Lib.identity); |
| 102 | |
| 103 | connectors.enter().append('g') |
| 104 | .classed('line', true); |
| 105 | |
| 106 | connectors.exit().remove(); |
| 107 | |
| 108 | var len = connectors.size(); |
| 109 | |
| 110 | connectors.each(function(di, i) { |
| 111 | // don't draw lines between nulls |
| 112 | if(i !== len - 1 && !di.cNext) return; |
| 113 | |
| 114 | var xy = getXY(di, xa, ya, isHorizontal); |
| 115 | var x = xy[0]; |
| 116 | var y = xy[1]; |
| 117 | |
| 118 | var shape = ''; |
| 119 | |
| 120 | if(x[3] !== undefined && y[3] !== undefined) { |
| 121 | if(isHorizontal) { |
| 122 | shape += 'M' + x[0] + ',' + y[1] + 'L' + x[2] + ',' + y[2]; |
| 123 | shape += 'M' + x[1] + ',' + y[1] + 'L' + x[3] + ',' + y[2]; |
| 124 | } else { |
| 125 | shape += 'M' + x[1] + ',' + y[1] + 'L' + x[2] + ',' + y[3]; |
| 126 | shape += 'M' + x[1] + ',' + y[0] + 'L' + x[2] + ',' + y[2]; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if(shape === '') shape = 'M0,0Z'; |
| 131 | |
| 132 | Lib.ensureSingle(d3.select(this), 'path') |
| 133 | .attr('d', shape) |
| 134 | .call(Drawing.setClipUrl, plotinfo.layerClipId, gd); |
| 135 | }); |
| 136 | }); |
| 137 | } |
| 138 | |
| 139 | function getXY(di, xa, ya, isHorizontal) { |
| 140 | var s = []; |