|
| 1 | +<Window x:Class="Custom_BarChart.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:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF" |
| 7 | + xmlns:local="clr-namespace:Custom_BarChart" |
| 8 | + mc:Ignorable="d" |
| 9 | + Title="MainWindow" Height="450" Width="800"> |
| 10 | + |
| 11 | + <Grid> |
| 12 | + <Grid.DataContext> |
| 13 | + <local:ViewModel/> |
| 14 | + </Grid.DataContext> |
| 15 | + |
| 16 | + <Grid.Resources> |
| 17 | + <local:InteriorConverter x:Key="interiorConverter"/> |
| 18 | + </Grid.Resources> |
| 19 | + |
| 20 | + <chart:SfChart Margin="10"> |
| 21 | + |
| 22 | + <chart:SfChart.PrimaryAxis> |
| 23 | + <chart:CategoryAxis LabelFormat="yyyy"></chart:CategoryAxis> |
| 24 | + </chart:SfChart.PrimaryAxis> |
| 25 | + |
| 26 | + <chart:SfChart.SecondaryAxis> |
| 27 | + <chart:NumericalAxis></chart:NumericalAxis> |
| 28 | + </chart:SfChart.SecondaryAxis> |
| 29 | + |
| 30 | + <chart:ColumnSeries XBindingPath="Year" YBindingPath="India" ItemsSource="{Binding DataPoints}"> |
| 31 | + <chart:ColumnSeries.CustomTemplate> |
| 32 | + <DataTemplate> |
| 33 | + <Canvas> |
| 34 | + <Rectangle Fill="{Binding Converter={StaticResource interiorConverter}}" Height="{Binding Height}" Width="{Binding Width}" Canvas.Left="{Binding RectX}" Canvas.Top="{Binding RectY}"></Rectangle> |
| 35 | + </Canvas> |
| 36 | + </DataTemplate> |
| 37 | + </chart:ColumnSeries.CustomTemplate> |
| 38 | + <chart:ColumnSeries.AdornmentsInfo> |
| 39 | + <chart:ChartAdornmentInfo AdornmentsPosition="TopAndBottom" LabelPosition="Center" SegmentLabelContent="LabelContentPath" ShowLabel="True" > |
| 40 | + <chart:ChartAdornmentInfo.LabelTemplate> |
| 41 | + <DataTemplate> |
| 42 | + <StackPanel Orientation="Horizontal"> |
| 43 | + <Label Content="{Binding Item.India}" Foreground="White" FontSize="11"></Label> |
| 44 | + </StackPanel> |
| 45 | + </DataTemplate> |
| 46 | + </chart:ChartAdornmentInfo.LabelTemplate> |
| 47 | + </chart:ChartAdornmentInfo> |
| 48 | + </chart:ColumnSeries.AdornmentsInfo> |
| 49 | + </chart:ColumnSeries> |
| 50 | + |
| 51 | + </chart:SfChart> |
| 52 | + </Grid> |
| 53 | + |
| 54 | +</Window> |
0 commit comments