This is a migrated thread and some comments may be shown as answers.

Report with Multiple Charts and a single Datasource

1 Answer 125 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kobus Botha
Top achievements
Rank 1
Kobus Botha asked on 13 Oct 2010, 06:15 AM
Hi,

I have a report with multiple charts but only one sql datasource and uses filtering of the results for each chart.
The sql datasource calls a stored procedure with parameters and returns the results for all charts.
I noticed a performance issue on the report with large datasets and found out that even though I have one datasource the stored procedure is executed on the database for each chart with exactly the same parameters (in the designer and in the silverlight report viewer). 

I have tried to use the needdatasource event of the charts and execute the sql there for the first chart and use the same dataset in the others but that does not seem to work either.
I have placed the code below.

If a stored procedure is used and the parameters of the stored procedure is not changed it would make sense to only execute it once right?

Thanks for the Help,
Kobus

public

 

 

partial class Report1 : Telerik.Reporting.Report

 

 

 

{

 

 

 

DataSet dataSetChart = null;

 

 

 

public SummaryDashboardReport()

 

 

{

 

 

InitializeComponent();

 

 

 

 

}
 

 

 

 

private void char1_NeedDataSource(object sender, EventArgs e)

{

dataSetChart = FillChartDataSet();

(sender 

 

as Telerik.Reporting.Processing.Chart).DataSource = dataSetChart;

 

 

 

}

 

 

 

 

 

private void chart2_NeedDataSource(object sender, EventArgs e)

{

(sender 

 

as Telerik.Reporting.Processing.Chart).DataSource = dataSetChart;

 

 

 

}
}

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 15 Oct 2010, 05:30 PM
Hello Kobus Botha,

Currently the data is being retrieved for every report data item. Thus our suggestion is to create a method with some custom logic that will fill the dataset just once and use the chart's NeedDataSource event to call your method and set the datasource as shown in the following code snippet:

private void chart1_NeedDataSource(object sender, EventArgs e)
{
    ((Telerik.Reporting.Processing.Chart)sender).DataSource = this.getData();
}
  
private void chart2_NeedDataSource(object sender, EventArgs e)
{
    ((Telerik.Reporting.Processing.Chart)sender).DataSource = this.getData();
}
  
private object getData()
{
    if (this.productCatalogDataSet.ProductCatalogDataSetTable.Count == 0)
    {
        this.productCatalogDataSetTableAdapter1.Fill(this.productCatalogDataSet.ProductCatalogDataSetTable);
    }
  
    return this.productCatalogDataSet.ProductCatalogDataSetTable;
}

Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Kobus Botha
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or