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

Programatically settings pie chart data

3 Answers 128 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 30 Apr 2013, 11:58 AM
I'm trying to set a pie chart with data programatically but I'm unsure how to do this nor can I find documentation for this method. I'm populating the graph on the NeedDataSource event like so:

private void graph1_NeedDataSource(object sender, EventArgs e)
{
 
}

I'm also unclear as how the graph1.DataSource method works, as I assigned it to an object containing string, int, List<string> and List<int> and the result was a full blue pie chart with a series (?) called System.Collections.Generic.List`1 [System.String]

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 03 May 2013, 08:46 AM
Hi Ken,

In order to use data having nested collections in it as values for the Graph item, the data should be flattened or you should use only one of the collections. Our suggestion is once the data is prepared to run the Graph Wizard to create your Graph item definition, and in the end to remove the set value for DataSource(thus the NeedDataSource event for the item will fire) and assign the new data as follows:
private void Graph1_NeedDataSource(object sender, EventArgs e)
{
    Telerik.Reporting.Processing.DataItem graph = (Telerik.Reporting.Processing.DataItem)sender;
    graph.DataSource = GetData();
}

Please check Graph members article from the API reference section for more details about Graph item's events.

If you need further help, let us know more details about the scenario and the reason why you need to assign the chart DataSource at runtime.

All the best,
Stef
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Jason
Top achievements
Rank 1
answered on 06 May 2014, 06:21 PM
I am trying to set the datasource of a Graph item programatically using the graph's NeedDataSource event as well, and it works fine when I run the preview in the designer, but the graph does not work when I try to display it in a Web Forms Report Viewer. It just displays a blank graph with no data. Please help.
0
Nasko
Telerik team
answered on 09 May 2014, 12:42 PM
Hello Jason,

We have replied to your inquiry in your support ticket on the same issue. Let us continue the discussion there, as the problem has some specifics not related to the topic discussed in this forum thread.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Ken
Top achievements
Rank 1
Answers by
Stef
Telerik team
Jason
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or