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
@@ -33,16 +29,14 @@ public partial class MainWindow : ContentPage
33
29
SfCircularChartchart=newSfCircularChart();
34
30
}
35
31
}
36
-
{% endhighlight %}
37
-
38
-
{% endtabs %}
32
+
```
39
33
40
34
## Register the handler
41
35
42
36
Syncfusion.Maui.Core nuget is a dependent package for all Syncfusion controls of .NET MAUI. In the MauiProgram.cs file, register the handler for Syncfusion core.
43
37
44
-
{% highlight C# %}
45
-
38
+
######
39
+
```C#
46
40
usingMicrosoft.Maui;
47
41
usingMicrosoft.Maui.Hosting;
48
42
usingMicrosoft.Maui.Controls.Compatibility;
@@ -69,33 +63,23 @@ namespace ChartGettingStarted
69
63
}
70
64
}
71
65
}
72
-
73
-
{% endhighlight %}
66
+
```
74
67
75
68
## Initialize view model
76
69
77
70
Now, let us define a simple data model that represents a data point in the chart.
78
-
79
-
{% tabs %}
80
-
81
-
{% highlight c# %}
82
-
71
+
###### C#
72
+
```C#
83
73
publicclassSales
84
74
{
85
75
publicstringProduct { get; set; }
86
76
publicdoubleSalesRate { get; set; }
87
77
}
88
-
89
-
{% endhighlight %}
90
-
91
-
{% endtabs %}
78
+
```
92
79
93
80
Next, create a view model class and initialize a list of `Model` objects as follows.
94
-
95
-
{% tabs %}
96
-
97
-
{% highlight c# %}
98
-
81
+
######
82
+
```C#
99
83
publicclassChartViewModel
100
84
{
101
85
publicList<Sales> Data { get; set; }
@@ -112,19 +96,13 @@ public class ChartViewModel
112
96
};
113
97
}
114
98
}
99
+
```
115
100
116
-
{% endhighlight %}
117
-
118
-
{% endtabs %}
119
-
120
-
Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `ViewModel` class.
121
-
122
-
N> Add namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
123
-
124
-
{% tabs %}
125
-
126
-
{% highlight xaml %}
101
+
* Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `ViewModel` class.
127
102
103
+
* Add namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
@@ -136,41 +114,32 @@ N> Add namespace of `ViewModel` class to your XAML Page, if you prefer to set `B
136
114
</chart:SfCircularChart.BindingContext>
137
115
</chart:SfCircularChart>
138
116
</ContentPage>
139
-
140
-
{% endhighlight %}
141
-
142
-
{% highlight C# %}
143
-
117
+
```
118
+
###### C#
119
+
```C#
144
120
ChartViewModelviewModel=newChartViewModel();
145
121
chart.BindingContext=viewModel;
146
-
147
-
{% endhighlight %}
148
-
149
-
{% endtabs %}
122
+
```
150
123
151
124
## Populate chart with data
152
125
153
126
Adding [PieSeries](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.PieSeries.html) to the charts [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCircularChart.html#Syncfusion_Maui_Charts_SfCircularChart_Series) collection and binding `Data` to the series [ItemsSource](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_ItemsSource) property from its BindingContext to create our own Product Sales Pie chart.
154
127
155
-
N> The circular chart has [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCircularChart.html#Syncfusion_Maui_Charts_SfCircularChart_Series) as its default content.
156
-
157
-
N> 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.CircularSeries.html#Syncfusion_Maui_Charts_CircularSeries_YBindingPath) properties must be configured so that the chart may get values from the respective properties in the data model.
128
+
* The circular chart has [Series](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCircularChart.html#Syncfusion_Maui_Charts_SfCircularChart_Series) as its default content.
158
129
159
-
{% tabs %}
160
-
161
-
{% highlight xaml %}
130
+
* 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.CircularSeries.html#Syncfusion_Maui_Charts_CircularSeries_YBindingPath) properties must be configured so that the chart may get values from the respective properties in the data model.
The title of the chart acts as the title to provide quick information to the user about the data being plotted in the chart. You can set title using the [Title](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartBase.html#Syncfusion_Maui_Charts_ChartBase_Title) property of circular chart as follows.
190
156
191
-
{% tabs %}
192
-
193
-
{% highlight xaml %}
194
-
157
+
###### Xaml
158
+
```xaml
195
159
<chart:SfCircularChart>
196
160
<chart:SfCircularChart.Title>
197
161
<LabelText="PRODUCT SALES"/>
198
162
</chart:SfCircularChart.Title>
199
163
. . .
200
164
</chart:SfCircularChart>
201
-
202
-
{% endhighlight %}
203
-
204
-
{% highlight C# %}
205
-
165
+
```
166
+
###### C#
167
+
```C#
206
168
SfCircularChartchart=newSfCircularChart();
207
169
chart.Title=newLabel
208
170
{
209
171
Text="PRODUCT SALES"
210
172
};
211
-
212
-
{% endhighlight %}
213
-
214
-
{% endtabs %}
173
+
```
215
174
216
175
## Enable the data labels
217
176
218
177
The [ShowDataLabels](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_ShowDataLabels) property of series can be used to enable data labels to improve the readability of the circular chart. The label visibility is set to `False` by default.
219
178
220
-
{% tabs %}
221
-
222
-
{% highlight xaml %}
223
-
179
+
###### Xaml
180
+
```xaml
224
181
<chart:SfCircularChart>
225
182
. . .
226
183
<chart:PieSeriesShowDataLabels="True"/>
227
184
</chart:SfCircularChart>
228
-
229
-
{% endhighlight %}
230
-
231
-
{% highlight C# %}
232
-
185
+
```
186
+
###### C#
187
+
```C#
233
188
SfCircularChartchart=newSfCircularChart();
234
189
. . .
235
190
PieSeriesseries=newPieSeries();
236
191
series.ShowDataLabels=true;
237
192
chart.Series.Add(series);
238
-
239
-
{% endhighlight %}
240
-
241
-
{% endtabs %}
193
+
```
242
194
243
195
## Enable a legend
244
196
245
197
The legend provides information about the data point displayed in the circular chart. The [Legend](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartBase.html#Syncfusion_Maui_Charts_ChartBase_Legend) property of the chart was used to enable it.
246
198
247
-
{% tabs %}
248
-
249
-
{% highlight xaml %}
250
-
199
+
###### Xaml
200
+
```xaml
251
201
<chart:SfCircularChart>
252
202
. . .
253
203
<chart:SfCircularChart.Legend>
254
204
<chart:ChartLegend/>
255
205
</chart:SfCircularChart.Legend>
256
206
</chart:SfCircularChart>
257
-
258
-
{% endhighlight %}
259
-
260
-
{% highlight C# %}
261
-
207
+
```
208
+
###### C#
209
+
```C#
262
210
SfCircularChartchart=newSfCircularChart();
263
211
. . .
264
212
chart.Legend=newChartLegend();
265
-
266
-
{% endhighlight %}
267
-
268
-
{% endtabs %}
213
+
```
269
214
270
215
## Enable Tooltip
271
216
272
217
Tooltips are used to show information about the segment, when mouse over on it. Enable tooltip by setting series [EnableTooltip](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_EnableTooltip) property as true.
273
218
274
-
{% tabs %}
275
-
276
-
{% highlight xaml %}
277
-
219
+
###### Xaml
220
+
```xaml
278
221
<chart:SfCircularChart>
279
222
. . .
280
223
<chart:PieSeriesEnableTooltip="True"/>
281
224
</chart:SfCircularChart>
282
-
283
-
{% endhighlight %}
284
-
285
-
{% highlight C# %}
286
-
225
+
```
226
+
###### C#
227
+
```C#
287
228
SfCircularChartchart=newSfCircularChart();
288
229
. . .
289
230
PieSeriesseries=newPieSeries();
290
231
series.EnableTooltip=true;
291
232
chart.Series.Add(series);
292
-
293
-
{% endhighlight %}
294
-
295
-
{% endtabs %}
233
+
```
296
234
297
235
The following code example gives you the complete code of above configurations.
298
-
299
-
{% tabs %}
300
-
301
-
{% highlight xaml %}
302
-
236
+
###### Xaml
237
+
```xaml
303
238
<chart:SfCircularChart>
304
239
<chart:SfCircularChart.Title>
305
240
<LabelText="PRODUCT SALES"/>
@@ -317,11 +252,9 @@ The following code example gives you the complete code of above configurations.
317
252
EnableTooltip="True"
318
253
YBindingPath="SalesRate"/>
319
254
</chart:SfCircularChart>
320
-
321
-
{% endhighlight %}
322
-
323
-
{% highlight C# %}
324
-
255
+
```
256
+
###### C#
257
+
```C#
325
258
usingSyncfusion.Maui.Charts;
326
259
. . .
327
260
publicpartialclassMainPage : ContentPage
@@ -347,9 +280,6 @@ public partial class MainPage : ContentPage
347
280
this.Content=chart;
348
281
}
349
282
}
350
-
351
-
{% endhighlight %}
352
-
353
-
{% endtabs %}
283
+
```
354
284
355
285

0 commit comments