Setting Up Several Calculated Statistics

Fore Example

Executing the example requires a form containing the following components:

Add links to the following system assemblies:

The example handles the OnClick event for the Button1 component:

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    EaxStat: IEaxStatistics;
    Tree: ITsStatisticsTree;
    i: integer;
    Nodes: ITreeListNodes;
    StatNode, ParentNode: ITreeListNode;
    HashT: IHashtable;
    Wbk: IEaxWorkbook;
Begin
    EaxStat := UiErAnalyzer1.ErAnalyzer.Statistics;
    Wbk := UiErAnalyzer1.ErAnalyzer As IEaxWorkbook;
    Wbk.Statistics.Visible := True;
    Wbk.Statistics.Enabled := True;
    // Exclude part of statistics from tree creation
    EaxStat.StatisticsVisible(TsStatisticsType.Max) := False;
    EaxStat.StatisticsVisible(TsStatisticsType.Min) := False;
    EaxStat.StatisticsVisible(TsStatisticsType.Average) := False;
    // Get statistics
    Tree := EaxStat.AllStatistics;
    // Clear the component to display statistics tree
    Nodes := TreeList1.Nodes;
    Nodes.Clear;
    // Build the tree
    If Tree = Null Then
        Return;
    End If;
    HashT := New Hashtable.Create;
    For i := 0 To Tree.Count - 1 Do
        ParentNode := Null;
        If Tree.ParentNode(i) <> -1 Then
            ParentNode := HashT(Tree.ParentNode(i));
        End If;
        StatNode := Nodes.AddChild(ParentNode, Tree.Name(i));
        If Tree.Type(i) <> TsStatisticsTreeNodeType.Category Then
            StatNode.ColumnText(1) := Tree.Value(i);
        End If;
        StatNode.Data := i;
        HashT(i) := StatNode;
    End For;
    HashT.Clear;
    Nodes.TreeControl.InnerRoot.Expand(True);
End Sub Button1OnClick;

After executing the example on clicking the button the statistics tree is built for the workbook table. The tree does not display the Minimum, Maximum and Average values.

Fore.NET Example

Executing this example requires a form containing the following components:

Example is a handler of the Click event for the button1 component.

Imports Prognoz.Platform.Interop.ForeCollections;
Imports Prognoz.Platform.Interop.Transform;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Forms;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    EaxStat: IEaxStatistics;
    Tree: ITsStatisticsTree;
    i: integer;
    Nodes: ITreeListNodes;
    StatNode, ParentNode: ITreeListNode;
    HashT: IHashtable;
    Wbk: IEaxWorkbook;
Begin
    EaxStat := UiErAnalyzer1.ErAnalyzer.Statistics;
    Wbk := UiErAnalyzer1.ErAnalyzer As IEaxWorkbook;
    Wbk.Statistics.Visible := True;
    Wbk.Statistics.Enabled := True;
    // Exclude part of statistics from tree creation
    EaxStat.StatisticsVisible[TsStatisticsType.tstMax] := False;
    EaxStat.StatisticsVisible[TsStatisticsType.tstMin] := False;
    EaxStat.StatisticsVisible[TsStatisticsType.tstAverage] := False;
    // Get statistics
    Tree := EaxStat.AllStatistics;
    // Clear the component to display statistics tree
    Nodes := treeListNet1.CtrlBox.Nodes;
    Nodes.Clear();
    // Build the tree
    If Tree = Null Then
        Return;
    End If;
    HashT := New Hashtable.Create();
    For i := 0 To Tree.Count - 1 Do
        ParentNode := Null;
        If Tree.ParentNode[i] <> -1 Then
            ParentNode := HashT[Tree.ParentNode[i]] As ITreeListNode;
        End If;
        StatNode := Nodes.AddChild(ParentNode, Tree.Name[i]);
        If Tree.Type[i] <> TsStatisticsTreeNodeType.tstntCategory Then
            StatNode.ColumnText[1] := Tree.Value[i].ToString();
        End If;
        StatNode.Data := i;
        HashT[i] := StatNode;
    End For;
    HashT.Clear();
    Nodes.TreeControl.InnerRoot.Expand(True);
End Sub;

The result of example execution matches with that of the Fore example.

See also:

Examples | ILaner