Edit this page


VictoryTooltip is a label component with defaultEvents It renders a customizeable flyout container as well as a VictoryLabel component. VictoryTooltip can be used with any Victory component by setting the labelComponent prop like so labelComponent={<VictoryTooltip/>

VictoryVoronoiTooltip attaches the VictoryTooltip label component to an invisible VictoryVoronoi data component. VictoryVoronoi tooltip is useful for adding tooltips to elements that do not have individual data elements, like VictoryLine, or adding tooltips to any element that is too small to hover over effectively.

This guide discusses customization and advanced usage of tooltips in Victory

Simple tooltips

The simplest way to add tooltips to a chart is to use VictoryTooltip as a labelComponent as in the example below:


When tooltips are added to a chart in this way, defaultEvents on VictoryTooltip are automatically added to the component using them, in this case VictoryBar. By default, VictoryTooltip will adjust its position, orientation, and the width and height of its container to match the corresponding data and labels.

Customizing Tooltips

Tooltips can be customized directly on the the VictoryTooltip component


VictoryTooltip is composed of VictoryLabel and the primitive Flyout component. Both of these components are highly configurable, but may also be replaced if necessary.


Tooltips with VictoryVoronoiContainer

Voronoi tooltips are useful for adding tooltips to a line, or adding tooltips to data points that are too small to hover over effectively. VictoryVoronoiContainer calculates a voronoi diagram based on the data of every child component it renders. The voronoi data is used to associate a mouse position with its nearest data point(s). When VictoryVoronoiContainer is added as the containerComponent of your chart, changes in mouse position will add and remove the active prop on appropriate data and label elements.


Mutli-point Tooltips with VictoryVoronoiContainer

VictoryVoronoiContainer can also be used to create multi-point labels when the labels prop is provided. In the example below the dimension prop is used to indicate that the voronoi diagram will only be specific to the x dimension. For a given mouse position, all data matching the associated x value will be activated regardless of y value. In the following example, this leads to several tooltips being active at the same time. Provide a labels and (optionally) a labelComponent prop to configure multi-point labels.


Tooltips with Other Events

VictoryTooltip automatically attaches events to data components. When events of the same type are specified for data components, it is necessary to reconcile events so that tooltips still work. For web, the default tooltip events are:

static defaultEvents = [{
  target: "data",
  eventHandlers: {
    onMouseOver: () => {
      return {
        target: "labels",
        mutation: () => ({ active: true })
    onMouseOut: () => {
      return {
        target: "labels",
        mutation: () => ({ active: false })

When other onMouseOver and onMouseOut events are specified for data, the event returns described above must be added to the events for tooltips to continue to work properly.


Wrapping VictoryTooltip

The events that control VictoryTooltip are stored on the static defaultEvents property. Wrapped instances of VictoryTooltip will need to replicate or hoist this property in order to add automatic events to the components that use them.