MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ChartBase

    Show / Hide Table of Contents

    Class ChartBase

    The ChartBase class is the base for SfCartesianChart and SfCircularChart types.

    Inheritance
    System.Object
    ChartBase
    SfCartesianChart
    SfCircularChart
    SfFunnelChart
    SfPyramidChart
    Implements
    Microsoft.Maui.IContentView
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IPadding
    Namespace: Syncfusion.Maui.Charts
    Assembly: Syncfusion.Maui.Charts.dll
    Syntax
    public abstract class ChartBase : View, IContentView, IView, IElement, ITransform, IPadding, IChart

    Constructors

    ChartBase()

    Initializes a new instance of the ChartBase class.

    Declaration
    public ChartBase()

    Fields

    LegendProperty

    Identifies the Legend bindable property.

    Declaration
    public static readonly BindableProperty LegendProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Legend bindable property.

    PlotAreaBackgroundViewProperty

    Identifies the PlotAreaBackgroundView bindable property.

    Declaration
    public static readonly BindableProperty PlotAreaBackgroundViewProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    TitleProperty

    Identifies the Title bindable property.

    Declaration
    public static readonly BindableProperty TitleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Title bindable property.

    TooltipBehaviorProperty

    Identifies the TooltipBehavior bindable property.

    Declaration
    public static readonly BindableProperty TooltipBehaviorProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for TooltipBehavior bindable property.

    Properties

    Legend

    Gets or sets the legend that helps to identify the corresponding series or data point in chart.

    Declaration
    public ChartLegend Legend { get; set; }
    Property Value
    Type Description
    ChartLegend

    This property takes a ChartLegend instance as value and its default value is null.

    Remarks

    To render a legend, create an instance of ChartLegend, and assign it to the Legend property.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
     
    <chart:SfCircularChart>
    
           <chart:SfCircularChart.BindingContext>
               <local:ViewModel/>
           </chart:SfCircularChart.BindingContext>
    
           <chart:SfCircularChart.Legend>
               <chart:ChartLegend/>
           </chart:SfCircularChart.Legend>
    
           <chart:SfCircularChart.Series>
               <chart:PieSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue" />
           </chart:SfCircularChart.Series>
    
    </chart:SfCircularChart>
    SfCircularChart chart = new SfCircularChart();
    
    ViewModel viewModel = new ViewModel();
    chart.BindingContext = viewModel;
    
    chart.Legend = new ChartLegend();
    
    PieSeries series = new PieSeries()
    {
        ItemsSource = viewmodel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue",
    };
    chart.Series.Add(series);

    PlotAreaBackgroundView

    Gets or sets the view to the background of chart area.

    Declaration
    public View PlotAreaBackgroundView { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Controls.View

    Defaults to null.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCircularChart>
    
            <chart:SfCircularChart.BindingContext>
                <local:ViewModel/>
            </chart:SfCircularChart.BindingContext>
    
            <chart:SfCartesianChart.PlotAreaBackgroundView>
                <BoxView Color="Aqua" Margin = "10" CornerRadius = "5" />
            </chart:SfCartesianChart.PlotAreaBackgroundView>
    
            <chart:SfCircularChart.Series>
                <chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue1"/>
            </chart:SfCircularChart.Series>
    
    </chart:SfCircularChart>
     SfCircularChart chart = new SfCircularChart();
    
     ViewModel viewModel = new ViewModel();
     chart.BindingContext = viewModel;
    
     BoxView boxView = new BoxView()
     {
        Color = Colors.Aqua,
        Margin = 10,
        CornerRadius = 5,
     };
    
     chart.PlotAreaBackgroundView = boxView
    
     DoughnutSeries series = new DoughnutSeries()
     {
        ItemsSource = viewmodel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue1",
        SelectionBrush = Colors.Blue
     };
     chart.Series.Add(series);

    Title

    Gets or sets the title for chart. It supports the string or any view as title.

    Declaration
    public object Title { get; set; }
    Property Value
    Type Description
    System.Object

    Default value is null.

    Remarks

    Example code for string as title.

    • MainPage.xaml
    • MainPage.xaml.cs
        <chart:SfCartesianChart Title="Average High/Low Temperature">
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        chart.Title = "Average High / Low Temperature";

    Example code for View as title.

    • MainPage.xaml
    • MainPage.xaml.cs
        <chart:SfCartesianChart>
    
              <chart:SfCartesianChart.Title>
                  <Label Text = "Average High/Low Temperature" 
                         HorizontalOptions="Fill"
                         HorizontalTextAlignment="Center"
                         VerticalOptions="Center"
                         FontSize="16"
                         TextColor="Black"/>
              </chart:SfCartesianChart.Title>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        chart.Title = new Label()
        { 
            Text = "Average High / Low Temperature",
            HorizontalOptions = LayoutOptions.Fill,
            HorizontalTextAlignment = TextAlignment.Center,
            VerticalOptions = LayoutOptions.Center,
            FontSize = 16,
            TextColor = Colors.Black
        };

    TooltipBehavior

    Gets or sets a tooltip behavior that allows to customize the default tooltip appearance in the chart.

    Declaration
    public ChartTooltipBehavior TooltipBehavior { get; set; }
    Property Value
    Type Description
    ChartTooltipBehavior

    This property takes ChartTooltipBehavior instance as value and its default value is null.

    Remarks

    To display the tooltip on the chart, set the EnableTooltip property as true in ChartSeries.

    To customize the appearance of the tooltip elements like Background, TextColor and Font, create an instance of ChartTooltipBehavior class, modify the values, and assign it to the chart’s TooltipBehavior property.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCircularChart>
    
            <chart:SfCircularChart.BindingContext>
                <local:ViewModel/>
            </chart:SfCircularChart.BindingContext>
    
            <chart:SfCircularChart.TooltipBehavior>
                <chart:ChartTooltipBehavior/>
            </chart:SfCircularChart.TooltipBehavior>
    
            <chart:SfCircularChart.Series>
                <chart:PieSeries EnableTooltip="True" ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue1"/>
            </chart:SfCircularChart.Series>
    
    </chart:SfCircularChart>
     SfCircularChart chart = new SfCircularChart();
    
     ViewModel viewModel = new ViewModel();
     chart.BindingContext = viewModel;
    
     chart.TooltipBehavior = new ChartTooltipBehavior();
    
     PieSeries series = new PieSeries()
     {
        ItemsSource = viewmodel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue1",
        EnableTooltip = true
     };
     chart.Series.Add(series);
    See Also
    EnableTooltip

    Methods

    OnBindingContextChanged()

    Invoked when binding context changed.

    Declaration
    protected override void OnBindingContextChanged()

    Implements

    Microsoft.Maui.IContentView
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IPadding
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved