Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

Description

The Direction property is used to specify in what direction a Graph will read its data from the Report.

For normal Group/Total report, the Direction, is always Cols.

For Cross-Tab Graphs, use any of the following TCrGraphDirection values:

TCrGraphDirection

Meaning

 

 

Rows

Use only row values in graph.

 

 

Cols

Use only column values in graph.

 

 

RowCol

Graph by row values, then by column values.

 

 

ColRow

Graph by column values, then by row values.

 

 

Unknown

The direction of the graph is unknown.

 

 

Example

The sample code below illustrates the use of the GraphData object to change the Direction in which the Graph will read its data from the Report. In this case, the Report is a Cross Tab Report (which is a requirement in order to change the Direction), and the Graph will read its data from the Rows:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then Crpe1.GraphData[0].Direction := Rows;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphData Item property

Declaration

property Item[const nIndex: integer]: TCrpeGraphData;

VCL Reference

302

Description

The Item property is a default array property. It is read-only, and only available at runtime. Its primary use is to provide an easy way to navigate through the various items stored in the GraphData object, allowing the object to be treated like an array.

Item is a default property, so it does not need to be specified when using the subscript: GraphData[2] is the same as GraphData.Item[2].

Item returns a reference to itself, so the GraphData properties can be used right after the subscript: GraphData[2].SummarizedFieldN := 1;

Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GraphData.Retrieve;

{Set GraphData object to the 2nd graph} Crpe1.GraphData.Item[1];

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GraphData.Retrieve;

{Set GraphData object to the 2nd graph} Crpe1.GraphData[1];

GraphData ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphData item number, or set the GraphData object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox. This Index is updated whenever the Item property is used (GraphData[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.

VCL Reference

303

Example

The following code illustrates the use of the ItemIndex property to make sure the GraphData object is pointing to the first GraphData item:

if Crpe1.GraphData.ItemIndex <> 0 then Crpe1.GraphData[0];

GraphData Number property

Declaration

property Number: TCrGraphDataNumber;

Type

TCrGraphDataNumber = integer;

Description

The Number property specifies the Graph Number.

If the Retrieve method is used to fill the GraphData object with information from the Report, each GraphData item will have a unique Graph Number assigned by the VCL.

If the manual Add method is used instead, a Graph number will have to be specified which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered, Page 37).

The primary use of the Number property is as a look-up to point the GraphData object to the item with the Graph number specified. The default array property, Item, however, provides an easier way to navigate through the object.

Example

The sample code below illustrates the use of the Number property to navigate the GraphData object to the item that specifies the details for Graph number 0 (the first Graph in the Report):

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GraphData.Retrieve;

Crpe1.GraphData.Number := 0;

Crpe1.GraphData.SummarizedFieldN := 2;Crpe1.Execute;

VCL Reference

304

GraphData RowGroupN property

Declaration

property RowGroupN: smallint;

Description

The RowGroupN property specifies which Group number in the report is used to create the values in the Rows of the Graph.

Group numbers start with 1.

Use -1 for default (no change).

Example

The sample code below illustrates the use of the GraphData object to change the Group Field that Rows of the Graph are based on:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GraphData.Retrieve;

if Crpe1.GraphData.Count > 0 then Crpe1.GraphData[0].RowGroupN := 2;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphData Section property

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphData object is currently pointed to. It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property. It should primarily be used as a read-only property after the GraphData information has been retrieved with the Retrieve method. If the manual Add method is used to add items to the GraphData object, then Section will have to be assigned the correct value in code.

VCL Reference

305

Соседние файлы в папке crystal