SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & 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!

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 AndrewWould 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
    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 AndrewIt'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
    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 AndrewNo problem. Thanks for the followup.Regards Ian
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.