ComponentOne Chart for .NET (2.0) Search HelpCentral 

Displaying String Values as Annotations

At times, it is very convenient to use string values as annotations along the X or Y axes, and numeric values along the other axis.

For example, suppose a data source contains 2 columns, one with a company name (string), and one with the number of ComponentOne products purchased by that company. To create a bar chart summarizing this data, one might create a series that uses the number of products on the Y axis, and then create an array with counting numbers and use this array for X values. Then, create ValueLabels for the X axis, pairing each company name with a count number, thus producing a chart similar to the following:

Since this situation occurs often, C1Chart accepts ChartDataArray with stringsautomatically enumerates the array values, and creates ValueLabels for the appropriate axis. Using this behavior, it is possible (and very convenient) to set the Data Field properties for a ChartDataSeries to the string values directly and get the same results:

·      Visual Basic

C1Chart1.ChartGroups(0).ChartData.SeriesList(0).X.DataField = "CompanyNames"

C1Chart1.ChartGroups(0).ChartData.SeriesList(0).Y.DataField = "UnitsPurchased"

·      C#

c1Chart1.ChartGroups[0].ChartData.SeriesList[0].X.DataField = "CompanyNames";

c1Chart1.ChartGroups[0].ChartData.SeriesList[0].Y.DataField = "UnitsPurchased";

·      Delphi

c1Chart1.ChartGroups[0].ChartData.SeriesList[0].X.DataField := 'CompanyNames';

c1Chart1.ChartGroups[0].ChartData.SeriesList[0].Y.DataField := 'UnitsPurchased';


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.