|
| 1 | +<Window x:Class="DynamicTargetLineSample.MainWindow" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 5 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 6 | + xmlns:local="clr-namespace:DynamicTargetLineSample" |
| 7 | + xmlns:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF" |
| 8 | + mc:Ignorable="d" |
| 9 | + Title="MainWindow" Height="450" Width="800"> |
| 10 | + |
| 11 | + <Window.DataContext> |
| 12 | + <local:ViewModel x:Name="viewModel"/> |
| 13 | + </Window.DataContext> |
| 14 | + |
| 15 | + <Grid> |
| 16 | + <Grid.ColumnDefinitions> |
| 17 | + <ColumnDefinition Width="*"></ColumnDefinition> |
| 18 | + <ColumnDefinition Width="200"></ColumnDefinition> |
| 19 | + </Grid.ColumnDefinitions> |
| 20 | + |
| 21 | + <chart:SfChart Grid.Column="0"> |
| 22 | + |
| 23 | + <chart:SfChart.PrimaryAxis> |
| 24 | + <chart:CategoryAxis EdgeLabelsDrawingMode="Fit" ShowGridLines="False" Header="Months"/> |
| 25 | + </chart:SfChart.PrimaryAxis> |
| 26 | + |
| 27 | + <chart:SfChart.SecondaryAxis> |
| 28 | + <chart:NumericalAxis x:Name="Y_Axis" Minimum="0" Maximum="20000" Interval="5000" ShowGridLines="False" Header="Revenue" LabelFormat="'$'0" PlotOffsetEnd="30"/> |
| 29 | + </chart:SfChart.SecondaryAxis> |
| 30 | + |
| 31 | + <chart:SfChart.Annotations> |
| 32 | + <chart:HorizontalLineAnnotation Y1="{Binding Y1}" |
| 33 | + Stroke="Black" |
| 34 | + StrokeThickness="2" |
| 35 | + StrokeDashArray="5,2,2" |
| 36 | + Text="Target" |
| 37 | + FontSize="14" |
| 38 | + FontWeight="Bold" |
| 39 | + HorizontalTextAlignment="Left" |
| 40 | + VerticalTextAlignment="Top"> |
| 41 | + </chart:HorizontalLineAnnotation> |
| 42 | + </chart:SfChart.Annotations> |
| 43 | + |
| 44 | + <chart:ColumnSeries ItemsSource="{Binding Data}" |
| 45 | + XBindingPath="Months" |
| 46 | + YBindingPath="Revenue" |
| 47 | + Palette="Custom" |
| 48 | + Opacity="0.7"> |
| 49 | + <chart:ColumnSeries.ColorModel> |
| 50 | + <chart:ChartColorModel> |
| 51 | + <chart:ChartColorModel.CustomBrushes> |
| 52 | + <SolidColorBrush Color="#FF4500"/> |
| 53 | + <SolidColorBrush Color="#1E90FF"/> |
| 54 | + <SolidColorBrush Color="#32CD32"/> |
| 55 | + <SolidColorBrush Color="#FFD700"/> |
| 56 | + <SolidColorBrush Color="#FF1493"/> |
| 57 | + <SolidColorBrush Color="#9400D3"/> |
| 58 | + <SolidColorBrush Color="#00CED1"/> |
| 59 | + </chart:ChartColorModel.CustomBrushes> |
| 60 | + </chart:ChartColorModel> |
| 61 | + </chart:ColumnSeries.ColorModel> |
| 62 | + </chart:ColumnSeries> |
| 63 | + |
| 64 | + </chart:SfChart> |
| 65 | + |
| 66 | + <StackPanel Orientation="Vertical" Margin="10" Grid.Column="1"> |
| 67 | + <TextBlock Text="Adjust Target Line" FontSize="16" FontWeight="Bold" TextAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,20"/> |
| 68 | + <TextBox Text="{Binding Y1}" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextChanged="TextBox_TextChanged" Margin="0,0,0,20" Padding="10"/> |
| 69 | + <Slider Minimum="{Binding Minimum, Source={x:Reference Y_Axis}}" |
| 70 | + Maximum="{Binding Maximum, Source={x:Reference Y_Axis}}" |
| 71 | + Value="{Binding Y1}" HorizontalAlignment="Stretch"/> |
| 72 | + </StackPanel> |
| 73 | + </Grid> |
| 74 | +</Window> |
0 commit comments