SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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
    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.