Pre loader

Custom numeric format in Vertical slices XAxis label (decimal separator)

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

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

Images
  • You must to post comments
1
0

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

  • You must to post comments
1
0

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

Images
  • Yuriy Zadereckiy
    Hi Manuel, you are welcome! Please feel free to ask if you have any other questions.
  • You must to post comments
0
0

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

  • You must to post comments
0
0

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

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies