Skip to content

Commit ae2feeb

Browse files
committed
implement valuehoverformat for isosurface and volume traces
1 parent 2384391 commit ae2feeb

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

src/plots/gl3d/scene.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ proto.render = function() {
392392
}
393393
tx = vectorTx.join('<br>');
394394
} else if(trace.type === 'isosurface' || trace.type === 'volume') {
395-
labels.valueLabel = Axes.tickText(scene._mockAxis, scene._mockAxis.d2l(selection.traceCoordinate[3]), 'hover').text;
395+
labels.valueLabel = Axes.hoverLabelText(scene._mockAxis, scene._mockAxis.d2l(selection.traceCoordinate[3]), trace.valuehoverformat);
396396
vectorTx.push('value: ' + labels.valueLabel);
397397
if(selection.textLabel) {
398398
vectorTx.push(selection.textLabel);

src/traces/isosurface/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ var attrs = module.exports = overrideAll(extendFlat({
210210
xhoverformat: axisHoverFormat('x'),
211211
yhoverformat: axisHoverFormat('y'),
212212
zhoverformat: axisHoverFormat('z'),
213+
valuehoverformat: axisHoverFormat('value', 1),
213214

214215
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
215216
},

src/traces/isosurface/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
4343
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
4444
handleCalendarDefaults(traceIn, traceOut, ['x', 'y', 'z'], layout);
4545

46+
coerce('valuehoverformat');
4647
['x', 'y', 'z'].forEach(function(dim) {
4748
coerce(dim + 'hoverformat');
4849

src/traces/volume/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var attrs = module.exports = overrideAll(extendFlat({
4646
xhoverformat: isosurfaceAttrs.xhoverformat,
4747
yhoverformat: isosurfaceAttrs.yhoverformat,
4848
zhoverformat: isosurfaceAttrs.zhoverformat,
49+
valuehoverformat: isosurfaceAttrs.valuehoverformat,
4950
hovertemplate: isosurfaceAttrs.hovertemplate
5051
},
5152

test/jasmine/tests/gl3d_hover_click_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ describe('Test gl3d trace click/hover:', function() {
12681268
});
12691269
});
12701270

1271-
describe('hover on traces with (x|y|z|u|v|w)hoverformat', function() {
1271+
describe('hover on traces with (x|y|z|u|v|w)hoverformat and valuehoverformat', function() {
12721272
'use strict';
12731273

12741274
var gd, fig;
@@ -1393,16 +1393,17 @@ describe('hover on traces with (x|y|z|u|v|w)hoverformat', function() {
13931393
});
13941394

13951395
[
1396-
{type: 'isosurface', nums: 'x: 1.0\ny: 1.00\nz: 1.000\nvalue: 8'},
1397-
{type: 'volume', nums: 'x: 1.0\ny: 1.00\nz: 1.000\nvalue: 8'},
1396+
{type: 'isosurface', nums: 'x: 1.0\ny: 1.00\nz: 1.000\nvalue: 8.0000'},
1397+
{type: 'volume', nums: 'x: 1.0\ny: 1.00\nz: 1.000\nvalue: 8.0000'},
13981398
].forEach(function(t) {
13991399
it('@gl ' + t.type + ' trace', function(done) {
14001400
fig.data = [{
14011401
showscale: false,
1402-
hoverinfo: 'x+y+z+u+v+w',
1402+
hoverinfo: 'x+y+z+u+v+w+value',
14031403
xhoverformat: '.1f',
14041404
yhoverformat: '.2f',
14051405
zhoverformat: '.3f',
1406+
valuehoverformat: '.4f',
14061407
x: [0, 1, 0, 1, 0, 1, 0, 1],
14071408
y: [0, 0, 1, 1, 0, 0, 1, 1],
14081409
z: [0, 0, 0, 0, 1, 1, 1, 1],

0 commit comments

Comments
 (0)