|
| 1 | +<Window x:Class="ChartSample.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:ChartSample" |
| 7 | + xmlns:chart="http://schemas.syncfusion.com/wpf" |
| 8 | + xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" |
| 9 | + mc:Ignorable="d" |
| 10 | + Title="MainWindow" Height="600" Width="800"> |
| 11 | + <Window.Resources> |
| 12 | + |
| 13 | + <chart:ChartColorModel x:Key="CustomColor"> |
| 14 | + <chart:ChartColorModel.CustomBrushes> |
| 15 | + <SolidColorBrush Color="#0078DE" /> |
| 16 | + <SolidColorBrush Color="#00CC6A" /> |
| 17 | + <SolidColorBrush Color="#B146C2" /> |
| 18 | + <SolidColorBrush Color="#FFB900" /> |
| 19 | + <SolidColorBrush Color="#7A7574" /> |
| 20 | + <SolidColorBrush Color="#7200E6" /> |
| 21 | + <SolidColorBrush Color="#007F00" /> |
| 22 | + <SolidColorBrush Color="#FA9901" /> |
| 23 | + </chart:ChartColorModel.CustomBrushes> |
| 24 | + </chart:ChartColorModel> |
| 25 | + </Window.Resources> |
| 26 | + |
| 27 | + <Window.DataContext> |
| 28 | + <local:ViewModel x:Name="viewModel"/> |
| 29 | + </Window.DataContext> |
| 30 | + |
| 31 | + <Grid Margin="10"> |
| 32 | + <Grid.RowDefinitions> |
| 33 | + <RowDefinition Height="Auto"/> |
| 34 | + <RowDefinition Height="Auto"/> |
| 35 | + <RowDefinition /> |
| 36 | + </Grid.RowDefinitions> |
| 37 | + <Border Grid.Row="0" > |
| 38 | + <TextBlock Text="Create beautiful charts using JSON data in WPF" Margin="10" TextAlignment="Center" FontSize="20" /> |
| 39 | + </Border> |
| 40 | + <Border Grid.Row="1"> |
| 41 | + |
| 42 | + <Border Margin="2" CornerRadius="20" BorderBrush="Gray" BorderThickness="1" Grid.Column="0"> |
| 43 | + <StackPanel Orientation="Vertical"> |
| 44 | + <Grid> |
| 45 | + <TextBox x:Name="JsonBox" Margin="10" Height="150" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" TextAlignment="Left" MaxLength="50000" IsReadOnly="False" AcceptsReturn="True" /> |
| 46 | + <TextBlock IsHitTestVisible="False" FontSize="16" Margin="10" Height="150" Text="To start, paste your JSON data or web service link. As you make text changes, the data will be processed and verified." TextWrapping="Wrap" TextAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Gray"> |
| 47 | + <TextBlock.Style> |
| 48 | + <Style TargetType="{x:Type TextBlock}"> |
| 49 | + <Setter Property="Visibility" Value="Collapsed"/> |
| 50 | + <Style.Triggers> |
| 51 | + <DataTrigger Binding="{Binding Text, ElementName=JsonBox}" Value=""> |
| 52 | + <Setter Property="Visibility" Value="Visible"/> |
| 53 | + </DataTrigger> |
| 54 | + </Style.Triggers> |
| 55 | + </Style> |
| 56 | + </TextBlock.Style> |
| 57 | + </TextBlock> |
| 58 | + </Grid> |
| 59 | + <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> |
| 60 | + <Button Margin="5" Background="LightBlue" Click="LoadJson" Width="150" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Content="Load Example Data" /> |
| 61 | + <Button Margin="5" Background="LightBlue" Content="Generate Chart" HorizontalContentAlignment="Center" Width="150" Click="PrepareChart"> |
| 62 | + </Button> |
| 63 | + </StackPanel> |
| 64 | + </StackPanel> |
| 65 | + </Border> |
| 66 | + </Border> |
| 67 | + <Grid Grid.Row="2"> |
| 68 | + <Grid.ColumnDefinitions> |
| 69 | + <ColumnDefinition Width="*"/> |
| 70 | + <ColumnDefinition Width="250"/> |
| 71 | + </Grid.ColumnDefinitions> |
| 72 | + <Border Margin="2" CornerRadius="20" BorderBrush="Gray" BorderThickness="1" Grid.Column="0"> |
| 73 | + <TabControl Margin="10" Name="tab" > |
| 74 | + <TabItem> |
| 75 | + <TabItem.Header> |
| 76 | + <StackPanel Orientation="Horizontal" Margin="2"> |
| 77 | + <Image Source="/ChartSample;component/ImageIcons/bar_icon.png" Width="10" Height="10" Margin="2"/> |
| 78 | + <TextBlock Text="Column"/> |
| 79 | + </StackPanel> |
| 80 | + </TabItem.Header> |
| 81 | + <chart:SfChart Background="White"> |
| 82 | + <chart:SfChart.PrimaryAxis> |
| 83 | + <chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False" /> |
| 84 | + </chart:SfChart.PrimaryAxis> |
| 85 | + |
| 86 | + <chart:SfChart.SecondaryAxis> |
| 87 | + <chart:NumericalAxis/> |
| 88 | + </chart:SfChart.SecondaryAxis> |
| 89 | + |
| 90 | + <chart:FastColumnBitmapSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom"/> |
| 91 | + </chart:SfChart> |
| 92 | + </TabItem> |
| 93 | + <TabItem> |
| 94 | + <TabItem.Header> |
| 95 | + <StackPanel Orientation="Horizontal" Margin="2"> |
| 96 | + <Image Source="/ChartSample;component/ImageIcons/line_icon.png" Width="10" Height="10" Margin="2"/> |
| 97 | + <TextBlock Text="Line"/> |
| 98 | + </StackPanel> |
| 99 | + </TabItem.Header> |
| 100 | + <chart:SfChart Background="White" ColorModel="{StaticResource CustomColor}" Palette="Custom"> |
| 101 | + <chart:SfChart.PrimaryAxis> |
| 102 | + <chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False"/> |
| 103 | + </chart:SfChart.PrimaryAxis> |
| 104 | + |
| 105 | + <chart:SfChart.SecondaryAxis> |
| 106 | + <chart:NumericalAxis /> |
| 107 | + </chart:SfChart.SecondaryAxis> |
| 108 | + |
| 109 | + <chart:FastLineSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" /> |
| 110 | + </chart:SfChart> |
| 111 | + </TabItem> |
| 112 | + <TabItem> |
| 113 | + <TabItem.Header> |
| 114 | + <StackPanel Orientation="Horizontal" Margin="2"> |
| 115 | + <Image Source="/ChartSample;component/ImageIcons/bar_icon.png" Width="10" Height="10" Margin="2"/> |
| 116 | + <TextBlock Text="Bar"/> |
| 117 | + </StackPanel> |
| 118 | + </TabItem.Header> |
| 119 | + <chart:SfChart Background="White"> |
| 120 | + <chart:SfChart.PrimaryAxis> |
| 121 | + <chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False"/> |
| 122 | + </chart:SfChart.PrimaryAxis> |
| 123 | + |
| 124 | + <chart:SfChart.SecondaryAxis> |
| 125 | + <chart:NumericalAxis /> |
| 126 | + </chart:SfChart.SecondaryAxis> |
| 127 | + <chart:FastBarBitmapSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom"/> |
| 128 | + </chart:SfChart> |
| 129 | + </TabItem> |
| 130 | + <TabItem> |
| 131 | + <TabItem.Header> |
| 132 | + <StackPanel Orientation="Horizontal" Margin="2"> |
| 133 | + <Image Source="/ChartSample;component/ImageIcons/scatter_icon.png" Width="10" Height="10" Margin="2"/> |
| 134 | + <TextBlock Text="Scatter"/> |
| 135 | + </StackPanel> |
| 136 | + </TabItem.Header> |
| 137 | + <chart:SfChart Background="White"> |
| 138 | + <chart:SfChart.PrimaryAxis> |
| 139 | + <chart:CategoryAxis LabelPlacement="BetweenTicks" ShowGridLines="False"/> |
| 140 | + </chart:SfChart.PrimaryAxis> |
| 141 | + |
| 142 | + <chart:SfChart.SecondaryAxis> |
| 143 | + <chart:NumericalAxis /> |
| 144 | + </chart:SfChart.SecondaryAxis> |
| 145 | + |
| 146 | + <chart:ScatterSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom" > |
| 147 | + |
| 148 | + </chart:ScatterSeries> |
| 149 | + </chart:SfChart> |
| 150 | + </TabItem> |
| 151 | + <TabItem> |
| 152 | + <TabItem.Header> |
| 153 | + <StackPanel Orientation="Horizontal" Margin="2"> |
| 154 | + <Image Source="/ChartSample;component/ImageIcons/pie_icon.png" Width="10" Height="10" Margin="2"/> |
| 155 | + <TextBlock Text="Pie"/> |
| 156 | + </StackPanel> |
| 157 | + </TabItem.Header> |
| 158 | + <chart:SfChart > |
| 159 | + |
| 160 | + <chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="{Binding XBindingPath}" YBindingPath="{Binding YBindingPath}" ColorModel="{StaticResource CustomColor}" Palette="Custom" /> |
| 161 | + </chart:SfChart> |
| 162 | + </TabItem> |
| 163 | + </TabControl> |
| 164 | + </Border> |
| 165 | + <Border Margin="2" CornerRadius="20" BorderBrush="Gray" BorderThickness="1" Grid.Column="1"> |
| 166 | + <StackPanel Margin="2" Orientation="Vertical"> |
| 167 | + <TextBlock HorizontalAlignment="Center" Text="Data" FontSize="20" Margin="5"/> |
| 168 | + <TextBlock Text="Select X Value" FontSize="12" Margin="5"/> |
| 169 | + <ComboBox Text="XBindingPath" Margin="5" ItemsSource="{Binding XColumns}" SelectedIndex="0" SelectedItem="{Binding XBindingPath,Mode=TwoWay}" /> |
| 170 | + <TextBlock Text="Select Y Value" FontSize="12" Margin="5"/> |
| 171 | + <ComboBox Text="XBindingPath" Margin="5" ItemsSource="{Binding YColumns}" SelectedIndex="0" SelectedItem="{Binding YBindingPath,Mode=TwoWay}" /> |
| 172 | + <Button Margin="5,30,5,5" HorizontalContentAlignment="Center" Width="200" Background="LightBlue" Content="Download Image" Click="Button_Click"/> |
| 173 | + </StackPanel> |
| 174 | + </Border> |
| 175 | + |
| 176 | + </Grid> |
| 177 | + </Grid> |
| 178 | +</Window> |
0 commit comments