Skip to content

Commit a53baf6

Browse files
committed
Make selection work
1 parent 47cf7e2 commit a53baf6

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

src/traces/scattergl/index.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var createLine = require('regl-line2d');
1313
var createError = require('regl-error2d');
1414
var cluster = require('point-cluster');
1515
var arrayRange = require('array-range');
16-
var Text = require('gl-text');
16+
var Text = require('../../../../gl-text/index');
1717

1818
var Registry = require('../../registry');
1919
var Lib = require('../../lib');
@@ -861,24 +861,40 @@ function selectPoints(searchInfo, polygon) {
861861

862862
// update texts selection
863863
if(hasText) {
864-
var el, textOptions, selOptions;
864+
var textOptions = {};
865865
if(els) {
866-
for(i = 0; i < els.length; i++) {
867-
el = els[i];
868-
selOptions = scene.selectedOptions[stash.index];
869-
if(!selOptions) continue;
870-
textOptions = selOptions.textfont;
871-
if(!textOptions) continue;
872-
// scene.glText[stash.index][el].update(textOptions[el]);
873-
}
866+
applyTextoption(textOptions, els, scene.selectedOptions[stash.index]);
874867
}
875868
if(unels) {
876-
for(i = 0; i < unels.length; i++) {
877-
el = unels[i];
878-
selOptions = scene.unselectedOptions[stash.index];
879-
if(!selOptions) continue;
880-
textOptions = selOptions.textfont || scene.textOptions[stash.index][el];
881-
// scene.glText[stash.index][el].update(textOptions);
869+
applyTextoption(textOptions, unels, scene.unselectedOptions[stash.index]);
870+
}
871+
872+
scene.glText[stash.index].update(textOptions);
873+
}
874+
875+
function applyTextoption(textOptions, els, selOptions) {
876+
if(!selOptions) return;
877+
for(var i = 0; i < els.length; i++) {
878+
var el = els[i];
879+
if(selOptions.textfont) {
880+
if(selOptions.textfont.color) {
881+
if(!textOptions.color) textOptions.color = [];
882+
textOptions.color[el] = selOptions.textfont.color;
883+
}
884+
if(selOptions.textfont.family || selOptions.textfont.size) {
885+
if(!textOptions.font) textOptions.font = [];
886+
textOptions.font[el] = {};
887+
if(selOptions.textfont.family) {
888+
textOptions.font[el].family = selOptions.textfont.family;
889+
}
890+
if(selOptions.textfont.size) {
891+
textOptions.font[el].size = selOptions.textfont.size;
892+
}
893+
}
894+
}
895+
if('opacity' in selOptions) {
896+
if(!textOptions.opacity) textOptions.opacity = [];
897+
textOptions.opacity[el] = selOptions.opacity;
882898
}
883899
}
884900
}

0 commit comments

Comments
 (0)