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

pie chart problems

1 Answer 189 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carisch
Top achievements
Rank 1
Carisch asked on 13 Sep 2007, 07:09 PM
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.
Thanks,

Brian.

1 Answer, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 15 Sep 2007, 02:44 PM
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()  
        {  
            InitializeComponent();  
            //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.DataBind();  
            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;  
            radChart1.Update();  
              
            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");  
            dbConn.Open();  
            //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",   
                dbConn);  
 
            //execute the query and close the connection to the database  
            try 
            {  
                da.Fill(dt);  
            }  
            finally 
            {  
                dbConn.Close();  
            }  
            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,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Chart (obsolete as of Q1 2013)
Asked by
Carisch
Top achievements
Rank 1
Answers by
Kiril
Telerik team
Share this question
or