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

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

2 Answers 72 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sailaja
Top achievements
Rank 1
Sailaja asked on 30 Apr 2012, 12:17 PM
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 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 02 May 2012, 09:24 AM
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 >>

0
Sailaja
Top achievements
Rank 1
answered on 02 May 2012, 01:35 PM
hi Petar,
Thanks alot
Tags
ChartView
Asked by
Sailaja
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Sailaja
Top achievements
Rank 1
Share this question
or