-
-
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
Box points hover & select #2094
Changes from 1 commit
cfc8725
53c446b
581f3fa
e59f283
5c58049
aef61ae
d352fa5
6a878b0
0027b84
a1ea1e8
6bfcbe0
9ca410a
7e44c9c
f228a5e
b4d8044
9e69900
8901528
b66628e
a3ec75a
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 |
---|---|---|
|
@@ -56,6 +56,7 @@ module.exports = function calc(gd, trace) { | |
var n = Lib.findBin(pos[i], posBins); | ||
if(n >= 0 && n < pLen) { | ||
var pt = {v: v, i: i}; | ||
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. This here was the key to make box point hover and selection somewhat clean. Box calcdata traces have one item per box to be displayed. Box points data-esque array of objects used to be created during 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. ... probably best to review this file as a whole: 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. Definitely nice and clean - I was curious whether this degraded performance for large data sets, but it looks like very little if at all function r(n) { var v = 0; for(var i = 0; i < n; i++) v += Math.random(); return v; }
function a(n, m) { var out = new Array(n); for(var i = 0; i < n; i++) out[i] = r(m); return out; }
var y = a(1000000, 10)
// I had to patch timeit to support n = 1
timeit(function() { Plotly.newPlot(gd,[{type: 'box', y: y, jitter: 0.5, hoveron: 'points'}]) }, 1) On my computer 1 million points (of which ~5k are outliers) takes ~3 sec, and difference between this branch and master is within the noise (~10% or less) 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.
Thanks for taking a look at this 🐎 |
||
arraysToCalcdata(pt, trace, i); | ||
ptsPerBin[n].push(pt); | ||
} | ||
} | ||
|
@@ -176,6 +177,18 @@ function initNestedArray(len) { | |
return arr; | ||
} | ||
|
||
function arraysToCalcdata(pt, trace, i) { | ||
var trace2calc = { | ||
text: 'tx' | ||
}; | ||
|
||
for(var k in trace2calc) { | ||
if(Array.isArray(trace[k])) { | ||
pt[trace2calc[k]] = trace[k][i]; | ||
} | ||
} | ||
} | ||
|
||
function sortByVal(a, b) { return a.v - b.v; } | ||
|
||
function extractVal(o) { return o.v; } |
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.
text
is expected to be an array as long as the sample arrayy
(x
) for vertical (horizontal) box plots, matching each sample pt one-to-one.