Chart.js: Tooltips & x-axis mode v2.2.0

Created on 29 Jul 2016  路  7Comments  路  Source: chartjs/Chart.js

Hi,

1 - Tooltips arrow default position is "right" and we can see the arrow blink from the right to its calculated position during fade in and fade out animation.
arrow

2 - For bar chart, x-axis mode (thanks for this option @Mesonyx) depends of "stacked" param
if stacked is true, mode = label
stacked
if stacked is false, mode = single
no_stacked
So i'm wondering if "x-axis" shouldn't be an option instead of a "mode". It will give the liberty to have x-axis + single or x-axis + label.

3 - For line chart, when pointRadius = 0 (for a clean design or when there is a lot of data points) tooltip is visible only if your cursor is on the 1px corresponding to the X.
tooltips_line
It is possible to have something like padding left/right = space between two points / 2 for the "hover zone" of the tooltip.
padding_line

bug

Most helpful comment

The animation is definitely a bug. I thought it was already reported, but I couldn't find a duplicate issue.

That's an interesting idea for the x axis hover. Thoughts @simonbrunel @zachpanz88 @Mesonyx ?

For #3, the points have a hitRadius option that is a number that is added to the radius to determine the hit region. The default is 1. This could be changed, but it isn't what you really want. One thing I have envisioned is to have a 'nearest' hover / tooltip mode. This would always pick the nearest point and then use that. Would that be more like what you are looking for?

All 7 comments

The animation is definitely a bug. I thought it was already reported, but I couldn't find a duplicate issue.

That's an interesting idea for the x axis hover. Thoughts @simonbrunel @zachpanz88 @Mesonyx ?

For #3, the points have a hitRadius option that is a number that is added to the radius to determine the hit region. The default is 1. This could be changed, but it isn't what you really want. One thing I have envisioned is to have a 'nearest' hover / tooltip mode. This would always pick the nearest point and then use that. Would that be more like what you are looking for?

Nearest mode should be perfect :)

nearest mode is exactly the 50% rule between two data points ( at least for tooltips.mode: 'x-axis'). would be great to have such an option!

@frlinw the concept of the x-axis mode was I think implemented in #3400. We now have an intersect mode that configures tooltip modes to run either all the time or only when the cursor intersects an item in the chart. Will try and figure out why the flip happens though .. it could be that something is calculated during draw instead of during the update

Great work, waiting for 2.4 so :) I will test it asap

@etimberg Just a question, you can't have 'label' mode (now 'index') + nearest feature?

@frlinw you can do index mode and intersect: false which will find the nearest item, then display the tooltip for all things at the same index.

Fixed last remaining issue, the weird arrow during hover, in #3446

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JAIOMP picture JAIOMP  路  3Comments

JewelsJLF picture JewelsJLF  路  3Comments

benmccann picture benmccann  路  3Comments

HeinPauwelyn picture HeinPauwelyn  路  3Comments

SylarRuby picture SylarRuby  路  3Comments