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

Binding data to graph programatically

1 Answer 206 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 09 May 2018, 06:47 PM

I've read many posts regarding this but I still can't find a solution to my problem.

I currently have a graph (stacked bar) in a report created with Visual Studio designer.

 

I then try to bind some data to the graph, but the graph always appears empty in the previews:

public GraphReport()
        {
            InitializeComponent();

            var h1 = new Person
            {
                Name = "John",
                Age = 28
            };

            var h2 = new Human
            {
                Name = "Carl",
                Age = 31
            };
            var list = new List<Human> { h1, h2 };
            graph1.DataSource = list;
        }

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 14 May 2018, 09:28 AM
Hello Adrian,

I am not certain which preview is used. If you are referring to design-time preview it will not be available when the data for the Graph item is set in code-behind. To enable design-time preview you can configure ObjectDataSource component to retrieve the collection of Human objects and set it as Graph.DataSource property in the report designer.

In case, the Graph is empty when run-time preview is used my suggestion is to check if Category and Series groupings for the Graph item and the properties of the series are set correctly. Check this example as a reference.

In case the issue persists send us the problematic report in a support ticket so we can check the settings of the Graph item and provide you further suggestions.


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
Adrian
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or