Tooltips are displayed by adding a TooltipInteractivityOperation object to InteractivityOperationsCollection:
VB.NET | |
---|---|
chartControl.InteractivityOperations.Add(New TooltipInteractivityOperation()) |
C# | |
---|---|
chartControl.InteractivityOperations.Add(new TooltipInteractivityOperation()); |
You must also tell the chart which tooltips you want to display. This is done by properly modifying the Interactivity and SeriesInteractivity objects assigned to almost all chart elements. The following code creates a bar chart and assigns tooltips to all chart elements:
VB.NET | |
---|---|
|
C# | |
---|---|
|
It is obvious in this code that the tooltips displayed by all chart elements except the data items in the series are controlled by the Interactivity object attached to them. This provides a very consistent way for working with all interactivity features, and tooltips in particular.
To add tooltips to data items, you need to use a slightly different programming technique. This is because it is not realistic to attach an Interactivity object to each data item, as this will increase the memory usage of the component, especially when you have many data points. Instead, each series has an attached SeriesInteractivity object, which exposes collections for the same properties as the Interactivity object. For example, the Tooltip property becomes a Tooltips collection. The SeriesInteractivity object also exposes several properties that define how to map the entries in the collections to the different data items. For example, in DataPoints mode the control assigns tooltips to the data items by cycling over the Tooltips collection. This model is much more flexible than assigning an Interactivity object for each data item. For example, let's say that you have to use the same tooltip for all data items. In this case all you have to do is to add the tooltip to the Tooltips collection and set the TooltipMode to SeriesTooltipMode.DataPoints:
VB.NET | |
---|---|
|
C# | |
---|---|
bar.Interactivity.TooltipMode = SeriesTooltipMode.DataPoints; |
Note that we can also modify some properties of the TooltipInteractivityOperation, such as AutoPopDelay and InitialDelay, which control the delays for showing and hiding tooltips.
Related Examples
Windows Forms: Interactivity\Tooltips and Cursors
Web forms: Getting started\HTML image map, Getting started\HTML image map postback
See Also
ChartControl | SeriesInteractivity | Interactivity | HTML Image Map | HTML Image Map with Postback