|
| 1 | +<?xml version="1.0" encoding="utf-8" ?> |
| 2 | +<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
| 4 | + xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts" |
| 5 | + xmlns:local="clr-namespace:TargetLineSample" |
| 6 | + x:Class="TargetLineSample.MainPage"> |
| 7 | + |
| 8 | + <Grid> |
| 9 | + <Grid.ColumnDefinitions> |
| 10 | + <ColumnDefinition Width="*"></ColumnDefinition> |
| 11 | + <ColumnDefinition Width="200"></ColumnDefinition> |
| 12 | + </Grid.ColumnDefinitions> |
| 13 | + |
| 14 | + <Grid.BindingContext> |
| 15 | + <local:ViewModel x:Name="viewModel"/> |
| 16 | + </Grid.BindingContext> |
| 17 | + |
| 18 | + <chart:SfCartesianChart Grid.Column="0"> |
| 19 | + |
| 20 | + <chart:SfCartesianChart.XAxes> |
| 21 | + <chart:CategoryAxis ShowMajorGridLines="False"> |
| 22 | + <chart:CategoryAxis.Title> |
| 23 | + <chart:ChartAxisTitle Text="Months"/> |
| 24 | + </chart:CategoryAxis.Title> |
| 25 | + </chart:CategoryAxis> |
| 26 | + </chart:SfCartesianChart.XAxes> |
| 27 | + |
| 28 | + <chart:SfCartesianChart.YAxes> |
| 29 | + <chart:NumericalAxis x:Name="Y_Axis" Minimum="0" Maximum="20000" Interval="5000" ShowMajorGridLines="False"> |
| 30 | + <chart:NumericalAxis.Title> |
| 31 | + <chart:ChartAxisTitle Text="Revenue"/> |
| 32 | + </chart:NumericalAxis.Title> |
| 33 | + <chart:NumericalAxis.LabelStyle> |
| 34 | + <chart:ChartAxisLabelStyle LabelFormat="'$'0"/> |
| 35 | + </chart:NumericalAxis.LabelStyle> |
| 36 | + </chart:NumericalAxis> |
| 37 | + </chart:SfCartesianChart.YAxes> |
| 38 | + |
| 39 | + <chart:SfCartesianChart.Annotations> |
| 40 | + <chart:HorizontalLineAnnotation Y1="{Binding Y1}" |
| 41 | + Stroke="Black" |
| 42 | + StrokeWidth="2" |
| 43 | + StrokeDashArray="5,2,2" |
| 44 | + Text="Target"> |
| 45 | + <chart:HorizontalLineAnnotation.LabelStyle> |
| 46 | + <chart:ChartAnnotationLabelStyle TextColor="Black" FontSize="14" FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/> |
| 47 | + </chart:HorizontalLineAnnotation.LabelStyle> |
| 48 | + </chart:HorizontalLineAnnotation> |
| 49 | + </chart:SfCartesianChart.Annotations> |
| 50 | + |
| 51 | + <chart:ColumnSeries ItemsSource="{Binding Data}" |
| 52 | + XBindingPath="Months" |
| 53 | + YBindingPath="Revenue" |
| 54 | + PaletteBrushes="{Binding CustomBrushes}" |
| 55 | + Opacity="0.7"/> |
| 56 | + |
| 57 | + </chart:SfCartesianChart> |
| 58 | + |
| 59 | + <VerticalStackLayout Spacing="5" Grid.Column="1" Padding="10"> |
| 60 | + <Label Text="Adjust Target Line" FontSize="16" FontAttributes="Bold" HorizontalOptions="Center"/> |
| 61 | + <Entry Text="{Binding Y1}" Keyboard="Numeric" TextChanged="Entry_TextChanged"/> |
| 62 | + <Slider Minimum="{Binding Minimum, Source={x:Reference Y_Axis}}" Maximum="{Binding Maximum, Source={x:Reference Y_Axis}}" Value="{Binding Y1}"/> |
| 63 | + </VerticalStackLayout> |
| 64 | + </Grid> |
| 65 | + |
| 66 | +</ContentPage> |
0 commit comments