Skip to content

Commit b92059a

Browse files
committed
add isDimmed option to fillColor util
1 parent 1e4e25d commit b92059a

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/traces/scattergl/convert.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var DASHES = require('../../constants/gl2d_dashes');
3030

3131
var AXES = ['xaxis', 'yaxis'];
3232
var DESELECTDIM = 0.2;
33-
var transparent = [0, 0, 0, 0];
33+
var TRANSPARENT = [0, 0, 0, 0];
3434

3535
function LineWithMarkers(scene, uid) {
3636
this.scene = scene;
@@ -259,10 +259,14 @@ function isSymbolOpen(symbol) {
259259
return symbol.split('-open')[1] === '';
260260
}
261261

262-
function fillColor(colorIn, colorOut, offsetIn, offsetOut) {
263-
for(var j = 0; j < 4; j++) {
262+
function fillColor(colorIn, colorOut, offsetIn, offsetOut, isDimmed) {
263+
var dim = isDimmed ? DESELECTDIM : 1;
264+
var j;
265+
266+
for(j = 0; j < 3; j++) {
264267
colorIn[4 * offsetIn + j] = colorOut[4 * offsetOut + j];
265268
}
269+
colorIn[4 * offsetIn + j] = dim * colorOut[4 * offsetOut + j];
266270
}
267271

268272
proto.update = function(options, cdscatter) {
@@ -582,7 +586,7 @@ proto.updateFancy = function(options) {
582586
var colors = convertColorScale(markerOpts, markerOpacity, traceOpacity, len);
583587
var borderWidths = convertNumber(markerOpts.line.width, len);
584588
var borderColors = convertColorScale(markerOpts.line, markerOpacity, traceOpacity, len);
585-
var index, size, symbol, symbolSpec, isOpen, _colors, _borderColors, bw, minBorderWidth;
589+
var index, size, symbol, symbolSpec, isOpen, isDimmed, _colors, _borderColors, bw, minBorderWidth;
586590

587591
sizes = convertArray(markerSizeFunc, markerOpts.size, len);
588592

@@ -592,6 +596,7 @@ proto.updateFancy = function(options) {
592596
symbol = symbols[index];
593597
symbolSpec = MARKER_SYMBOLS[symbol];
594598
isOpen = isSymbolOpen(symbol);
599+
isDimmed = selIds && !selIds[index];
595600

596601
if(symbolSpec.noBorder && !isOpen) {
597602
_colors = borderColors;
@@ -615,23 +620,12 @@ proto.updateFancy = function(options) {
615620
this.scatter.options.glyphs[i] = symbolSpec.unicode;
616621
this.scatter.options.borderWidths[i] = 0.5 * ((bw > minBorderWidth) ? bw - minBorderWidth : 0);
617622

618-
// FIXME
619-
620-
for(j = 0; j < 4; ++j) {
621-
var color = colors[4 * index + j];
622-
if(selIds && !selIds[index] && j === 3) {
623-
color *= DESELECTDIM;
624-
}
625-
this.scatter.options.colors[4 * i + j] = color;
626-
this.scatter.options.borderColors[4 * i + j] = borderColors[4 * index + j];
627-
}
628-
629623
if(isOpen && !symbolSpec.noBorder && !symbolSpec.noFill) {
630-
fillColor(this.scatter.options.colors, transparent, i, 0);
624+
fillColor(this.scatter.options.colors, TRANSPARENT, i, 0);
631625
} else {
632-
fillColor(this.scatter.options.colors, _colors, i, index);
626+
fillColor(this.scatter.options.colors, _colors, i, index, isDimmed);
633627
}
634-
fillColor(this.scatter.options.borderColors, _borderColors, i, index);
628+
fillColor(this.scatter.options.borderColors, _borderColors, i, index, isDimmed);
635629
}
636630

637631
// prevent scatter from resnapping points

0 commit comments

Comments
 (0)