-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Histogram events & bin hover label improvements #2113
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
Changes from all commits
59b6463
6dc9904
ccf1a76
1b356d2
8f8add1
7686096
8d36d81
a7e2f32
6b74fbe
b91d1cb
ad0e08f
6cb4e71
7581567
51ad8c2
3aa03f7
cc454dc
2696c1c
0331a16
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ var ONEHOUR = constants.ONEHOUR; | |
var ONEMIN = constants.ONEMIN; | ||
var ONESEC = constants.ONESEC; | ||
var MINUS_SIGN = constants.MINUS_SIGN; | ||
var BADNUM = constants.BADNUM; | ||
|
||
var MID_SHIFT = require('../../constants/alignment').MID_SHIFT; | ||
|
||
|
@@ -1216,12 +1217,28 @@ axes.tickText = function(ax, x, hover) { | |
return out; | ||
}; | ||
|
||
axes.hoverLabelText = function(ax, val) { | ||
/** | ||
* create text for a hover label on this axis, with special handling of | ||
* log axes (where negative values can't be displayed but can appear in hover text) | ||
* | ||
* @param {object} ax: the axis to format text for | ||
* @param {number} val: calcdata value to format | ||
* @param {Optional(number)} val2: a second value to display | ||
* | ||
* @returns {string} `val` formatted as a string appropriate to this axis, or | ||
* `val` and `val2` as a range (ie '<val> - <val2>') if `val2` is provided and | ||
* it's different from `val`. | ||
*/ | ||
axes.hoverLabelText = function(ax, val, val2) { | ||
if(val2 !== BADNUM && val2 !== val) { | ||
return axes.hoverLabelText(ax, val) + ' - ' + axes.hoverLabelText(ax, val2); | ||
} | ||
|
||
var logOffScale = (ax.type === 'log' && val <= 0); | ||
var tx = axes.tickText(ax, ax.c2l(logOffScale ? -val : val), 'hover').text; | ||
|
||
if(logOffScale) { | ||
return val === 0 ? '0' : '-' + tx; | ||
return val === 0 ? '0' : MINUS_SIGN + tx; | ||
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. been around for a while, using regular dash instead of unicode minus. tested in 3aa03f7#diff-846cf5b534aa0d22bdd1da2b43ac3cbaR517 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. I was wondering about that. Thanks 👌 |
||
} | ||
|
||
// TODO: should we do something special if the axis calendar and | ||
|
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.
I'm a little surprised that this hadn't come up before (other than the test below that was actually wrong before), and obviously it's a bit questionable exactly what small fraction to put here... but if we just use straight
<
vs<=
etc it's pretty easy to trickfindBin
on the edges.