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

Dynamic CategoryAxis for MVC Kendo Chart

1 Answer 522 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 25 May 2017, 03:48 PM

Hello,  currently i have this and it works great..   What i need is for the Categories in CategoryAxis to be dynamicand not the static .Categories("1", "2", "3", "4", "5")..       

I already have the value i want to put in there coming from my model,  its "@item.SurveyLinearCounts.FirstOrDefault().Min"   for the minimum value  and  @item.SurveyLinearCounts.FirstOrDefault().Max"   for the maximum

   How do i do this.?

 @(Html.Kendo().Chart<AnalyzeResponseViewModel>()
                                  .Name(@item.SurveyQuestionID.ToString())
                                  .Legend(legend => legend
                                      .Position(ChartLegendPosition.Top)
                                      .Visible(true)
                                  )
                                  .ChartArea(chartArea => chartArea
                                      .Background("transparent")
                                  )
                                  .Series(series =>
                                  {
                                      series.Column(model => model.ResponseCount).Name("Count").Tooltip(tooltip => tooltip.Visible(true).Template("#= series.name #: #=  value #"));
                                  })
                                   .CategoryAxis(axis => axis
                                      .Categories("1", "2", "3", "4", "5")
                                      .MajorGridLines(lines => lines.Visible(false))
                                  )
                              .
                              )
                                  .ValueAxis(axis => axis
                                      .Numeric()
                                      .Line(line => line.Visible(false))
                                      .MajorGridLines(lines => lines.Visible(true))
                                  )
                                  .DataSource(ds => ds
                                      .Read(read => read.Action("GetSurveyResponseChart", "DataSource", new { item.SurveyQuestionID })))
                                  .Tooltip(tooltip => tooltip.Visible(true).Template("#= series.name #: #= value #")))

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 29 May 2017, 10:14 AM
Hello Richard,

If possible, I suggest adding a Categories model property.

We have a How-to article which shows binding to dynamic series that you may find useful:

http://docs.telerik.com/aspnet-mvc/helpers/chart/how-to/create-dynamic-series

Let me know if you need more help.

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