diff --git a/Chart_GettingStarted/Chart_GettingStarted/ChartViewModel.cs b/Chart_GettingStarted/Chart_GettingStarted/ChartViewModel.cs deleted file mode 100644 index 7a5bb04..0000000 --- a/Chart_GettingStarted/Chart_GettingStarted/ChartViewModel.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Chart_GettingStarted -{ - public class ChartViewModel - { - public List Data { get; set; } - - public ChartViewModel() - { - Data = new List() - { - new Stage(){Name = "Stage A", Value=12}, - new Stage(){Name = "Stage B", Value=21}, - new Stage(){Name = "Stage C", Value=29}, - new Stage(){Name = "Stage D", Value=37}, - }; - } - } -} diff --git a/Chart_GettingStarted/Chart_GettingStarted/MainPage.xaml b/Chart_GettingStarted/Chart_GettingStarted/MainPage.xaml index 7411659..9171a95 100644 --- a/Chart_GettingStarted/Chart_GettingStarted/MainPage.xaml +++ b/Chart_GettingStarted/Chart_GettingStarted/MainPage.xaml @@ -6,18 +6,18 @@ x:Class="Chart_GettingStarted.MainPage"> - + - + diff --git a/Chart_GettingStarted/Chart_GettingStarted/Stage.cs b/Chart_GettingStarted/Chart_GettingStarted/StageModel.cs similarity index 89% rename from Chart_GettingStarted/Chart_GettingStarted/Stage.cs rename to Chart_GettingStarted/Chart_GettingStarted/StageModel.cs index fc7762d..2287b31 100644 --- a/Chart_GettingStarted/Chart_GettingStarted/Stage.cs +++ b/Chart_GettingStarted/Chart_GettingStarted/StageModel.cs @@ -6,7 +6,7 @@ namespace Chart_GettingStarted { - public class Stage + public class StageModel { public string Name { get; set; } public double Value { get; set; } diff --git a/Chart_GettingStarted/Chart_GettingStarted/StageViewModel.cs b/Chart_GettingStarted/Chart_GettingStarted/StageViewModel.cs new file mode 100644 index 0000000..fce12df --- /dev/null +++ b/Chart_GettingStarted/Chart_GettingStarted/StageViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Chart_GettingStarted +{ + public class StageViewModel + { + public List Data { get; set; } + + public StageViewModel() + { + Data = new List() + { + new StageModel(){Name = "Stage A", Value=12}, + new StageModel(){Name = "Stage B", Value=21}, + new StageModel(){Name = "Stage C", Value=29}, + new StageModel(){Name = "Stage D", Value=37}, + }; + } + } +} diff --git a/README.md b/README.md index 0b1ee9c..d578594 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ public partial class MainWindow : ContentPage { this.InitializeComponent(); SfPyramidChart chart = new SfPyramidChart(); + this.Content = chart; } } ``` @@ -72,38 +73,38 @@ Now, let us define a simple data model that represents a data point in the chart **[C#]** ``` - public class Stage + public class StageModel { public string Name { get; set; } public double Value { get; set; } } ``` -Next, create a view model class and initialize a list of `Model` objects as follows. +Next, create a StageViewModel class and initialize a list of `StageModel` objects as follows. **[C#]** ``` -public class ChartViewModel +public class StageViewModel { - public List Data { get; set; } + public List Data { get; set; } - public ChartViewModel() + public StageViewModel() { - Data = new List() + Data = new List() { - new Stage(){Name = "Stage A", Value = 12}, - new Stage(){Name = "Stage B", Value = 21}, - new Stage(){Name = "Stage C", Value = 29}, - new Stage(){Name = "Stage D", Value = 37}, + new StageModel(){Name = "Stage A", Value = 12}, + new StageModel(){Name = "Stage B", Value = 21}, + new StageModel(){Name = "Stage C", Value = 29}, + new StageModel(){Name = "Stage D", Value = 37}, }; } } ``` -Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `ViewModel` class. +Create a `StageViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `StageViewModel` class. > **_Note:_** -Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML. +Add the namespace of `StageViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML. **[XAML]** ``` @@ -114,7 +115,7 @@ Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set ` - + @@ -122,8 +123,10 @@ Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set ` **[C#]** ``` -ChartViewModel viewModel = new ChartViewModel(); +SfPyramidChart chart = new SfPyramidChart(); +StageViewModel viewModel = new StageViewModel(); chart.BindingContext = viewModel; +this.Content = chart; ``` ## Populate chart with data @@ -142,7 +145,7 @@ chart.BindingContext = viewModel; **[C#]** ``` SfPyramidChart chart = new SfPyramidChart(); -ChartViewModel viewModel = new ChartViewModel(); +StageViewModel viewModel = new StageViewModel(); chart.BindingContext = viewModel; chart.ItemsSource = viewModel.Data; chart.XBindingPath = "Name"; @@ -243,7 +246,7 @@ The following code example gives you the complete code of above configurations.