Skip to content

Commit 94f6195

Browse files
committed
add 'divergence' hoverinfo flag
1 parent 8531e23 commit 94f6195

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

src/plots/gl3d/scene.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,26 @@ function render(scene) {
8989
var tx;
9090

9191
if(trace.type === 'cone' || trace.type === 'streamtube') {
92-
var coneTx = [];
92+
var vectorTx = [];
9393
if(isHoverinfoAll || hoverinfoParts.indexOf('u') !== -1) {
94-
coneTx.push('u: ' + formatter('xaxis', selection.traceCoordinate[3]));
94+
vectorTx.push('u: ' + formatter('xaxis', selection.traceCoordinate[3]));
9595
}
9696
if(isHoverinfoAll || hoverinfoParts.indexOf('v') !== -1) {
97-
coneTx.push('v: ' + formatter('yaxis', selection.traceCoordinate[4]));
97+
vectorTx.push('v: ' + formatter('yaxis', selection.traceCoordinate[4]));
9898
}
9999
if(isHoverinfoAll || hoverinfoParts.indexOf('w') !== -1) {
100-
coneTx.push('w: ' + formatter('zaxis', selection.traceCoordinate[5]));
100+
vectorTx.push('w: ' + formatter('zaxis', selection.traceCoordinate[5]));
101101
}
102102
if(isHoverinfoAll || hoverinfoParts.indexOf('norm') !== -1) {
103-
coneTx.push('norm: ' + selection.traceCoordinate[6].toPrecision(3));
103+
vectorTx.push('norm: ' + selection.traceCoordinate[6].toPrecision(3));
104+
}
105+
if(isHoverinfoAll || hoverinfoParts.indexOf('divergence') !== -1) {
106+
vectorTx.push('divergence: ' + selection.traceCoordinate[7].toPrecision(3));
104107
}
105108
if(selection.textLabel) {
106-
coneTx.push(selection.textLabel);
109+
vectorTx.push(selection.textLabel);
107110
}
108-
tx = coneTx.join('<br>');
111+
tx = vectorTx.join('<br>');
109112
} else {
110113
tx = selection.textLabel;
111114
}

src/traces/streamtube/attributes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ fromMesh3d.forEach(function(k) {
114114
attrs[k] = mesh3dAttrs[k];
115115
});
116116

117-
// TODO maybe add divergence field?
118117
attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
119118
editType: 'calc',
120-
flags: ['x', 'y', 'z', 'u', 'v', 'w', 'norm', 'text', 'name'],
119+
flags: ['x', 'y', 'z', 'u', 'v', 'w', 'norm', 'divergence', 'text', 'name'],
121120
dflt: 'x+y+z+norm+text+name'
122121
});
123122

src/traces/streamtube/convert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ proto.handlePick = function(selection) {
5151

5252
// u/v/w norm
5353
selection.data.intensity * this.data._normMax,
54+
// divergence
55+
selection.data.divergence
5456
];
5557

5658
return true;

test/jasmine/tests/streamtube_test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ describe('@gl Test streamtube hover', function() {
268268
'w: 0.1693927'
269269
].join('\n')
270270
});
271+
return Plotly.restyle(gd, 'hoverinfo', 'divergence');
272+
})
273+
.then(delay(20))
274+
.then(_hover)
275+
.then(function() {
276+
assertHoverLabelContent({nums: 'divergence: 0.465'});
271277
})
272278
.catch(failTest)
273279
.then(done);

0 commit comments

Comments
 (0)