diff --git a/Circular_chart_sample/CircularChartSample/MainPage.xaml b/Circular_chart_sample/CircularChartSample/MainPage.xaml index 8aba295..fd026ad 100644 --- a/Circular_chart_sample/CircularChartSample/MainPage.xaml +++ b/Circular_chart_sample/CircularChartSample/MainPage.xaml @@ -13,7 +13,7 @@ - + diff --git a/Circular_chart_sample/CircularChartSample/ViewModel.cs b/Circular_chart_sample/CircularChartSample/ViewModel.cs index 1d7b98c..46b557d 100644 --- a/Circular_chart_sample/CircularChartSample/ViewModel.cs +++ b/Circular_chart_sample/CircularChartSample/ViewModel.cs @@ -6,23 +6,23 @@ namespace CircularChartSample { - public class ViewModel - { - public List Data { get; set; } + public class SalesViewModel + { + public List Data { get; set; } - public ViewModel() - { - Data = new List() + public SalesViewModel() { - new Sales(){Product = "iPad", SalesRate = 70}, - new Sales(){Product = "iPhone", SalesRate = 65}, - new Sales(){Product = "MacBook", SalesRate = 60}, - new Sales(){Product = "Mac", SalesRate = 55}, - new Sales(){Product = "Others", SalesRate = 50}, - }; + Data = new List() + { + new SalesModel(){Product = "iPad", SalesRate = 70}, + new SalesModel(){Product = "iPhone", SalesRate = 65}, + new SalesModel(){Product = "MacBook", SalesRate = 60}, + new SalesModel(){Product = "Mac", SalesRate = 55}, + new SalesModel(){Product = "Others", SalesRate = 50}, + }; } } - public class Sales + public class SalesModel { public string Product { get; set; } public double SalesRate { get; set; } diff --git a/README.md b/README.md index e311ff1..c81779a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ public partial class MainWindow : ContentPage { this.InitializeComponent(); SfCircularChart chart = new SfCircularChart(); + this.Content = chart; } } ``` @@ -70,37 +71,37 @@ namespace ChartGettingStarted Now, let us define a simple data model that represents a data point in the chart. ###### C# ```C# -public class Sales +public class SalesModel { public string Product { get; set; } public double SalesRate { get; set; } } ``` -Next, create a view model class and initialize a list of `Model` objects as follows. +Next, create a SalesViewModel class and initialize a list of `SalesModel` objects as follows. ###### ```C# -public class ChartViewModel +public class SalesViewModel { - public List Data { get; set; } + public List Data { get; set; } - public ChartViewModel() + public SalesViewModel() { - Data = new List() + Data = new List() { - new Sales(){Product = "iPad", SalesRate = 25}, - new Sales(){Product = "iPhone", SalesRate = 35}, - new Sales(){Product = "MacBook", SalesRate = 15}, - new Sales(){Product = "Mac", SalesRate = 5}, - new Sales(){Product = "Others", SalesRate = 10}, + new SalesModel(){Product = "iPad", SalesRate = 25}, + new SalesModel(){Product = "iPhone", SalesRate = 35}, + new SalesModel(){Product = "MacBook", SalesRate = 15}, + new SalesModel(){Product = "Mac", SalesRate = 5}, + new SalesModel(){Product = "Others", SalesRate = 10}, }; } } ``` -* Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `ViewModel` class. +* Create a `SalesViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `SalesViewModel` class. -* Add namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML. +* Add namespace of `SalesViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML. ###### Xaml ```xaml - + ``` ###### C# ```C# -ChartViewModel viewModel = new ChartViewModel(); -chart.BindingContext = viewModel; +SfCircularChart chart = new SfCircularChart(); +this.BindingContext = new SalesViewModel(); +this.Content = chart; ``` ## Populate chart with data @@ -141,7 +143,7 @@ Adding [PieSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.Pi ###### C# ```C# SfCircularChart chart = new SfCircularChart(); -ChartViewModel viewModel = new ChartViewModel(); +SalesViewModel viewModel = new SalesViewModel(); chart.BindingContext = viewModel; PieSeries series = new PieSeries(); series.ItemsSource = viewModel.Data; @@ -240,7 +242,7 @@ The following code example gives you the complete code of above configurations.