Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Sorting on bar chart not working

$
0
0

Hi there,

My bar chart is not picking up the sort order I am applying.  I am returning Json with 4 categories - High, Medium, Low and Very Low, each returning a sort order to force the graph to display in that correct order.  However, the graph renders in the wrong order.  Please can you assist.  I have attached a screenshot of what is rendered, code below.  Everything else in my chart is working fine.

 === JSON RETURNED ===

[{"Share":3,"VisibleInLegend":true,"Color":"#E8412D","category":"High","SortOrder":4,"PercentageField":"9%"},{"Share":9,"VisibleInLegend":true,"Color":"#ED8132","category":"Medium","SortOrder":3,"PercentageField":"29%"},{"Share":3,"VisibleInLegend":true,"Color":"#FFB400","category":"Low","SortOrder":2,"PercentageField":"9%"},{"Share":16,"VisibleInLegend":true,"Color":"#92CE7A","category":"Very Low","SortOrder":1,"PercentageField":"51%"}]​

=== VIEW ====

 @( Html.Kendo().Chart<Models.RiskItemsBarChartModel>()
                .Name("riskItems")
                .ChartArea(chartArea => chartArea.Background("#F5F5F5"))
                .Title(title => title
                    .Text("Risk Items")
                    .Position(ChartTitlePosition.Top))
                .DataSource(ds => ds
                    .Read(read => read.Action("RiskItemsBarChart", "Reporting"))
                    .Group(g => g.Add(d => d.category))
                    .Sort(g => g.Add(d => d.SortOrder))
                )
                .Series(series => series
                    .Bar(d => d.Share, d => d.Color).CategoryField("category")
                    .Name("#:group.value#")
                    .Stack(true)
                    .Labels(labels => labels
                        .Visible(true)
                        .Template("#= value # (#= dataItem.PercentageField #)")
                        .Position(ChartBarLabelsPosition.InsideBase)
                    )
                )
                .CategoryAxis(axis => axis
                    .Visible(false)
                )
                .Tooltip(tooltip => tooltip
                    .Visible(false)
                )
                .Legend(legend => legend
                    .Visible(true)
                    .Position(ChartLegendPosition.Bottom)
                )
                .Events(events => events
                    .SeriesClick("onSeriesClick_riskItems")
                    .DataBound("onDataBound_riskItems")
                )
            )

Thanks, Mark


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>