### RadarChart Example Initialization Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radar-chart.md Demonstrates how to initialize a RadarChart with sample data entries. This is a fundamental setup for displaying data. ```csharp var chart = new RadarChart { Entries = new[] { new ChartEntry(30) { Label = "Speed" }, new ChartEntry(60) { Label = "Power" }, new ChartEntry(45) { Label = "Accuracy" } } }; ``` -------------------------------- ### Install .NET MAUI Workloads Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/app-host-builder-extensions.md Install the necessary .NET workloads for Android, iOS, and macOS Catalyst development to support microcharts. ```bash dotnet workload install android ios maccatalyst maui ``` -------------------------------- ### RadarChart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/configuration.md Demonstrates how to instantiate and configure a RadarChart with custom properties. ```csharp var chart = new RadarChart { LineSize = 2.5f, PointMode = PointMode.Circle, PointSize = 16, BorderLineColor = SKColors.Gray.WithAlpha(100), BorderLineSize = 1.5f, Entries = entries }; ``` -------------------------------- ### AnimateAsync Method Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart.md Example demonstrating manual control of chart entrance and exit animations. ```csharp // Manual animation control await chart.AnimateAsync(true); // Entrance animation // ... later ... await chart.AnimateAsync(false); // Exit animation ``` -------------------------------- ### BarChart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/bar-chart.md Example of creating and configuring a BarChart with series data. Ensure ChartEntry and ChartSerie are properly defined. ```csharp var chart = new BarChart { Series = new[] { new ChartSerie { Name = "Sales", Color = SKColors.Blue, Entries = new[] { new ChartEntry(10), new ChartEntry(20) } } } }; ``` -------------------------------- ### Create a PointChart Instance Source: https://github.com/microcharts-dotnet/microcharts/wiki/PointChart Instantiate a PointChart and assign entries to it. This is the basic setup for displaying a point chart. ```csharp var chart = new PointChart { Entries = entries }; ``` -------------------------------- ### ChartEntry Initialization Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-entry.md Demonstrates how to create a ChartEntry instance and set its label, value label, and color. ```csharp var entry = new ChartEntry(42.5f) { Label = "Q1 Results", ValueLabel = "45.5K", Color = SKColors.Blue }; ``` -------------------------------- ### GenerateDefaultSerie Implementation Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/series-chart.md Example of how a default ChartSerie is created when Entries are set directly. ```csharp new ChartSerie { Entries = value.ToList(), Name = "Default - AutoGenerated", Color = null } ``` -------------------------------- ### RadialGaugeChart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/configuration.md Demonstrates how to instantiate and configure a RadialGaugeChart with custom properties. ```csharp var chart = new RadialGaugeChart { LineSize = -1, StartAngle = -90, LineAreaAlpha = 80, Entries = entries }; ``` -------------------------------- ### DonutChart Initialization Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/donut-chart.md Example of initializing a DonutChart with a specific hole radius and entries. Ensure 'entries' is a valid IEnumerable. ```csharp var chart = new DonutChart { HoleRadius = 0.4f, Entries = entries }; ``` -------------------------------- ### Create a LineChart Instance Source: https://github.com/microcharts-dotnet/microcharts/wiki/LineChart Instantiate a LineChart by providing a collection of entries. This is the basic setup for displaying a line chart. ```csharp var chart = new LineChart { Entries = entries }; ``` -------------------------------- ### Axis-Based Chart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/configuration.md Demonstrates how to instantiate and configure an axis-based chart (e.g., BarChart) with custom properties. ```csharp var chart = new BarChart { LegendOption = SeriesLegendOption.Top, LabelOrientation = Orientation.Vertical, ValueLabelOption = ValueLabelOption.TopOfElement, ValueLabelTextSize = 14, SerieLabelTextSize = 14, Series = series }; ``` -------------------------------- ### Complete Microcharts.Maui Setup in MauiProgram.cs Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/app-host-builder-extensions.md This snippet shows the complete setup for integrating Microcharts.Maui into a .NET MAUI application's MauiProgram.cs file. It includes the necessary using statements and the UseMicrocharts() extension method call. ```csharp // MauiProgram.cs using Microsoft.Maui; using Microsoft.Maui.Hosting; using Microcharts.Maui; namespace MyChartApp; public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }) .UseMicrocharts(); return builder.Build(); } } ``` -------------------------------- ### Chart Constructor Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart.md This example shows the initialization of a concrete chart implementation, such as PieChart, by setting its entries and visual properties. ```csharp var pieChart = new PieChart { Entries = new[] { new ChartEntry(30) { Label = "Q1", Color = SKColors.Blue }, new ChartEntry(40) { Label = "Q2", Color = SKColors.Red } }, BackgroundColor = SKColors.White, LabelTextSize = 16 }; ``` -------------------------------- ### Create a Simple Line Chart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/line-chart.md Demonstrates the basic setup for a LineChart with a single series of entries. Each entry has a value and a label. ```csharp var chart = new LineChart { Entries = new[] { new ChartEntry(10) { Label = "Jan" }, new ChartEntry(25) { Label = "Feb" }, new ChartEntry(18) { Label = "Mar" } } }; ``` -------------------------------- ### Draw Method Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart.md Example of how to call the Draw method within a platform-specific view's PaintSurface event handler. ```csharp // Typically called from platform-specific view's PaintSurface event void OnPaintCanvas(SKPaintSurfaceEventArgs e) { chart.Draw(e.Surface.Canvas, e.Info.Width, e.Info.Height); } ``` -------------------------------- ### Configure ChartSerie Properties Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/configuration.md Example of creating and configuring a ChartSerie with a name, color, and entries. ```csharp var serie = new ChartSerie { Name = "Product A", Color = SKColors.Blue, Entries = entries }; ``` -------------------------------- ### Basic Pie Chart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/00-START-HERE.md Demonstrates how to create a basic PieChart with sample data entries. Each entry requires a value, label, and color. ```csharp var chart = new PieChart { Entries = new[] { new ChartEntry(30) { Label = "A", Color = SKColors.Red }, new ChartEntry(40) { Label = "B", Color = SKColors.Green } } }; ``` -------------------------------- ### Configure PointMode for LineChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Example of configuring the PointMode for a LineChart. This example sets points to be displayed as circles and specifies their size. ```csharp var chart = new LineChart { PointMode = PointMode.Circle, PointSize = 14, Entries = entries }; ``` -------------------------------- ### Create LineChart Instance Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/line-chart.md Example of creating a LineChart and assigning a series with data entries. Use this to set up a basic line chart with a single series. ```csharp var chart = new LineChart { Series = new[] { new ChartSerie { Name = "Temperature", Color = SKColors.Red, Entries = entries } } }; ``` -------------------------------- ### Create a Basic Pie Chart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/pie-chart.md This example demonstrates how to create a basic PieChart with three entries, each having a value, label, and color. Ensure ChartEntry is properly defined. ```csharp var chart = new PieChart { Entries = new[] { new ChartEntry(30) { Label = "Sales", Color = SKColors.Blue }, new ChartEntry(25) { Label = "Marketing", Color = SKColors.Red }, new ChartEntry(45) { Label = "Development", Color = SKColors.Green } } }; ``` -------------------------------- ### Initialize LineChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/line-chart.md Initializes a new LineChart instance with default settings. This is a basic setup for creating a line chart. ```csharp public LineChart() ``` -------------------------------- ### Create PointChart with Entries Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Example of creating a PointChart and assigning data entries. Ensure ChartEntry objects are properly initialized with values and labels. ```csharp var chart = new PointChart { Entries = new[] { new ChartEntry(10) { Label = "A" }, new ChartEntry(25) { Label = "B" }, new ChartEntry(18) { Label = "C" } } }; ``` -------------------------------- ### Create RadialGaugeChart with Entries Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radial-gauge-chart.md Example of creating a RadialGaugeChart and assigning entries to it. Each entry represents a value with a label and color. ```csharp var chart = new RadialGaugeChart { Entries = new[] { new ChartEntry(75) { Label = "CPU Usage", Color = SKColors.Orange }, new ChartEntry(45) { Label = "Memory", Color = SKColors.Blue }, new ChartEntry(90) { Label = "Disk", Color = SKColors.Red } } }; ``` -------------------------------- ### DonutChart with GraphPosition Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Example of setting the GraphPosition for a DonutChart. Ensure 'entries' is defined. ```csharp var chart = new DonutChart { GraphPosition = GraphPosition.Center, LabelMode = LabelMode.LeftAndRight, Entries = entries }; ``` -------------------------------- ### MAUI Integration Setup Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/00-START-HERE.md Shows how to integrate Microcharts into a MAUI application by using the `UseMicrocharts()` extension method in `MauiProgram.cs` and referencing the `ChartView` in XAML. ```csharp // MauiProgram.cs public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder.UseMauiApp().UseMicrocharts(); return builder.Build(); } // XAML ``` -------------------------------- ### SKColor Usage Examples Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Demonstrates various ways to define SKColor, including named colors, RGB parsing, RGBA instantiation, and alpha manipulation. ```csharp // Named colors var color = SKColors.Blue; var color = SKColors.Red; var color = SKColors.Transparent; // RGB var color = SKColor.Parse("#FF0000"); // RGBA var color = new SKColor(255, 0, 0, 128); // Red with 50% alpha // With transparency var color = SKColors.Blue.WithAlpha(200); ``` -------------------------------- ### Define PieChart with Entries Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/simple-chart.md This example demonstrates how to instantiate a PieChart and populate its Entries property with ChartEntry objects, each having a value, label, and color. ```csharp var chart = new PieChart { Entries = new ChartEntry[] { new ChartEntry(30) { Label = "Sales", Color = SKColors.Blue }, new ChartEntry(20) { Label = "Marketing", Color = SKColors.Red }, new ChartEntry(50) { Label = "Development", Color = SKColors.Green } } }; ``` -------------------------------- ### DonutChart Constructor Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/donut-chart.md Initializes a new DonutChart instance with default settings. This is a basic setup for creating a donut chart. ```csharp public DonutChart() ``` -------------------------------- ### RadarChart Constructor Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radar-chart.md Initializes a new radar chart with default settings. Use this for a basic radar chart setup. ```csharp public RadarChart() ``` -------------------------------- ### Create a ChartEntry Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/README.md Example of creating a single data point for a chart. Use this when you have individual values with optional labels and colors. ```csharp var entry = new ChartEntry(value: 42.5f) { Label = "Name", ValueLabel = "42.5", Color = SKColors.Blue, TextColor = SKColors.Gray }; ``` -------------------------------- ### Single Series Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-serie.md Illustrates the creation of a single ChartSerie with a name, color, and a collection of ChartEntry objects. This is useful for charts displaying a single dataset. ```csharp var serie = new ChartSerie { Name = "Q1 Revenue", Color = SKColors.Blue, Entries = new[] { new ChartEntry(10000) { Label = "Jan" }, new ChartEntry(12000) { Label = "Feb" }, new ChartEntry(15000) { Label = "Mar" } } }; ``` -------------------------------- ### UWP ChartView Setup Source: https://github.com/microcharts-dotnet/microcharts/wiki/Home Declares a `ChartView` in UWP XAML and assigns chart data to it in the page's constructor. ```xml ``` ```csharp public MainPage() { this.InitializeComponent(); // ... our chart data and chart type here ... chartView.Chart = chart; } ``` -------------------------------- ### Line Chart with Area Fill Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/README.md Illustrates creating a LineChart with spline mode, area fill, and fade-out gradient effect. Requires entry data. ```csharp var chart = new LineChart { LineMode = LineMode.Spline, LineAreaAlpha = 64, EnableYFadeOutGradient = true, Entries = entries }; ``` -------------------------------- ### Xamarin.Android ChartView Setup Source: https://github.com/microcharts-dotnet/microcharts/wiki/Home Integrates a `ChartView` into a Xamarin.Android application's layout and assigns chart data to it. ```xml ``` ```csharp protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); // ... our chart data and chart type here ... var chartView = FindViewById(Resource.Id.chartView); chartView.Chart = chart; } ``` -------------------------------- ### Classic Donut Chart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/donut-chart.md Demonstrates creating a classic donut chart with a hole radius of 0.5f and defining sales, marketing, and operations entries with corresponding colors. ```csharp var chart = new DonutChart { HoleRadius = 0.5f, Entries = new[] { new ChartEntry(40) { Label = "Sales", Color = SKColors.Blue }, new ChartEntry(30) { Label = "Marketing", Color = SKColors.Red }, new ChartEntry(30) { Label = "Operations", Color = SKColors.Green } } }; ``` -------------------------------- ### Real-Time Chart Updates in MAUI Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-view-maui.md Example of a MAUI ContentPage that displays a LineChart and updates it in real-time every second. ```csharp public partial class LiveChartPage : ContentPage { private LineChart chart; private List entries; public LiveChartPage() { InitializeComponent(); entries = new List { new ChartEntry(10), new ChartEntry(20), new ChartEntry(15) }; chart = new LineChart { Entries = entries }; ChartView.Chart = chart; // Update chart every second Dispatcher.StartTimer(TimeSpan.FromSeconds(1), () => { entries.Add(new ChartEntry(Random.Shared.Next(30))); entries.RemoveAt(0); chart.Entries = entries; // Triggers animation return true; }); } } ``` -------------------------------- ### Basic ChartEntry Creation Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-entry.md A simple example of creating a ChartEntry with only a numeric value, suitable for basic chart data. ```csharp var entry = new ChartEntry(100); ``` -------------------------------- ### Multi-Series Bar Chart Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/00-START-HERE.md Illustrates the creation of a BarChart with multiple series. Each series can have a name and a collection of entries. Legend options can also be configured. ```csharp var chart = new BarChart { Series = new[] { new ChartSerie { Name = "Q1", Entries = q1 }, new ChartSerie { Name = "Q2", Entries = q2 } }, LegendOption = SeriesLegendOption.Top }; ``` -------------------------------- ### Xamarin.MacOS ChartView Setup Source: https://github.com/microcharts-dotnet/microcharts/wiki/Home Initializes and adds a `ChartView` to the view in a Xamarin.MacOS application, configuring its layout and assigning chart data. ```csharp public override void ViewDidLoad() { base.ViewDidLoad(); // ... our chart data and chart type here ... var chartView = new ChartView { Frame = View.Bounds, AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable, Chart = chart, }; View.AddSubview(chartView); } ``` -------------------------------- ### Initialize RadialGaugeChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radial-gauge-chart.md Initializes a new radial gauge chart with default settings. This is a basic setup for creating a chart instance. ```csharp public RadialGaugeChart() ``` -------------------------------- ### Setup Chart Data Entries Source: https://github.com/microcharts-dotnet/microcharts/wiki/Home Defines an array of `ChartEntry` objects to populate a chart. Each entry includes a value, label, value label, and color. ```csharp var entries = new[] { new ChartEntry(212) { Label = "UWP", ValueLabel = "112", Color = SKColor.Parse("#2c3e50") }, new ChartEntry(248) { Label = "Android", ValueLabel = "648", Color = SKColor.Parse("#77d065") }, new ChartEntry(128) { Label = "iOS", ValueLabel = "428", Color = SKColor.Parse("#b455b6") }, new ChartEntry(514) { Label = "Forms", ValueLabel = "214", Color = SKColor.Parse("#3498db") } }; ``` -------------------------------- ### Create a ChartSerie Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/README.md Example of creating a named collection of entries for multi-series charts. This allows grouping related data points under a single series name. ```csharp var serie = new ChartSerie { Name = "Series Name", Entries = entries, Color = SKColors.Blue // Optional override }; ``` -------------------------------- ### Setting Chart Data in Code-Behind Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/app-host-builder-extensions.md Shows how to instantiate a chart (e.g., PieChart) and assign it to the ChartView's Chart property in the code-behind file of a .NET MAUI page. This example uses PieChart with sample data. ```csharp namespace MyChartApp; public partial class ChartPage : ContentPage { public ChartPage() { InitializeComponent(); var chart = new PieChart { Entries = new[] { new ChartEntry(40) { Label = "Q1" }, new ChartEntry(35) { Label = "Q2" }, new ChartEntry(25) { Label = "Q3" } } }; chartView.Chart = chart; } } ``` -------------------------------- ### Invalidated Event Usage Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart.md Example of subscribing to the Invalidated event to trigger a canvas view redraw. ```csharp var chart = new PieChart(); chart.Invalidated += (sender, e) => { // Trigger platform view redraw canvasView.InvalidateSurface(); }; ``` -------------------------------- ### ObserveInvalidate Method Example Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart.md Example of using a weak event handler to observe chart invalidation, commonly used internally by platform views for redraw notifications. ```csharp // Weak event handler usage (platform views use this internally) var handler = chart.ObserveInvalidate(canvasView, view => { view.InvalidateSurface(); }); ``` -------------------------------- ### Set Start Angle for Radial Gauge Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radial-gauge-chart.md Defines the starting angle in degrees for the gauge arc. -90 degrees corresponds to the top (12 o'clock) position. ```csharp public float StartAngle { get; set; } = -90; ``` -------------------------------- ### Create a ChartSerie Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-serie.md Demonstrates how to create a ChartSerie instance using object initializer syntax. This is the recommended way to instantiate a ChartSerie. ```csharp var serie = new ChartSerie { Name = "Sales", Entries = entries, Color = SKColors.Blue }; ``` -------------------------------- ### Set Gauge Starting Angle to Right Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radial-gauge-chart.md Customizes the starting angle of the gauge arcs to begin from the right side (0 degrees). Modify `StartAngle` to change the orientation. ```csharp var chart = new RadialGaugeChart { StartAngle = 0, // Start at right (3 o'clock) Entries = entries }; ``` -------------------------------- ### Simplified Entry Assignment on SeriesChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-serie.md Illustrates a shortcut for assigning entries directly to a SeriesChart, which automatically creates a default ChartSerie. This simplifies chart setup when only one series is needed. ```csharp var chart = new BarChart { Entries = entries // Auto-generates a default series }; // Equivalent to: // chart.Series = new[] { new ChartSerie { Entries = entries } } ``` -------------------------------- ### YAxisTextFont Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets the font used for Y-axis labels. ```APIDOC ## YAxisTextFont ### Description Gets or sets the font used for Y-axis labels. ### Code Example ```csharp // Example of setting a font (actual SKFont creation not shown) // chart.YAxisTextFont = new SKFont(...); ``` ``` -------------------------------- ### Create a Simple Point Chart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Demonstrates the basic creation of a PointChart with a single series of entries. Each entry has a value and a label. ```csharp var chart = new PointChart { Entries = new[] { new ChartEntry(30) { Label = "Jan" }, new ChartEntry(45) { Label = "Feb" }, new ChartEntry(40) { Label = "Mar" } } }; ``` -------------------------------- ### Build Full Solution Source: https://github.com/microcharts-dotnet/microcharts/blob/main/CLAUDE.md Builds the entire Microcharts .NET solution in Release configuration. This is the preferred build command. ```bash # Build the full solution (preferred) dotnet build Sources/Microcharts.Maui.sln --configuration Release ``` -------------------------------- ### YAxisTextFont Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets the font used for Y-axis labels. ```csharp public SKFont YAxisTextFont { get; set; } ``` -------------------------------- ### Initialize a new PieChart instance Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/pie-chart.md Use this constructor to create a new PieChart with default settings. No parameters are required. ```csharp public PieChart() ``` -------------------------------- ### Configure LabelMode for DonutChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Example of setting the LabelMode for a DonutChart. This determines how the labels for each segment are rendered. ```csharp var chart = new DonutChart { LabelMode = LabelMode.LeftAndRight, Entries = entries }; ``` -------------------------------- ### DonutChart Usage Source: https://github.com/microcharts-dotnet/microcharts/wiki/DonutChart Demonstrates how to create and initialize a DonutChart with entries. ```APIDOC ## Usage ```csharp var chart = new DonutChart { Entries = entries }; ``` ``` -------------------------------- ### ValueLabelOrientation Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets the orientation of value labels. This property accepts the same values as LabelOrientation. ```APIDOC ## ValueLabelOrientation ### Description Gets or sets the orientation of value labels. ### Property Type `Orientation` ### Values - `Default`: Converted to Vertical - `Horizontal`: Labels horizontal (left-to-right) - `Vertical`: Labels vertical (rotated) ### Remarks Same values as `LabelOrientation`. ``` -------------------------------- ### Xamarin.Forms ChartView Setup Source: https://github.com/microcharts-dotnet/microcharts/wiki/Home Defines a `ChartView` in XAML for a Xamarin.Forms application and assigns chart data in code-behind. ```xml ``` ```csharp protected override void OnAppearing() { base.OnAppearing(); // ... our chart data and chart type here ... chartView.Chart = chart; } ``` -------------------------------- ### Xamarin.iOS ChartView Setup Source: https://github.com/microcharts-dotnet/microcharts/wiki/Home Adds a `ChartView` to the view hierarchy in a Xamarin.iOS application and assigns chart data. ```csharp public override void ViewDidLoad() { base.ViewDidLoad(); // ... our chart data and chart type here ... var chartView = new ChartView { Frame = new CGRect(0, 0, View.Bounds.Width, 250), AutoresizingMask = UIViewAutoresizing.FlexibleWidth, Chart = chart }; View.AddSubview(chartView); } ``` -------------------------------- ### Create a Pie Chart Source: https://github.com/microcharts-dotnet/microcharts/wiki/PieChart Instantiate a PieChart and assign entries to it. Ensure 'entries' is a collection of ChartEntry objects. ```csharp var chart = new PieChart { Entries = entries }; ``` -------------------------------- ### Instantiate a BarChart Source: https://github.com/microcharts-dotnet/microcharts/wiki/BarChart This snippet shows the basic instantiation of a BarChart with entries. Ensure 'entries' is defined before use. ```csharp var chart = new BarChart { Entries = entries }; ``` -------------------------------- ### ValueLabelTextSize Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets the font size of value labels. The default size is 16 pixels. ```APIDOC ## ValueLabelTextSize ### Description Gets or sets the font size of value labels. ### Property Type `float` ### Default `16` pixels ### Example ```csharp chart.ValueLabelTextSize = 14; ``` ``` -------------------------------- ### LineChart with Horizontal Labels Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Example of configuring a LineChart with horizontal label orientation and vertical value label orientation. ```csharp var chart = new LineChart { LabelOrientation = Orientation.Horizontal, ValueLabelOrientation = Orientation.Vertical, Entries = entries }; ``` -------------------------------- ### Simple Single Series BarChart Initialization Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/series-chart.md Demonstrates initializing a BarChart with a single series of entries, where the series is auto-generated. ```csharp var chart = new BarChart { Entries = entries // Auto-generates a series }; ``` -------------------------------- ### Initialize PointChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Initializes a new instance of the PointChart class with default settings. Use this to create a basic PointChart. ```csharp public PointChart() ``` -------------------------------- ### StartAngle Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radial-gauge-chart.md Sets the starting angle for the gauge arc in degrees, with -90 degrees being the default top position. ```APIDOC ## StartAngle ### Description Angle where gauge arc begins, in degrees. ### Property `public float StartAngle { get; set; } = -90; ` ### Values | Angle | Position | |-------|----------| | `-90` | Top (12 o'clock) - default | | `0` | Right (3 o'clock) | | `90` | Bottom (6 o'clock) | | `180` | Left (9 o'clock) | The gauge arc then progresses clockwise 360° from this starting point. ``` -------------------------------- ### Pack All NuGet Packages (macOS/Linux) Source: https://github.com/microcharts-dotnet/microcharts/blob/main/CLAUDE.md Executes a shell script to pack all NuGet packages for the Microcharts .NET library on macOS or Linux systems. ```bash # Pack all NuGet packages (macOS/Linux) ./buildpackages-maui.sh ``` -------------------------------- ### Initialize RadarChart Source: https://github.com/microcharts-dotnet/microcharts/wiki/RadarChart Instantiate a RadarChart with a collection of entries. This is the primary way to create a RadarChart instance for rendering. ```csharp var chart = new RadarChart { Entries = entries }; ``` -------------------------------- ### Per-Entry Coloring BarChart Initialization Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/series-chart.md Demonstrates initializing a BarChart where the series itself has no color, allowing individual entries to define their colors. ```csharp var chart = new BarChart { Series = new[] { new ChartSerie { Color = null, // Use per-entry colors Entries = new[] { new ChartEntry(10) { Color = SKColors.Red }, new ChartEntry(20) { Color = SKColors.Green }, new ChartEntry(15) { Color = SKColors.Blue } } } } }; ``` -------------------------------- ### PointAreaAlpha Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Gets or sets the transparency of the area below points. This controls the fill opacity for the area under the data points. ```APIDOC ## PointAreaAlpha Property ### Description Gets or sets the transparency of the area below points. ### Property Type `byte` ### Range 0-255 ### Transparency Levels - **0:** No area fill - **100:** Semi-transparent (default) - **255:** Opaque fill ### Example ```csharp chart.PointAreaAlpha = 50; // More transparent ``` ``` -------------------------------- ### Create a Bar Chart with Rounded Bars and Background Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/bar-chart.md Illustrates how to configure rounded corners for bars and set the alpha for the bar area background. Requires pre-defined entries. ```csharp var chart = new BarChart { CornerRadius = 8, BarAreaAlpha = 64, Entries = entries }; ``` -------------------------------- ### SerieLabelTextSize Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets the font size of series names in the legend. The default size is 16 pixels. ```APIDOC ## SerieLabelTextSize ### Description Gets or sets the font size of series names in legend. ### Property Type `float` ### Default `16` pixels ``` -------------------------------- ### Basic Pie Chart Usage Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/pie-chart.md Demonstrates how to create a basic PieChart with a set of entries. Each entry defines a value, label, and color for a slice. ```APIDOC ## Basic Pie Chart ### Description Creates a basic PieChart with specified entries. ### Code ```csharp var chart = new PieChart { Entries = new[] { new ChartEntry(10) { Label = "A", Color = SKColors.Red }, new ChartEntry(20) { Label = "B", Color = SKColors.Green }, new ChartEntry(30) { Label = "C", Color = SKColors.Blue } } }; ``` ``` -------------------------------- ### LabelOrientation Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets the orientation of X-axis labels. Labels can be Default (converted to Vertical), Horizontal, or Vertical. ```APIDOC ## LabelOrientation ### Description Gets or sets the orientation of X-axis labels. ### Property Type `Orientation` ### Values - `Default`: Converted to Vertical - `Horizontal`: Labels horizontal (left-to-right) - `Vertical`: Labels vertical (rotated) ### Example ```csharp chart.LabelOrientation = Orientation.Vertical; ``` ``` -------------------------------- ### LegendOption Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets where the series legend appears on the chart. Options include Top, Bottom, or None. ```APIDOC ## LegendOption ### Description Gets or sets where the series legend appears. ### Property Type `SeriesLegendOption` ### Values - `Top`: Legend appears above chart - `Bottom`: Legend appears below chart - `None`: No legend (default) ### Example ```csharp var chart = new BarChart { LegendOption = SeriesLegendOption.Top, Series = series }; ``` ``` -------------------------------- ### Multiple Series BarChart Initialization Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/series-chart.md Shows how to initialize a BarChart with multiple series, each having a custom name. ```csharp var chart = new BarChart { Series = new[] { new ChartSerie { Name = "2023", Entries = entries2023 }, new ChartSerie { Name = "2024", Entries = entries2024 } } }; ``` -------------------------------- ### Create Basic Gauge Chart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/radial-gauge-chart.md Demonstrates creating a simple RadialGaugeChart with a single data entry. Use this for displaying a single progress value. ```csharp var chart = new RadialGaugeChart { Entries = new[] { new ChartEntry(75) { Label = "Temperature", Color = SKColors.Red } } }; ``` -------------------------------- ### ChartView.Chart Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-view-maui.md Gets or sets the Chart to display in the ChartView. Changes to this property automatically trigger a view refresh. ```APIDOC ## Chart ### Description Gets or sets the Chart to display in this view. Setting the Chart to null displays a transparent view. Chart changes automatically trigger view refresh. ### Property Signature ```csharp public Chart Chart { get; set; } ``` ### Property Details - **Type**: `Chart` - **Default**: `null` - **Bindable**: Yes (BindableProperty) - **Property Name**: `ChartProperty` ### Usage Example (XAML) ```xml ``` ### Usage Example (C#) ```csharp chartView.Chart = new BarChart { Entries = entries }; ``` ### Remarks - Setting Chart to null displays a transparent view - Chart changes automatically trigger view refresh - Weak event handlers prevent memory leaks when chart is replaced ``` -------------------------------- ### Create a Donut Chart Source: https://github.com/microcharts-dotnet/microcharts/wiki/DonutChart Instantiates a DonutChart with a given set of entries. Ensure 'entries' is a collection of ChartEntry objects. ```csharp var chart = new DonutChart { Entries = entries }; ``` -------------------------------- ### Configure Square Points with Custom Sizing Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Shows how to set the point shape to square, customize the point size, and control the area fill transparency for a PointChart. ```csharp var chart = new PointChart { PointMode = PointMode.Square, PointSize = 18, PointAreaAlpha = 75, Entries = entries }; ``` -------------------------------- ### PointMode Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Gets or sets the shape of data points. This property determines whether points are displayed as circles, squares, or not at all. ```APIDOC ## PointMode Property ### Description Gets or sets the shape of data points. ### Property Type `PointMode` ### Possible Values - `Circle`: Filled circles (default) - `Square`: Filled squares - `None`: No points ### Example ```csharp chart.PointMode = PointMode.Circle; chart.PointSize = 16; ``` ``` -------------------------------- ### Full ChartEntry Configuration Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-entry.md Shows how to fully configure a ChartEntry by setting its value, label, value label, primary color, text color, and value label color. ```csharp var entry = new ChartEntry(45.5f) { Label = "January", ValueLabel = "45.5", Color = SKColors.Blue, TextColor = SKColors.DarkGray, ValueLabelColor = SKColors.Black }; ``` -------------------------------- ### PointSize Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Gets or sets the diameter of data points in pixels. This property controls the visual size of each point on the chart. ```APIDOC ## PointSize Property ### Description Gets or sets the diameter of data points in pixels. ### Property Type `float` ### Range 0 to canvas size ### Example ```csharp chart.PointSize = 20; // Larger points ``` ``` -------------------------------- ### ValueLabelOption Property Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Gets or sets where value labels are positioned on the chart. Options include TopOfChart, TopOfElement, OverElement, or None. ```APIDOC ## ValueLabelOption ### Description Gets or sets where value labels are positioned. ### Property Type `ValueLabelOption` ### Values - `TopOfChart`: All labels at top of chart - `TopOfElement`: Labels above each bar/point - `OverElement`: Labels centered on bars/points - `None`: No labels ### Remarks - LineChart with multiple series changes `TopOfChart` to `TopOfElement` automatically - See specific chart documentation for variations ### Example ```csharp chart.ValueLabelOption = ValueLabelOption.TopOfElement; ``` ``` -------------------------------- ### Configure LineMode for LineChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Example of setting the LineMode for a LineChart to use smooth spline interpolation. This also sets the thickness of the line. ```csharp var chart = new LineChart { LineMode = LineMode.Spline, LineSize = 2, Entries = entries }; ``` -------------------------------- ### Accessing an Asset File Source: https://github.com/microcharts-dotnet/microcharts/blob/main/Sources/Microcharts.Samples.Android/Assets/AboutAssets.txt Demonstrates how to open and read a raw asset file using the Android AssetManager. Ensure the file has a Build Action of 'AndroidAsset'. ```csharp public class ReadAsset : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); InputStream input = Assets.Open ("my_asset.txt"); } } ``` -------------------------------- ### BarChart with Legend and Value Labels Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/axis-based-chart.md Example of creating a BarChart with legend positioned at the top and value labels displayed on top of elements. ```csharp var chart = new BarChart { LegendOption = SeriesLegendOption.Top, ValueLabelOption = ValueLabelOption.TopOfElement, Series = new[] { new ChartSerie { Name = "Product A", Entries = entries1 }, new ChartSerie { Name = "Product B", Entries = entries2 } } }; ``` -------------------------------- ### BarChart Constructor Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/bar-chart.md Initializes a new BarChart instance. Use this to create a basic bar chart configuration. ```csharp public BarChart() ``` -------------------------------- ### Configure Orientation for BarChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Example of setting label orientations for a BarChart. This demonstrates using both vertical labels for the bars and horizontal labels for the values. ```csharp var chart = new BarChart { LabelOrientation = Orientation.Vertical, ValueLabelOrientation = Orientation.Horizontal, Entries = entries }; ``` -------------------------------- ### Creating a Collection of ChartEntries for a Chart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/chart-entry.md Illustrates how to create an array of ChartEntry objects, each with a value and label, and assign them to a BarChart. ```csharp var entries = new[] { new ChartEntry(10) { Label = "Mon", Color = SKColors.Red }, new ChartEntry(25) { Label = "Tue", Color = SKColors.Orange }, new ChartEntry(18) { Label = "Wed", Color = SKColors.Yellow }, new ChartEntry(32) { Label = "Thu", Color = SKColors.Green }, new ChartEntry(28) { Label = "Fri", Color = SKColors.Blue } }; var chart = new BarChart { Entries = entries }; ``` -------------------------------- ### Create a Single Series Bar Chart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/bar-chart.md Demonstrates how to create a basic bar chart with a single series of entries. Each entry can have a label and a color. ```csharp var chart = new BarChart { Entries = new[] { new ChartEntry(10) { Label = "Q1", Color = SKColors.Blue }, new ChartEntry(25) { Label = "Q2", Color = SKColors.Red }, new ChartEntry(18) { Label = "Q3", Color = SKColors.Green } } }; ``` -------------------------------- ### Colored Series LineChart Initialization Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/series-chart.md Illustrates initializing a LineChart with a series that has a custom name and a specific color. ```csharp var chart = new LineChart { Series = new[] { new ChartSerie { Name = "Revenue", Color = SKColors.Green, Entries = entries } } }; ``` -------------------------------- ### Set Animation Duration Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/types.md Configures the animation duration for charts using TimeSpan. Examples show setting duration in milliseconds, seconds, and with a TimeSpan constructor. ```csharp chart.AnimationDuration = TimeSpan.FromMilliseconds(500); chart.AnimationDuration = TimeSpan.FromSeconds(2); chart.AnimationDuration = new TimeSpan(0, 0, 1, 500); // 1.5 seconds ``` -------------------------------- ### Loading a Font from Assets Source: https://github.com/microcharts-dotnet/microcharts/blob/main/Sources/Microcharts.Samples.Android/Assets/AboutAssets.txt Shows how to load a font file directly from the Android assets directory using Typeface.CreateFromAsset. The path is relative to the assets folder. ```csharp Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); ``` -------------------------------- ### Configure .NET MAUI Project for Microcharts Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/app-host-builder-extensions.md Specify the target frameworks in your .csproj file to ensure compatibility with the required platforms for microcharts. ```xml net10.0-windows; net10.0-maccatalyst; net10.0-ios; net10.0-android ``` -------------------------------- ### Set PointMode for PointChart Source: https://github.com/microcharts-dotnet/microcharts/blob/main/_autodocs/api-reference/point-chart.md Configures the shape of the data points. Supported modes include Circle, Square, and None. This example sets points to be circles. ```csharp chart.PointMode = PointMode.Circle; chart.PointSize = 16; ```