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

Stack Chart Error Past 6 Bar Items

2 Answers 64 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Jako
Top achievements
Rank 1
Jako asked on 29 Oct 2014, 12:11 PM
Hello

I am receiving errors when I create a stacked chart with more than 5 stacked bars. Errors are as follow:

1) Order not followed (01,07,06 ,05,04,03,02,) instead of (01,02,03,04,05,06,07)
2) Value of Source bar 1 and Source bar 2 gets swapped. Comparison value for those two bars are still correct. 

BookscanWeek is a string. I have tried setting it as integer to no avail.

Why does it not work when more than 5 bars? 

Help much appreciated


@(Html.Kendo().Chart(Model.StackChartData)
                              .Name("ValueStackChart")
                              .Theme("Silver")
                              
                              .ChartArea(chartArea => chartArea
                                  .Background("white")
                              )
                              .HtmlAttributes(new { style = "height:400px;" })
                              .Series(series =>
                              {
                                  series.Column(model => model.Value)
                                      .Name("#= group.value #")
                                      .Stack(true);
                              })
                            .Legend(legend => legend
                                .Visible(true)
                                .Position(ChartLegendPosition.Right)
                            )
                            .CategoryAxis(axis => axis
                                .Categories(model => model.BookscanWeek)
                                .Labels(labels => labels.Rotation(270))
                              
                            )
                            .ValueAxis(axis => axis.Numeric("Value")
                                .Labels(labels => labels
                                    .Format("R {0:N}")
                                    .Skip(2)
                                    .Step(2)
                                )
                              )
                              .DataSource(dataSource => dataSource
                                    .Group(group => group.Add(model => model.Element))
                                    
                                )
                              .Tooltip(tooltip => tooltip
                                  .Visible(true)
                                  .Format("R {0:N}")
                              ))

2 Answers, 1 is accepted

Sort by
0
Accepted
Iliana Dyankova
Telerik team
answered on 31 Oct 2014, 08:00 AM
Hi Jako,

In order to achieve the expected result you should sort the dataSource by the BookscanWeek field: 
//....
DataSource(dataSource => dataSource
   .Group(group => group.Add(model => model.Element))
   .Sort(sort => sort.Add(model => model.BookscanWeek).Ascending())
)

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jako
Top achievements
Rank 1
answered on 31 Oct 2014, 08:22 AM
Hello Iliana

Thank you , that resolved my random sorting and data swapping.

Regards
Tags
Charts
Asked by
Jako
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Jako
Top achievements
Rank 1
Share this question
or