IPPSpeedometerSectors.Add

Fore Syntax

Add(Value: IPPSpeedometerSector): Integer;

Fore.NET Syntax

Add(Value: Prognoz.Platform.Interop.Speedometer.PPSpeedometerSector): integer;

Parameters

Value. Added sector.

Description

The Add method adds a sector to the collection.

Fore Example

Executing the example requires that the repository contains a database with the ADHOC identifier. A dashboard must contain a speedometer.

Add links to the Adhoc, Drawing, Express, Metabase, Speedometer system assemblies.

Sub UserProc;
Var
    Speedometer: IPPSpeedometer;
    MB: IMetabase;
    AdhocReport: IAdhocReport;
    EaxSpeedometer: IEaxSpeedometer;
    Enalyzer: IEaxAnalyzer;
    DsObjs: IAdhocDataSourceObjects;
    Scales: IPPSpeedometerScales;
    Scale: IPPSpeedometerScale;
    Sectors: IPPSpeedometerSectors;
    Sector: IPPSpeedometerSector;
    SolidBrush: IGxSolidBrush;
    Color: IGxColor;
Begin
    MB := MetabaseClass.Active;
    // Get dashboard 
    AdhocReport := MB.ItemById("ADHOC").Edit As IAdhocReport;
    // Get dashboard data sources
    DsObjs := AdhocReport.DataSourceObjects;
    // Get speedometer
    Enalyzer := DsObjs.Item(0).GetSourceObject As IEaxAnalyzer;
    EaxSpeedometer := Enalyzer.Speedometer;
    // Get speedometer parameters
    Speedometer := EaxSpeedometer.Speedometer;
    // Get collection of speedometer scales
    Scales := Speedometer.Scales;
    // Get data scale
    Scale := Scales.DataScale;
    // Get collection of scale sectors
    Sectors := Scale.Sectors;
    // Display size of sectors collection
    Debug.WriteLine("Sectors before removal: " + Sectors.Count.ToString);
    // Clear collection of sectors
    Sectors.RemoveAll;
    // Create a new sector
    Sector := New PPSpeedometerSector.Create;
    // Set sector start and end values
    Sector.StartValue := 15000;
    Sector.EndValue := 20000;
    // Set sector start and end width
    Sector.StartSize := 20;
    Sector.EndSize := 60;
    // Determine offset measurement unit  - percents
    Scale.IsAbsoluteSectorOffset := False;
    // Set sector offset
    Sector.Offset := 0.1;
    // Set up sector background fill color
    Sector.EnableBrush := True;
    Color := New GxColor.CreateRGB(0,255,0);
    SolidBrush := New GxSolidBrush.Create(Color);
    Sector.Background := SolidBrush;
    // Add a new sector to collection
    Sectors.Add(Sector);
    (Enalyzer As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the console window displays the size of the sectors collection. The sectors collection is cleared, after which a new sector is created, set up and added to the collection.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.AdHoc;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Speedometer;
Imports Prognoz.Platform.Interop.Drawing;

Public Shared Sub Main(Params: StartParams);
Var
    Speedometer: IPPSpeedometer;
    MB: IMetabase;
    AdhocReport: IAdhocReport;
    EaxSpeedometer: IEaxSpeedometer;
    Enalyzer: IEaxAnalyzer;
    DsObjs: IAdhocDataSourceObjects;
    Scales: IPPSpeedometerScales;
    Scale: PPSpeedometerScale;
    Sectors: IPPSpeedometerSectors;
    Sector: PPSpeedometerSector;
    SolidBrush: GxSolidBrushClass;
    Color: GxColorClass;
    BrushColor: GxColor;
Begin
    MB := Params.Metabase;
    // Get dashboard 
    AdhocReport := MB.ItemById["ADHOC"].Edit() As IAdhocReport;
    // Get dashboard data sources
    DsObjs := AdhocReport.DataSourceObjects;
    // Get speedometer
    Enalyzer := DsObjs.Item[0].GetSourceObject() As IEaxAnalyzer;
    EaxSpeedometer := Enalyzer.Speedometer;
    // Get speedometer parameters
    Speedometer := EaxSpeedometer.Speedometer;
    // Get collection of speedometer scales
    Scales := Speedometer.Scales;
    // Get data scale
    Scale := Scales.DataScale;
    // Get collection of scale sectors
    Sectors := Scale.Sectors;
    // Display size of sectors collection
    System.Diagnostics.Debug.WriteLine("Sectors before removal: " + Sectors.Count.ToString());
    // Clear collection of sectors
    Sectors.RemoveAll();
    // Create a new sector
    Sector := New PPSpeedometerSector.Create();
    // Set sector start and end values
    Sector.StartValue := 15000;
    Sector.EndValue := 20000;
    // Set sector start and end width
    Sector.StartSize := 20;
    Sector.EndSize := 60;
    // Determine offset measurement unit  - percents
    Scale.IsAbsoluteSectorOffset := False;
    // Set sector offset
    Sector.Offset := 0.1;
    // Set up sector background fill color
    Sector.EnableBrush := True;
    Color := New GxColorClassClass();
    BrushColor := Color.FromKnownColor(GxKnownColor.clGreen);
    SolidBrush := New GxSolidBrushClass();
    SolidBrush.Color := BrushColor;
    Sector.Background := SolidBrush;
    // Add a new sector to collection
    Sectors.Add(Sector);
    (Enalyzer As IMetabaseObject).Save();
End Sub;

See also:

IPPSpeedometerSectors

Related work items

Requirement