[Resolved] Concrete example of Chart Bound to DataSource.

Stimulsoft Reports.WEB discussion
Post Reply
mvines
Posts: 35
Joined: Wed Aug 05, 2009 2:55 pm

[Resolved] Concrete example of Chart Bound to DataSource.

Post by mvines »

I've been playing with your 'Chart on Databand' example report to try to figure out exactly how charting works with your web designer control. I have had some success when the datasource contains a column that has the value I want to associate to a name, similar to the 'Chart on Databand' report. What I am having no luck with is a calculated value associated to a name. For example, I am trying to convert the chart to instead show the number of products in each category.

I assumed I would need to set the

Code: Select all

Argument Data Column = Products.CategoriesProducts.CategoryName
and the

Code: Select all

Value = {Count(Products.ProductID)}
However, when previewing the report I recieve the following error.

Code: Select all

\Temp\0oyamqzi.0.cs(63,32) : error CS0103: The name 'Count' does not exist in the current context
Could you please provide me with a simple walk through on how to create this chart using the existing 'Chart on Databand' example report.

Thanks for your time,
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

[Resolved] Concrete example of Chart Bound to DataSource.

Post by Edward »

Hi,

Please change

{Count(Products.ProductID)}

as follows:

{Count()}

Thank you.
mvines
Posts: 35
Joined: Wed Aug 05, 2009 2:55 pm

[Resolved] Concrete example of Chart Bound to DataSource.

Post by mvines »

Thanks for responding Edward.

Unfortunately this causes the exact same compilation error to occur.

Code: Select all

\Temp\0oyamqzi.0.cs(63,32) : error CS0103: The name 'Count' does not exist in the current context
What I would really like is for someone familiar with how charting works to open up the Demo report 'Chart on Databand' and convert it to show the Count of Products per Category, and then just let me know step by step what they had to do to accomplish it. Hopefully it only takes a few seconds start to finish, I know I can fail at it in about 20 seconds.

Thanks again for taking the time to respond, it is appreciated
mvines
Posts: 35
Joined: Wed Aug 05, 2009 2:55 pm

[Resolved] Concrete example of Chart Bound to DataSource.

Post by mvines »

To add what I hope is more useful information, the line of code that is failing in the report is:

Code: Select all

public void Item24__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e)
        {
            e.Value = ToString(Count());
        }
With the following namespaces referenced

Code: Select all

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using Stimulsoft.Controls;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Report;
using Stimulsoft.Report.ReportControls;
using Stimulsoft.Report.Components;
What Namespace is Count in?
mvines
Posts: 35
Joined: Wed Aug 05, 2009 2:55 pm

[Resolved] Concrete example of Chart Bound to DataSource.

Post by mvines »

I think I may be arriving at the source of the issue. I believe it is a bug in the charting code generator.

When I open the demo report 'Groups with Ranges' I see that it uses the Count function in its footer section. Browsing the generated source code reveals the following lines of code:

Code: Select all

public void Text9__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e)
        {
            e.Value = "#%#Count: {Count()}";
            e.StoreToPrinted = true;
        }
Noting that in this functioning example "{Count()}" is a string value which I assume is parsed and interpreted by some engine farther down the line. I think that when the chart code generator creates the following code:

Code: Select all

public void Item24__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e)
        {
            e.Value = ToString(Count());
        }
It is in error, and should be producing something like:

Code: Select all

public void Item24__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e)
        {
            e.Value = "#%#{Count()}";
        }
I'm taking a stab in the dark, but I can not explain the behavior I am seeing any other way.

Thanks again for your time,

Matt

Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

[Resolved] Concrete example of Chart Bound to DataSource.

Post by Edward »

Hi Matt,

Yes, you are right, with help of just Count function no way to resolve the task.

But there is a workaround using Totals.Sum function. Please see attached sample project. Report Title in this project contains all necessary hints about all required steps for its design.

StiWebDesignerChartOnDataBand.zip

Thank you.
mvines
Posts: 35
Joined: Wed Aug 05, 2009 2:55 pm

[Resolved] Concrete example of Chart Bound to DataSource.

Post by mvines »

Thanks Edward, that definitely got me on the right track.

Your project was close, but not quite what I needed. I was looking to have all of that information on the same chart. So all I had to do to your project to get that to happen was.

1. Move the chart out of the databand.
2. Delete the databand.
3. Set the charts DataSource to Categories.

I noticed that Categories.CategoryName can be set to either Argument Data Column, or Argument, and the chart still comes out as expected.
I also noticed that Chart.CountData can be set to any value, and it does not have an effect on this particular chart. I still don't understand what CountData does. If you could fill me in I would appreciate it.
Lastly, I noticed that If I entered into the Value field {Totals.Count(Products.ProductID)} I did not receive a Report Compilation error. This did not result in the correct chart either, but it did compile.

So, it will be really difficult to train my users, but at least it is possible, thanks for all your input.

Is the issue with Count actually a bug? And do you think it will be resolved in the next release?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

[Resolved] Concrete example of Chart Bound to DataSource.

Post by Edward »

mvines wrote:Thanks Edward, that definitely got me on the right track.

Your project was close, but not quite what I needed. I was looking to have all of that information on the same chart. So all I had to do to your project to get that to happen was.

1. Move the chart out of the databand.
2. Delete the databand.
3. Set the charts DataSource to Categories.

I noticed that Categories.CategoryName can be set to either Argument Data Column, or Argument, and the chart still comes out as expected.
You are very welcome. Actually the difference between these properties is the follows:
DataColumn specifies a Data Column which specifies a DataColumn from Chart.DataSource property. Chart will produce as many values as that DataSource contains.
In case of Argument you can use instead of the DataColumn any expression. This expression will be calculated 'Chart.CountData' times or 'Chart.DataSource' times (as many times as amount of records in that DataSource).
I also noticed that Chart.CountData can be set to any value, and it does not have an effect on this particular chart. I still don't understand what CountData does. If you could fill me in I would appreciate it.
That is because Chart.DataSource has a higher priority than Chart.CounData.
Lastly, I noticed that If I entered into the Value field {Totals.Count(Products.ProductID)} I did not receive a Report Compilation error. This did not result in the correct chart either, but it did compile.
The Totals.Count function expects a DataSource as its parameter:

Totals.Count(Products) -is an equivalent of Products.DataTable.Rows.Count and returns amount of records in the 'Products' datasource.

Please see the report in the attachment.

You could also prepare all required data using 'Data From other Source' datasource. This DataSource can be based on the 'Products' DataSource and group and count its records according with CategoryID DataColumn.

The attached report shows both techniques.

Thank you.
Attachments
245.CountProductsByCategories.mrt
(31.44 KiB) Downloaded 400 times
Post Reply