-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add (x|y|z)hoverformat to a number of cartesian and gl3d traces #5563
Changes from 5 commits
d546fd6
78c7249
67a194d
2384391
ae2feeb
8c33d50
498d73e
aeba545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,10 +322,14 @@ proto.render = function() { | |
if(trace.setContourLevels) trace.setContourLevels(); | ||
} | ||
|
||
function formatter(axisName, val) { | ||
var axis = scene.fullSceneLayout[axisName]; | ||
function formatter(axLetter, val, hoverformat) { | ||
var ax = scene.fullSceneLayout[axLetter + 'axis']; | ||
|
||
return Axes.tickText(axis, axis.d2l(val), 'hover').text; | ||
if(ax.type !== 'log') { | ||
val = ax.d2l(val); | ||
} | ||
|
||
return Axes.hoverLabelText(ax, val, hoverformat); | ||
} | ||
|
||
var oldEventData; | ||
|
@@ -337,9 +341,9 @@ proto.render = function() { | |
var ptNumber = selection.index; | ||
|
||
var labels = { | ||
xLabel: formatter('xaxis', selection.traceCoordinate[0]), | ||
yLabel: formatter('yaxis', selection.traceCoordinate[1]), | ||
zLabel: formatter('zaxis', selection.traceCoordinate[2]) | ||
xLabel: formatter('x', selection.traceCoordinate[0], trace.xhoverformat), | ||
yLabel: formatter('y', selection.traceCoordinate[1], trace.yhoverformat), | ||
zLabel: formatter('z', selection.traceCoordinate[2], trace.zhoverformat) | ||
}; | ||
|
||
var hoverinfo = Fx.castHoverinfo(traceNow, scene.fullLayout, ptNumber); | ||
|
@@ -358,17 +362,17 @@ proto.render = function() { | |
var vectorTx = []; | ||
|
||
if(trace.type === 'cone' || trace.type === 'streamtube') { | ||
labels.uLabel = formatter('xaxis', selection.traceCoordinate[3]); | ||
labels.uLabel = formatter('x', selection.traceCoordinate[3], trace.uhoverformat); | ||
if(isHoverinfoAll || hoverinfoParts.indexOf('u') !== -1) { | ||
vectorTx.push('u: ' + labels.uLabel); | ||
} | ||
|
||
labels.vLabel = formatter('yaxis', selection.traceCoordinate[4]); | ||
labels.vLabel = formatter('y', selection.traceCoordinate[4], trace.vhoverformat); | ||
if(isHoverinfoAll || hoverinfoParts.indexOf('v') !== -1) { | ||
vectorTx.push('v: ' + labels.vLabel); | ||
} | ||
|
||
labels.wLabel = formatter('zaxis', selection.traceCoordinate[5]); | ||
labels.wLabel = formatter('z', selection.traceCoordinate[5], trace.whoverformat); | ||
if(isHoverinfoAll || hoverinfoParts.indexOf('w') !== -1) { | ||
vectorTx.push('w: ' + labels.wLabel); | ||
} | ||
|
@@ -388,7 +392,7 @@ proto.render = function() { | |
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right above here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In principle yes but that's extremely low priority IMO |
||
tx = vectorTx.join('<br>'); | ||
} else if(trace.type === 'isosurface' || trace.type === 'volume') { | ||
labels.valueLabel = Axes.tickText(scene._mockAxis, scene._mockAxis.d2l(selection.traceCoordinate[3]), 'hover').text; | ||
labels.valueLabel = Axes.hoverLabelText(scene._mockAxis, scene._mockAxis.d2l(selection.traceCoordinate[3]), trace.valuehoverformat); | ||
vectorTx.push('value: ' + labels.valueLabel); | ||
if(selection.textLabel) { | ||
vectorTx.push(selection.textLabel); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
var FORMAT_LINK = require('../constants/docs').FORMAT_LINK; | ||
|
||
module.exports = function axisHoverFormat(x, mockedAxis) { | ||
return { | ||
valType: 'string', | ||
dflt: '', | ||
editType: 'none', | ||
description: [ | ||
'Sets the hover text formatting rule for `' + x + '`', | ||
' using d3 formatting mini-languages which are very similar to those in Python.', | ||
'See: ' + FORMAT_LINK, | ||
alexcjohnson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'By default the values are formatted using ' + ( | ||
mockedAxis ? | ||
'generic number format' : | ||
('`' + x + 'axis.hoverformat`') | ||
) + '.', | ||
].join(' ') | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that
Axes.hoverLabelText
was not used ingl3d
hover before. And for forlog
axes it was needed to convert the value.