30 Oct 202418 minutes to read
The Funnel Chart was created from the scratch using the upgraded APIs and performance of the .NET MAUI graphics library and framework layouts. However, a minor code change is required. In addition, SfChart has been divided into five chart controls in .NET MAUI for a better user experience and understanding.
Xamarin |
.NET MAUI |
SfChart
|
SfCartesianChart
SfCircularChart
SfFunnelChart
SfPyramidChart
SfPolarChart
|
To make the migration easier, the most of the APIs from the Xamarin SfChart were kept in the .NET MAUI SfFunnelChart. Currently, most of the features have been added to the SfFunnelChart, but only a few are pending in the .NET MAUI, along with some limitations. Please refer to the following details and the API migration information available below.
API migration
To initialize the control, import the Chart namespace and Initialize SfFunnelChart, as shown in the following code sample.
Xamarin |
<ContentPage
. . .
xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms">
<chart:SfChart/>
</ContentPage>
using Syncfusion.SfChart.XForms;
...
SfChart chart = new SfChart();
this.Content = chart;
|
.NET MAUI |
<ContentPage
. . .
xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts">
<chart:SfFunnelChart/>
</ContentPage>
using Syncfusion.Maui.Charts;
. . .
SfFunnelChart chart = new SfFunnelChart();
this.Content = chart;
|
The following table illustrates the API migration for the chart.
Xamarin |
.NET MAUI |
ColorModel, CustomBrushes |
PaletteBrushes |
ChartBehaviors |
TooltipBehavior, SelectionBehavior |
Series
The following properties are given in SfFunnelChart.
Xamarin |
.NET MAUI |
Color |
- |
ColorModel |
PaletteBrushes |
SelectedDataPointColor |
SelectionBrush |
DataMarker |
ShowDataLabels, DataLabelSettings |
The following code example explains how to migrate the series of Xamarin SfChart to the .NET MAUI SfFunnelChart.
Xamarin |
<chart:SfChart>
<chart:FunnelSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"/>
</chart:SfChart>
SfChart chart = new SfChart();
. . .
FunnelSeries series = new FunnelSeries();
series.ItemsSource = Data;
series.XBindingPath = "XValue";
series.YBindingPath = "YValue";
chart.Series.Add(series);
this.Content = chart;
|
.NET MAUI |
<chart:SfFunnelChart ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
</chart:SfFunnelChart>
SfFunnelChart chart = new SfFunnelChart();
ChartViewModel viewModel = new ChartViewModel();
chart.BindingContext = viewModel;
chart.ItemsSource = viewModel.Data;
chart.XBindingPath = "XValue";
chart.YBindingPath = "YValue";
this.Content = chart;
|
Legend
Xamarin |
.NET MAUI |
DockPosition |
Placement |
IsVisible |
IsVisible |
Title |
Upcoming |
ToggleSeriesVisibility |
ToggleSeriesVisibility |
OverflowMode |
Upcoming |
MaxWidth |
Upcoming |
Orientation |
Upcoming |
IsIconVisible |
Upcoming |
ItemMargin |
Upcoming |
IconWidth |
Upcoming |
IconHeight |
Upcoming |
OffsetX |
Upcoming |
OffsetY |
Upcoming |
The following code example shows how to enable legend in chart.
Xamarin |
<chart:SfChart>
<chart:SfChart.Legend>
<chart:ChartLegend/>
</chart:SfChart.Legend>
</chart:SfChart>
SfChart chart = new SfChart();
. . .
chart.Legend = new ChartLegend();
this.Content = chart;
|
.NET MAUI |
<chart:SfFunnelChart>
. . .
<chart:SfFunnelChart.Legend>
<chart:ChartLegend/>
</chart:SfFunnelChart.Legend>
</chart:SfFunnelChart>
SfFunnelChart chart = new SfFunnelChart();
. . .
chart.Legend = new ChartLegend();
this.Content = chart;
|
Data Label
To customize the data label appearance, create an instance of the ChartDataMarker class and add it to the DataMarker of Series. For SfFunnelChart, you can set the FunnelDataLabelSettings instance to the DataLabelSettings property, as shown in the below code sample.
Xamarin |
<chart:SfChart>
<chart:FunnelSeries ItemsSource ="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
<chart:FunnelSeries.DataMarker>
<chart:ChartDataMarker ShowLabel="True">
<chart:ChartDataMarker.LabelStyle>
<chart:DataMarkerLabelStyle TextColor="Blue"
BorderColor="Red"
BorderThickness="2"
BackgroundColor="Aqua"
Angle="315"
Margin="5"
FontSize="18"
FontAttributes="Italic"/>
</chart:ChartDataMarker.LabelStyle>
</chart:ChartDataMarker>
</chart:FunnelSeries.DataMarker>
</chart:FunnelSeries>
</chart:SfChart>
SfChart chart = new SfChart();
. . .
FunnelSeries series = new FunnelSeries();
. . .
series.DataMarker = new ChartDataMarker();
series.DataMarker.ShowLabel = true;
var style = new DataMarkerLabelStyle();
style.TextColor = Color.Blue;
style.BorderColor = Color.Red;
style.BorderThickness = 2;
style.BackgroundColor = Color.Aqua;
style.Angle = 315;
style.Margin = 5;
style.FontSize = 18;
series.DataMarker.LabelStyle = style;
chart.Series.Add(series);
this.Content = chart;
|
.NET MAUI |
<chart:SfFunnelChart ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
ShowDataLabels="True">
<chart:SfFunnelChart.DataLabelSettings>
<chart:FunnelDataLabelSettings>
<chart:FunnelDataLabelSettings.LabelStyle>
<chart:ChartDataLabelStyle TextColor="Blue"
Stroke="Red"
StrokeWidth="2"
Background="Aqua"
Margin="10"
FontSize="16"
FontAttributes="Bold"/>
</chart:FunnelDataLabelSettings.LabelStyle>
</chart:FunnelDataLabelSettings>
</chart:SfFunnelChart.DataLabelSettings>
</chart:SfFunnelChart>
SfFunnelChart chart = new SfFunnelChart();
. . .
chart.ShowDataLabels = true;
chart.DataLabelSettings = new FunnelDataLabelSettings();
var style = new ChartDataLabelStyle();
style.TextColor = Colors.Blue;
style.Stroke = Colors.Red;
style.StrokeWidth = 2;
style.Background = Colors.Aqua;
style.Margin = 5;
style.FontSize = 18;
chart.DataLabelSettings.LabelStyle = style;
this.Content = chart;
|
To customize the tooltip appearance, create an instance of the ChartTooltipBehavior class and add it to the ChartBehaviors collection of SfChart. For SfFunnelChart, you can directly set the ChartTooltipBehavior instance to the TooltipBehavior property, as shown in the below code sample.
Xamarin |
<chart:SfChart>
. . .
<chart:SfChart.ChartBehaviors>
<chart:ChartTooltipBehavior BackgroundColor="Blue"
TextColor="White"
Margin="5"
FontSize="15"/>
</chart:SfChart.ChartBehaviors>
<chart:FunnelSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfChart>
SfChart chart = new SfChart();
. . .
FunnelSeries series = new FunnelSeries ();
. . .
series.EnableTooltip = true;
chart.Series.Add(series);
ChartTooltipBehavior tool = new ChartTooltipBehavior();
tool.BackgroundColor = Color.Blue;
tool.TextColor = Color.White;
tool.Margin = new Thickness(5, 5, 5, 5);
tool.FontSize = 15;
chart.ChartBehaviors.Add(tool);
this.Content = chart;
|
.NET MAUI |
<chart:SfFunnelChart ItemsSource="{Binding Data1}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True">
<chart:SfFunnelChart.TooltipBehavior>
<chart:ChartTooltipBehavior Background="Blue"
TextColor="White"
Margin="5"
FontSize="15"/>
</chart:SfFunnelChart.TooltipBehavior>
</chart:SfFunnelChart>
SfFunnelChart chart = new SfFunnelChart();
. . .
chart.EnableTooltip=true;
ChartTooltipBehavior tooltip = new ChartTooltipBehavior();
tooltip.Background = Colors.Blue;
tooltip.TextColor = Colors.White;
tooltip.Margin = new Thickness(5, 5, 5, 5);
tooltip.FontSize = 15;
chart.TooltipBehavior = tooltip;
this.Content = chart;
|
Selection
Create an instance of the ChartSelectionBehavior class and add it to the ChartBehaviors collection of SfChart. For SfFunnelChart, you can directly set the DataPointSelectionBehavior instance to the SelectionBehavior property, as shown in the below code sample.
Xamarin |
<chart:SfChart>
...
<chart:SfChart.ChartBehaviors>
<chart:ChartSelectionBehavior/>
</chart:SfChart.ChartBehaviors>
<chart:FunnelSeries EnableDataPointSelection="True"
SelectedDataPointIndex="2"
SelectedDataPointColor="Red"
ItemsSource ="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"/>
</chart:SfChart>
SfChart chart = new SfChart();
FunnelSeries series = new FunnelSeries();
. . .
series.EnableDataPointSelection = true;
series.SelectedDataPointIndex = 2;
series.SelectedDataPointColor = Color.Red;
ChartSelectionBehavior selectionBehavior = new ChartSelectionBehavior();
chart.ChartBehaviors.Add(selectionBehavior);
chart.Series.Add(series);
this.Content = chart;
|
.NET MAUI |
<chart:SfFunnelChart ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
<chart:SfFunnelChart.SelectionBehavior>
<chart:DataPointSelectionBehavior SelectedIndex="2"
SelectionBrush="red"/>
</chart:SfFunnelChart.SelectionBehavior>
</chart:SfFunnelChart>
SfFunnelChart chart = new SfFunnelChart();
. . .
DataPointSelectionBehavior selection = new DataPointSelectionBehavior();
selection.SelectedIndex = 2;
selection.SelectionBrush = Colors.Red;
chart.SelectionBehavior = selection;
this.Content = chart;
|
Upcoming features in .NET MAUI
Chart
- Listen to property change support for chart.
- Notify event or method when chart is rendering.
- Suspend and resume notification.
- Support for chart animation.
- Exploding segments on touch.
- Funnel neck customization support.
Legend
- Title support for legend.
- Support to enable or disable the legend icon visibility.
- Legend floating support.
- Event or method to notify when a legend item is clicked.
- The ability to show/hide corresponding data points by legend item toggle.
Data label
- Connector lines customization support.
- In.NET MAUI, the ChartDataPoint model class was no longer available. Instead, create your own model.
Support and feedback
If you are unable to find the migration information you require in the self-help resources listed above, please contact us by creating a support ticket. Do not see what you need? Please request it in our feedback portal.