The Wayback Machine - https://web.archive.org/web/20200606062957/https://github.com/chartjs/Chart.js/issues/6200
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

Docs for "hover"/interaction modes are too focused on tooltips #6200

Open
fgblomqvist opened this issue Apr 11, 2019 · 4 comments
Open

Docs for "hover"/interaction modes are too focused on tooltips #6200

fgblomqvist opened this issue Apr 11, 2019 · 4 comments

Comments

@fgblomqvist
Copy link

@fgblomqvist fgblomqvist commented Apr 11, 2019

Documentation Is:

  • Missing or needed
  • Confusing
  • Not Sure?

Please Explain in Detail...

Took me forever and a half to realize that the Interactions settings are not only for tooltips, but can also apply to points (and maybe other things, idk?). Wanted to have the point nearest to the hover location always render, and only measure on the x axis, which I already achieved for the tooltip by reading the docs on Interactions and the different modes and settings. This, turns out, is super simple to achieve for points by setting options.hover to:

{
  mode: 'nearest',
  intersect: false,
  axis: 'x'
}

Maybe there is a more "point-specific" place to set these settings, but they didn't work in either options.elements or options.elements.point. Nonetheless, it was not obvious that these settings would affect the point.

Your Proposal for Changes

I think there are a couple issues at hand here. The first one is that the docs on this are overly focused on the tooltips. All the examples on the Modes page are about tooltips, which is arguably fine, however, on the main Interactions page, the setting mode is described as follows:

Sets which elements appear in the tooltip. See Interaction Modes for details.

Which combined with the fact that the Modes page only utilizes tooltip examples, led my brain to believe that these settings were only for tooltips (you could argue that I should have tried the global hover settings, but since I believed that it was only for tooltips, I didn't). I think that description should be changed to something more generic (similar to the other settings descriptions). Furthermore, I think that a list/sentence mentioning which objects these settings would/could apply to should be stated somewhere, either on the main Interactions page or somewhere on the Modes page. Is it only tooltips and points?

The second issue is that I think options.elements.point should accept these settings, just how options.tooltips accept them. At some point, I did try adding a simple mode: nearest to the point section, thinking that maybe the point just use the same settings (and they just were never documented). That didn't work. I think it would be logical to have it accept the settings, where else do you set them if they're only supposed to affect the points rendering? (options.hover don't seem to be global either for that matter, it doesn't affect the tooltips?)

Maybe I'm the only one who mixed all this up and to whom it doesn't come off as logical, but just figured I'd put it out there in case there are others that would agree.

@kurkle
Copy link
Collaborator

@kurkle kurkle commented Apr 16, 2019

Interaction settings are configured separately for hover and tooltips.

I'm not sure why you think options.elements.point should accept interaction options and how would that differ from hover? Do you need different interaction mode for line and point for example (I wonder how it would work)?

Hover effects are configured at element level though.

I agree the documentation needs changes, first the Interaction settings talks only about hover while all those mode samples are for tooltips (hover is mentioned there though).

@fgblomqvist
Copy link
Author

@fgblomqvist fgblomqvist commented Apr 16, 2019

I think, simplifying my argument a bit, to begin with, what confuses me is that I consider the tooltip to be an integral part of the chart, and it is generally shown on hover. When I see options.hover, I think "ah these are options that configure what happens when I hover over the chart area". In my mind, that includes anything on the chart, such as tooltips, points, lines, etc.. Currently, it is clearly limited to only controlling line and point behavior. E.g. the tooltip is left out of it for some reason.

The questions I would ask myself are:

  • When I hover over the chart area, which points should trigger the hover effect?
  • When I hover over the chart area, which points should the tooltip be shown for?

Essentially, what I am proposing, is that the current options.hover get moved to options.elements.point, retaining the exact same behavior as it currently has (since the current behavior seems unrelated to the line anyway). Secondly, if one wants to, one could still use options.hover, which would work as global hover options, trickling down into both options.elements.point as well as options.tooltips.

I'm sorry if it's still unclear.

@kurkle
Copy link
Collaborator

@kurkle kurkle commented Apr 16, 2019

I agree those interactions should both be configured by one set of options, by default. I don't think elements.point is the place though - consider bar and pie/doughnut charts for example.

Considering backward compatibility, these things can't be changed until v3.

@fgblomqvist
Copy link
Author

@fgblomqvist fgblomqvist commented Apr 16, 2019

Sounds good, yeah I've only been using line charts so don't have any insights into how it would work with the other types. At least, for now, it's been noted down, thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.