(gd, index)
| 51 | } |
| 52 | |
| 53 | function drawOne(gd, index) { |
| 54 | // remove the existing selection if there is one. |
| 55 | // because indices can change, we need to look in all selection layers |
| 56 | gd._fullLayout._paperdiv |
| 57 | .selectAll('.selectionlayer [data-index="' + index + '"]') |
| 58 | .remove(); |
| 59 | |
| 60 | var o = helpers.makeSelectionsOptionsAndPlotinfo(gd, index); |
| 61 | var options = o.options; |
| 62 | var plotinfo = o.plotinfo; |
| 63 | |
| 64 | // this selection is gone - quit now after deleting it |
| 65 | // TODO: use d3 idioms instead of deleting and redrawing every time |
| 66 | if(!options._input) return; |
| 67 | |
| 68 | drawSelection(gd._fullLayout._selectionLayer); |
| 69 | |
| 70 | function drawSelection(selectionLayer) { |
| 71 | var d = getPathString(gd, options); |
| 72 | var attrs = { |
| 73 | 'data-index': index, |
| 74 | 'fill-rule': 'evenodd', |
| 75 | d: d |
| 76 | }; |
| 77 | |
| 78 | var opacity = options.opacity; |
| 79 | var fillColor = 'rgba(0,0,0,0)'; |
| 80 | var lineColor = options.line.color || Color.contrast(gd._fullLayout.plot_bgcolor); |
| 81 | var lineWidth = options.line.width; |
| 82 | var lineDash = options.line.dash; |
| 83 | if(!lineWidth) { |
| 84 | // ensure invisible border to activate the selection |
| 85 | lineWidth = 5; |
| 86 | lineDash = 'solid'; |
| 87 | } |
| 88 | |
| 89 | var isActiveSelection = couldHaveActiveSelection(gd) && |
| 90 | gd._fullLayout._activeSelectionIndex === index; |
| 91 | |
| 92 | if(isActiveSelection) { |
| 93 | fillColor = gd._fullLayout.activeselection.fillcolor; |
| 94 | opacity = gd._fullLayout.activeselection.opacity; |
| 95 | } |
| 96 | |
| 97 | var allPaths = []; |
| 98 | for(var sensory = 1; sensory >= 0; sensory--) { |
| 99 | var path = selectionLayer.append('path') |
| 100 | .attr(attrs) |
| 101 | .style('opacity', sensory ? 0.1 : opacity) |
| 102 | .call(Color.stroke, lineColor) |
| 103 | .call(Color.fill, fillColor) |
| 104 | // make it easier to select senory background path |
| 105 | .call(Drawing.dashLine, |
| 106 | sensory ? 'solid' : lineDash, |
| 107 | sensory ? 4 + lineWidth : lineWidth |
| 108 | ); |
| 109 | |
| 110 | setClipPath(path, gd, options); |
no test coverage detected
searching dependent graphs…