DataTransformer: IVZDataAdapter;
The DataTransformer property determines data transformer.
Executing the example requires that the repository contains an express report with the EXP identifier. The Size metric should be selected in the bubble tree report. The module containing the example should have links to the Express, Metabase and Visualizators system assemblies. The specified procedure should be called from the Main entry point.
Transform a set of numbers by the custom transformer used to increase the input value as much as 20 times:
// Determine custom data transformer
Class MyAdapter: object, IVZDataAdapter
// Input value is to be increased 20-fold
Function GetData(Value: Variant): Variant;
Begin
Return Value * 20
End Function GetData;
End Class MyAdapter;
Sub UserProc;
Var
Metabase: IMetabase; // Metabase
EaxAnalyzer: IEaxAnalyzer; // Express report
BubbleTree: IVZBubbleTree; // Bubble tree
SizeVisual: IVZNumericVisual; // Visualizator of tree bubbles size
DataSourceMapping: IVZDataSourceMapping; // Settings for data mapping with colors
DataTransformer: IVZDataAdapter; // Data transformer
Begin
// Get metabase object
Metabase := MetabaseClass.Active;
// Open express report
EaxAnalyzer := Metabase.ItemById("EXP").Edit As IEaxAnalyzer;
// Get bubble tree
BubbleTree := EaxAnalyzer.BubbleTree.BubbleTree;
// Get visualizer used to determine tree bubbles size
SizeVisual := BubbleTree.SizeVisual;
// Get settings of data mapping
DataSourceMapping := SizeVisual.NumericMapping;
// Set mapping type "Data transformer"
DataSourceMapping.MappingType := VisualizatorDataMappingType.DataMappingTransformer;
// Create and set custom data transformer
DataTransformer := New MyAdapter.Create;
DataSourceMapping.DataTransformer := DataTransformer;
Debug.WriteLine("Data transformation:");
Debug.IndentLevel := 1;
Debug.WriteLine("Input: -0.05, output: " +
((DataTransformer.GetData(-0.05)) As Double).ToString);
Debug.WriteLine("Input: 0, output: " +
((DataTransformer.GetData(0)) As Double).ToString);
Debug.WriteLine("Input: 0.05, output: " +
((DataTransformer.GetData(0.05)) As Double).ToString);
Debug.WriteLine("Input: 5, output: " +
((DataTransformer.GetData(5)) As Double).ToString);
Debug.WriteLine("Input: 1000, output: " +
((DataTransformer.GetData(1000)) As Double).ToString);
// Set visualizer used to determine tree bubbles size
BubbleTree.SizeVisual := SizeVisual;
End Sub UserProc;
After executing the example, the custom transformer is created used to increase output value as much as 20 times, the development environment console window shows results of number transformation: -0.05, 0, 0.05, 5 and 1000:
Data transformation:
Input: -0.05, ouput: -1
Input: 0, output: 0
Input: 0.05, output: 1
Input: 5, output: 100
Input: 1000, output: 20000
See also: