-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Array support for trace hoverinfo
#1761
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 4 commits
aab3366
2acf548
b649b11
7ed8681
371d31e
e8a9ddd
3c693a0
d7999e2
3c3fda4
d1f03c0
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ lib.valObjects = coerceModule.valObjects; | |
lib.coerce = coerceModule.coerce; | ||
lib.coerce2 = coerceModule.coerce2; | ||
lib.coerceFont = coerceModule.coerceFont; | ||
lib.coerceHoverinfo = coerceModule.coerceHoverinfo; | ||
lib.validate = coerceModule.validate; | ||
|
||
var datesModule = require('./dates'); | ||
|
@@ -349,10 +350,21 @@ lib.noneOrAll = function(containerIn, containerOut, attrList) { | |
} | ||
}; | ||
|
||
lib.mergeArray = function(traceAttr, cd, cdAttr) { | ||
/** merge data array into calcdata items | ||
* | ||
* @param {array} traceAttr : trace attribute | ||
* @param {object} cd : calcdata trace | ||
* @param {string} cdAttr : calcdata key | ||
* @param {function} [fn] : optional function to apply to each array item | ||
*/ | ||
lib.mergeArray = function(traceAttr, cd, cdAttr, fn) { | ||
fn = fn || lib.identity; | ||
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 wonder whether it would be worth avoiding
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. That won't make that much of a difference (at least in Chrome 58) https://gist.github.com/etpinard/4a5c7983a619efb4c98cb927529b9af6 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. awesome, thanks for checking. |
||
|
||
if(Array.isArray(traceAttr)) { | ||
var imax = Math.min(traceAttr.length, cd.length); | ||
for(var i = 0; i < imax; i++) cd[i][cdAttr] = traceAttr[i]; | ||
for(var i = 0; i < imax; i++) { | ||
cd[i][cdAttr] = fn(traceAttr[i]); | ||
} | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ module.exports = { | |
textfont: scatterAttrs.textfont, | ||
textposition: scatterAttrs.textposition, | ||
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { | ||
flags: ['a', 'b', 'c', 'text', 'name'] | ||
flags: ['a', 'b', 'text', 'name'] | ||
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. fyi @rreusser |
||
}), | ||
hoveron: scatterAttrs.hoveron, | ||
}; |
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 hope nobody minds this abstraction. The hoverinfo
dflt
is ✨ : special ✨ , so I think it deserves its owncoerce
function.