Skip to content

Commit 0e2a5cb

Browse files
commit
1 parent bb23737 commit 0e2a5cb

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

EmptyPointsSample/EmptyPointsSample/View/CustomizingEmptyPoints.xaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<local:ViewModel/>
1111
</ContentPage.BindingContext>
1212

13-
<chart:SfCartesianChart IsTransposed="True" Margin="20">
13+
<chart:SfCartesianChart Margin="20">
1414

1515
<chart:SfCartesianChart.Title>
1616
<Label Text="Sales Performance Across Product Categories" FontSize="14" HorizontalOptions="Center" ></Label>
@@ -33,13 +33,12 @@
3333
</chart:SfCartesianChart.YAxes>
3434

3535
<chart:ColumnSeries ItemsSource="{Binding ProductSales}"
36-
XBindingPath="Product"
37-
YBindingPath="Sales"
38-
Fill="#2196F3"
39-
ShowDataLabels="True"
40-
EmptyPointMode="Average">
36+
XBindingPath="Product"
37+
YBindingPath="Sales"
38+
Fill="#2196F3"
39+
EmptyPointMode="Average">
4140
<chart:ColumnSeries.EmptyPointSettings>
42-
<chart:EmptyPointSettings Fill="LightGrey" StrokeWidth="2" />
41+
<chart:EmptyPointSettings Fill="LightGrey"/>
4342
</chart:ColumnSeries.EmptyPointSettings>
4443
</chart:ColumnSeries>
4544

EmptyPointsSample/EmptyPointsSample/View/EmptyPointModeAverage.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
XBindingPath="Product"
3737
YBindingPath="Sales"
3838
Fill="#2196F3"
39-
ShowDataLabels="True"
4039
EmptyPointMode="Average">
4140
</chart:ColumnSeries>
4241

EmptyPointsSample/EmptyPointsSample/View/EmptyPointModeNone.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
YBindingPath="Sales"
3838
StrokeWidth="2"
3939
Fill="#2196F3"
40-
ShowDataLabels="True"
4140
EmptyPointMode="None">
4241
</chart:LineSeries>
4342

EmptyPointsSample/EmptyPointsSample/View/EmptyPointModeZero.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
YBindingPath="Sales"
3838
StrokeWidth="2"
3939
Fill="#2196F3"
40-
ShowDataLabels="True"
4140
EmptyPointMode="Zero">
4241
</chart:AreaSeries>
4342

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# How to handle the empty points gap in .NET MAUI Cartesian Chart
22
In .NET MAUI [SfCartesianChart](https://www.syncfusion.com/maui-controls/maui-cartesian-charts), empty points represent missing or null data in a series. These points can occur due to unavailable data, improper formatting, or explicit assignment of null or double.NaN.
33

4+
In .NET MAUI [SfCartesianChart](https://www.syncfusion.com/maui-controls/maui-cartesian-charts), empty points represent missing or null data in a series. These points can occur due to unavailable data, improper formatting, or explicit assignment of null or double.NaN.
5+
46
This article covers handling empty points using [EmptyPointMode](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.EmptyPointMode.html) to manage missing data and customizing empty points to enhance their visual appearance.
57

68
**Handling Empty Points Using EmptyPointMode**
@@ -19,7 +21,6 @@ Empty points are not rendered in the chart, leaving gaps in the series.
1921
XBindingPath="Product"
2022
YBindingPath="Sales"
2123
StrokeWidth="2"
22-
ShowDataLabels="True"
2324
EmptyPointMode="None"
2425
</chart:LineSeries>
2526
@@ -35,14 +36,14 @@ LineSeries series = new LineSeries()
3536
XBindingPath = "Product",
3637
YBindingPath = "Sales",
3738
StrokeWidth = 2,
38-
ShowDataLabels = true,
3939
EmptyPointMode = EmptyPointMode.None,
4040
};
4141
4242
chart.Series.Add(series);
4343
this.Content = chart;
4444
```
45-
![EmptyPointMode-None.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM3OTgxIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.NMODfKeo-tmoCOnS_V13vi_pFpoSci_PC3ZwgT3NivI)
45+
![EmptyPointMode-None.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM4MTc3Iiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.rCNEgkYk4PlxIast3LGTiauSFofqwNGTHU89wBdn4BY)
46+
4647
**2. Zero**
4748

4849
Empty points are replaced with zero, maintaining continuity in the series.
@@ -54,7 +55,6 @@ Empty points are replaced with zero, maintaining continuity in the series.
5455
<chart:AreaSeries ItemsSource="{Binding ProductSales}"
5556
XBindingPath="Product"
5657
YBindingPath="Sales"
57-
ShowDataLabels="True"
5858
EmptyPointMode="Zero"/>
5959
</chart:SfCartesianChart>
6060
```
@@ -67,13 +67,13 @@ AreaSeries series = new AreaSeries()
6767
ItemsSource = new ViewModel().ProductSales,
6868
XBindingPath = "Product",
6969
YBindingPath = "Sales",
70-
ShowDataLabels = true,
7170
EmptyPointMode = EmptyPointMode.Zero,
7271
};
7372
chart.Series.Add(series);
7473
this.Content = chart;
7574
```
76-
![EmptyPointMode-zero.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM3OTg1Iiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.L7lIUH25RUnmk6UFRnZdaRwxXRXw2lrp9ffFXBDUNVQ)
75+
![EmptyPointMode-zero.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM4MTc5Iiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.40gf7wl743HeVWGvwPjz4MR2o2l2yA6CW5G5YOIdFdg)
76+
7777
**3. Average**
7878

7979
Empty points are replaced with the average value of surrounding data points.
@@ -85,7 +85,6 @@ Empty points are replaced with the average value of surrounding data points.
8585
<chart:ColumnSeries ItemsSource="{Binding ProductSales}"
8686
XBindingPath="Product"
8787
YBindingPath="Sales"
88-
ShowDataLabels="True"
8988
EmptyPointMode="Average"/>
9089
</chart:SfCartesianChart>
9190
```
@@ -98,13 +97,12 @@ ColumnSeries series = new ColumnSeries()
9897
ItemsSource = new ViewModel().ProductSales,
9998
XBindingPath = "Product",
10099
YBindingPath = "Sales",
101-
ShowDataLabels = true,
102100
EmptyPointMode = EmptyPointMode.Average,
103101
}
104102
chart.Series.Add(series);
105103
this.Content = chart;
106104
```
107-
![EmptyPointMode-Average.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM3OTgzIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.U0JRL1NyQFlN_HVOAucnGrt-nmQZpeUYjw50HKWrXZc)
105+
![EmptyPointMode-Average.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM4MTgwIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.6_78cUYRCPosrsZla-xjlc7QALQdPiiKiswMDz5I2S4)
108106
By default, the [EmptyPointMode](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.EmptyPointMode.html) property is set to [None](elp.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.EmptyPointMode.html#Syncfusion_Maui_Toolkit_Charts_EmptyPointMode_None).
109107

110108
**Customizing Empty Points**
@@ -119,42 +117,46 @@ The following example demonstrates how to customize empty points:
119117

120118
**[XAML]**
121119
```
122-
<chart:SfCartesianChart IsTransposed="True">
120+
<chart:SfCartesianChart>
123121
. . .
124122
<chart:ColumnSeries ItemsSource="{Binding ProductSales}"
125123
XBindingPath="Product"
126124
YBindingPath="Sales"
127-
ShowDataLabels="True"
128125
EmptyPointMode="Average">
129126
<chart:ColumnSeries.EmptyPointSettings>
130-
<chart:EmptyPointSettings Fill="LightGrey" StrokeWidth="2" />
127+
<chart:EmptyPointSettings Fill="LightGrey"/>
131128
</chart:ColumnSeries.EmptyPointSettings>
132129
</chart:LineSeries>
133130
</chart:SfCartesianChart>
134131
```
135132
**[C#]**
136133
```
137134
SfCartesianChart chart = new SfCartesianChart();
138-
chart.IsTransposed = true;
139135
. . .
140136
ColumnSeries series = new ColumnSeries()
141137
{
142138
ItemsSource = new ViewModel().ProductSales,
143139
XBindingPath = "Product",
144140
YBindingPath = "Sales",
145-
ShowDataLabels = true,
146141
EmptyPointMode = EmptyPointMode.Average
147142
};
148143
149144
EmptyPointSettings emptypointSettings = new EmptyPointSettings()
150145
{
151146
Fill = Colors.LightGray,
152-
StrokeWidth = 2
153147
};
154148
155149
series.EmptyPointSettings = emptypointSettings;
156150
chart.Series.Add(series);
157151
this.Content = chart;
158152
```
159-
![Customizing_Empty_Points.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM3OTg0Iiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.pFiLeI23El957IQcI4HMr-v76CoXa4GIuUIPAnfKdfY)
153+
![Customizing_Empty_Points.png](https://support.syncfusion.com/kb/agent/attachment/article/19659/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM4MTgxIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.6JH-gSBZYdsTZZV9vXpAdof9t0DZwuadMyZgleKltSE)
160154
By using [EmptyPointMode](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.EmptyPointMode.html) and [EmptyPointSettings](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.EmptyPointSettings.html), you can efficiently manage missing data in .NET MAUI Cartesian Charts, ensuring a smooth, accurate, and visually appealing charting experience.
155+
156+
**Troubleshooting**
157+
158+
Path too long exception
159+
160+
If you are facing a path too long exception when building this example project, close Visual Studio and rename the repository to a shorter name before building the project.
161+
162+
For more details, refer to the KB on [How to handle the empty points gap in .NET MAUI Cartesian Chart]()

0 commit comments

Comments
 (0)