ComponentOne Chart for .NET (2.0) Search HelpCentral 

Defining the ChartGroup Object

Data in a chart is organized into ChartGroups. Each chart contains two ChartGroups (although most charts will only use the first ChartGroup), each of which is treated as a separate entity. ChartGroups allow more than one chart to be displayed in the ChartArea and provide access to many of the chart-specific properties.

In C1Chart, a chart group is represented by a ChartGroup object. The ChartGroup objects are organized into the ChartGroupsCollection, which is accessed through the ChartGroups object. This collection provides access to the ChartGroups through two methods.

First the individual chart groups can be accessed through the collection. For example, the following code shows how to access individual chart groups through the ChartGroupsCollection object:

·      Visual Basic

C1Chart1.ChartGroups.ChartGroupsCollection(0).ChartType = Chart2DTypeEnum.XYPlot

·      C#

C1Chart1.ChartGroups.ChartGroupsCollection[0].ChartType = Chart2DTypeEnum.XYPlot;

·      Delphi

begin

 C1Chart1.ChartGroups.ChartGroupsCollection[0].ChartType:=Chart2DTypeEnum.XYPlot;

end;

Secondly, the Group0 and Group1 properties of the ChartGroup's object return the associated ChartGroup and allow circumvention of the long collection name by using the following code:

·      Visual Basic

C1Chart1.ChartGroups.Group1.ChartType = Chart2DTypeEnum.XYPlot

·      C#

C1Chart1.ChartGroups.Group1.ChartType = Chart2DTypeEnum.XYPlot;

·      Delphi

C1Chart1.ChartGroups.Group1.ChartType := Chart2DTypeEnum.XYPlot;

The ChartGroupsCollection accepts usual iteration methods as illustrated below:

·      Visual Basic

Dim cg As ChartGroup
For Each cg In C1Chart1.ChartGroups.ChartGroupsCollection

    cg.ChartType = Chart2DTypeEnum.XYPlot

Next

·      C#

ChartGroup cg;

foreach ( cg In C1Chart1.ChartGroups.ChartGroupsCollection )

    cg.ChartType = Chart2DTypeEnum.XYPlot;

·      Delphi

var

  cgs: ChartGroups;

  i:   Integer;

begin

  cgs := C1Chart1.ChartGroups.ChartGroupsCollection;

  for i := 0 to cvs.Count – 1 do

  begin

    cgs[i].ChartType := Chart2DTypeEnum.XYPlot;

  end;

end;


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