Skip to content

Commit 2a0593e

Browse files
Merge pull request #3 from SyncfusionExamples/917099-Update-GettingStarted_FunnelChart_MAUI_sample
917099-Updated Getting Started Funnel Chart MAUI sample
2 parents 5340929 + ca4426d commit 2a0593e

5 files changed

Lines changed: 47 additions & 45 deletions

File tree

Chart_GettingStarted/Chart_GettingStarted/Admission.cs renamed to Chart_GettingStarted/Chart_GettingStarted/AdmissionModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Chart_GettingStarted
88
{
9-
public class Admission
9+
public class AdmissionModel
1010
{
1111
public string XValue { get; set; }
1212
public double YValue { get; set; }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Chart_GettingStarted
8+
{
9+
public class AdmissionViewModel
10+
{
11+
public List<AdmissionModel> Data { get; set; }
12+
13+
public AdmissionViewModel()
14+
{
15+
Data = new List<AdmissionModel>()
16+
{
17+
new AdmissionModel() {XValue = "Enrolled", YValue=175},
18+
new AdmissionModel() {XValue = "Admits", YValue=190},
19+
new AdmissionModel() {XValue = "Applicants", YValue=245},
20+
new AdmissionModel() {XValue = "Inquiries ", YValue=290},
21+
new AdmissionModel() {XValue = "Prospects ", YValue=320},
22+
};
23+
}
24+
}
25+
}

Chart_GettingStarted/Chart_GettingStarted/ChartViewModel.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

Chart_GettingStarted/Chart_GettingStarted/MainPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</chart:SfFunnelChart.Title>
1717

1818
<chart:SfFunnelChart.BindingContext>
19-
<model:ChartViewModel/>
19+
<model:AdmissionViewModel/>
2020
</chart:SfFunnelChart.BindingContext>
2121

2222
<chart:SfFunnelChart.Legend>

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public partial class MainWindow : ContentPage
2828
{
2929
this.InitializeComponent();
3030
SfFunnelChart chart = new SfFunnelChart();
31+
this.Content = chart;
3132
}
3233
}
3334
```
@@ -72,39 +73,39 @@ Now, let us define a simple data model that represents a data point in the chart
7273

7374
**[C#]**
7475
```
75-
public class Admission
76+
public class AdmissionModel
7677
{
7778
public string XValue { get; set; }
7879
public double YValue { get; set; }
7980
}
8081
```
8182

82-
Next, create a view model class and initialize a list of `Model` objects as follows.
83+
Next, create a AdmissionViewModel class and initialize a list of `AdmissionModel` objects as follows.
8384

8485
**[C#]**
8586
```
86-
public class ChartViewModel
87+
public class AdmissionViewModel
8788
{
88-
public List<Admission> Data { get; set; }
89+
public List<AdmissionModel> Data { get; set; }
8990
90-
public ChartViewModel()
91+
public AdmissionViewModel()
9192
{
92-
Data = new List<Admission>()
93+
Data = new List<AdmissionModel>()
9394
{
94-
new Admission() {XValue = "Enrolled", YValue=175},
95-
new Admission() {XValue = "Admits", YValue=190},
96-
new Admission() {XValue = "Applicants", YValue=245},
97-
new Admission() {XValue = "Inquiries ", YValue=290},
98-
new Admission() {XValue = "Prospects ", YValue=320},
95+
new AdmissionModel() {XValue = "Enrolled", YValue=175},
96+
new AdmissionModel() {XValue = "Admits", YValue=190},
97+
new AdmissionModel() {XValue = "Applicants", YValue=245},
98+
new AdmissionModel() {XValue = "Inquiries ", YValue=290},
99+
new AdmissionModel() {XValue = "Prospects ", YValue=320},
99100
};
100101
}
101102
}
102103
```
103104

104-
Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `ViewModel` class.
105+
Create a `AdmissionViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `AdmissionViewModel` class.
105106

106107
> **_Note:_**
107-
Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
108+
Add the namespace of `AdmissionViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
108109

109110
**[XAML]**
110111
```
@@ -115,15 +116,16 @@ Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set `
115116
116117
<chart:SfFunnelChart>
117118
<chart:SfFunnelChart.BindingContext>
118-
<model:ChartViewModel/>
119+
<model:AdmissionViewModel/>
119120
</chart:SfFunnelChart.BindingContext>
120121
</chart:SfFunnelChart>
121122
</ContentPage>
122123
```
123124

124125
**[C#]**
125126
```
126-
ChartViewModel viewModel = new ChartViewModel();
127+
SfFunnelChart chart = new SfFunnelChart();
128+
AdmissionViewModel viewModel = new AdmissionViewModel();
127129
chart.BindingContext = viewModel;
128130
```
129131

@@ -143,7 +145,7 @@ chart.BindingContext = viewModel;
143145
**[C#]**
144146
```
145147
SfFunnelChart chart = new SfFunnelChart();
146-
ChartViewModel viewModel = new ChartViewModel();
148+
AdmissionViewModel viewModel = new AdmissionViewModel();
147149
chart.BindingContext = viewModel;
148150
chart.ItemsSource = viewModel.Data;
149151
chart.XBindingPath = "XValue";
@@ -244,7 +246,7 @@ The following code example gives you the complete code of above configurations.
244246
<Label Text="School Admission"/>
245247
</chart:SfFunnelChart.Title>
246248
<chart:SfFunnelChart.BindingContext>
247-
<model:ChartViewModel/>
249+
<model:AdmissionViewModel/>
248250
</chart:SfFunnelChart.BindingContext>
249251
<chart:SfFunnelChart.Legend>
250252
<chart:ChartLegend/>
@@ -266,7 +268,7 @@ public partial class MainPage : ContentPage
266268
Text = "School Admission"
267269
};
268270
chart.Legend = new ChartLegend();
269-
ChartViewModel viewModel = new ChartViewModel();
271+
AdmissionViewModel viewModel = new AdmissionViewModel();
270272
chart.BindingContext = viewModel;
271273
272274
chart.ItemsSource = viewModel.Data;

0 commit comments

Comments
 (0)