You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-23Lines changed: 26 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,10 @@ namespace ChartGettingStarted
27
27
publicMainPage()
28
28
{
29
29
InitializeComponent();
30
+
Gridgrid=newGrid();
30
31
SfCartesianChartchart=newSfCartesianChart();
32
+
grid.Add(chart);
33
+
this.Content=grid;
31
34
}
32
35
}
33
36
}
@@ -71,36 +74,36 @@ namespace ChartGettingStarted
71
74
Now, let us define a simple data model that represents a data point in the chart.
72
75
######
73
76
```C#
74
-
publicclassPerson
77
+
publicclassPersonModel
75
78
{
76
79
publicstringName { get; set; }
77
80
publicdoubleHeight { get; set; }
78
81
}
79
82
```
80
-
Next, create a view model class and initialize a list of `Person` objects as follows.
83
+
Next, create a PersonViewModel class and initialize a list of `PersonModel` objects as follows.
81
84
###### C#
82
85
```C#
83
-
publicclassViewModel
86
+
publicclassPersonViewModel
84
87
{
85
-
publicList<Person> Data { get; set; }
88
+
publicList<PersonModel> Data { get; set; }
86
89
87
-
publicViewModel()
90
+
publicPersonViewModel()
88
91
{
89
-
Data=newList<Person>()
92
+
Data=newList<PersonModel>()
90
93
{
91
-
newPerson { Name="David", Height=170 },
92
-
newPerson { Name="Michael", Height=96 },
93
-
newPerson { Name="Steve", Height=65 },
94
-
newPerson { Name="Joel", Height=182 },
95
-
newPerson { Name="Bob", Height=134 }
94
+
newPersonModel { Name="David", Height=170 },
95
+
newPersonModel { Name="Michael", Height=96 },
96
+
newPersonModel { Name="Steve", Height=65 },
97
+
newPersonModel { Name="Joel", Height=182 },
98
+
newPersonModel { Name="Bob", Height=134 }
96
99
};
97
100
}
98
101
}
99
102
```
100
103
101
-
Set the `ViewModel` instance as the `BindingContext` of your page to bind `ViewModel` properties to the chart.
104
+
Set the `PersonViewModel` instance as the `BindingContext` of your page to bind `PersonViewModel` properties to the chart.
102
105
103
-
* Add namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
106
+
* Add namespace of `PersonViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
104
107
###### Xaml
105
108
```xaml
106
109
<ContentPage
@@ -111,7 +114,7 @@ Set the `ViewModel` instance as the `BindingContext` of your page to bind `ViewM
111
114
xmlns:model="clr-namespace:ChartGettingStarted">
112
115
113
116
<ContentPage.BindingContext>
114
-
<model:ViewModel></model:ViewModel>
117
+
<model:PersonViewModel/>
115
118
</ContentPage.BindingContext>
116
119
</ContentPage>
117
120
```
@@ -153,7 +156,7 @@ Run the project and check if you get following output to make sure you have conf
153
156
154
157
## Populate Chart with data
155
158
156
-
As we are going to visualize the comparison of heights in the data model, add [ColumnSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ColumnSeries.html?tabs=tabid-1) to [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_Series) property of chart, and then bind the `Data` property of the above `ViewModel` to the `ColumnSeries.ItemsSource` as follows.
159
+
As we are going to visualize the comparison of heights in the data model, add [ColumnSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ColumnSeries.html?tabs=tabid-1) to [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_Series) property of chart, and then bind the `Data` property of the above `PersonViewModel` to the `ColumnSeries.ItemsSource` as follows.
157
160
158
161
* The cartesian chart has [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_Series) as its default content.
159
162
* You need to set [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)
0 commit comments