-
Notifications
You must be signed in to change notification settings - Fork 348
Can't use function in d3.tip.attr() #174
Comments
|
I'm using the following versions from CDNJS: https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js |
@neuquen Do you have any sample code to test this against? |
I'm no expert at A workaround would be to embed the dynamic class generation inside a wrapper element in Is it normal for a d3 plugin to dynamically calculate |
I actually am already doing your suggestion as my workaround:
However, as you can see above, now I need to wrap the content each within a container D3 does allow passing in a function to It outlines the behavior
|
@neuquen But how is If you are already using rect.on('mouseover', function(d) {
tip.attr('class', d.value ? 'class1' : 'class2').show(d)
}) If this is a bug or misuse of If it isn't a bug or plugin design problem, it should be a separate feature request issue or PR for custom dynamic handling of the class attribute, since |
Thanks @vdh. You're exactly right. After a closer look I realize now that when instantiating the tip, there is no reason that the .attr should have access to the selection. What is throwing me off though is the fact that tip.direction and tip.offset do have access. When I define the tip I am doing the following:
I haven't looked closely enough at the d3-tip code to know if this is possible, but it looks like html, offset, and direction are all getting called within tip.show(). Could the same behavior be applied to |
Yes, It may be a bit trickier to do the same for |
I'd like to style two separate tooltips, depending on the data, so I want to pass in a function, but it doesn't look like that is currently supported.
I'm trying to do the below:
The text was updated successfully, but these errors were encountered: