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

DataSource and two or many bars

1 Answer 41 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Stim24
Top achievements
Rank 1
Stim24 asked on 25 Sep 2019, 08:27 AM

How create chart with 2 or 3 bars from DataSource

series.Bar(model => model.Sum).Name(""); // One Bar

series.Bar(model => model.Sum).Name(""); //  Need new data????

 

@(Html.Kendo().Chart<CoreDiag.Models.CKassaLine>(Model)
            .Name("Name1") // The name of the Chart is mandatory. It specifies the "id" attribute of the widget.
            .Title("Name1")
            .Series(series =>
            {
                series.Bar(model => model.Sum).Name("");
            })
            .CategoryAxis(axis => axis
                .Categories(model => model.Period)
            )
             
  )

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 27 Sep 2019, 12:35 PM

Hi Tim,

For remote data binding, you need to specify a remote endpoint or web service returning data in JSON/JSONP format and utilize the DataSource as a mediator between the chart and the underlying data.

First, within the DataSource property, you need to point the action method that the Chart will read data items from. And then within Series, you need to clarify which property to be used for the configuration of the chart series.

E.g.

.DataSource(ds => ds.Read(read => read.Action("_SpainElectricityProduction", "Bar_Charts")))
        .Series(series => {
            series.Column(model => model.Nuclear).Name("Nuclear").CategoryField("Year");
            series.Column(model => model.Hydro).Name("Hydro").CategoryField("Year");
            series.Column(model => model.Wind).Name("Wind").CategoryField("Year");
        })

Keep in mind that specifying a Name as "" will render a tooltip of undefined.

Please review the below Chart demo for full implementation of the above approach:

If there is anything else, we could help with, please contact us back.

Regards,
Nikolay
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
Stim24
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or