Customizing ToolTips in a Graph

By default, the graph registers a callback for ToolTips, which provides ToolTip text to the underlying graph engine. In most graphs, when the mouse pointer is over a component that represents data, the graph displays the data value that the component represents, as well as the labels that identify the group and the series to which the component belongs. In a scatter, bubble, or stock market graph, the graph displays each of the values that the marker represents.

When the mouse pointer is not positioned over a component that represents data, the graph does not display a ToolTip.

Properties for managing ToolTips

The following properties of the Graph class control the display of ToolTips.

Property

Description

MarkerTooltipType

Whether ToolTips are displayed for markers, and if so, the kind of information that appears in the ToolTips: the data value, the cumulative data value (stacked graphs), the percent of the group value (pie graphs), or information about the group or series to which the data belongs. Except for MTT_NONE, you can combine these values, using a bitwise OR ( | ) to show more than one kind of information in the ToolTip.

GroupTooltipLabelType

Whether group information appears in ToolTips, and if so, the kind of information that appears in the ToolTip: the dimension name and the dimension member, or only the dimension member.

SeriesTooltipLabelType

Whether series information appears in ToolTips, and if so, the kind of information that appears in the ToolTip: the dimension name and the dimension member, or only the dimension member.

ToolTipDelay

The number of milliseconds between the time that the mouse stops moving and the time that the ToolTip appears.

Example: Displaying the data value and group information in ToolTips

The following code sets the ToolTips so that they display the data value that the marker represents and the group to which the marker belongs. For group information, the ToolTip will display the dimension (such as "Product") the dimension member (such as "Shoes").


graph.setMarkerTooltipType((Graph.MTT_VALUES | Graph.MTT_TEXT)); graph.setSeriesTooltipLabelType(Graph.TLT_NONE); graph.setGroupTooltipLabelType(Graph.TLT_DIM_MEMBER);

Adding a customized callback for ToolTips

If you want to display information other than information about the data value and the group and series to which the data belongs, then you can write your own callback, which can provide any text that you want in the ToolTip. The CustomToolTipCallback interface specifies a single method, getToolTipText, which you can implement. The graph calls this method and displays the text from this method in the ToolTip.

The getToolTipText method takes two arguments:

You implement getToolTipText and use the information from the ComponentHandle to specify text that you want to display in the ToolTip.

Registering the customized callback with the graph

If you implement the CustomToolTipCallback interface, then you register the customized callback by calling the setCustomToolTipCallback method of the graph.