<div class="demo-section k-content wide">
@(Html.Kendo().Chart<Telerik.Models.Testing>()
.Name("chart2")
.Title("Testing")
.Legend(legend => legend
.Position(ChartLegendPosition.Top)
)
.DataSource(ds => ds.Read(read => read.Action("MyData", "Binding")))
.Series(series =>
{
series.Column(m => m.Severity.Contains("TestingThis"), categoryExpression: m => m.Iteration)
.Name("Severity Levels")
.Aggregate(ChartSeriesAggregate.Count)
.Labels(l => l.Visible(true));
})
)
</div>
I get an InvalidOperationException: Bound columns require a field or property access expression.
The problem lies here: series.Column(m => m.Severity.Contains("TestingThis"), categoryExpression: m => m.Iteration)
Is there any way for me to filter that Severity column from my data model?
5 Answers, 1 is accepted
Hi Denys,
There are two approaches that you might undertake when filtering the data source is the end goal. Via the filter option of the data source, you could apply the following:
.DataSource(ds => ds.Read(read => read.Action("_SpainElectricityProduction", "Bar_Charts")).Filter(f=>f.Add(m=>m.Nuclear).IsEqualTo(122)))
As well as, you could send an additional parameter to the server-side and return only the relevant data:
.DataSource(ds => ds.Read(read => read.Action("_SpainElectricityProduction", "Bar_Charts").Data("additionalData"))
<script>
function additionalData(e) {
// return the additional data
}
</script>
Give these suggestions a try and let me know how they work out for you.
Kind regards,
Tsvetomir
Progress Telerik

Hi tsvetomir,
Thanks for the response.Are there any other examples you could send my way in regards to grouping. I am trying to create a chart out of a SQL query that has a count and groups on two columns.
Hi Denys,
The Kendo UI Chart widgets are client-side widgets that consume data and represent it. The back-end implementation is none of its concerns, therefore, the implementation of the server-side logic is up to the developer.
However, every Chart type has a live demo that demonstrates how to achieve remote data binding functionality. Here is an example:
https://demos.telerik.com/aspnet-core/bar-charts/remote-data-binding
The full list of chart types could be found on the landing page of the demos website:
https://demos.telerik.com/aspnet-core/
I hope you find this helpful.
Regards,
Tsvetomir
Progress Telerik

I have remotely data binded some data but now I am doing something else to get data over.
The main issue I am having now is overlapping names in category axis. Here are some screenshots of my code. I tried searching for a solution in the telerik forums. I tried out a template but it still did not work.
Thanks, DC
Hi Denys,
In case of having multiple CategoryAxis declarations in the Chart, you would have to explicitly set the corresponding axis to each of the axes. Here is an example:
.Series(series =>
{
series.Bar(new double[] { 56000, 63000, 74000, 91000, 117000, 138000 }).Name("Total Visits").CategoryAxis("cat1");
series.Bar(new double[] { 52000, 34000, 23000, 48000, 67000, 83000 }).Name("Unique visitors").CategoryAxis("cat2");
})
.CategoryAxis(axis => axis
.Name("cat1")
.Categories("Jan", "Feb", "Mar", "Apr", "May", "Jun")
.MajorGridLines(lines => lines.Visible(false))
)
.CategoryAxis(axis => axis
.Name("cat2")
.Categories("Jan", "Mar", "Apr", "May", "Jun")
.MajorGridLines(lines => lines.Visible(false))
)
Best regards,
Tsvetomir
Progress Telerik