Hovering interactions

Tooltips respond to hover events. The next table lists properties of the hover object, which can be configured globally using Chart.defaults.global.hover or locally using options.hover:

Object

Value

Description

intersect

true or false

Same behavior as tooltip.intersect. Tooltips can respond to different intersect states when hovering.

mode

nearest, index, dataset, x, y. Deprecated values are label (same as index), and single (behaves like nearest when intersect: true).

Same behavior as tooltip.mode. Tooltips can respond to a different mode when hovering.

axis

x, y, xy

Selects parameters that are used to calculate the distance from the value point to the cursor during a hover event. The default is x. Horizontal bar charts override this to y so that mode:index can select different bars.

animationDuration

Number

The duration of the animation. This affects any hovering events, including tooltips.

Configuration options for the hover object

Both the hover and the tooltip objects support the mode and intersect properties. They are similar, but the hover property also applies to non-tooltip events (configured with the optional onHover callback).

If the intersect property is true, the event will only be fired if the mouse is directly over a bar or pie slice, or within a certain radius from the value point (for line, scatter, and bubble charts). If intersect is false, the event may be fired before the mouse is over the value point.

The mode property selects the data values related to the event. If intersect is false, and mode is nearest, it will select the nearest point.

When used in tooltips, the mode property also determines which items appear in a tooltip. If nearest, it will show the value that is nearest to the point where the mouse is (typical in scatter and bubble charts). The property can also have the following values:

  • point, showing only items that actually intersect the point (typical inline charts)
  • index, showing all the points at the same index (typical in a bar or pie chart)
  • dataset, listing all points in the dataset

There are also two more modes that are exclusive to Cartesian scales: x and y, which selects all points with the same values of x and y, respectively.

Edit the Tooltips/tooltip-3-modes.html file and experiment with different modes. The following screenshots show some tooltip modes applied to a line chart with three datasets:

Tooltip interaction modes: (a) displays single value point; (b) displays items with same index (or x value in this case);
(c) displays items with same y value; (d) displays all items in a dataset. Code: Tooltips/tooltip-3-modes.html.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.20.25