Execute: ITsStatisticsTree;
Execute(): Prognoz.Platform.Interop.Transform.ITsStatisticsTree;
The Execute method is used to build a summary statistics tree.
Values, for which summary statistics are calculated, are determined by the ITsStatistics.Values property.
Executing the example requires a form with the following components:
LanerBox with the LanerBox1 identifier.
UiErAnalayzer with the UiErAnalayzer1 identifier, which is a data source for LanerBox1. A workbook of the time series database must be loaded to UiErAnalayzer1.
TreeList with the TreeList1 identifier containing three columns.
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(0) As ILanerCalculateSerie;
If CalcSerie.Transform <> Null Then
Transform := CalcSerie.Transform.Transform As IMsFormulaTransform;
If (Transform <> Null) And (Transform.FormulaCount <> 0) Then
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.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.ForeCollections;
Imports Prognoz.Platform.Interop.Forms;
Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;
Imports Prognoz.Platform.Interop.Tab;
Imports Prognoz.Platform.Interop.Transform;
…
Public 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
treeListNet1.CtrlBox.Nodes.Clear();
treeListNet1.CtrlBox.ShowColumnHeaders := True;
If lanerBoxNet1.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 := lanerBoxNet1.SelectedSeries[0] As ILanerCalculateSerie;
If CalcSerie.Transform <> Null Then
Transform := CalcSerie.Transform.Transform As IMsFormulaTransform;
If (Transform <> Null) And (Transform.FormulaCount <> 0) Then
Formula := Transform.FormulaItem[0];
SummaryStat := Formula.Method.Summary[Transform.CreateCoord(Null)];
Stat.SummaryStatistics := SummaryStat;
End If;
End If;
// Get range of cells selected in uiErAnalyzerNet1
Grid := uiErAnalyzerNet1.ErAnalyzer.ErAnalyzer.Grid;
TabSheet := Grid.TabSheet;
TabSelection := TabSheet.View.Selection;
If TabSelection.Range.IsCell Then
Range := Grid.SpecificRange[EaxRangeType.ertInternal];
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.tstSkew] := False;
Stat.IncludeStatistics[TsStatisticsType.tstKurt] := 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]] As ITreeListNode;
End If;
StatNode := treeListNet1.CtrlBox.Nodes.AddChild(ParentNode, Tree.Name[i]);
If Tree.Type[i] = TsStatisticsTreeNodeType.tstntStatistics Then
StatNode.ColumnText[1] := Tree.Value[i].ToString();
StatNode.ColumnText[2] := Tree.ShortName[i].ToString();
System.Diagnostics.Debug.WriteLine(Tree.StatNode[Tree.Data[i] As TsStatisticsType]);
End If;
HashT[i] := StatNode;
End For;
HashT.Clear();
treeListNet1.CtrlBox.Nodes.TreeControl.InnerRoot.Expand(True);
End Sub UserProc;
See also: