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

Function drawSelection

src/components/selections/draw.js:70–141  ·  view source on GitHub ↗
(selectionLayer)

Source from the content-addressed store, hash-verified

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);
111
112 if(isActiveSelection) {
113 var editHelpers = arrayEditor(gd.layout, 'selections', options);
114
115 path.style({
116 cursor: 'move',
117 });
118
119 var dragOptions = {
120 element: path.node(),
121 plotinfo: plotinfo,
122 gd: gd,
123 editHelpers: editHelpers,
124 isActiveSelection: true // i.e. to enable controllers
125 };
126
127 var polygons = readPaths(d, gd);

Callers 1

drawOneFunction · 0.85

Calls 3

couldHaveActiveSelectionFunction · 0.85
activateSelectionFunction · 0.85
setClipPathFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…