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

How to bind array values to make 2 lineseries line chart please ?

2 Answers 275 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 20 Jun 2016, 08:26 AM
I want to bind on one array to draw a 2 lines chart like
            decimal[] pumpA_array = { 18.6m, 26.5m, 25.8m, 24.3m, 24.9m, 23.2m, 22.0m, 22.4m, 22.9m, 21.7m, 21.2m, 20.2m };
            decimal[] pumpB_array = { 5m, 10m, 15m, 20m, 25m, 30m, 35m, 30m, 25m, 24m, 22m, 20m };

 

 

How must i bind to my array's to get 2 lines like Attached image file please ?

In the telerik example datasource get only one array OR it is declaratively...

 

THANKS for your help

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Stanimir
Telerik team
answered on 20 Jun 2016, 08:51 AM
Hello Pierre,

You can only data bind a Chart instance with a single data source. In your cease you need to transform your two arrays in a single IEnumerable data source or DataSet (review the following example http://demos.telerik.com/aspnet-ajax/htmlchart/examples/databinding/bindtodataset/defaultcs.aspx) then data bind the chart with it.

Regards,
Stanimir
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Pierre
Top achievements
Rank 1
answered on 20 Jun 2016, 10:15 AM

Hello Stanimir,

As you say, it's OK !

 

Great THANKS

 

PS: My working example:

            DataSet ds = new DataSet("PumpPressure");
            DataTable dt = new DataTable("PumpA");
            dt.Columns.Add("ID", Type.GetType("System.Int32"));
            dt.Columns.Add("ValuePumpA", Type.GetType("System.Decimal"));
            dt.Columns.Add("ValuePumpB", Type.GetType("System.Decimal"));
            dt.Columns.Add("ValuePumpC", Type.GetType("System.Decimal"));
            dt.Columns.Add("ValuePumpD", Type.GetType("System.Decimal"));
            for (int i = 0; i < 12; i++)
            {
                dt.Rows.Add(i,i*1.5m,i*2m,Math.Sin(i)*2,Math.Cos(i)*3);
            }

            ds.Tables.Add(dt);

            RadHtmlChart1.DataSource = GetData();
            RadHtmlChart1.DataBind();

 

 

Tags
Chart (HTML5)
Asked by
Pierre
Top achievements
Rank 1
Answers by
Stanimir
Telerik team
Pierre
Top achievements
Rank 1
Share this question
or