-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Mouse event sensors for bar charts #1428
base: develop
Are you sure you want to change the base?
Conversation
Add 'hidden' bars over the existing bars. These act as mouse interaction sensor for bars, and is particularly helpful for bars that have a low enough value to be difficult to click on. Also need to make a slight change to dc.css and dc.min.css.
I'm in favor of this. People have used bar chart labels as a workaround here, but you don't always want that clutter. A couple things need to be cleaned up:
I am conflicted about whether/how the background should be highlighted or not when it's hovered. (You can barely see the grey highlight on the first screenshot, but it's easier to see IRL.) It's kind of nice to have the additional interaction indicating that clicking there is like clicking on the bar. But I found it distracting that it's a different color depending whether the bar is selected or not. I wonder if anyone else has an opinion about this. My instinct it to use a very pale green there instead of blue or grey but that is of course a matter of opinion! Obviously it should be controlled by CSS. Finally, I think we should put the feature under a flag (say |
Great! I'll take a look when I get a chance. |
Made some more changes:
Testing with the other examples also made me realize two things that I'll look into when I get a chance:
|
I have run into this issue myself and would love to have a feature like this. However, I would point out that that the issue of not being able to hover/click small bars isn't limited just to bar charts. For example, pie charts and row charts have the same problem. In my opinion, a general solution would be better. I don't know what that is, but I think having the labels be clickable / hoverable might be satisfactory. |
I'm really excited for the new version to be compatible with d3 v4/v5! Thanks for the update!
I'd like to propose the addition of mouse-sensor bars for the bar charts. These are 'hidden' bars that span the entire height of the chart, beyond the top of the visible bar. This is particularly helpful for bars with a small enough value that it is barely visible.
Note: this requires update to bar-chart.js as well as a css change that I made in dc.css - but may need to also be made elsewhere? And as you can see, I did not make any changes to dc.js, dc.min.js, or dc.min.css.