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

0
0

for HorizontalLineAnnoataion and VerticalLineAnnotation, if the LabelPlacement is set to values other than Auto or Axis, the label is still seen even the ShowLabel is set to false.

Here is the source code
Xaml

<sc:SciChartSurface.XAxis>

</sc:SciChartSurface.XAxis>
<sc:SciChartSurface.YAxis>

</sc:SciChartSurface.YAxis>

        <sc:SciChartSurface.Annotations>
            <sc:VerticalLineAnnotation VerticalAlignment="Stretch" x:Name="V1"
                                      FontSize="12"
                                      FontWeight="Bold"
                                      ShowLabel="True"
                                      Stroke="Brown"
                                      StrokeThickness="2"
                                      X1="9" LabelPlacement="Auto"
                                      Y1="4" />

            <sc:HorizontalLineAnnotation HorizontalAlignment="Stretch" x:Name="H1"
                                        FontSize="12"
                                        FontWeight="Bold"
                                        LabelPlacement="TopLeft"
                                        ShowLabel="True"
                                        Stroke="Orange"
                                        StrokeThickness="2"
                                        X1="7"
                                        Y1="2.8" />
        </sc:SciChartSurface.Annotations>
    </sc:SciChartSurface>
    <UniformGrid Rows="1" VerticalAlignment="Top" HorizontalAlignment="Right">
        <CheckBox IsChecked="{Binding ElementName=H1, Path=ShowLabel}" Foreground="White"  Margin="3">
            <CheckBox.Content>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="H1" VerticalAlignment="Center"/>
                    <ComboBox ItemsSource="{Binding Source={x:Static local:MainWindow.LabelPlacements}}" SelectedItem="{Binding ElementName=H1, Path=LabelPlacement}" />
                </StackPanel>
            </CheckBox.Content>
        </CheckBox>
        <CheckBox IsChecked="{Binding ElementName=V1, Path=ShowLabel}" Foreground="White" Margin="3">
            <CheckBox.Content>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="V1" VerticalAlignment="Center"/>
                    <ComboBox ItemsSource="{Binding Source={x:Static local:MainWindow.LabelPlacements}}" SelectedItem="{Binding ElementName=V1, Path=LabelPlacement}" />
                </StackPanel>
            </CheckBox.Content>
        </CheckBox>
    </UniformGrid>
</Grid>

And the cs
using SciChart.Charting.Visuals.Annotations;
using System;
using System.Windows;

namespace SciChartLineAnnotation
{
///

/// Interaction logic for MainWindow.xaml
///

public partial class MainWindow : Window
{
public static LabelPlacement[] LabelPlacements { get; private set; }

    static MainWindow()
    {
        Array array = System.Enum.GetValues(typeof(LabelPlacement));
        LabelPlacements = new LabelPlacement[array.Length];
        int idx = 0;
        foreach(var item in array)
        {
            LabelPlacements[idx++] = (LabelPlacement)item;
        }
    }

    public MainWindow()
    {
        InitializeComponent();
    }
}

}

Version
5.0.0.10963
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.