Skip to content

Commit 3862b40

Browse files
Updated ViewModel
1 parent 4463380 commit 3862b40

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

Polar_chart_sample/PolarChartSample/MainPage.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
x:Class="PolarChartSample.MainPage">
77

88
<ContentPage.BindingContext>
9-
<model:ViewModel/>
9+
<model:PlantViewModel/>
1010
</ContentPage.BindingContext>
1111

1212
<chart:SfPolarChart>

Polar_chart_sample/PolarChartSample/Model.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace PolarChartSample
88
{
9-
public class Model
9+
public class PlantModel
1010
{
1111
public string? Direction { get; set; }
1212
public double Tree { get; set; }

Polar_chart_sample/PolarChartSample/ViewModel.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77

88
namespace PolarChartSample
99
{
10-
public class ViewModel
10+
public class PlantViewModel
1111
{
12-
public ObservableCollection<Model> PlantDetails { get; set; }
13-
public ViewModel()
12+
public ObservableCollection<PlantModel> PlantDetails { get; set; }
13+
public PlantViewModel()
1414
{
15-
PlantDetails = new ObservableCollection<Model>()
15+
PlantDetails = new ObservableCollection<PlantModel>()
1616
{
17-
new Model(){ Direction = "North", Tree = 80, Flower = 42, Weed = 63},
18-
new Model(){ Direction = "NorthEast", Tree = 85, Flower = 40, Weed = 70},
19-
new Model(){ Direction = "East", Tree = 78 , Flower = 47, Weed = 65},
20-
new Model(){ Direction = "SouthEast", Tree = 90 , Flower = 40, Weed = 70},
21-
new Model(){ Direction = "South", Tree = 78 , Flower = 27, Weed = 47},
22-
new Model(){ Direction = "SouthWest", Tree = 83 , Flower = 45, Weed = 65},
23-
new Model(){ Direction = "West", Tree = 79 , Flower = 40, Weed = 58},
24-
new Model(){ Direction = "NorthWest", Tree = 88 , Flower = 38, Weed = 73}
17+
new PlantModel(){ Direction = "North", Tree = 80, Flower = 42, Weed = 63},
18+
new PlantModel(){ Direction = "NorthEast", Tree = 85, Flower = 40, Weed = 70},
19+
new PlantModel(){ Direction = "East", Tree = 78 , Flower = 47, Weed = 65},
20+
new PlantModel(){ Direction = "SouthEast", Tree = 90 , Flower = 40, Weed = 70},
21+
new PlantModel(){ Direction = "South", Tree = 78 , Flower = 27, Weed = 47},
22+
new PlantModel(){ Direction = "SouthWest", Tree = 83 , Flower = 45, Weed = 65},
23+
new PlantModel(){ Direction = "West", Tree = 79 , Flower = 40, Weed = 58},
24+
new PlantModel(){ Direction = "NorthWest", Tree = 88 , Flower = 38, Weed = 73}
2525
};
2626
}
2727
}

README.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Now, let us define a simple data model that represents a data point on the chart
7676

7777
###### C#
7878
```C#
79-
public class PlantData
79+
public class PlantModel
8080
{
8181
public string Direction { get; set; }
8282
public double Tree { get; set; }
@@ -85,34 +85,34 @@ Now, let us define a simple data model that represents a data point on the chart
8585
}
8686
```
8787

88-
Next, create a view model class and initialize a list of `PlantData` objects as follows.
88+
Next, create a PlantViewModel class and initialize a list of `PlantModel` objects as follows.
8989

9090
######
9191
```C#
92-
public class ViewModel
92+
public class PlantViewModel
9393
{
94-
public List<PlantData> PlantDetails { get; set; }
94+
public List<PlantModel> PlantDetails { get; set; }
9595

96-
public ViewModel()
96+
public PlantViewModel()
9797
{
98-
PlantDetails = new List<PlantData>()
98+
PlantDetails = new List<PlantModel>()
9999
{
100-
new PlantData(){ Direction = "North", Tree = 80, Flower = 42, Weed = 63},
101-
new PlantData(){ Direction = "NorthEast", Tree = 85, Flower = 40, Weed = 70},
102-
new PlantData(){ Direction = "East", Tree = 78 , Flower = 47, Weed = 65},
103-
new PlantData(){ Direction = "SouthEast", Tree = 90 , Flower = 40, Weed = 70},
104-
new PlantData(){ Direction = "South", Tree = 78 , Flower = 27, Weed = 47},
105-
new PlantData(){ Direction = "SouthWest", Tree = 83 , Flower = 45, Weed = 65},
106-
new PlantData(){ Direction = "West", Tree = 79 , Flower = 40, Weed = 58},
107-
new PlantData(){ Direction = "NorthWest", Tree = 88 , Flower = 38, Weed = 73}
100+
new PlantModel(){ Direction = "North", Tree = 80, Flower = 42, Weed = 63},
101+
new PlantModel(){ Direction = "NorthEast", Tree = 85, Flower = 40, Weed = 70},
102+
new PlantModel(){ Direction = "East", Tree = 78 , Flower = 47, Weed = 65},
103+
new PlantModel(){ Direction = "SouthEast", Tree = 90 , Flower = 40, Weed = 70},
104+
new PlantModel(){ Direction = "South", Tree = 78 , Flower = 27, Weed = 47},
105+
new PlantModel(){ Direction = "SouthWest", Tree = 83 , Flower = 45, Weed = 65},
106+
new PlantModel(){ Direction = "West", Tree = 79 , Flower = 40, Weed = 58},
107+
new PlantModel(){ Direction = "NorthWest", Tree = 88 , Flower = 38, Weed = 73}
108108
};
109109
}
110110
}
111111
```
112112

113-
Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from the `ViewModel` class.
113+
Create a `PlantViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from the `PlantViewModel` class.
114114

115-
* Add the namespace of the `ViewModel` class to your XAML page, if you prefer to set the `BindingContext` in XAML.
115+
* Add the namespace of the `PlantViewModel` class to your XAML page, if you prefer to set the `BindingContext` in XAML.
116116

117117
###### Xaml
118118
```xaml
@@ -124,14 +124,14 @@ Create a `ViewModel` instance and set it as the chart's `BindingContext`. This e
124124
xmlns:model="clr-namespace:ChartGettingStarted">
125125

126126
<ContentPage.BindingContext>
127-
<model:ViewModel></model:ViewModel>
127+
<model:PlantViewModel/>
128128
</ContentPage.BindingContext>
129129
</ContentPage>
130130
```
131131

132132
###### C#
133133
```C#
134-
this.BindingContext = new ViewModel();
134+
this.BindingContext = new PlantViewModel();
135135
```
136136

137137
## Initialize Chart axis
@@ -162,7 +162,7 @@ chart.SecondaryAxis = secondaryAxis;
162162

163163
## Populate Chart with data
164164

165-
To create a polar chart, you can add a [PolarLineSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.PolarLineSeries.html?tabs=tabid-1%2Ctabid-4) to the polar chart [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfPolarChart.html#Syncfusion_Maui_Charts_SfPolarChart_Series) property of the chart, and then bind the `PlantData` property of the above `ViewModel` to the `PolarLineSeries.ItemsSource` as follows.
165+
To create a polar chart, you can add a [PolarLineSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.PolarLineSeries.html) to the polar chart [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfPolarChart.html#Syncfusion_Maui_Charts_SfPolarChart_Series) property of the chart, and then bind the `PlantDetails` property of the above `PlantViewModel` to the `PolarLineSeries.ItemsSource` as follows.
166166

167167
* In order to plot the series, the [XBindingPath](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_XBindingPath) and [YBindingPath](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.XYDataSeries.html#Syncfusion_Maui_Charts_XYDataSeries_YBindingPath) properties need to be configured correctly. These properties allow the chart to retrieve values from the corresponding properties in the data model.
168168

@@ -204,17 +204,17 @@ chart.SecondaryAxis = secondaryAxis;
204204

205205
//Initialize the series
206206
PolarLineSeries series1 = new PolarLineSeries();
207-
series1.ItemsSource = (new ViewModel()).PlantDetails;
207+
series1.ItemsSource = (new PlantViewModel()).PlantDetails;
208208
series1.XBindingPath = "Direction";
209209
series1.YBindingPath = "Tree";
210210

211211
PolarLineSeries series2 = new PolarLineSeries();
212-
series2.ItemsSource = (new ViewModel()).PlantDetails;
212+
series2.ItemsSource = (new PlantViewModel()).PlantDetails;
213213
series2.XBindingPath = "Direction";
214214
series2.YBindingPath = "Weed";
215215

216216
PolarLineSeries series3 = new PolarLineSeries();
217-
series3.ItemsSource = (new ViewModel()).PlantDetails;
217+
series3.ItemsSource = (new PlantViewModel()).PlantDetails;
218218
series3.XBindingPath = "Direction";
219219
series3.YBindingPath = "Flower";
220220

@@ -312,19 +312,19 @@ chart.Legend = new ChartLegend();
312312
###### C#
313313
```C#
314314
PolarLineSeries series1 = new PolarLineSeries();
315-
series1.ItemsSource = (new ViewModel()).PlantDetails;
315+
series1.ItemsSource = (new PlantViewModel()).PlantDetails;
316316
series1.XBindingPath = "Direction";
317317
series1.YBindingPath = "Tree";
318318
series1.Label = "Tree";
319319

320320
PolarLineSeries series2 = new PolarLineSeries();
321-
series2.ItemsSource = (new ViewModel()).PlantDetails;
321+
series2.ItemsSource = (new PlantViewModel()).PlantDetails;
322322
series2.XBindingPath = "Direction";
323323
series2.YBindingPath = "Weed";
324324
series2.Label = "Weed";
325325

326326
PolarLineSeries series3 = new PolarLineSeries();
327-
series3.ItemsSource = (new ViewModel()).PlantDetails;
327+
series3.ItemsSource = (new PlantViewModel()).PlantDetails;
328328
series3.XBindingPath = "Direction";
329329
series3.YBindingPath = "Flower";
330330
series3.Label = "Flower";
@@ -361,7 +361,7 @@ The following code example gives you the complete code of above configurations.
361361
xmlns:model="clr-namespace:ChartGettingStarted">
362362

363363
<ContentPage.BindingContext>
364-
<model:ViewModel></model:ViewModel>
364+
<model:PlantViewModel/>
365365
</ContentPage.BindingContext>
366366

367367
<ContentPage.Content>
@@ -426,7 +426,7 @@ The following code example gives you the complete code of above configurations.
426426

427427
PolarLineSeries series1 = new PolarLineSeries()
428428
{
429-
ItemsSource = (new ViewModel()).PlantDetails,
429+
ItemsSource = (new PlantViewModel()).PlantDetails,
430430
XBindingPath = "Direction",
431431
YBindingPath = "Tree",
432432
Label="Tree",
@@ -436,7 +436,7 @@ The following code example gives you the complete code of above configurations.
436436

437437
PolarLineSeries series2 = new PolarLineSeries()
438438
{
439-
ItemsSource = (new ViewModel()).PlantDetails,
439+
ItemsSource = (new PlantViewModel()).PlantDetails,
440440
XBindingPath = "Direction",
441441
YBindingPath = "Weed",
442442
Label="Weed",
@@ -446,7 +446,7 @@ The following code example gives you the complete code of above configurations.
446446

447447
PolarLineSeries series3 = new PolarLineSeries()
448448
{
449-
ItemsSource = (new ViewModel()).PlantDetails,
449+
ItemsSource = (new PlantViewModel()).PlantDetails,
450450
XBindingPath = "Direction",
451451
YBindingPath = "Flower",
452452
Label="Flower",

0 commit comments

Comments
 (0)