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

Pie Chart with ObjectDataSource(?)

1 Answer 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Angelo
Top achievements
Rank 1
Angelo asked on 20 Jul 2017, 07:55 AM

Hello! I apologize for my poor English first.

I am a beginner on Telerik Report. I have to create a Pie chart that displays a datasource's data. Make my point clear:

I am making a Report build on three lists of objects, one object of every list it's named: Status (it can be: Open, On track, Cancelled etc...).

The chart should displays the average of every "Status" inside the three lists of the Report in percent (for example: Open 100%; Open 50%, Open 75% etc...)

The problem is: I don't know how to bind via code the Chart with the ObjectDataSource, I am using Graph Wizard.

I wrote this code 

 private void graph1_NeedDataSource(object sender, EventArgs e)
        {           
            Telerik.Reporting.Processing.Chart chart = sender as Telerik.Reporting.Processing.Chart;
            chart.DataSource = CbpGlobalInitiativesUsdByCountryFollowUpStructure; //it's the DataSource of the entire Report
        }

The Binding of the graph already has "Property path: DataSource", "Expression: =Field.List1 =Field.List2 =Field.List3"

I saw a tutorial and at this point the chart should already works, instead nothing happens!

Where am I get wrong?

Thank you,

Angelo

 

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 24 Jul 2017, 01:17 PM
Hello Angelo,

Chart item is obsolete as of Q1 2013 and it is recommended to switch to a Graph item. To bind the Graph to the report's data source, use = ReportItem.DataObject expression when adding the binding for the Graph's DataSource property - check Use DataObject as a datasource for nested data items (Table, List, Crosstab, Graph).

For building a Pie chart, you can use Graph Wizard where you will need to choose the chart type and connect this chart to the data source. Choose the report's data source as this will allow you to build the Pie chart using the existing data fields in the Wizard. At runtime, the Graph's data source will be replaced with the one set via bindings.

I hope this information will help.


Regards,
Katia
Progress Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Angelo
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or