Skip to content

Commit a9040d1

Browse files
authored
Merge pull request #2647 from plotly/single-cone
Fix single cone
2 parents df67a27 + 7da71ae commit a9040d1

File tree

7 files changed

+64
-11
lines changed

7 files changed

+64
-11
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"es6-promise": "^3.0.2",
7171
"fast-isnumeric": "^1.1.1",
7272
"font-atlas-sdf": "^1.3.3",
73-
"gl-cone3d": "^v1.0.0",
73+
"gl-cone3d": "^v1.0.1",
7474
"gl-contour2d": "^1.1.4",
7575
"gl-error3d": "^1.0.7",
7676
"gl-heatmap2d": "^1.0.4",

src/traces/cone/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fromMesh3d.forEach(function(k) {
170170
attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
171171
editType: 'calc',
172172
flags: ['x', 'y', 'z', 'u', 'v', 'w', 'norm', 'text', 'name'],
173-
dflt: 'x+y+z+norm+text'
173+
dflt: 'x+y+z+norm+text+name'
174174
});
175175

176176
module.exports = attrs;

src/traces/cone/calc.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@ module.exports = function calc(gd, trace) {
1717
var len = Math.min(u.length, v.length, w.length);
1818
var normMax = -Infinity;
1919
var normMin = Infinity;
20-
var compMax = -Infinity;
2120

2221
for(var i = 0; i < len; i++) {
2322
var uu = u[i];
24-
var u2 = uu * uu;
2523
var vv = v[i];
26-
var v2 = vv * vv;
2724
var ww = w[i];
28-
var w2 = ww * ww;
29-
var norm = Math.sqrt(u2 + v2 + w2);
25+
var norm = Math.sqrt(uu * uu + vv * vv + ww * ww);
3026

3127
normMax = Math.max(normMax, norm);
3228
normMin = Math.min(normMin, norm);
33-
compMax = Math.max(compMax, u2, v2, w2);
3429
}
3530

3631
trace._normMax = normMax;
40 KB
Loading
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"data": [
3+
{
4+
"type": "cone",
5+
"x": [1], "y": [1], "z": [1],
6+
"u": [1], "v": [1], "w": [0]
7+
}
8+
],
9+
"layout": {
10+
"scene": {
11+
"camera": {
12+
"eye": {"x": -0.76, "y": 1.8, "z": 0.92}
13+
}
14+
}
15+
}
16+
}

test/jasmine/tests/cone_test.js

+42
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,46 @@ describe('@gl Test cone interactions', function() {
265265
.catch(failTest)
266266
.then(done);
267267
});
268+
269+
it('should display hover labels (multi-trace case)', function(done) {
270+
function _hover() {
271+
mouseEvent('mouseover', 245, 230);
272+
return delay(20)();
273+
}
274+
275+
Plotly.plot(gd, [{
276+
type: 'cone',
277+
name: 'blue cone',
278+
x: [1], y: [1], z: [1],
279+
u: [1], v: [1], w: [0],
280+
colorscale: 'Blues',
281+
showscale: false
282+
}, {
283+
type: 'cone',
284+
name: 'green cone',
285+
x: [3], y: [3], z: [3],
286+
u: [0], v: [0], w: [2],
287+
colorscale: 'Greens',
288+
showscale: false
289+
}], {
290+
scene: {
291+
camera: {
292+
eye: {x: -0.76, y: 1.8, z: 0.92}
293+
}
294+
},
295+
margin: {l: 0, t: 0, r: 0, b: 0},
296+
width: 400,
297+
height: 400
298+
})
299+
.then(delay(20))
300+
.then(_hover)
301+
.then(function() {
302+
assertHoverLabelContent({
303+
nums: ['x: 1', 'y: 1', 'z: 1', 'norm: 1.41'].join('\n'),
304+
name: 'blue cone'
305+
});
306+
})
307+
.catch(failTest)
308+
.then(done);
309+
});
268310
});

0 commit comments

Comments
 (0)