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

Using a reports Data Source object as the datasource for a reporting chart

3 Answers 179 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 23 Jan 2013, 12:11 AM
Hey there, I've been looking for tutorials on how to use a list in my report's Data Source object as the Data Source for a report's chart. I simply have an object (objectDataSource1) that contains all of the information I need for my report. It also has a list called "Loans" in it that simply is a collection of Loan objects in which I want to use for my DataSource for my chart I'll be implementing into the report. Is this possible? If so, would anyone be able to point me in the proper location of a tutorial to accomplish this, or show a basic example in doing so? Thanks a ton in advance.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 25 Jan 2013, 12:37 PM
Hello Bryan,

In that case, you can use Bindings to set the data-source of the chart. The binding will look like this:
Property:                      Expression:
DataSource               = ReportItem.DataObject.Loans

Then you could use the list properties in the chart directly. Note that in the chart you do not need =Fields.MyField to use a property in the expression, you could simply use its name. See one of the demo reports that we ship with the product e.g. DashBoard report.

Regards,
Steve
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Bryan
Top achievements
Rank 1
answered on 06 Feb 2013, 09:52 PM
Once you have the binding set to your List of objects, Is it possible to set a "barSeries" to one of those objects in your datasource? For example, The Data source is looking at a list of car objects. I want to show different colored bars on the chart that indicate each different car along the X axis, and the Y axis says the max speed the car can go.

Say here is my Binding for the DataSource for my chart:  
=Fields.Cars

The DataSource has 3 Cars:
=Fields.Cars[0]       (Ford Mustang)
=Fields.Cars[1]       (Pontiac sunfire)
etc

Those car objects have properties, including max speed

=Fields.Cars[0].MaxSpeed    (110)
=Fields.Cars[1].MaxSpeed    (95)

I'm trying to chart these cars as a bar series along the x axis. What is happening is when I set up the "Series" for the chart, it puts all 3 cars in that one series and there's no color variation between the bars. I'd like to put each car in it's own series so I can add color variations to the chart as well as more than 1 "series" to the legend.

0
Stef
Telerik team
answered on 11 Feb 2013, 04:02 PM
Hi Bryan,

In order to manipulate bars appearance you need access to the data source. In the attached sample report the chart data source is bound via user-defined function to the field containing list of cars. In that user-defined function, instead of passing the data to the chart directly, the records in the list with cars is evaluated and series are created for each item, so the color can be different for each bar.

I hope this helps.

Regards,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Bryan
Top achievements
Rank 1
Answers by
Steve
Telerik team
Bryan
Top achievements
Rank 1
Stef
Telerik team
Share this question
or