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

How put lable in chart control?

1 Answer 63 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.
vikas Ahlawat
Top achievements
Rank 1
vikas Ahlawat asked on 24 Oct 2009, 09:23 AM
i have bind my chart control with the database table
u can see the picture here          http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=68854

DataSet ds = new DataSet();
            SqlConnection con = new SqlConnection("Data Source =.\\SQLEXPRESS;Initial Catalog = schoolmgt; password=; Integrated Security = true;");
            con.Open();
            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";
            radChart1.DataBind();
            radChart2.DataBind();
            radChart3.DataBind();
            radChart4.DataBind();
            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
here 
http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=68854

1 Answer, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 28 Oct 2009, 01:45 PM
Hi vikas Ahlawat,

You can handle the PrePaint event and change the labels on the axis:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        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";
    }
}


Best,
Evtim
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.
Tags
Chart (obsolete as of Q1 2013)
Asked by
vikas Ahlawat
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Share this question
or