Hello. I display labels on BarSeries. Please see the picture in 'BarChartLabels.PNG' file. But as you can see there, sometimes the numerical values of labels are too long and look ugly. How to round fractional part of labels of BarSeries to thousandths for example?
6 Answers, 1 is accepted
0
Hello Yaroslav,
You can set Format property of labels as you can see in our help topic Label Definition. Another option is if you have a template for labels with TextBlock inside to set FormatString property of the Text.
I hope this information helps.
Regards,
Milena
Telerik by Progress
You can set Format property of labels as you can see in our help topic Label Definition. Another option is if you have a template for labels with TextBlock inside to set FormatString property of the Text.
I hope this information helps.
Regards,
Milena
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0

Dmitry
Top achievements
Rank 1
answered on 19 Sep 2016, 07:18 AM
Thank you, Milena. I'll read about LabelDefinition and try. I bag your pardon I've been sick these days and therefore couldn't reply to you in time.
0

Dmitry
Top achievements
Rank 1
answered on 23 Sep 2016, 09:00 AM
Hello, Milena, please give me an example of both label formatting options, if this is possible ofcourse. Thank you very much in advance.
0

Dmitry
Top achievements
Rank 1
answered on 24 Sep 2016, 08:33 AM
Hello, Milena. I've already solved the problem by the use of your adviced aproach of Label Definition. See below:
But you wrote: "...Another option is if you have a template for labels with TextBlock inside to set FormatString property of the Text..". So if this is possible, please give me an example of this aproach.
<
telerik:RadCartesianChart
Visibility
=
"{Binding IsComparativeBarChartVisible}"
>
<!-- X-axis -->
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:CategoricalAxis
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
<!-- Y-axis -->
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
Title
=
"Относительная величина"
Minimum
=
"{Binding ComparativeChartMinimum}"
Maximum
=
"{Binding ComparativeChartMaximum}"
/>
</
telerik:RadCartesianChart.VerticalAxis
>
<!--Bar chart itself-->
<
telerik:RadCartesianChart.Series
>
<
telerik:BarSeries
ShowLabels
=
"True"
CategoryBinding
=
"Category"
ValueBinding
=
"Value"
ItemsSource
=
"{Binding ComparativeData}"
>
<!--AND FINALLY, HERE I ASSIGN THE FORMAT TO A LABEL-->
<
telerik:BarSeries.LabelDefinitions
>
<
telerik:ChartSeriesLabelDefinition
Format
=
"{} {0:0.###}"
/>
</
telerik:BarSeries.LabelDefinitions
>
</
telerik:BarSeries
>
</
telerik:RadCartesianChart.Series
>
</
telerik:RadCartesianChart
>
0
Accepted
Hello Yaroslav,
I'm glad that you found a solution. The second option I mentioned was in case you are using a template for the labels:
I hope this information helps.
Regards,
Milena
Telerik by Progress
I'm glad that you found a solution. The second option I mentioned was in case you are using a template for the labels:
<
telerik:BarSeries.LabelDefinitions
>
<
telerik:ChartSeriesLabelDefinition
>
<
telerik:ChartSeriesLabelDefinition.Template
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding Value, StringFormat={}{0:0.00}}"
/>
</
DataTemplate
>
</
telerik:ChartSeriesLabelDefinition.Template
>
</
telerik:ChartSeriesLabelDefinition
>
</
telerik:BarSeries.LabelDefinitions
>
I hope this information helps.
Regards,
Milena
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0

Dmitry
Top achievements
Rank 1
answered on 27 Sep 2016, 12:32 PM
Thank you very much for your help and support.