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

Example

The following code illustrates the use of the GraphOptions Legend property:

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

if Crpe1.GraphOptions.Count > 0 then Crpe1.GraphOptions[0].Legend := cTrue;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphOptions Max property

Declaration

property Max: double;

Description

The Max property specifies the maximum value that will appear in the graph. Any Graph values above this value are not charted.

Example

The following code illustrates the use of the GraphOptions Max property:

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

if Crpe1.GraphOptions.Count > 0 then Crpe1.GraphOptions[0].Max := 144000;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphOptions Min property

Declaration

property Min: double;

Description

The Min property specifies the minimum value that will appear in the Graph. Any Graph values below this value are not charted.

VCL Reference

318

Example

The following code illustrates the use of the GraphOptions Min property:

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

if Crpe1.GraphOptions.Count > 0 then Crpe1.GraphOptions[0].Min := 40;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphOptions Number property

Declaration

property Number: TCrGraphOptionsNumber;

Type

TCrGraphOptionsNumber = integer;

Description

The Number property specifies the Graph Number.

If the Retrieve method is used to fill the GraphOptions object with information from the Report, each GraphOptions 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 GraphOptions 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 following code illustrates the use of the Number property to navigate the GraphOptions object to the specific item that has a Number value of 1:

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

{Set GraphOptions to item with Number value of 1} Crpe1.GraphOptions.Number = 1; Crpe1.GraphOptions.BarDirection := bdHorizontal; Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

319

GraphOptions Section property

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphOptions 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 GraphOptions information has been retrieved with the Retrieve method. If the manual Add method is used to add items to the GraphOptions object, then Section will have to be assigned the correct value in code.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH

Report Header

 

 

PH

Page Header

GH

Group Header

 

 

D

Details

 

 

GF

Group Footer

 

 

PF

Page Footer

RF

Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections. Numbers are used to designate different Groups: GH1, GF2, etc. See About Section Names, Volume 1, Chapter 7 for more details on the syntax.

Example

In the following example, the Section property is used to apply changes only to Graphs which exist in a given Report Section (Page Header in this case):

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

for cnt := 0 to (Crpe1.GraphOptions.Count - 1) do begin

if Crpe1.GraphOptions[cnt].Section = 'PH' then Crpe1.GraphOptions[cnt].BarDirection := bdHorizontal;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

VCL Reference

320

GraphOptions SectionAsCode property

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers. Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names, Volume 1, Chapter 7.

Example

The following example uses the SectionAsCode property to apply conditional changes to Graphs. In this case, there is a Graph in each of three Group Header sections (GH1a, GH2a, GH3a). Since the Section Code for GH1a is 3000, GH2a is 3001, and GH3a is 3002, it is possible to do a simple mathematical calculation on the remainder of the Section Code divided by 1000 to change the options of the Graph only if it is not in GH1:

var

cnt: integer; begin

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

for cnt := 0 to (Crpe1.GraphOptions.Count - 1) do begin

{if the remainder of the SectionCode divided by 1000 is greater than zero, then apply the change}

if (Crpe1.GraphOptions[cnt].SectionAsCode mod 1000 > 0) then Crpe1.GraphOptions[cnt].GridLines := cTrue;

end; end;

GraphOptions Methods

GraphOptions Add method

Declaration

procedure Add(GraphNumber: TCrGraphOptionsNumber);

VCL Reference

321

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