I want to display a point as a decimar separator in numeric values. I have achieved this in chart axis and vertical slices tooltips, creating a custom NumericLabelProvider (see attached picture). How can I do the same with vertical slices xacis labels? (in the picture attached, note that every numeric value has a point as a decimar separator, but vertical slice label has a comma). I have defined LabelTextFormatting of the slice with “#.##E+0”, but it doesn’t work.
Thanks in advance
Regads, Juan
- You must login to post comments
Hi Manuel,
Thanks for your reply. The reason why the label gets formatted with comma as a decimal separator is because of your localization settings. This is the default behavior, and in this MSDN article you can find the explanation:
The “.” custom format specifier inserts a localized decimal separator into the result string.
To workaround it, you could bind the Text property of AnnotationLabel directly to the X1 property and provide the desired formatting in code using value converter:
<s:VerticalLineAnnotation ...
ShowLabel="False">
<s:AnnotationLabel LabelPlacement="Axis" Text="{Binding X1, Converter=...}" />
</s:VerticalLineAnnotation>
Please don’t forget to hide the default label setting ShowLabel to “False”.
Hope this helps!
Best regards,
Yuriy
- Yuriy Zadereckii answered 9 years ago
- last edited 9 years ago
- You must login to post comments
Hi Yuriy,
My problem is that I create vertical line annotations in my code behind. But your answer has inspired me a solution: I have set the default label with no LabelTextFormatting, so it takes the x axis format (with point as a decimal separator), and I have added an AnnotationLabel, with LabelPlacement = bottom, for the name (see attached figure)
Thanks!
Regards,
Manuel
- Jose Mora Almerich answered 9 years ago
- Hi Manuel, you are welcome! Please feel free to ask if you have any other questions.
- You must login to post comments
Hi Manuel,
From the VerticalLineAnnotation Documentation:
// Changing the Label TextFormatting
By default, the label text is formatted by the axis. See the AxisBase.CursorTextFormatting property.You can also override the textformatting by using a .NET Formatting string by setting the VerticalLineAnnotation.LabelTextFormatting property.
<s:SciChartSurface.Annotations>
<s:VerticalLineAnnotation X1="4" Stroke="Orange" StrokeThickness="2" LabelTextFormatting="$0.00">
<s:VerticalLineAnnotation.AnnotationLabels>
<s:AnnotationLabel LabelPlacement="Axis" Foreground="White" />
</s:VerticalLineAnnotation.AnnotationLabels>
</s:VerticalLineAnnotation>
</s:SciChartSurface.Annotations>
Does this help? If not, let me know and we can investigate.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 9 years ago
- You must login to post comments
No, it doesn’t work.
As I told before, I set LabelTextFormatting in c# code, but it still shows a comma separator instead of point.
It’s true that label text is formatted according to x axis by default, but i need to add some extra information on label, so I set LabeltextFormatting. Am I doing something wrong?
var slice = new VerticalLineAnnotation()
{
X1 = x,
ShowLabel = true,
LabelPlacement = LabelPlacement.Axis,
FontSize = 8,
LabelTextFormatting = "Slice" + (this.mSlicesList.Count + 1).ToString() + "\r" + "#.##E+0",
IsEditable = true,
Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 255)),
};
Regards
- Jose Mora Almerich answered 9 years ago
- You must login to post comments
Please login first to submit.