Hello
I’m working on a WPF app. Everything is OK except that I don’t understand how to render the series above the annotations.
The XAML code is the following:
<s:SciChartSurface Name="sciChartSurface"
s:ThemeManager.Theme="SciChartv4Dark"
Annotations="{Binding Path=Annotations}"
ChartTitle="{Binding Path=GraphTitle}"
DataContext="{Binding Path=ChartViewModel,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type charts:ChartView}}}"
FocusVisualStyle="{x:Null}"
Focusable="True"
SeriesSource="{Binding Path=Series}"
Padding="0 5 8 0">
<s:SciChartSurface.RenderSurface>
<s:HighQualityRenderSurface/>
</s:SciChartSurface.RenderSurface>
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
[...]
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
<!-- Create an X Axis -->
<s:SciChartSurface.XAxis>
<s:NumericAxis AutoRange="{Binding Path=XAxis.AutoScaling,
Converter={StaticResource BooleanToAutoRangeConverter}}"
AxisTitle="{Binding Path=XAxis.AxisTitle}"
DrawMajorGridLines="{Binding Path=XAxis.ShowGridLines}"
DrawMinorGridLines="False"
DrawMinorTicks="True"
GrowBy="0, 0.1"
AxisBandsFill="#1c1c1e"
VisibleRange="{Binding Path=XAxis.AxisRange,
Mode=TwoWay}"
MajorDelta="{Binding XAxis.MajorDelta, Mode=TwoWay}"
MinorDelta="{Binding XAxis.MinorDelta, Mode=TwoWay}"
AutoTicks="{Binding XAxis.AutoTicks}"
/>
</s:SciChartSurface.XAxis>
<!-- Create a Y Axis -->
<s:SciChartSurface.YAxis>
<s:NumericAxis AutoRange="{Binding Path=YAxis.AutoScaling,
Converter={StaticResource BooleanToAutoRangeConverter}}"
AxisAlignment="Left"
AxisTitle="{Binding Path=YAxis.AxisTitle}"
DrawMajorGridLines="{Binding Path=YAxis.ShowGridLines}"
DrawMinorGridLines="False"
DrawMinorTicks="True"
GrowBy="0.1, 0.1"
IsPrimaryAxis="True"
AxisBandsFill="#1c1c1e"
VisibleRange="{Binding Path=YAxis.AxisRange,
Mode=TwoWay}"
MajorDelta="{Binding YAxis.MajorDelta, Mode=TwoWay}"
MinorDelta="{Binding YAxis.MinorDelta, Mode=TwoWay}"
AutoTicks="{Binding YAxis.AutoTicks}"
/>
</s:SciChartSurface.YAxis>
</s:SciChartSurface>
Edit: this is the code that creates the horizontal annotation:
/// <summary>
/// Creates a chart annotation
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
private AnnotationBase CreateChartAnnotation(Annotation a)
{
HorizontalLineAnnotation annotation;
//not used??
//ColorToBrushConverter brushConverter = new ColorToBrushConverter();
annotation = new HorizontalLineAnnotation() { Y1 = a.ThresholdValue.Value };
annotation.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(a.Stroke));
annotation.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
annotation.IsEditable = false;
annotation.LabelTextFormatting = string.Format("{0} 0.0", a.Label);
annotation.StrokeThickness = 2;
annotation.LabelPlacement = LabelPlacement.Axis;
annotation.ShowLabel = a.ShowLabel;
if (a.DashArray != null)
{
annotation.StrokeDashArray = new DoubleCollection(a.DashArray);
}
return annotation;
}
I tried to set AnnotationCanvas.BelowChart but the behaviour is very strange: the horizontal annotation line is no more continuous
I attached two jpegs
Regards
Gianpaolo
- gianpaolo filippa asked 7 years ago
- last edited 7 years ago
- You must login to post comments
Hi there,
Thank you for your question. This is correct behavior. Unfortunately, SciChart doesn’t allow placing annotations above grid lines but below RenderableSeries. There is no way to workaround this.
What I can suggest is to set DrawMajorBands = false for the axis.
Best regards,
Taras B.
SciChart Developer
- Taras Bulka answered 7 years ago
- You must login to post comments
Please login first to submit.