|
1 | 1 | 'use strict'; |
2 | 2 |
|
| 3 | +var tinycolor = require('tinycolor2'); |
3 | 4 | var polybool = require('polybooljs'); |
4 | 5 | var pointInPolygon = require('point-in-polygon/nested'); // could we use contains lib/polygon instead? |
5 | 6 |
|
@@ -112,17 +113,30 @@ function prepSelect(evt, startX, startY, dragOptions, mode) { |
112 | 113 | fullLayout.newshape : |
113 | 114 | fullLayout.newselection; |
114 | 115 |
|
| 116 | + var fillC = (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'rgba(0,0,0,0)'; |
| 117 | + var fillColor = tinycolor(fillC); |
| 118 | + var fillAlpha = fillColor.getAlpha(); |
| 119 | + var fillRGB = Color.tinyRGB(fillColor); |
| 120 | + |
| 121 | + var strokeC = newStyle.line.color || ( |
| 122 | + isCartesian ? |
| 123 | + Color.contrast(gd._fullLayout.plot_bgcolor) : |
| 124 | + '#7f7f7f' // non-cartesian subplot |
| 125 | + ); |
| 126 | + |
| 127 | + var strokeColor = tinycolor(strokeC); |
| 128 | + var strokeAlpha = strokeColor.getAlpha(); |
| 129 | + var strokeRGB = Color.tinyRGB(strokeColor); |
| 130 | + |
115 | 131 | outlines.enter() |
116 | 132 | .append('path') |
117 | 133 | .attr('class', 'select-outline select-outline-' + plotinfo.id) |
118 | 134 | .style({ |
119 | 135 | opacity: isDrawMode ? newStyle.opacity / 2 : 1, |
120 | | - fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none', |
121 | | - stroke: newStyle.line.color || ( |
122 | | - isCartesian ? |
123 | | - Color.contrast(gd._fullLayout.plot_bgcolor) : |
124 | | - '#7f7f7f' // non-cartesian subplot |
125 | | - ), |
| 136 | + fill: fillRGB, |
| 137 | + 'fill-opacity': fillAlpha, |
| 138 | + stroke: strokeRGB, |
| 139 | + 'stroke-opacity': strokeAlpha, |
126 | 140 | 'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width), |
127 | 141 | 'stroke-width': newStyle.line.width + 'px', |
128 | 142 | 'shape-rendering': 'crispEdges' |
|
0 commit comments