-
-
Couldn't load subscription status.
- Fork 1.9k
histogram: in hover labels, harmonize start/end values of shared bins #4662
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 1 commit
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 |
|---|---|---|
|
|
@@ -102,12 +102,20 @@ function calc(gd, trace) { | |
| }; | ||
| } | ||
|
|
||
| if(!gd._fullLayout._roundFnOpts) gd._fullLayout._roundFnOpts = {}; | ||
| var groupName = trace['_' + mainData + 'bingroup']; | ||
| var roundFnOpts = {leftGap: Infinity, rightGap: Infinity}; | ||
| if(groupName) { | ||
| if(!gd._fullLayout._roundFnOpts[groupName]) gd._fullLayout._roundFnOpts[groupName] = roundFnOpts; | ||
| roundFnOpts = gd._fullLayout._roundFnOpts[groupName]; | ||
| } | ||
|
|
||
| // bin the data | ||
| // and make histogram-specific pt-number-to-cd-index map object | ||
| var nMax = size.length; | ||
| var uniqueValsPerBin = true; | ||
| var leftGap = Infinity; | ||
| var rightGap = Infinity; | ||
| var leftGap = roundFnOpts.leftGap; | ||
| var rightGap = roundFnOpts.rightGap; | ||
| var ptNumber2cdIndex = {}; | ||
| for(i = 0; i < pos0.length; i++) { | ||
| var posi = pos0[i]; | ||
|
|
@@ -124,10 +132,17 @@ function calc(gd, trace) { | |
| rightGap = Math.min(rightGap, binEdges[n + 1] - posi); | ||
| } | ||
| } | ||
| roundFnOpts.leftGap = leftGap; | ||
| roundFnOpts.rightGap = rightGap; | ||
|
|
||
| var roundFn; | ||
| if(!uniqueValsPerBin) { | ||
| roundFn = getBinSpanLabelRound(leftGap, rightGap, binEdges, pa, calendar); | ||
| roundFn = function(v, isRightEdge) { | ||
| return function() { | ||
| var roundFnOpts = gd._fullLayout._roundFnOpts[groupName]; | ||
| return getBinSpanLabelRound(roundFnOpts.leftGap, roundFnOpts.rightGap, binEdges, pa, calendar)(v, isRightEdge); | ||
|
||
| }; | ||
| }; | ||
| } | ||
|
|
||
| // average and/or normalize the data, if needed | ||
|
|
@@ -173,6 +188,8 @@ function calc(gd, trace) { | |
| if(uniqueValsPerBin) { | ||
| cdi.ph0 = cdi.ph1 = (inputPoints[i].length) ? pos0[inputPoints[i][0]] : pos[i]; | ||
| } else { | ||
| // Defer evaluation of ph(0|1) in crossTraceCalc | ||
| trace._computePh = true; | ||
| cdi.ph0 = roundFn(binEdges[i]); | ||
| cdi.ph1 = roundFn(binEdges[i + 1], true); | ||
| } | ||
|
|
||
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.
Non-blocking,
We could rewrite this:
to make it easier to read 3
gd._fullLayout._roundFnOpts[groupName].