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

RadChart not showing appropriate data when binding to DataSet

1 Answer 31 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Zeyad
Top achievements
Rank 1
Zeyad asked on 31 Jan 2019, 06:10 PM

Hello,

 

I have the following SQL statement

SELECT DATEADD(week, DATEDIFF(week, 0, homeworks_homeworks.submission_date), - 1) AS HwWeek, COUNT(homeworks_homeworks.homework_id) AS HwCounter, edu_subjects.subject_id, edu_subjects.subject_name
FROM     homeworks_homeworks INNER JOIN
                  edu_subjects ON homeworks_homeworks.homework_subject_id = edu_subjects.subject_id
GROUP BY DATEADD(week, DATEDIFF(week, 0, homeworks_homeworks.submission_date), - 1), edu_subjects.subject_id, edu_subjects.subject_name

 

Where the results are shown like this

 

2019-01-13 00:00:00.000      1      1      Arabic
2019-01-13 00:00:00.000      1      2      English
2019-01-27 00:00:00.000      3      2      English
2019-02-03 00:00:00.000      3      2      English

 

When adding dynamic LineSeries as the following

if (_dsHwRep1.Tables.Count > 0)
            {
                
                int _tblCounter = _dsHwRep1.Tables[0].Rows.Count;
                string _firstCol = "";
                for(int x=0;x<_tblCounter;x++)
                {
                    
                    if(_firstCol != _dsHwRep1.Tables[0].Rows[x]["subject_name"].ToString())
                    {
                        _firstCol = _dsHwRep1.Tables[0].Rows[x]["subject_name"].ToString();
                        LineSeries _lSer = new LineSeries();
                        _lSer.Name = _firstCol;
                        _lSer.DataFieldY = "HwCounter";
                        HW_rep1.PlotArea.Series.Add(_lSer);
                    }
                }
                
                
                
                
                

                HW_rep1.DataSource = _dsHwRep1.Tables[0];
                HW_rep1.DataBind();
            }

 

 

The Chart binds correctly, but shows for example Arabic, 1 3 3 where it should just be 1 and not having the 3 values.

 

 

Any ideas?

 

Thank you

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 05 Feb 2019, 09:19 AM
Hi Zeyad,

When binding RadHtmlChart you have to make sure that each Column of the DataTable corresponds to the series items values bound to a single series You will need to change a bit the structure of the data in order to bind the chart with it in the desired way. You can see a sample on how to do this here:
https://www.telerik.com/support/code-library/group-radhtmlchart-data-source

Regards,
Vessy
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 (HTML5)
Asked by
Zeyad
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or