XAxis labels from data field?

4 posts, 0 answers
  1. Gary
    Gary avatar
    4 posts
    Member since:
    Nov 2008

    Posted 10 Nov 2008 Link to this post

    Hello,

    I'm trying to change the default labels on the XAxis from 1,2,3,4,5 etc and use the value from one of the fields in my bound table? I've seen examples that should do the trick, but I've tried and I can't get those labels to change, even when attempting to hard code values into them.

    Please advise.

    Thanks,

    -Gary
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 12 Nov 2008 Link to this post

    Hello Gary,

    The easiest way to get labels from the data source is to use:
    this.radChart1.PlotArea.XAxis.DataLabelsColumn = "labelsColumn"

    If you want to customize the labels by hard-coding the values, you should first disable AutoScale:
    this.radChart1.PlotArea.XAxis.AutoScale = false

    Best,
    Evtim
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Gary
    Gary avatar
    4 posts
    Member since:
    Nov 2008

    Posted 12 Nov 2008 Link to this post

    Hello,

    Thanks very much for your response. Unfortunately I'm still having problems getting this to work. Where should I put this code? I've tried handling the ItemDataBound event and set the value there and I've also tried just setting the value after calling the DataBind() method, but the labels are not changing.

    (I'm setting the AutoScale property to false right after creating my RadChart.)

    Based on the name it seems XAxis.DataLabelsColumn is one label for the entire XAxis while I need a label for each individual row in the data source. Is my undestanding incorrect? I don't see my hardcoded text values anywhere so I'm not sure.

    One more thing, when I debug the project I can see my value in the property, but I don't see it on the chart. Is there a way for me to send you my project, since I'm probably doing something in the wrong order or something?

    Thanks,

    -Gary




  5. Gary
    Gary avatar
    4 posts
    Member since:
    Nov 2008

    Posted 13 Nov 2008 Link to this post

    I see what I was missing, I didn't realize the string "labelsColumn" in your example was supposed to be the name of my column in the datatable (I was expecting "labelsColumn" to show up in the Chart, doh!).

    It is working now. (I knew I was just missing it.)

    Thanks.
Back to Top