Skip to content

Commit 6337ca2

Browse files
committed
radius now passed from spec
1 parent 0bc59c8 commit 6337ca2

File tree

4 files changed

+20
-52
lines changed

4 files changed

+20
-52
lines changed

src/traces/streamtubes/attributes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ module.exports = {
8181
connectgaps: scatterAttrs.connectgaps,
8282
line: extendFlat({}, {
8383
width: scatterLineAttrs.width,
84+
connectionradius: extendFlat({}, scatterMarkerAttrs.size, {
85+
dflt: 1,
86+
description: 'Sets the radius of the line connection. Either a number, or an array with as many elements as the number of points.'
87+
}),
8488
showscale: {
8589
valType: 'boolean',
8690
role: 'info',

src/traces/streamtubes/convert.js

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ function convertPlotlyOptions(scene, data) {
137137
if('line' in data) {
138138
params.lineColor = formatColor(line, 1, len);
139139
params.lineWidth = line.width;
140+
params.connectionradius = line.connectionradius;
140141
}
141142

142143
if('marker' in data) {
@@ -284,19 +285,13 @@ proto.update = function(data) {
284285
this.textMarkers = null;
285286
}
286287

287-
if(true) {
288-
var delaunayOptions = calculateMesh(this.data.x, this.data.y, this.data.z, options.lineWidth, options.lineColor, options.scatterSize, options.scatterColor, this.scene.dataScale);
289-
if(this.delaunayMesh) {
290-
this.delaunayMesh.update(delaunayOptions);
291-
} else {
292-
delaunayOptions.gl = gl;
293-
this.delaunayMesh = createMesh(delaunayOptions);
294-
this.scene.glplot.add(this.delaunayMesh);
295-
}
296-
} else if(this.delaunayMesh) {
297-
this.scene.glplot.remove(this.delaunayMesh);
298-
this.delaunayMesh.dispose();
299-
this.delaunayMesh = null;
288+
var meshOptions = calculateMesh(this.data.x, this.data.y, this.data.z, options.connectionradius, options.lineColor, options.scatterSize, options.scatterColor, this.scene.dataScale);
289+
if(this.delaunayMesh) {
290+
this.delaunayMesh.update(meshOptions);
291+
} else {
292+
meshOptions.gl = gl;
293+
this.delaunayMesh = createMesh(meshOptions);
294+
this.scene.glplot.add(this.delaunayMesh);
300295
}
301296

302297
};
@@ -322,10 +317,8 @@ function createLineWithMarkers(scene, data) {
322317
return plot;
323318
}
324319

325-
module.exports = createLineWithMarkers;
326-
327320
function calculateMesh(inputX, inputY, inputZ, inputW, inputC, inputMW, inputMC, scalingFactor) {
328-
debugger
321+
329322
function addVertex(X, Y, Z, x, y, z) {
330323
X.push(x);
331324
Y.push(y);
@@ -799,51 +792,19 @@ debugger
799792
return vOffset + mx.length;
800793
}
801794

802-
function colorer(d) {
803-
var colorArray = [d, 0, 1 - d];
804-
return colorArray;
805-
}
806-
807-
function makeCircularSampleModel() {
808-
809-
var pointCount = 10;
810-
var n;
811-
812-
var p = {
813-
x: [],
814-
y: [],
815-
z: [],
816-
r: [],
817-
c: []
818-
}
819-
820-
for (n = 0; n < pointCount; n++) {
821-
822-
p.x.push(Math.cos(10 * n / pointCount) * 100);
823-
p.y.push(Math.sin(10 * n / pointCount) * 100);
824-
p.z.push(1000 * n / pointCount * 0.2 - 100);
825-
p.r.push(5 + 2 * Math.sin(1000 * n / pointCount / 20));
826-
p.c.push(0.5 + Math.sin(n * 2) / 2);
827-
}
828-
829-
return p;
830-
}
831-
832795
var x, y, z;
833796

834797
var index = 0;
835798

836799
var n, r, r2, c, c1, c2;
837800

838-
var p = makeCircularSampleModel();
801+
var scaler = 0.01; // fixme figure out something for sensibly calculating dimensions
839802

840-
var scaler =0.01;
841-
842-
p = {
803+
var p = {
843804
x: inputX,
844805
y: inputY,
845806
z: inputZ,
846-
r: Array.isArray(inputW) ? inputW * scaler: inputX.map(function() {return inputW * scaler}),
807+
r: Array.isArray(inputW) ? inputW : inputX.map(function() {return inputW;}),
847808
c: inputC
848809
}
849810

@@ -949,3 +910,4 @@ debugger
949910
}
950911
}
951912

913+
module.exports = createLineWithMarkers;

src/traces/streamtubes/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3737
if(subTypes.hasLines(traceOut)) {
3838
coerce('connectgaps');
3939
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
40+
coerce('line.connectionradius', traceIn.connectionradius)
4041
}
4142

4243
if(subTypes.hasMarkers(traceOut)) {

test/image/mocks/gl3d_streamtubes_basic.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
"mode": "lines+markers+text",
1010
"line": {
1111
"width": [10,16,12,18,20,28,22,24,14,26,30],
12+
"connectionradius": 0.3,
1213
"colorscale": "Viridis",
1314
"color": [0,1,2,3,4,5,6,7,8,9,10]
1415
},
1516
"marker": {
16-
"size": [10,16,12,18,20,28,22,24,14,26,30],
17+
"size": [32,32,32,32,32,32,32,32,32,32,32],
1718
"colorscale": "Viridis",
1819
"color": [10,9,8,7,6,5,4,3,2,1,0],
1920
"showscale": true

0 commit comments

Comments
 (0)