Position Labels in CodeBehind

Thread is closed for posting
6 posts, 1 answers
  1. IT
    IT avatar
    26 posts
    Member since:
    Dec 2008

    Posted 09 Jun 2009 Link to this post

    Hi Folks - Just wanted to know how you go about positioning the value labels of a chart in code behind.

    i know you can position them in design view but i really want to position them all in code behind
    i would need hem positioned in the middle of the bar if possible.


    Thanks Folks
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 11 Jun 2009 Link to this post

    Hi Brian,

    I assume you are talking for the series labels. Here is a sample code:
    series.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside; 
    series.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center; 

    Let me know if those are not the labels you want to position but, please, specify to which labels you refer.

    Best,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. IT
    IT avatar
    26 posts
    Member since:
    Dec 2008

    Posted 12 Jun 2009 Link to this post

    Hi Evrim,

    Thanks for the reply

    that looks about right but not sure how to use it?

    can you give me an example?

  4. Answer
    Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 15 Jun 2009 Link to this post

    Hello Brian,

    Here is a sample usage in Page_Load:
    protected void Page_Load(object sender, EventArgs e) 
        // In this case, we use SqlDataSource to fill in the chart 
        this.RadChart1.DataSource = SqlDataSource1; 
        this.RadChart1.DataBind(); 
     
        foreach(Series series in this.RadChart1.Series) 
        { 
            series.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;  
            series.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center; 
        } 

    Best,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. IT
    IT avatar
    26 posts
    Member since:
    Dec 2008

    Posted 15 Jun 2009 Link to this post

    Hi there,

    thanks for the quick reply.

    what namespace is 'series' in?


    Regards,


  6. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 17 Jun 2009 Link to this post

    Hi Brian,

    Here is the foreach statement again, including the namespace:
    foreach(Telerik.Charting.ChartSeries series in radChart1.Series) 
      ... 

    All the best,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top