Skip to content

Commit

Permalink
allow scattergl marker opacity, symbol & font size as well as hoverla…
Browse files Browse the repository at this point in the history
…ble font size & namelength to be typedArrays
  • Loading branch information
archmoj committed Jan 6, 2020
1 parent 3355eff commit 9a772c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/traces/scattergl/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function convertStyle(gd, trace) {
opts.markerSel = convertMarkerSelection(trace, trace.selected);
opts.markerUnsel = convertMarkerSelection(trace, trace.unselected);

if(!trace.unselected && Array.isArray(trace.marker.opacity)) {
if(!trace.unselected && Lib.isArrayOrTypedArray(trace.marker.opacity)) {
var mo = trace.marker.opacity;
opts.markerUnsel.opacity = new Array(mo.length);
for(i = 0; i < mo.length; i++) {
Expand Down Expand Up @@ -187,15 +187,18 @@ function convertTextStyle(gd, trace) {
optsOut.color = tfc;
}

if(Array.isArray(tfs) || Array.isArray(tff)) {
if(Lib.isArrayOrTypedArray(tfs) || Array.isArray(tff)) {
// if any textfont param is array - make render a batch
optsOut.font = new Array(count);
for(i = 0; i < count; i++) {
var fonti = optsOut.font[i] = {};

fonti.size = Array.isArray(tfs) ?
(isNumeric(tfs[i]) ? tfs[i] : 0) :
tfs;
fonti.size = (
Lib.isTypedArray(tfs) ? tfs[i] :
Array.isArray(tfs) ? (
isNumeric(tfs[i]) ? tfs[i] : 0
) : tfs
);

fonti.family = Array.isArray(tff) ? tff[i] : tff;
}
Expand All @@ -214,7 +217,7 @@ function convertMarkerStyle(trace) {
var optsOut = {};
var i;

var multiSymbol = Array.isArray(optsIn.symbol);
var multiSymbol = Lib.isArrayOrTypedArray(optsIn.symbol);
var multiColor = Lib.isArrayOrTypedArray(optsIn.color);
var multiLineColor = Lib.isArrayOrTypedArray(optsIn.line.color);
var multiOpacity = Lib.isArrayOrTypedArray(optsIn.opacity);
Expand Down
8 changes: 4 additions & 4 deletions src/traces/scattergl/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function calcHover(pointData, x, y, trace) {

var font = trace.textfont;
if(font) {
di.ts = Array.isArray(font.size) ? font.size[id] : font.size;
di.ts = Lib.isArrayOrTypedArray(font.size) ? font.size[id] : font.size;
di.tc = Array.isArray(font.color) ? font.color[id] : font.color;
di.tf = Array.isArray(font.family) ? font.family[id] : font.family;
}
Expand All @@ -118,7 +118,7 @@ function calcHover(pointData, x, y, trace) {
if(marker) {
di.ms = Lib.isArrayOrTypedArray(marker.size) ? marker.size[id] : marker.size;
di.mo = Lib.isArrayOrTypedArray(marker.opacity) ? marker.opacity[id] : marker.opacity;
di.mx = Array.isArray(marker.symbol) ? marker.symbol[id] : marker.symbol;
di.mx = Lib.isArrayOrTypedArray(marker.symbol) ? marker.symbol[id] : marker.symbol;
di.mc = Lib.isArrayOrTypedArray(marker.color) ? marker.color[id] : marker.color;
}

Expand All @@ -143,10 +143,10 @@ function calcHover(pointData, x, y, trace) {
if(hoverlabel) {
di.hbg = Array.isArray(hoverlabel.bgcolor) ? hoverlabel.bgcolor[id] : hoverlabel.bgcolor;
di.hbc = Array.isArray(hoverlabel.bordercolor) ? hoverlabel.bordercolor[id] : hoverlabel.bordercolor;
di.hts = Array.isArray(hoverlabel.font.size) ? hoverlabel.font.size[id] : hoverlabel.font.size;
di.hts = Lib.isArrayOrTypedArray(hoverlabel.font.size) ? hoverlabel.font.size[id] : hoverlabel.font.size;
di.htc = Array.isArray(hoverlabel.font.color) ? hoverlabel.font.color[id] : hoverlabel.font.color;
di.htf = Array.isArray(hoverlabel.font.family) ? hoverlabel.font.family[id] : hoverlabel.font.family;
di.hnl = Array.isArray(hoverlabel.namelength) ? hoverlabel.namelength[id] : hoverlabel.namelength;
di.hnl = Lib.isArrayOrTypedArray(hoverlabel.namelength) ? hoverlabel.namelength[id] : hoverlabel.namelength;
}
var hoverinfo = trace.hoverinfo;
if(hoverinfo) {
Expand Down

0 comments on commit 9a772c6

Please sign in to comment.