Page 1 of 1

Chart on Databand

Posted: Wed Apr 30, 2008 2:48 am
by igor.kersic
Hi,

Sorry to bother, but I have Databand and inside of it I have a chart. I have the situation exactly as in Demo -> "Chart in Databand". I have two tables imported from .xsd, and I add .xml information dynamically to report.
For each row in databand chart is displayed, which is correct, but the question is how do I filter Chart values so that they are filtered by current databand column value. For example I need to this (said in sql) "select [chart.values] from [chart] where [chart.relationcolumn] = [databand.relationcolumn]". In short I need to filter chart displaying based on databand data (in which chart lays).
Please advise, how do I filter chart display based on databand column (again, chart is in databand), do I use some script, on some event of a chart (or databand)?

Thank you very much,
Igor

Chart on Databand

Posted: Thu May 01, 2008 1:14 am
by Edward
In that 'ChartOnDataBand' example Chart uses 'Categories' relation in its DataRelation property.
This relation provides filtering of the Products DataSource each time when the DataBand is rendered.
So filtering of the Products DataSource is made automatically there via 'Categories' relation in the underlying DataSet.
In the Sql version of this report you should reopen Sql-based DataSource for each new line of the DataBand in case if you do not use relations.
Not using relations is very useful when the Sql query can have huge amount of records and retrieving all of them is unnecessary and can take a lot of memory and time.
In this scenario Relations wouldn't used. You must just reconnect the chart's DataSource for each line of the DataBand.
In the BeforePrintEvent of the DataBand just add the following line:

Code: Select all

Products.Connect();
or set for Products DataSource the 'ReconnectOnEachRow' parameter in true.

Please see the attached report. This report was made with using of NWind.mdb file which is a MS Access database and it is included in Stimulsoft Reports.Net delivery. This file you can find in the following location, if the installation was made with default settings:

C:\Program Files\Stimulsoft Reports.Net 2008.1 Trial\.Net 2.0\Bin\Data\ or
C:\Program Files\Stimulsoft Reports.Net 2008.1\.Net 2.0\Bin\Data\

Also in the Sql based DataSource was defined a parameter, which allows filtering of the query when Sql command is called.

Thank you.

Chart on Databand

Posted: Mon May 05, 2008 4:24 am
by igor.kersic
Hi Edward,

Thank you for reply. I've set correctly (same as in ChartOnDataBand) relation and two tables and loaded predefined .xml. What happens is that :
1. Report creates correctly as many graphs as there is data in underlaying data band (exactly like in ChartOnDataBand -> it creates as many product charts as many categories)
2. The problem is that graphs are not filtered by particular underlaying column value, which means it shows every graph the same, for all underlaying data! (this comparing to ChartOnDatabind example would be as showing same graph (for every category) times(multiplied by) number of categories (so repeating the same graph).

Please advise, do you maybe know why 2. is happening. Chart is multiplied, but chart data is not filtered by underlaying databand (although the datarelation exists)?

Thank you very much for your patience,
Best regards,
Igor

Chart on Databand

Posted: Mon May 05, 2008 4:31 am
by Edward
In case if you have a DataRelation for your data, please set appropriate property of the Chart:

Chart1.DataRelation.

Thank you.

Chart on Databand

Posted: Mon May 05, 2008 7:40 am
by igor.kersic
Hi Edward,

It works after setting DataRelation property! Great!

Again, thanks for all answers, it helped so much!

Igor

Chart on Databand

Posted: Mon May 05, 2008 7:45 am
by Edward
You are welcome.

Please let us know if any help is required.

Thank you.