-
-
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
Hover label namelength #1822
Hover label namelength #1822
Conversation
@etpinard as I said I'll do, I opened a new PR, with fixed tests. Let me know what you think. I still have some concerns that I might need to do some updates to the documentation or something. Not sure how that goes here :) |
e939c86
to
542f39f
Compare
src/components/fx/attributes.js
Outdated
valType: 'number', | ||
min: 0, | ||
dflt: 15, | ||
role: 'style', |
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.
We should try adding arrayOk
support here, so that
trace = {
x: [1, 2, 3],
y: [2, 1, 2],
namelength: [15, 10, 40]
}
would work.
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.
see #1761 for an example on how to proceed.
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.
We should try adding arrayOk support here
good call - at first I was worried that this would just be confusing to look at ("I thought this was the same trace, why does it have a different name?") but it could actually come in handy for example if you vary the hover label font size, a bigger one may need more truncation of the name 👍
src/components/fx/hover.js
Outdated
@@ -689,7 +689,7 @@ function createHoverText(hoverData, opts, gd) { | |||
// strip out our pseudo-html elements from d.name (if it exists at all) | |||
name = svgTextUtils.plainText(d.name || ''); | |||
|
|||
if(name.length > 15) name = name.substr(0, 12) + '...'; | |||
if(name.length > commonLabelOpts.namelength && commonLabelOpts.namelength > 0) name = name.substr(0, commonLabelOpts.namelength - 3) + '...'; |
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.
Does this take care of namelength = 0
case which should hide the name text node completely?
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.
++ can you rewrite this as
if(/* */) {
}
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.
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.
Too bad the JS token Infinity
isn't JSON serializable. I'm ok with making namelength: 0
means no truncation, even though it feels contradictory to me.
Perhaps we should instead add support for an Infinity
-like value in valType: 'number'
attributes. For example, we could make namelength: null
correspond to namelength === Infinity
. Though, I can't think of any other attributes that could benefit from it, so I'm not sure it's worth the time.
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.
namelength: -1
? In the style of indexOf, that says "does not apply" to me. Sort of.
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.
@rreusser solid suggestion, I like it 👍
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.
-1
sounds good for "no truncation." I'm not sure why someone would want to use namelength=0
to completely hide the name, rather than using hoverinfo
but I bet someone will come up with a clever reason for it!
542f39f
to
c865049
Compare
c865049
to
8a308a8
Compare
@ckiss are you planning on addressing the comments above? I might have time to wrap this one up on Monday. |
@etpinard I'll address them Monday morning! Have a great weekend and sorry for the delay! |
- -1 for no constraint - more complete description - complete arrayOk support - tests
@ckiss I hope you don't mind, I took the liberty of finishing this up so we can get it in the next minor release. I switched to -1 for "no truncation", fleshed out the @etpinard any comments? |
💃 |
valType: 'number', | ||
min: 0, | ||
valType: 'integer', | ||
min: -1, | ||
dflt: 15, |
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.
don't you need to remove dflt
here too?
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 kept only the global default, because the trace-level default inherits from the global so doesn't use a default of its own.
You're right that we want a default - in fact, we need a default of 15 to preserve backward compatibility - this is just how that default gets propagated.
@alexcjohnson @etpinard sorry I didn't had time to complete this :( I was back from holidays monday and had lots on my plate... thanks for your help @alexcjohnson. I added a comment to your commit. Otherwise I'm happy, although where this was initially discussed a default value was mentioned. |
cool, thanks! |
resolves #1777