2 Bar Series with Data Binding

2 posts, 0 answers
  1. Marianne
    Marianne avatar
    10 posts
    Member since:
    Apr 2020

    Posted 09 Jun 2020 Link to this post

    I was able to create a bar chart with one set of bars (series)  and bound it to a DataTable without any problem.  Now my boss wants me to create two series - how do I bind it to a data source?  Do I bind it to a DataSet or bind the DataTables to each series?
  2. Nadya
    Nadya avatar
    510 posts

    Posted 11 Jun 2020 Link to this post

    Hello Marianne,

    If you want to have two BarSeries in RadChartView you can bind each separate seria to a data source by using the DataSource property. Thus, you can bind the BarSeries and add them to the Series collection. A sample example is demonstrated below:

    public RadForm1()
        DataTable table = new DataTable();
        table.Columns.Add("Value", typeof(double));
        table.Columns.Add("Name", typeof(string));
        table.Rows.Add(1, "John");
        table.Rows.Add(3, "Adam");
        table.Rows.Add(5, "Peter");
        table.Rows.Add(12, "Sam");
        table.Rows.Add(6, "Paul");
        BarSeries barSeries = new BarSeries();
        barSeries.DataSource = table;
        barSeries.ValueMember = "Value";
        barSeries.CategoryMember = "Name";
        DataTable table2 = new DataTable();
        table2.Columns.Add("Value", typeof(double));
        table2.Columns.Add("Name", typeof(string));
        table2.Rows.Add(2, "John");
        table2.Rows.Add(8, "Adam");
        table2.Rows.Add(7, "Peter");
        table2.Rows.Add(15, "Sam");
        table2.Rows.Add(20, "Paul");
        BarSeries barSeries2 = new BarSeries();
        barSeries2.DataSource = table2;
        barSeries2.ValueMember = "Value";
        barSeries2.CategoryMember = "Name";

    I hope this helps. If you have further questions please let me know.

    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top