Consider an example of adding a chart with the data slice added before as a data source to a regular report sheet.
Executing the example requires that the repository contains a regular report with the REPORT_INTRO identifier and a standard cube with the CUBE_SEP identifier used as a data source of the report. A slice with the Slice identifier is determined for data source of regular report.
To execute the example, add links to the Metabase, Report, Tab, Chart, Drawing system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
Tab: ITabSheet;
Chart: IPrxChart;
ClassId: String;
Placement: IGxRectF;
Source: IPrxDataSource;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("REPORT_INTRO").Edit;
Report := MObj As IPrxReport;
Tab := (Report.ActiveSheet As IPrxTable).TabSheet;
ClassId:="PrxChart";
Placement:=New GxRectF.Create(50,50,200,200);
Chart := (Tab.Objects.Add(ClassId,Placement)) As IPrxChart;
Chart.SourceType := PrxChartSourceType.Slice;
Source := Report.DataSources.FindById("CUBE_SEP");
Chart.Slice := Source.Slices.FindByName("Slice");
(Chart As IChart).Type := ChartType.Circles;
MObj.Save;
End Sub UserProc;
After executing the example a chart with the slice of the specified data source as the data source will be added to the regular report sheet. Location on the sheet and the Pie Chart type are set for the chart.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;
Imports Prognoz.Platform.Interop.Chart;
Imports Prognoz.Platform.Interop.Drawing;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
Tab: ITabSheet;
Chart: IPrxChart;
ClassId: String;
Placement: GxRectF = New GxRectFClass();
Source: IPrxDataSource;
Begin
MB := Params.Metabase;
MObj := MB.ItemById["REPORT_INTRO"].Edit();
Report := MObj As IPrxReport;
Tab := (Report.ActiveSheet As IPrxTable).TabSheet;
ClassId:="PrxChart";
Placement.Create(50,50,200,200);
Chart := (Tab.Objects.Add(ClassId,Placement)) As IPrxChart;
Chart.SourceType := PrxChartSourceType.pcstSlice;
Source := Report.DataSources.FindById("CUBE_SEP");
Chart.Slice := Source.Slices.FindByName("Slice");
(Chart As IChart).Type := ChartType.chtCircles;
MObj.Save();
End Sub;
See also: