Pre loader

Borders for line annotations

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

Hello again,

I would like to ask if there is a way to give a border (stroke and thickness) to horizontal and vertical line annotations.

I assume it has something to do with setting the WPF-style of the annotation element, but I’m running into a lot of errors while experimenting with this approach.

Is there an easy-to-understand example around?

Thank you verry much.

Version
v6.6.0.26505
  • You must to post comments
1
0

Hi Mark,

A LineAnnotation internally uses a System.Windows.Shapes.Line to render the actual line, and this type doesn’t have a border associated with it.

Here’s the ControlTemplate for the LineAnnotation:

<ControlTemplate x:Key="LineAnnotationTemplate" TargetType="a:LineAnnotation">
    <Grid x:Name="PART_LineAnnotationRoot">
        <Line
            x:Name="PART_GhostLine"
            Stroke="Transparent"
            StrokeThickness="{x:Static visuals:ManipulationMargins.AnnotationLineWidth}" />
        <Line
            x:Name="PART_Line"
            Stroke="{TemplateBinding Stroke}"
            StrokeDashArray="{TemplateBinding StrokeDashArray}"
            StrokeThickness="{TemplateBinding StrokeThickness}" 
            StrokeStartLineCap="{TemplateBinding StrokeStartLineCap}"
            StrokeEndLineCap="{TemplateBinding StrokeEndLineCap}"/>
    </Grid>
</ControlTemplate>

and style for LineAnnotation

<Style BasedOn="{StaticResource AnnotationBaseStyle}" TargetType="a:LineAnnotation">
    <Setter Property="Stroke" Value="{me:ThemeBinding RubberBandStrokeBrush}" />
    <Setter Property="StrokeThickness" Value="2.0" />
    <Setter Property="Template" Value="{StaticResource LineAnnotationTemplate}" />
</Style>

I’m not sure you could alter this to use a Border type as SciChart is expecting PART_Line in the ControlTemplate to be of type Line, which has X1 X2 Y1 Y2 properties. Border doesn’t have these.

Curious what visual effect you’re trying to achieve (and what requirement / why?) We may be able to find an alternative solution.

Best regards,
Andrew

  • Marc Vahldieck
    I answered in another reply so I could attach am image.
  • You must to post comments
1
0

I understand, so it’s a little bit more complicated.

I experimented with the Box-Annotation. Is it possible to make the Box editable/drag-able in only one direction (for example, only dragging the box along the x-Axis) but disable the usage of the four “corner points”? Because, the “corner points” still allow for the box to be edited in x/y-direction.

Regarding the visual effect, we are trying to work closely long the visual design guideline our employer gave us. I have attached an example. As you can see, the central vertical bar in the image has a black border and an orange core.

If you can suggest an alternative, I’m all ears.

Images
  • You must to post comments
0
0

OK great to have a little more context to work with

BoxAnnotation (any annotation) can be restricted to resizing in one direction by setting the Annotation.ResizeDirections property. You can limit dragging as well by setting Annotation.DragDirections property.

You may also find the CompositeAnnotation feature useful. This lets you group annotations (e.g. thick line, with 2 thin lines at edges) and have X1 X2 Y1 Y2, dragging, resizing and placement like a normal annotation.

There’s some cool examples such as creating effects like this:

enter image description here

Does this give you enough to work with?

Best regards
Andrew

  • Marc Vahldieck
    Yes, definitely. I was not aware of the “ResizeDirections” and “CompositeAnnotation”. Both look promising. Thank you verry much.
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.