pie chart problems

2 posts, 0 answers
  1. Carisch
    Carisch avatar
    25 posts
    Member since:
    Aug 2007

    Posted 13 Sep 2007 Link to this post

    First off, clicking start new thread on IE7 takes me to a blank page.  wtf.

    Winforms radchart product.
    I would like to see an example of a pie chart where the values are relevant, and the LABELS or legend is relevant also.  If you look at the example shipped with your project under RadChart > Data Binding > Database, I see a pie chart connected to customer by country data.  But the labels are total worthless, they only stated the number graphed.  Of course in a real sample(or project) you'd want to know what customer is associated with the values 13, 7, 2, 2, etc.

    I've searched for about an hour now, and still I have not seen an adequate sample to create such an easy task.

  2. Kiril
    Kiril avatar
    158 posts

    Posted 15 Sep 2007 Link to this post

    Hello Brian,

    Thanks for taking the time to write us.

    We tried to reproduce the scenario you described, but we didn't get any problems opening a new thread in IE7. If you continue experiencing this problem, please notify us.

    I just took a look at the example you were referring to from the Q1 Service Pack 2, and I have to agree with you. It does look a bit too basic, and does not showcase the capabilities of the chart. The databinding example in the upcoming Q2 release shows the country name as the label, indicating what percentage of customers are from a particular country.

    You can choose the column which is used to set labels in the piechart by using the LabelsColumn member of the DataManager. Here's a code block illustrating the approach I described.

            public Form1()  
                //gets the data from the database  
                DataTable dt = GetData();  
                radChart1.ChartTitle.TextBlock.Text = "Customers by Country";  
                radChart1.DataManager.DataSource = dt;  
                //set the column in the datasource to be used for the labels  
                radChart1.DataManager.LabelsColumn = "COUNTRY";  
                //sets the labels so that there are no overlaps  
                radChart1.IntelligentLabelsEnabled = true;  
                radChart1.Series[0].Name = "Country";  
                //the legend will display the labels of the items, instead of the name of the series  
                radChart1.Series[0].Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;  
                this.EnabledQSFButtons = QSFButtons.None;  
            /// <summary>  
            /// Returns a datatable containing data retrieved from the database  
            /// </summary>  
            /// <returns></returns>  
            private DataTable GetData()  
                DataTable dt = new DataTable();  
                //opens a connection to the northwind database - the file should be placed in the executable directory of the project  
                System.Data.OleDb.OleDbConnection dbConn =   
                    new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\DataSources\\Nwind.mdb");  
                //initialize a command returning a list of countries and the number of customers in each one  
                OleDbDataAdapter da = new OleDbDataAdapter(  
                    @"SELECT TOP 6 COUNTRY, count(*)
                    FROM CUSTOMERS 
                    GROUP BY COUNTRY",   
                //execute the query and close the connection to the database  
                return dt;  

    I hope this helps. Thank you for coming forward with this suggestion. We realize the importance of the examples, and we continually strive to make them more useful, but there's only so many scenarios we can cover. Your feedback focuses our efforts on the scenarios that you, our customers, use. This is why we value hearing from you so much. Thanks again for writing.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft R3 2016 release webinar banner
Back to Top