Pre loader

Annotation line showing too thin

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

0
0

Hi Guys

We are drawing annotation lines on our charts using the following

                        <visuals:HorizontalLineAnnotation HorizontalAlignment="Stretch"
                                                          AnnotationCanvas="BelowChart"
                                                          IsHidden="{Binding IsUpperThresholdVisible, Converter={StaticResource InvertBoolean}}"
                                                          Stroke="Gainsboro"
                                                           
                                                          StrokeThickness="0.75"
                                                          XAxisId="IndicatorXAxis"
                                                          YAxisId="StandardAxis"
                                                          Y1="{Binding UpperThreshold}">
                            <visuals:AnnotationLabel  TextFormatting="0"
                                                      FontSize="11"
                                                      FontFamily="Segoe UI"
                                                      Foreground="Black"
                                                      FontWeight="Bold"
                                                      LabelPlacement="Axis" />
                        </visuals:HorizontalLineAnnotation>
                        <visuals:HorizontalLineAnnotation HorizontalAlignment="Stretch"
                                                          AnnotationCanvas="BelowChart"
                                                          IsHidden="{Binding IsLowerThresholdVisible, Converter={StaticResource InvertBoolean}}"
                                                          Stroke="Gainsboro"
                                                          StrokeThickness="0.75"
                                                          XAxisId="IndicatorXAxis"
                                                          YAxisId="StandardAxis"
                                                          Y1="{Binding LowerThreshold}">
                            <visuals:AnnotationLabel  TextFormatting="0"
                                                      FontSize="11"
                                                      Foreground="Black"
                                                      FontFamily="Segoe UI"
                                                      FontWeight="Bold"
                                                      LabelPlacement="Axis" />
                        </visuals:HorizontalLineAnnotation>

The y1 value for each is set in Binding initially and once rendered can be manipulated by the user using a numeric up-down for each line.

Our problem is that when the lines are initially rendered they do not always display with the correct thickness (see Annotation Too Thin.png attached). When the line is subsequently moved using the numeric up-down to change its Y1 value the line then shows at the correct thickness.

We have tried snap to pixels to no effect and looked for, but did not find, anti-aliasing for annotation lines.

Could you point us in the right direction for this one please?

Thanks in advance
Ian Carson

Images
  • You must to post comments
0
0

If you set the line thickness to 0.75 (which you have), then WPF will try to render it between pixels. The result will be it will fade (become thicker/thinner) as you move it, as it spans pixels. Sometimes WPF will render it inside 1 pixel, sometimes spanning 2.

The best result to get a thin sharp line is to set line thickness to 1.0.

  • Ian Carson
    Hi Andrew Would that it were that simple! :) I just tried 1px and the -20 line (as per the previous attachments) disappears completely. Move it to -19 or -21 and it reappears (as a 1px line). This issue is not restricted to the negative value lines either. On other charts where the annotation Y1 value is positive I'm seeing the same issue. Not sure what's happening here at all. Regards Ian
  • Andrew Burnett-Thompson
    Ok so the lines disappearing also sounds like SnapToDevicePixels / UseLayoutRounding. WPF does strange things. Question: can you reproduce this in any of our examples? There is nothing magic we are doing here, just displaying a line on a canvas! Andrew
  • Ian Carson
    Hi Andrew It's not a perfect solution but by setting the Margin in the line annotation to (0,0.5,0,0.5) it solves the problem for where we want the lines to appear. SnapToDevicePixels not set, UseLayoutRounding not set. Regards Ian
  • Andrew Burnett-Thompson
    Ah, I remember seeing this elsewhere. Before when we were drawing Gridlines on the WPF canvas (now we use bitmaps), we had to set the pixel offset to 0.5 (e.g. draw at X=10.5, 20.5 not 10, 20) and set SnapsToDevicePixels/UseLayoutRounding=true to get the lines sharp. Beats me why in WPF you need 0.5 pixels to make a line snap to the nearest pixel but that seemed to work. You have discovered the same! Glad you got the problem sorted and sorry I couldn't be more help. Andrew
  • Ian Carson
    Hi Andrew No problem. Thanks for the followup. Regards Ian
  • You must to post comments
Showing 1 result
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