New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Data Navigation

This help article describes the Data Navigation functionality (added in the Q1 2014 release), that lets you zoom and scroll data over time in the ASP.NET AJAX Chart and provides an example on how to configure it in Example 1.

Overview of RadHtmlChart Data Navigation Feature

The Data Navigation functionality added as the Stock layout of a RadHtmlChart allows users to visualize data over time with the ability to zoom and scroll certain periods. As you can see in Figure 1, there aretwo main areas: the main chart (in the yellow box) and the navigator pane area (in the green box). The supported series types you can use in the main chart area and in the navigator include:

Data Navigation Element Structure

The Stock chart layout consists of two parts:

  • Main chart - Data from the selected time period is plotted in the main chart. A user can drag the plot area of the main chart to either side (left or right) in order to scroll to preceding or subsequent time intervals.While dragging, a tooltip in the upper part of the main chart called the Selection Hint shows the selected time interval.

  • Navigator pane - Located below the main chart, the navigator pane is a view that shows the trend of the full data. Users can use the navigator pane to select a desired time period through the Range Selector element. Users can drag the whole Range Selector element to the left or right side in order to scroll over the full data to a preceding or subsequent time frame.A user can also click and drag the left or right sides of the Range Selector to expand or collapse it from either side, which lets the user to zoom in/out the selected time interval.With each change of the selected range, the corresponding data will be plotted dynamically on the main chart (see Figure 1).

Figure 1: The visual elements in a stock chart layout.

htmlchart-stockchart-simple-example

An Example of Configuring a Stock Chart Layout with Data Navigation

The setup of a Stock chart layout with a Data Navigation requires that you:

  • Configure a main chart:

    1. Instantiate a RadHtmlChart object and set its Layout property to "Stock".

    2. Bind the chart to a data source that contains a DateTime field for the x-axis and use a numeric field for the y-axis.

    3. Create a supported series type and configure it to load data for the y-axis throughthe corresponding properties (i.e., DataFieldY for Area, Column and Line series and DataOpenField, DataHighField, DataLowField, DataCloseField for Candlestick series).

    4. Set the DataLabelsField property of the x-axis to the name of the DateTime field of the data source in order to distribute dates over the x-axis. You must either set the Type property of the x-axis to Date or don't set it ( i.e., Type="Date" is the default value when you pass DateTime values to the x-axis).

    5. The format strings of the dates over the x-axis can be controlled for each BaseUnit (the x-axis' BaseUnit property of the main chart is automatically changed according to the Navigator pane's RangeSelector) through the XAxis.LabelsAppearance.DateFormats property which takes:

      • SecondsFormat
      • MinutesFormat
      • HoursFormat
      • DaysFormat
      • WeeksFormat
      • MonthsFormat
      • YearsFormat

    You can find the list with the standard and custom format strings that can be used in Format Dates help article.

  • Configure the Navigator pane:

    1. Add the Navigator tag in the chart.
    2. Create a supported series type in the Navigator and set its DataFieldY property to afield name of the data source used to load the data.
    3. Fine tune the Navigator (e.g., modify the appearance of the XAxis, choose a range for the RangeSelector, set a DataFormatString for the Selection Hint, etc.).

Example 1 shows how to create the chart shown in Figure 1.

Example 1: The code that creates a RadHtmlChart with a Data Navigation functionality, shown in Figure 1.

ASP.NET
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Layout="Stock" Width="800" Height="500" Skin="Default">
	<Navigator Visible="true">
		<RangeSelector From="2008/05/01" To="2009/09/01" />
		<SelectionHint Visible="true" DataFormatString="From {0:d} to {1:d}" />
		<Series>
			<telerik:AreaSeries DataFieldY="DisneyClose">
			</telerik:AreaSeries>
		</Series>
		<XAxis Color="#aaaaaa">
			<LabelsAppearance>
				<TextStyle Color="#666666" />
			</LabelsAppearance>
		</XAxis>
	</Navigator>
	<PlotArea>
		<Series>
			<telerik:CandlestickSeries Name="Disney" DataOpenField="DisneyOpen" DataHighField="DisneyHigh" DataLowField="DisneyLow" DataCloseField="DisneyClose">
			</telerik:CandlestickSeries>
		</Series>
		<XAxis DataLabelsField="DisneyDate" Type="Date">
			<MajorGridLines Visible="false"></MajorGridLines>
			<MinorGridLines Visible="false"></MinorGridLines>
			<TitleAppearance Text="Date">
			</TitleAppearance>
		</XAxis>
		<YAxis>
			<LabelsAppearance DataFormatString="{0:C}">
			</LabelsAppearance>
			<MajorGridLines Visible="true" Color="#efefef" Width="1"></MajorGridLines>
			<MinorGridLines Visible="false"></MinorGridLines>
			<TitleAppearance Text="Price">
			</TitleAppearance>
		</YAxis>
	</PlotArea>
	<ChartTitle Text="The Walt Disney Company (DIS)">
	</ChartTitle>
</telerik:RadHtmlChart>

See Also