RadChartView & Piecharts, Basics?

1 Answer 97 Views
ChartView
Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
Deasun asked on 14 Apr 2022, 04:49 PM

Good evening,

I am having some basic issue with connecting a dataview to a chart and getting the piechart to show.

Heres My results:

the first chart is set up as follows:

 this.radChartView1.AreaType = ChartAreaType.Pie;
            PieSeries series = new PieSeries();
            series.DataPoints.Add(new PieDataPoint(50, "Germany"));
            series.DataPoints.Add(new PieDataPoint(70, "United States"));
            series.DataPoints.Add(new PieDataPoint(40, "France"));
            series.DataPoints.Add(new PieDataPoint(25, "United Kingdom") { Label = "My Label" });
            series.ShowLabels = true;
            series.DrawLinesToLabels = true;
            series.SyncLinesToLabelsColor = true;


            this.radChartView1.ShowSmartLabels = true;
            this.radChartView1.Series.Add(series);

Hardcoded.

the next one is my dataview;

 DataSet dsAnswer = new DataSet();
            DataView dvResult = new DataView();

            var db = Spectrotel.Library.DatabaseUtilities.DatabaseHelper.GetDB("RevIO");
            var cmd = db.GetStoredProcCommand("getme");
            string strSQLCMD = "";
            strSQLCMD = "[spectrotel].[sp_Rpt_Progress_getTodaysUsers]";
            cmd = db.GetStoredProcCommand(strSQLCMD);
            cmd.CommandTimeout = 10800;
            dsAnswer = db.ExecuteDataSet(cmd);
            dvResult = dsAnswer.Tables[0].AsDataView();

            radChartView2.AreaType = ChartAreaType.Pie;
            PieSeries series2 = new PieSeries();
            series2.DataSource = dvResult;
            series2.DisplayMember = "Bucket";
            //series.DataMember = "Cnts"; // it dont like this at all!
            series2.ShowLabels = true;
            series2.DrawLinesToLabels = true;
            series2.SyncLinesToLabelsColor = true;


            radChartView2.ShowSmartLabels = true;
            radChartView2.Series.Add(series2);

The data coming back from SQL is:

What am I doing wrong here?

Just want the basic C# code to get a piechart to appear like the first with my data.

 

Thanks.

Deasun.

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 18 Apr 2022, 11:53 AM

Hello Deasun,

Thank you for the provided details.

Looking at the code snippet for the second chart, the ValueMember property of the PieSeries is not set. This property needs to point to a value that will be used to calculate the PieSeries slice proportions. Upon checking the data from the DB, you can set the ValueMember property to the second column "Cnts".

series2.ValueMember = "Cnts";

I hope this information is helpful.

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ChartView
Asked by
Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or