2 posts, 0 answers
  1. gradford
    gradford avatar
    7 posts
    Member since:
    Nov 2009

    Posted 11 Nov 2009 Link to this post

    I have been running into some trouble regarding setting the DefaultLabelFormat value for both X and Y-Axis as well as ItemLabels.

    I generate random data for my charts, i.e.

                //Random random = new Random(this.GetHashCode() | (int)(DateTime.Now.Ticks)); 
                Random random = new Random(); 
                for (int i = 0; i < 3; i++) 
                    DataPoint dataPoint = new DataPoint(); 
                    dataPoint.YValue = random.Next(2, 12); 

    I tried using the following: 

    dataSeries.Definition.DefaultLabelFormat = "#%"
    Chart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#%"

    But this takes the percent value of all items in the series (instead of just taking the value and appending a % sign to it), and actually doesn't even show anything for the Y-Axis Label.

    So my question is, how I would get both the ItemLabel and Y-Axis Label to look like this: 5%

    (Basically just take my value and append a % sign to it).

    Thanks for your help!

  2. Ves
    Ves avatar
    2926 posts

    Posted 16 Nov 2009 Link to this post

    Hi Garrett,

    The "#%" token designates the share of the current item, compared to the sum of all the items in the series. If you need to display the actual value you can use the "#VAL" token and simply add the literals you need:

    MyChart.DefaultSeriesDefinition.DefaultLabelFormat = "#VAL%";
    MyChart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL%";

    You can find more information on the available tokens in this help topic.

    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