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

Binding Chart's series to dynamic data

3 Answers 318 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Steve Palm
Top achievements
Rank 1
Steve Palm asked on 03 Oct 2012, 06:02 PM
Hi,

We're developing software that allows users to create their own charts. Users specify the server connection, SQL queries and columns that will be used by the series. That means, the data where the charts will be bound are not strongly typed.

Grid allows for binding to a datatable (System.Data.Datatable). But charts doesn't seem so. Here's the code I used for Grid:

@model List<iGuideMobility.Web.Models.DataViewModel>

@(Html.Kendo().Grid(new System.Data.DataTable("DataSource1"))
    .Name(Model.First().PanelUserID.ToString())
    //.HtmlAttributes(new { style = "width:100%" })
    .HtmlAttributes(new { style = "height: 350px"  })
    .Columns(column =>
        {
            var cols = Model.First().PanelColumn;
            foreach (var col in cols)
            {
                column.Bound(col.strColumn.ToString()).Title(col.strCaption.ToString()).Width(Convert.ToInt32(col.intWidth.ToString()));
            }
        }
    )
    .DataSource(datasource => datasource 
        .Ajax()
        .Batch(true)
       .Read("PanelBinding_Read", "Home", new { intPanelID = Model.First().PanelID })
    ) 
 )

For Charts, it seems like we cannot implement the same logic of showing dynamic series bound to datasource that are created on runtime.

Can you point us to the right direction so we can accomplish this?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Iliana Nikolova
Telerik team
answered on 08 Oct 2012, 06:21 PM
Hello Steve,

I will recommend to check this forum thread - although it is due to the Telerik MVC Chart it discusses the same scenario.
 
Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Akash
Top achievements
Rank 1
answered on 20 Feb 2014, 11:52 PM
Did you figure out how to do this? We are trying to do something similar.
0
Daniel
Telerik team
answered on 25 Feb 2014, 05:07 PM
Hello,

The Chart builder does support a DataTable but the series can be configured dynamically by passing the field names as string so a similar approach can be used. I attached a sample project that demonstrates binding the Chart to a DataTable.

Regards,
Daniel
Telerik
Tags
Charts
Asked by
Steve Palm
Top achievements
Rank 1
Answers by
Iliana Nikolova
Telerik team
Akash
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or