How to put Negative sign at the end of a label for an axis of a chart view control

3 posts, 0 answers
  1. Sailaja
    Sailaja avatar
    2 posts
    Member since:
    Apr 2012

    Posted 30 Apr 2012 Link to this post

    HI,
    i am new to telerik chart view control.
    I want to display the negative sign at the end of a lable for an axis.
    For Ex:if the label value is: -10 it has to show 10- instead of -10.
    Can any one help me out of this problem..
    thanks.
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 02 May 2012 Link to this post

    Hi Sailaja,

    You can set a data template for the X axis label and use a converter to swap the place of the sign:
    <telerik:RadCartesianChart>          
     <telerik:RadCartesianChart.VerticalAxis>
      <telerik:LinearAxis>
       <telerik:LinearAxis.LabelTemplate>
        <DataTemplate>
         <TextBlock Text="{Binding Converter={StaticResource ReverseSignConverter}}" />

    And in the converter you need to do something like this:
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
     string stringValue = (string)value;
     double doubleValue = Double.Parse(stringValue);
     string result;
     
     if (doubleValue >= 0)
      result = doubleValue.ToString();
     else
      result = (-doubleValue).ToString() + "-";
     
     return result;
    }

    Greetings,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Sailaja
    Sailaja avatar
    2 posts
    Member since:
    Apr 2012

    Posted 02 May 2012 Link to this post

    hi Petar,
    Thanks alot
Back to Top