Skip to content

Commit 0f110e1

Browse files
committed
Merge pull request #589 from plotly/gl2d-fixes-for-carson
scattergl lines fixes for opacity and connectgaps
2 parents 923871a + 4837a42 commit 0f110e1

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

src/traces/scattergl/convert.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ var proto = LineWithMarkers.prototype;
107107

108108
proto.handlePick = function(pickResult) {
109109
var index = pickResult.pointId;
110+
110111
if(pickResult.object !== this.line || this.connectgaps) {
111112
index = this.idToIndex[pickResult.pointId];
112113
}
@@ -136,19 +137,20 @@ proto.isFancy = function(options) {
136137

137138
if(!options.x || !options.y) return true;
138139

139-
var marker = options.marker || {};
140-
if(Array.isArray(marker.symbol) ||
141-
marker.symbol !== 'circle' ||
142-
Array.isArray(marker.size) ||
143-
Array.isArray(marker.line.width) ||
144-
Array.isArray(marker.opacity)
145-
) return true;
146-
147-
var markerColor = marker.color;
148-
if(Array.isArray(markerColor)) return true;
140+
if(this.hasMarkers) {
141+
var marker = options.marker || {};
142+
143+
if(Array.isArray(marker.symbol) ||
144+
marker.symbol !== 'circle' ||
145+
Array.isArray(marker.size) ||
146+
Array.isArray(marker.color) ||
147+
Array.isArray(marker.line.width) ||
148+
Array.isArray(marker.line.color) ||
149+
Array.isArray(marker.opacity)
150+
) return true;
151+
}
149152

150-
var lineColor = Array.isArray(marker.line.color);
151-
if(Array.isArray(lineColor)) return true;
153+
if(this.hasLines && !this.connectgaps) return true;
152154

153155
if(this.hasErrorX) return true;
154156
if(this.hasErrorY) return true;
@@ -471,8 +473,10 @@ proto.updateFancy = function(options) {
471473

472474
proto.updateLines = function(options, positions) {
473475
var i;
476+
474477
if(this.hasLines) {
475478
var linePositions = positions;
479+
476480
if(!options.connectgaps) {
477481
var p = 0;
478482
var x = this.xData;
@@ -484,12 +488,11 @@ proto.updateLines = function(options, positions) {
484488
linePositions[p++] = y[i];
485489
}
486490
}
487-
this.lineOptions.positions = linePositions;
488491

489-
var lineColor = str2RGBArray(options.line.color);
490-
if(this.hasMarkers) lineColor[3] *= options.marker.opacity;
492+
this.lineOptions.positions = linePositions;
491493

492-
var lineWidth = Math.round(0.5 * this.lineOptions.width),
494+
var lineColor = convertColor(options.line.color, options.opacity, 1),
495+
lineWidth = Math.round(0.5 * this.lineOptions.width),
493496
dashes = (DASHES[options.line.dash] || [1]).slice();
494497

495498
for(i = 0; i < dashes.length; ++i) dashes[i] *= lineWidth;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"data": [
3+
{
4+
"x": [
5+
1,
6+
2,
7+
null,
8+
4,
9+
5
10+
],
11+
"y": [
12+
1,
13+
2,
14+
null,
15+
4,
16+
5
17+
],
18+
"connectgaps": false,
19+
"type": "scattergl",
20+
"opacity": 0.4
21+
}
22+
],
23+
"layout": {
24+
"xaxis": {
25+
"type": "linear",
26+
"range": [
27+
0.9867209252516599,
28+
5.01327907474834
29+
],
30+
"autorange": true
31+
},
32+
"yaxis": {
33+
"type": "linear",
34+
"range": [
35+
0.9529946929492039,
36+
5.047005307050796
37+
],
38+
"autorange": true
39+
},
40+
"height": 450,
41+
"width": 1100,
42+
"autosize": true
43+
}
44+
}

0 commit comments

Comments
 (0)