Skip to content

Commit e4a2035

Browse files
committed
add cone-specific hoverinfo flags
1 parent 55700b8 commit e4a2035

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

Diff for: src/plots/gl3d/scene.js

+31-6
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,53 @@ function render(scene) {
7171
trace = lastPicked.data;
7272
var ptNumber = selection.index;
7373
var hoverinfo = Fx.castHoverinfo(trace, scene.fullLayout, ptNumber);
74+
var hoverinfoParts = hoverinfo.split('+');
75+
var isHoverinfoAll = hoverinfo === 'all';
7476

75-
var xVal = formatter('xaxis', selection.traceCoordinate[0]),
76-
yVal = formatter('yaxis', selection.traceCoordinate[1]),
77-
zVal = formatter('zaxis', selection.traceCoordinate[2]);
77+
var xVal = formatter('xaxis', selection.traceCoordinate[0]);
78+
var yVal = formatter('yaxis', selection.traceCoordinate[1]);
79+
var zVal = formatter('zaxis', selection.traceCoordinate[2]);
7880

79-
if(hoverinfo !== 'all') {
80-
var hoverinfoParts = hoverinfo.split('+');
81+
if(!isHoverinfoAll) {
8182
if(hoverinfoParts.indexOf('x') === -1) xVal = undefined;
8283
if(hoverinfoParts.indexOf('y') === -1) yVal = undefined;
8384
if(hoverinfoParts.indexOf('z') === -1) zVal = undefined;
8485
if(hoverinfoParts.indexOf('text') === -1) selection.textLabel = undefined;
8586
if(hoverinfoParts.indexOf('name') === -1) lastPicked.name = undefined;
8687
}
8788

89+
var tx;
90+
91+
if(trace.type === 'cone') {
92+
var coneTx = [];
93+
if(isHoverinfoAll || hoverinfoParts.indexOf('u') !== -1) {
94+
coneTx.push('u: ' + formatter('xaxis', selection.traceCoordinate[3]));
95+
}
96+
if(isHoverinfoAll || hoverinfoParts.indexOf('v') !== -1) {
97+
coneTx.push('v: ' + formatter('yaxis', selection.traceCoordinate[4]));
98+
}
99+
if(isHoverinfoAll || hoverinfoParts.indexOf('w') !== -1) {
100+
coneTx.push('w: ' + formatter('zaxis', selection.traceCoordinate[5]));
101+
}
102+
if(isHoverinfoAll || hoverinfoParts.indexOf('norm') !== -1) {
103+
coneTx.push('norm: ' + selection.traceCoordinate[6].toPrecision(3));
104+
}
105+
if(selection.textLabel) {
106+
coneTx.push(selection.textLabel);
107+
}
108+
tx = coneTx.join('<br>');
109+
} else {
110+
tx = selection.textLabel;
111+
}
112+
88113
if(scene.fullSceneLayout.hovermode) {
89114
Fx.loneHover({
90115
x: (0.5 + 0.5 * pdata[0] / pdata[3]) * width,
91116
y: (0.5 - 0.5 * pdata[1] / pdata[3]) * height,
92117
xLabel: xVal,
93118
yLabel: yVal,
94119
zLabel: zVal,
95-
text: selection.textLabel,
120+
text: tx,
96121
name: lastPicked.name,
97122
color: Fx.castHoverOption(trace, ptNumber, 'bgcolor') || lastPicked.color,
98123
borderColor: Fx.castHoverOption(trace, ptNumber, 'bordercolor'),

Diff for: src/traces/cone/attributes.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ fromMesh3d.forEach(function(k) {
142142
attrs[k] = mesh3dAttrs[k];
143143
});
144144

145-
attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'});
145+
attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
146+
editType: 'calc',
147+
flags: ['x', 'y', 'z', 'u', 'v', 'w', 'norm', 'text', 'name'],
148+
dflt: 'x+y+z+norm+text'
149+
});
146150

147151
module.exports = attrs;

Diff for: src/traces/cone/convert.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@ proto.handlePick = function(selection) {
2929
if(selection.object === this.pts) {
3030
var selectIndex = selection.index = selection.data.index;
3131

32+
var uu = this.data.u[selectIndex];
33+
var vv = this.data.v[selectIndex];
34+
var ww = this.data.w[selectIndex];
35+
3236
selection.traceCoordinate = [
3337
this.data.x[selectIndex],
3438
this.data.y[selectIndex],
35-
this.data.z[selectIndex]
39+
this.data.z[selectIndex],
40+
41+
uu,
42+
vv,
43+
ww,
44+
45+
Math.sqrt(uu * uu + vv * vv + ww * ww)
3646
];
3747

3848
var text = this.data.text;

Diff for: test/image/mocks/gl3d_cone-wind.json

+2
Original file line numberDiff line numberDiff line change
@@ -129167,6 +129167,8 @@
129167129167
"colorscale": "Viridis",
129168129168
"cmin": 0,
129169129169
"cmax": 1
129170+
"hoverinfo": "u+v+w+text",
129171+
"text": "-> wind <-"
129170129172
}
129171129173
],
129172129174
"layout": {

0 commit comments

Comments
 (0)