Thanks for the update but there is still a problem.
Example code
Chartx.Title = new ChartTitle() { Text = "Chartx" };
Chartx.Legend = new ChartLegend();
Chartx.Legend.LabelStyle.TextColor = Color.Blue;
Chartx.Legend.LabelStyle.Margin = 5;
Chartx.Legend.IsVisible = false;
Chartx.Series.Clear();
PieSeries doughnutSeries = new PieSeries()
{
ItemsSource = Data1,
XBindingPath = "Item",
YBindingPath = "Value",
ExplodeAll = true,
DataMarkerPosition = CircularSeriesDataMarkerPosition.Inside,
ColorModel = new ChartColorModel()
{
Palette = ChartColorPalette.Custom,
CustomBrushes = new ChartColorCollection()
{
Color.Green,
Color.Yellow,
Color.Red,
Color.Gray,
Color.Pink,
}
}
};
//This Line
doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage;
Chartx.Series.Add(doughnutSeries);
Chartx.Legend.IsVisible = true;
With this line commented out - everything works but no percentage is shown. With the line commented in, it throws an exception.
System.NullReferenceException
Message=Object reference not set to an instance of an object.
Using the XAML provided with the
<ContentPage
xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms"
xmlns:rangenavigator="clr-namespace:Syncfusion.RangeNavigator.XForms;assembly=Syncfusion.SfChart.XForms"
xmlns:local="clr-namespace:ChartSample;assembly=ChartSample"
xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ChartSample.MyPage">
...
<chart:DoughnutSeries.DataMarker>
<chart:ChartDataMarker>
<chart:ChartDataMarker.LabelTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<Label FontSize="12" TextColor="White" Text="{Binding Name, StringFormat='{0} : '}" />
</StackLayout>
</DataTemplate>
</chart:ChartDataMarker.LabelTemplate>
</chart:ChartDataMarker>
</chart:DoughnutSeries.DataMarker>
Appears to reveal The attachable property 'DataMarker' was not found in type 'DoughnutSeries'.
So perhaps more xmlns are required or something else is missing.
Providing fragments of code rather than simple working samples means that if something is missing its difficult to find appropriate part. Whereas if the sample is complete then it is easier to extract relevent code.