Class ChartSeries
Represents the base class for all chart series types, including SfCartesianChart, SfCircularChart, and SfPolarChart.
Namespace: Syncfusion.Maui.Toolkit.Charts
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public abstract class ChartSeries : Element, IDatapointSelectionDependent, ITooltipDependent, IDataTemplateDependent
Constructors
ChartSeries()
Initializes a new instance of the ChartSeries.
Declaration
public ChartSeries()
Fields
EnableAnimationProperty
Identifies the EnableAnimation bindable property.
Declaration
public static readonly BindableProperty EnableAnimationProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Indicates whether animations are enabled for the chart series.
EnableTooltipProperty
Identifies the EnableTooltip bindable property.
Declaration
public static readonly BindableProperty EnableTooltipProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Indicates whether tooltips are enabled for the chart series.
FillProperty
Identifies the Fill bindable property.
Declaration
public static readonly BindableProperty FillProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents the fill brush for the chart series.
IsVisibleOnLegendProperty
Identifies the IsVisibleOnLegend bindable property.
Declaration
public static readonly BindableProperty IsVisibleOnLegendProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Indicates whether to display a legend item for the chart series.
IsVisibleProperty
Identifies the IsVisible bindable property.
Declaration
public static readonly BindableProperty IsVisibleProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Indicates whether the chart series is visible.
ItemsSourceProperty
Identifies the ItemsSource bindable property.
Declaration
public static readonly BindableProperty ItemsSourceProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents the data source for the chart series.
LabelContextProperty
Identifies the LabelContext bindable property.
Declaration
public static readonly BindableProperty LabelContextProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Determines the content to be displayed in the data labels.
LabelTemplateProperty
Identifies the LabelTemplate bindable property.
Declaration
public static readonly BindableProperty LabelTemplateProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Provides a template for customizing the data label.
LegendIconProperty
Identifies the LegendIcon bindable property.
Declaration
public static readonly BindableProperty LegendIconProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents the icon type for the legend.
OpacityProperty
Identifies the Opacity bindable property.
Declaration
public static readonly BindableProperty OpacityProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents the opacity of the chart series, where 0 is fully transparent and 1 is fully opaque.
PaletteBrushesProperty
Identifies the PaletteBrushes bindable property.
Declaration
public static readonly BindableProperty PaletteBrushesProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents a collection of brushes used in the chart series palette.
SelectionBehaviorProperty
Identifies the SelectionBehavior bindable property.
Declaration
public static readonly BindableProperty SelectionBehaviorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents the behavior of data point selection in the chart series.
ShowDataLabelsProperty
Identifies the ShowDataLabels bindable property.
Declaration
public static readonly BindableProperty ShowDataLabelsProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Indicates whether data labels are shown in the chart series.
TooltipTemplateProperty
Identifies the TooltipTemplate bindable property.
Declaration
public static readonly BindableProperty TooltipTemplateProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Provides a template for customizing the tooltip display in the chart series.
XBindingPathProperty
Identifies the XBindingPath bindable property.
Declaration
public static readonly BindableProperty XBindingPathProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Represents the binding path for the X-axis values in the chart series.
Properties
EnableAnimation
Gets or sets a value indicating whether to animate the chart series on loading.
Declaration
public bool EnableAnimation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableAnimation = "True"/>
</chart:SfCartesianChart>
EnableTooltip
Gets or sets a boolean value indicating whether the tooltip for series should be shown or hidden.
Declaration
public bool EnableTooltip { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts |
Remarks
The series tooltip will appear when you click or tap the series.
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
Fill
Gets or sets a brush value to customize the series appearance.
Declaration
public Brush Fill { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | It accepts a Microsoft.Maui.Controls.Brush value and its default value is null. |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
Fill = "Red"/>
</chart:SfCartesianChart>
IsVisible
Gets or sets a value that indicates whether the series is visible or not.
Declaration
public bool IsVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
IsVisible="False"/>
</chart:SfCartesianChart>
IsVisibleOnLegend
Gets or sets a value that indicates whether to show a legend item for this series.
Declaration
public bool IsVisibleOnLegend { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Legend>
<chart:ChartLegend />
</chart:SfCartesianChart.Legend>
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
IsVisibleOnLegend = "False"/>
</chart:SfCartesianChart>
ItemsSource
Gets or sets a data points collection that will be used to plot a chart.
Declaration
public object ItemsSource { get; set; }
Property Value
Type |
---|
System.Object |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue" />
</chart:SfCartesianChart>
LabelContext
Gets or sets an option that determines the content to be displayed in the data labels. It is recommended to use PieSeries, DoughnutSeries, and BarSeries with LabelContext set to Percentage.
Declaration
public LabelContext LabelContext { get; set; }
Property Value
Type | Description |
---|---|
LabelContext | It accepts the LabelContext values and its default value is YValue. |
Examples
<chart:SfCircularChart>
<chart:SfCircularChart.Series>
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
ShowDataLabels="True"
LabelContext="Percentage">
</chart:PieSeries>
</chart:SfCircularChart.Series>
</chart:SfCircularChart>
LabelTemplate
Gets or sets the DataTemplate that can be used to customize the appearance of the data label.
Declaration
public DataTemplate LabelTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | It accepts the Microsoft.Maui.Controls.DataTemplate values. |
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.Resources>
<DataTemplate x:Key="DataLabelTemplate">
<VerticalStackLayout>
<Image Source="image.png"
WidthRequest="20"
HeightRequest="20"/>
<Label Text="{Binding Label}"
TextColor="Black"
FontAttributes="Bold"
FontSize="12"/>
</VerticalStackLayout>
</DataTemplate>
</chart:SfCartesianChart.Resources>
<chart:SfCartesianChart.XAxes>
<chart:NumericalAxis/>
</chart:SfCartesianChart.XAxes>
<chart:SfCartesianChart.YAxes>
<chart:NumericalAxis/>
</chart:SfCartesianChart.YAxes>
<chart:SfCartesianChart.Series>
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
ShowDataLabels = "True"
LabelTemplate="{StaticResource DataLabelTemplate}">
</chart:ColumnSeries>
</chart:SfCartesianChart.Series>
</chart:SfCartesianChart>
LegendIcon
Gets or sets a legend icon that will be displayed in the associated legend item.
Declaration
public ChartLegendIconType LegendIcon { get; set; }
Property Value
Type | Description |
---|---|
ChartLegendIconType | It accepts ChartLegendIconType values and its default value is Circle. |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Legend>
<chart:ChartLegend />
</chart:SfCartesianChart.Legend>
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
LegendIcon = "Diamond"/>
</chart:SfCartesianChart>
Opacity
Gets or sets opacity of the chart series.
Declaration
public double Opacity { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Accepts |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
Opacity="0.5"/>
</chart:SfCartesianChart>
PaletteBrushes
Gets or sets the list of brushes that can be used to customize the appearance of the series.
Declaration
public IList<Brush> PaletteBrushes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<Microsoft.Maui.Controls.Brush> | This property accepts a list of brushes as input and comes with a set of predefined brushes by default. |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
PaletteBrushes = "{Binding CustomBrushes}"/>
</chart:SfCartesianChart>
SelectionBehavior
Gets or sets a value for initiating selection or highlighting of a single or multiple data points in the series.
Declaration
public DataPointSelectionBehavior SelectionBehavior { get; set; }
Property Value
Type | Description |
---|---|
DataPointSelectionBehavior | It accepts the DataPointSelectionBehavior values and its default value is null |
Remarks
This functionality is not supported for polar charts.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.Series>
<chart:ColumnSeries ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue">
<chart:ColumnSeries.SelectionBehavior>
<chart:DataPointSelectionBehavior SelectionBrush="#314A6E"/>
</chart:ColumnSeries.SelectionBehavior>
</chart:ColumnSeries>
</chart:SfCartesianChart.Series>
</chart:SfCartesianChart>
ShowDataLabels
Gets or sets a value that indicates to enable the data labels for the series..
Declaration
public bool ShowDataLabels { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts |
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:NumericalAxis/>
</chart:SfCartesianChart.XAxes>
<chart:SfCartesianChart.YAxes>
<chart:NumericalAxis/>
</chart:SfCartesianChart.YAxes>
<chart:SfCartesianChart.Series>
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
ShowDataLabels="True">
</chart:ColumnSeries>
</chart:SfCartesianChart.Series>
</chart:SfCartesianChart>
TooltipTemplate
Gets or sets the DataTemplate that can be used to customize the appearance of the tooltip.
Declaration
public DataTemplate TooltipTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | It accepts a Microsoft.Maui.Controls.DataTemplate value. |
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.Resources>
<DataTemplate x:Key="tooltipTemplate1">
<StackLayout Orientation = "Horizontal" >
<Label Text="{Binding Item.XValue}"
TextColor="Black"
FontAttributes="Bold"
FontSize="12"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<Label Text = " : "
TextColor="Black"
FontAttributes="Bold"
FontSize="12"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<Label Text = "{Binding Item.YValue}"
TextColor="Black"
FontAttributes="Bold"
FontSize="12"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</StackLayout>
</DataTemplate>
</chart:SfCartesianChart.Resources>
<chart:SfCartesianChart.XAxes>
<chart:NumericalAxis/>
</chart:SfCartesianChart.XAxes>
<chart:SfCartesianChart.YAxes>
<chart:NumericalAxis/>
</chart:SfCartesianChart.YAxes>
<chart:SfCartesianChart.Series>
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"
TooltipTemplate="{StaticResource tooltipTemplate1}">
</chart:ColumnSeries>
</chart:SfCartesianChart.Series>
</chart:SfCartesianChart>
XBindingPath
Gets or sets a path value on the source object to serve a x value to the series.
Declaration
public string XBindingPath { get; set; }
Property Value
Type | Description |
---|---|
System.String | The |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:ColumnSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue" />
</chart:SfCartesianChart>
XRange
Gets the XRange values.
Declaration
public DoubleRange XRange { get; }
Property Value
Type |
---|
DoubleRange |
YRange
Gets the YRange values.
Declaration
public DoubleRange YRange { get; }
Property Value
Type |
---|
DoubleRange |
Methods
CreateAnimation(Action<Double>)
Creates animation for chart elements, such as series and data labels.
Declaration
protected virtual Animation CreateAnimation(Action<double> callback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.Double> | callback |
Returns
Type |
---|
Microsoft.Maui.Controls.Animation |
CreateSegment()
Creates and initializes a new chart segment for the chart.
Declaration
protected abstract ChartSegment CreateSegment()
Returns
Type |
---|
ChartSegment |
DrawDataLabel(ICanvas, Brush, String, PointF, Int32)
Draws the data labels for the series.
Declaration
protected virtual void DrawDataLabel(ICanvas canvas, Brush fillColor, string label, PointF point, int index)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Graphics.ICanvas | canvas | |
Microsoft.Maui.Controls.Brush | fillColor | |
System.String | label | |
Microsoft.Maui.Graphics.PointF | point | |
System.Int32 | index |
DrawSeries(ICanvas, ReadOnlyObservableCollection<ChartSegment>, RectF)
Draw the series for the chart.
Declaration
protected virtual void DrawSeries(ICanvas canvas, ReadOnlyObservableCollection<ChartSegment> segments, RectF clipRect)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Graphics.ICanvas | canvas | |
System.Collections.ObjectModel.ReadOnlyObservableCollection<ChartSegment> | segments | |
Microsoft.Maui.Graphics.RectF | clipRect |
GetDataPointIndex(Single, Single)
Retrieves the index of a specific data point within a chart series, typically based on the interaction or coordinates on the chart.
Declaration
public virtual int GetDataPointIndex(float pointX, float pointY)
Parameters
Type | Name | Description |
---|---|---|
System.Single | pointX | |
System.Single | pointY |
Returns
Type |
---|
System.Int32 |