Overview

A Trackball is used to display information of a given point within the Chart. For example, in a Financial chart the Trackball can display the Open, High, Low and Close value of a stock for a single day. Normally, a Trackball is displayed when the user holds a finger on the plot area of the chart and drags it through the set of datapoints a given series represents. RadCartesianChart supports displaying a trackball via its trackball property.

Getting Started with Trackball

To define a trackball on your RadCartesianChart you need to use the TKCartesianTrackballDirective directive in your chart as shown below:

Example 1: Using the Trackball directive

<Trackball tkCartesianTrackball></Trackball>

Example 2: A Cartesian Chart with a Trackball defined on it:

<RadCartesianChart row="1" tkExampleTitle tkToggleNavButton>
    <DateTimeCategoricalAxis tkCartesianHorizontalAxis dateFormat="yyyy-MM-dd" verticalLocation="Bottom"></DateTimeCategoricalAxis>
    <LinearAxis tkCartesianVerticalAxis></LinearAxis>
    <Trackball tkCartesianTrackball></Trackball>
    <CandlestickSeries tkCartesianSeries categoryProperty="Date" openPropertyName="Open" highPropertyName="High" lowPropertyName="Low" closePropertyName="Close" [items]="candleStickSourceItems"></CandlestickSeries>
</RadCartesianChart>

Depending on your current setup, the trackball will display information about the datapoints within the chart in a different manner. For example, in a RangeBarSeries the trackball will display the range values alongside with the current category value. In a OhlcSeries or CandlestickSeries the trackball will display the Open, High, Low and Close values alongside with the current category value. Here's an example:

Figure 1: Trackball shown in action on iOS and Android

TelerikUI-Chart-Behaviors-TrackballTelerikUI-Chart-Behaviors-Trackball

Features

SnapMode

By using the snapMode property you can control how the trackball is positioned relative to the series and the datapoints within. Possible values are defined by the TrackballSnapMode enum.

Intersection Points

By using the showIntersectionPoints property you can determine whether information about all of the relevant datapoints will be shown in the trackball. This behavior is dependent on the snapMode property setting.

Custom Content

You can customize the content within the trackball by using the trackBallContentRequestedEvent event. This event is fired each time information about a given datapoint is needed for the trackball. The event exposes an instance of the TrackballCustomContentData. This class extends the ChartEventData class and adds two new properties:

  • seriesIndex - the index of the active series with which the user has started interacting
  • content - used to override the default datapoint content. By setting this property you can customize the content within the trackball for the provided data point. You can use the base event data properties to obtain the datapoint index and the business object for which the datapoint has been generated for

References

Want to see this scenario in action?
Check our SDK examples repo on GitHub. You will find this and many other practical examples with NativeScript UI.