Skip to content
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

Restore tooltip behavior when grouped #2684

Merged
merged 17 commits into from
Aug 26, 2019
Merged

Conversation

panthony
Copy link
Contributor

@panthony panthony commented Aug 19, 2019

In previous version of c3js when tooltip_grouped was true, the simple act of hovering above a category would highlight/show the data point(s) of that particular category.

But it was broken when c3js started to use a single rect for the whole chart.

This PR aims to restore this important behavior.

It also includes the fix proposed in #2151.

Closes #2362
Closes #1745
Closes #2641
Closes #1201

It removes one of the usage of pathSegList (#2075)

Left to do:

  • Add tests for timeseries

@codecov-io
Copy link

codecov-io commented Aug 19, 2019

Codecov Report

Merging #2684 into master will increase coverage by 1.51%.
The diff coverage is 95.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2684      +/-   ##
==========================================
+ Coverage   81.01%   82.52%   +1.51%     
==========================================
  Files          59       59              
  Lines        4640     4659      +19     
==========================================
+ Hits         3759     3845      +86     
+ Misses        881      814      -67
Impacted Files Coverage Δ
src/type.js 98.43% <ø> (-0.05%) ⬇️
src/shape.bar.js 100% <100%> (+1.33%) ⬆️
src/util.js 98.03% <100%> (+0.26%) ⬆️
src/grid.js 74.8% <100%> (+0.76%) ⬆️
src/core.js 90.9% <100%> (+0.15%) ⬆️
src/data.js 89.13% <100%> (+1.95%) ⬆️
src/interaction.js 80.85% <92.15%> (+30.85%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2bc2488...1e66104. Read the comment docs.

@panthony panthony force-pushed the patch/11-tooltip-rect branch 2 times, most recently from aaa19fb to e77e40e Compare August 19, 2019 13:32
@panthony panthony marked this pull request as ready for review August 19, 2019 13:36
@panthony panthony requested a review from kt3k August 19, 2019 13:37
@panthony
Copy link
Contributor Author

I added more tests but codecov did not re-run, not sure if possible to make it re-run manually.

@panthony panthony changed the title Restore tooltip behavior when grouped [WIP] Restore tooltip behavior when grouped Aug 20, 2019
@panthony panthony changed the title [WIP] Restore tooltip behavior when grouped Restore tooltip behavior when grouped Aug 20, 2019
@panthony panthony force-pushed the patch/11-tooltip-rect branch 2 times, most recently from f46d9b8 to ce4c62a Compare August 21, 2019 09:34
@panthony
Copy link
Contributor Author

@kt3k I was thinking about fixing #1658 too by moving data_onclick outside the loop and simply calling it once with closest which is supposed to be the closest data point to the mouse.

What do you think?

spec/interaction-spec.js Outdated Show resolved Hide resolved
spec/interaction-spec.js Outdated Show resolved Hide resolved
@kt3k
Copy link
Member

kt3k commented Aug 24, 2019

@panthony Thank you for tackling this. This was one of the most requested fixes in c3js! The examples seem working nicely on chrome and firefox 👍 Testing with mouse interaction looks so great!

I left a few comments.

I was thinking about fixing #1658 too by moving data_onclick outside the loop and simply calling it once with closest which is supposed to be the closest data point to the mouse.

Sounds good to me.

nbdavies and others added 12 commits August 26, 2019 11:29
1. config is called 'onmouseover' and not 'mouseover'
2. need to pass the event-rect as parameter to properly trigger event
This is not a boolean but rather the currently hovered data.

Once 'mouseout' is triggered this value is set to be undefined so let's
use this as default value.
Also add a bunch of tests around interaction with bar and line charts.
As timeseries uses 'Date' objects as 'x' value.
I believe it was necessary when we had multiple event rect across the
chart (maybe not?)

Tried en several charts and $$.d3.mouse(shape) always returns the same
values as pos.
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kt3k kt3k merged commit 74e53ba into c3js:master Aug 26, 2019
@IceCreamYou
Copy link

Is there a way to avoid this behavior? I have charts with large tooltips, and with this new behavior where tooltips appear when you're not hovering a point/bar, the tooltips get in the way. In particular they get in the way of drag-selections and sometimes even seeing the data point you're trying to hover. I know that I can set tooltip.grouped to false, and I can override tooltip.contents to still display grouped info in that case, but I want to keep the behavior that if a point and bar have the same index, hovering over the bar also gives the point hover styles (and vice versa). If possible, I would prefer not to have to revert to manually toggling classes based on what's hovered or where the mouse is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants