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

Binding line series to Array/List

3 Answers 302 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Andrey asked on 30 Aug 2012, 08:34 PM
Hi, 
I have my model described like: 
    public class PerformanceChartSeriesModel_2
    {
        public string[] Date { get; set; }
        public double[] P1 { get; set; }
    }

Now, I chart :
    @(Html.Kendo().Chart<PerformanceChartSeriesModel_2>()
        .Name("chartPerformance")        
        .Legend(legend => legend
        .Position(ChartLegendPosition.Bottom)
        )
        .DataSource(ds => ds
            .Read(read => read.Action("PerformanceChartData", "Performance").Data("performanceChartData"))
        )
       .Series(series =>
       {
           series.Line(p=>p.P1);                      
       })
               .CategoryAxis(axis =>
               {
                   axis.Categories(l => l.Date);
               })   

Neither series nor categories pick up values, series actually behave in a strange way drawing only one point.
Could you tell what is wrong, or how can I work with such model.
Thanks.

3 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 03 Sep 2012, 11:08 AM
Hello Andrey Dorokhov,

As you can see in our offline example line-charts/remote-data you need to pass an array with objects. Then you need to specify the bindable field.

If you want to pass an array to the series you can do this with ViewBag or Model.Something.

Kind regards,
Hristo Germanov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Attila
Top achievements
Rank 2
answered on 06 Oct 2017, 11:18 AM

Hi!

Can you show me the PerformanceChartData action of your Performance controller? I'm facing similar problem and try to find some solution... My action returns with Json(res.ToDataSourceResult(request)), where res is IEnumerable<MyClass>.

 

Many thanks

0
Stefan
Telerik team
answered on 11 Oct 2017, 06:45 AM
Hello, Attila,

In general, the Action should return an array of objects as Hristo suggested.

Please inspect the response from the server when the data is returned with "Json(res.ToDataSourceResult(request))"

The expected result can be observed in our demo:

http://demos.telerik.com/aspnet-mvc/line-charts/remote-data-binding

Please have in mind that this is an old thread and there is a big chance Andrey to not have the code available as this was 5 years ago.

If there is a specific issue, please provide more details or runnable example and we will gladly assist.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Chart
Asked by
Andrey
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Attila
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or