Add(Value: IVZLegendBase): Integer;
Add(Value: IVZLegendBase): integer;
Value. Legend added to collection.
The Add method adds the selected legend to visualizer legend collection.
This method returns index of the legend added to the collection.
To display the legend in visualizer, it is necessary to specify values for its properties. For example, the following properties are required for a color legend:
Executing the example requires that the repository contains an express report with the EXP identifier. The module containing the example should have links to the Drawing, Express, Metabase and Visualizators system assemblies. This procedure should be called from the Main entry point.
Before executing this example, the bubble tree looks as shown on the IVZBubbleTree interface description page. Then create a legend with intervals, that does not reduce bubble tree workspace. Select values of appropriate properties of color legend for all required properties of bubble tree workspace, set title and footer. Then add the legend to the bubble chart:
Sub UserProc;
Var
Metabase: IMetabase; // Metabase
Analyzer: IEaxAnalyzer; // Express report
BubbleTree: IVZBubbleTree; // Bubble tree
ColorLegend: IVZColorLegendBase; // Color legend
IntervalsLegend: IVZIntervalsLegend; // Legend with intervals
Begin
// Get metabase object
Metabase := MetabaseClass.Active;
// Get express report object
Analyzer := Metabase.ItemById("EXP").Edit As IEaxAnalyzer;
// Get bubble tree
BubbleTree := Analyzer.BubbleTree.BubbleTree;
// Get color legend of bubble tree
ColorLegend := BubbleTree.Legends.Item(0) As IVZColorLegendBase;
// Create new legend
IntervalsLegend := New VZIntervalsLegend.Create;
// Set color scale
IntervalsLegend.Scale := ColorLegend.Scale;
// Set formats of labels for scale intervals
IntervalsLegend.BetweenFormat := ColorLegend.BetweenFormat;
IntervalsLegend.GreaterFormat := ColorLegend.GreaterFormat;
IntervalsLegend.LessFormat := ColorLegend.LessFormat;
// Specify legend style
IntervalsLegend.Style := ColorLegend.Style;
// Select style for the no data bubble
IntervalsLegend.NoDataText := ColorLegend.NoDataText;
// Set legend title
IntervalsLegend.Header := ColorLegend.Header;
IntervalsLegend.Header.Text := "Title";
// Set legend footer
IntervalsLegend.Footer := ColorLegend.Header;
IntervalsLegend.Footer.Text := "Footer";
IntervalsLegend.Footer.Style.Alignment := GxStringAlignment.Near;
// Legend does not reduce bubble tree area
IntervalsLegend.IsOverlap := True;
// Add the legend to bubble chart
BubbleTree.Legends.Add(IntervalsLegend);
Debug.WriteLine("Total number of legends: " + BubbleTree.Legends.Count.ToString);
// Save changes, made in express report
(Analyzer As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, the legend with intervals is created that does not reduce bubble tree workspace. The values of appropriate properties of color legend for all required properties of the bubble tree workspace are selected, legend title and footer are set as well. Then the legend is added to the bubble chart:
The development environment console window shows total number of legends in the bubble tree:
Total number of legends: 2
Executing the example requires that the repository contains an express report with the EXP identifier. The selected procedure is the Main entry point in the Program module of the .NET assembly. The Express, Metabase and Visualizators assemblies should be imported to this module from the Prognoz.Platform.Interop system assembly.
Before executing this example, the bubble tree looks as shown on the IVZBubbleTree interface description page. Then create a legend with intervals, that does not reduce bubble tree workspace. Select values of appropriate properties of color legend for all required properties of bubble tree workspace, set title and footer. Then add the legend to the bubble chart:
Public Shared Sub Main(Params: StartParams);
Var
Metabase: IMetabase; // Metabase
Analyzer: IEaxAnalyzer; // Express report
BubbleTree: IVZBubbleTree; // Bubble tree
ColorLegend: IVZColorLegendBase; // Color legend
IntervalsLegend: IVZIntervalsLegend; // Legend with intervals
Begin
// Get metabase object
Metabase := Params.Metabase;
// Get express report object
Analyzer := Metabase.ItemById["EXP"].Edit() As IEaxAnalyzer;
// Get bubble tree
BubbleTree := Analyzer.BubbleTree.BubbleTree;
// Get color legend of bubble tree
ColorLegend := BubbleTree.Legends.Item[0] As IVZColorLegendBase;
// Create new legend
IntervalsLegend := New VZIntervalsLegend();
// Set color scale
IntervalsLegend.Scale := ColorLegend.Scale;
// Set formats of labels for scale intervals
IntervalsLegend.BetweenFormat := ColorLegend.BetweenFormat;
IntervalsLegend.GreaterFormat := ColorLegend.GreaterFormat;
IntervalsLegend.LessFormat := ColorLegend.LessFormat;
// Specify legend style
IntervalsLegend.Style := ColorLegend.Style;
// Select style for the no data bubble
IntervalsLegend.NoDataText := ColorLegend.NoDataText;
// Set legend title
IntervalsLegend.Header := ColorLegend.Header;
IntervalsLegend.Header.Text := "Title";
// Create legend footer
IntervalsLegend.Footer:= ColorLegend.Header;
IntervalsLegend.Footer.Text := "Footer";
IntervalsLegend.Footer.Style.Alignment := GxStringAlignment.gsaNear;
// Legend does not reduce bubble tree area
IntervalsLegend.IsOverlap := True;
// Add the legend to bubble chart
BubbleTree.Legends.Add(IntervalsLegend);
System.Diagnostics.Debug.WriteLine("Total number of legends: " +
BubbleTree.Legends.Count.ToString());
// Save changes, made in express report
(Analyzer As IMetabaseObject).Save();
End Sub;
The result of the executed example is the same as that, executed for Fore language.
See also: