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

Databinding Contains Functionaility

5 Answers 102 Views
Chart
This is a migrated thread and some comments may be shown as answers.
DC
Top achievements
Rank 1
DC asked on 13 Nov 2019, 10:05 PM

<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

Sort by
0
Accepted
Tsvetomir
Telerik team
answered on 18 Nov 2019, 12:46 PM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
DC
Top achievements
Rank 1
answered on 18 Nov 2019, 03:12 PM

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.

0
Tsvetomir
Telerik team
answered on 21 Nov 2019, 09:16 AM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
DC
Top achievements
Rank 1
answered on 22 Nov 2019, 10:16 PM

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

0
Tsvetomir
Telerik team
answered on 25 Nov 2019, 11:07 AM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Chart
Asked by
DC
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
DC
Top achievements
Rank 1
Share this question
or