How put lable in chart control?

Thread is closed for posting
2 posts, 0 answers
  1. vikas Ahlawat
    vikas Ahlawat avatar
    2 posts
    Member since:
    Oct 2009

    Posted 24 Oct 2009 Link to this post

    i have bind my chart control with the database table
    u can see the picture here

    DataSet ds = new DataSet();
                SqlConnection con = new SqlConnection("Data Source =.\\SQLEXPRESS;Initial Catalog = schoolmgt; password=; Integrated Security = true;");
                SqlCommand cmd = new SqlCommand("select Paper1,Paper2,Paper3,Paper4,Paper5 from Student_Exams_Marks_Detail where S_ID='" + comboBox3.Text + "'and Section='"+comboBox2.Text+"' and Class='"+comboBox1.Text+"' ", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds, "v");
                radChart1.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Years";
                radChart1.DataSource = ds.Tables["v"];
                radChart2.DataSource = ds.Tables["v"];
                radChart3.DataSource = ds.Tables["v"];
                radChart4.DataSource = ds.Tables["v"];
                // MessageBox.Show(ds.Tables["v"].Rows[0][1].ToString());
                //radChart1.Skin = "LightBlue";
                radChart2.ChartTitle.TextBlock.Text = "MY chart";
                ChartSeries s1 = new ChartSeries();
                s1.Name = "vikas";                 /////////// this is not working

    The problem is that the series name are according to database table , but i want to put diff lables , how can i do this for more clearly understand my problme u can see picture

  2. Dwight
    Dwight avatar
    475 posts

    Posted 28 Oct 2009 Link to this post

    Hi vikas Ahlawat,

    You can handle the PrePaint event and change the labels on the axis:
    public partial class Form1 : Form
        public Form1()
            this.radChart1.PrePaint += new EventHandler<EventArgs>(radChart1_PrePaint);
            // Other initialization goes here
        private void radChart1_PrePaint(object sender, EventArgs e)
            foreach (ChartAxisItem item in this.radChart1.PlotArea.XAxis.Items)
                item.TextBlock.Text = "Custom label";

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top