ITsStatistics.Execute

Syntax

Execute: ITsStatisticsTree;

Description

The Execute method is used to build a summary statistics tree.

Comments

Values, for which summary statistics are calculated, are determined by the ITsStatistics.Values property.

Example

Executing the example requires a form with the following components:

Add links to the Collection, Cubes, Ms, Stat, Transform system assemblies.

Sub UserProc;
Var
    Stat: ITsStatistics;
    CalcSerie: ILanerCalculateSerie;
    Transform: IMsFormulaTransform;
    Formula: IMsFormula;
    SummaryStat: ISummaryStatistics;
    TabSheet: ITabSheet;
    TabSelection: ITabSelection;
    Range: ITabRange;
    i, j: integer;
    Arr: IArrayList;
    Tree: ITsStatisticsTree;
    StatNode, ParentNode: ITreeListNode;
    HashT: IHashtable;
    Grid:IEaxGrid;
Begin
    // Clear component to display statistics tree
    TreeList1.Nodes.Clear;
    TreeList1.ShowColumnHeaders := True;
    If LanerBox1.SelectedSeriesCount = 0 Then
        Return;
    End If;
    // Create a class to build a statistics tree
    Stat := New TsStatistics.Create;
    // Send summary statistics to build a tree
    CalcSerie := LanerBox1.SelectedSeries(0As ILanerCalculateSerie;
    If CalcSerie.Transform <> Null Then
        Transform := CalcSerie.Transform.Transform As IMsFormulaTransform;
        If (Transform <> NullAnd (Transform.FormulaCount <> 0Then
            Formula := Transform.FormulaItem(0);
            SummaryStat := Formula.Method.Summary(Transform.CreateCoord(Null));
            Stat.SummaryStatistics := SummaryStat;
        End If;
    End If;
    // Get a range of cells selected in LanerBox
    Grid := UiErAnalyzer1.ErAnalyzer.Grid;
    TabSheet := Grid.TabSheet;
    TabSelection := TabSheet.View.Selection;
    If TabSelection.Range.IsCell Then
        Range := Grid.SpecificRange(EaxRangeType.Internal);
    Else
        Range := TabSelection.Range;
    End If;
    // Get values in selected range
    Arr := New ArrayList.Create;
    For i := Range.Left To Range.Right Do
        For j := Range.Top To Range.Bottom Do
            Arr.Add(TabSheet.CellValue(j, i));
        End For;
    End For;
    // Send values to build a tree
    Stat.Values := Arr.ToArray;
    // Exclude a part of statistics from tree building
    Stat.IncludeStatistics(TsStatisticsType.Skew) := False;
    Stat.IncludeStatistics(TsStatisticsType.Kurt) := False;
    // Include only calculated statistics to tree building
    Stat.CalculatedOnly := True;
    // Build a tree
    Tree := Stat.Execute;
    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 := TreeList1.Nodes.AddChild(ParentNode, Tree.Name(i));
        If Tree.Type(i) = TsStatisticsTreeNodeType.Statistics Then
            StatNode.ColumnText(1) := Tree.Value(i);
            StatNode.ColumnText(2) := Tree.ShortName(i);
            Debug.WriteLine(Tree.StatNode(Tree.Data(i) As TsStatisticsType));
        End If;
        HashT(i) := StatNode;
    End For;
    HashT.Clear;
    TreeList1.Nodes.TreeControl.InnerRoot.Expand(True);
End Sub UserProc;

After executing the example the tree of summary statistics calculated for data range selected in LanerBox1 is displayed in TreeList1. Calculated characteristics indexes are displayed in the console window.

See also:

ITsStatistics