Categorical Charts

With this feature, the enabled X axis can be used to plot not only values (e.g. number of sales, etc.), but also categories (e.g. months of the year, units, people, etc.). Using a Category axis, the Silverlight Chart treats data as a sequence of non-numerical text labels. The marker is placed according to the position of the category in the sequence. Data is provided per category.   Silverlight RadChart Categorical Chart

As you can see from the image above, RadChart automatically set X-Axis labels to the categories they represent and each numeric value is shown in the corresponding category. Note that the numeric values are from two data series and they share the same category.

To create categorical charts, you have to map the category values to the XCategory property of the DataPoint.

The only difference between categorical charts and a normal chart is the way the data is bound. Categorical charts use XCategory data point member while the other charts use XValue.

<telerik:DataPoint XCategory="Apples" YValue="41" /> 
<telerik:DataPoint XCategory="Oranges" YValue="33" /> 
<telerik:DataPoint XCategory="Grapes" YValue="25" /> 

DataSeries dataSeries = new DataSeries(); 
dataSeries.Definition = new BarSeriesDefinition(); 
dataSeries.Add( new DataPoint() { YValue = 41, XCategory = "Apples" } ); 
dataSeries.Add( new DataPoint() { YValue = 33, XCategory = "Oranges" } ); 
dataSeries.Add( new DataPoint() { YValue = 25, XCategory = "Grapes" } ); 
radChart.DefaultView.ChartArea.DataSeries.Add( dataSeries ); 
Dim dataSeries As New DataSeries() 
dataSeries.Definition = New BarSeriesDefinition() 
Dim dataPoint As New DataPoint() 
dataPoint.YValue = 41 
dataPoint.XCategory = "Apples" 
dataPoint = New DataPoint() 
dataPoint.YValue = 33 
dataPoint.XCategory = "Oranges" 
dataPoint = New DataPoint() 
dataPoint.YValue = 25 
dataPoint.XCategory = "Grapes" 

If you want to use data binding, then you have to set the DataPointMember to XCategory instead of XValue.

SeriesMapping seriesMapping = new SeriesMapping(); 
seriesMapping.SeriesDefinition = new BarSeriesDefinition(); 
ItemMapping itemMapping = new ItemMapping(); 
itemMapping.DataPointMember = DataPointMember.XCategory; 
itemMapping.FieldName = "Fruit"; 
itemMapping = new ItemMapping(); 
itemMapping.DataPointMember = DataPointMember.YValue; 
itemMapping.FieldName = "Orders"; 
Dim seriesMapping As New SeriesMapping() 
seriesMapping.SeriesDefinition = New BarSeriesDefinition() 
Dim itemMapping As New ItemMapping() 
itemMapping.DataPointMember = DataPointMember.XCategory 
itemMapping.FieldName = "Fruit" 
itemMapping = New ItemMapping() 
itemMapping.DataPointMember = DataPointMember.YValue 
itemMapping.FieldName = "Orders" 

If you are looking for more data binding options take a look at the Populating with Data Overview topic.

See Also

In this article