Dundas Chart for Windows Forms
Indexing Data Point X Values
See Also Send comments on this topic.
Working with Data > Indexing Data Point X Values



Glossary Item Box

Overview

Each data point in a series has X and Y values that determine its position in the plotting area. With some charts, the X value of points is not important, and does not have to be provided. In this case, the point positions in the plotting area are determined only by their point index (i.e. their location in the Points collection) and their Y values.

When X values are "indexed", the data point index, not a point's X value, is used to determine the position of points along the categorical (X) axis. For example in Figure 1 below, two charts are shown displaying the same data. However, the first chart uses non-indexed X values, therefore the X values of those points determine their location along the x-axis. The second chart is indexed, therefore its point indices are used to determine their position along the x-axis. In this case the X values are only used for the axis labels, and nothing more.

 

Figure 1: Two charts, one with non-indexed x-values (shown left), and the other with indexed x-values (shown right).

 

How to Index X Values

There are several ways to index data point X values :

 

Example

This example demonstrates how to display data using data point indexes. This code was used to generate the chart in Figure 1 above. The chart to the right has one extra line of code that sets the XValueIndexed property of the series to true.

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
...
  
' Create new series and add data.
mySeries = New Series("MySeries")

' Add points
mySeries.Points.AddXY(1, 12)
mySeries.Points.AddXY(2, 15)
mySeries.Points.AddXY(3, 19)
mySeries.Points.AddXY(4, 21)
mySeries.Points.AddXY(6, 22)
mySeries.Points.AddXY(7, 20)
mySeries.Points.AddXY(8, 16)
mySeries.Points.AddXY(9, 20)
mySeries.Points.AddXY(11, 19)

' Use point indexes instead of X values.
mySeries.XValueIndexed = True

' Add series into the series collection.
Chart1.Series.Add(mySeries)

C# Copy Code
using Dundas.Charting.WinControl;
...
  
// Create new series and add data.
Series mySeries = new Series("MySeries");

// Add points
mySeries.Points.AddXY(1,12);
mySeries.Points.AddXY(2,15);
mySeries.Points.AddXY(3,19);
mySeries.Points.AddXY(4,21);
mySeries.Points.AddXY(6,22);
mySeries.Points.AddXY(7,20);
mySeries.Points.AddXY(8,16);
mySeries.Points.AddXY(9,20);
mySeries.Points.AddXY(11,19);

// Use point indexes instead of X values.
mySeries.XValueIndexed = true;

// Add series into the series collection.
Chart1.Series.Add(mySeries);

See Also

©2009. All Rights Reserved.