Plugin.MAUI.GoogleChartsView 0.0.1.2

dotnet add package Plugin.MAUI.GoogleChartsView --version 0.0.1.2
NuGet\Install-Package Plugin.MAUI.GoogleChartsView -Version 0.0.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plugin.MAUI.GoogleChartsView" Version="0.0.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Plugin.MAUI.GoogleChartsView --version 0.0.1.2
#r "nuget: Plugin.MAUI.GoogleChartsView, 0.0.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Plugin.MAUI.GoogleChartsView as a Cake Addin
#addin nuget:?package=Plugin.MAUI.GoogleChartsView&version=0.0.1.2

// Install Plugin.MAUI.GoogleChartsView as a Cake Tool
#tool nuget:?package=Plugin.MAUI.GoogleChartsView&version=0.0.1.2

Plugin.MAUI.GoogleChartsView

MAUI.GoogleChartsView is a user-friendly charting control designed for .NET MAUI applications. By harnessing the capabilities of Google Charts, it offers customizable data visualizations to suit a wide range of data types. This library is an ideal choice for developers who aim to create visually engaging and informative charts in their .NET MAUI applications while avoiding the complexities associated with building charting solutions from the ground up.

Latest Release

In this latest release we have added the ZoomEnabled property to the control this allows the control to be able to zoom on all platforms.

Features

  • Supports various chart types, including Line, Bar, Pie, and more
  • Customizable chart options to fit your design needs
  • Seamless integration with .NET MAUI
  • Interactive features like tooltips and animations
  • Export charts as images (PNG format) on Android and iOS platforms
  • Responsive chart rendering for different screen sizes

Getting Started

Installation

Install the Plugin.MAUI.GoogleChartsView NuGet package in your .NET MAUI project.

Usage/Examples

  1. Add the GoogleChartsView control to your page:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:charts="clr-namespace:MAUI.GoogleChartsView;assembly=MAUI.GoogleChartsView"
             x:Class="MyApp.MainPage">

         <StackLayout>
           <HorizontalStackLayout>
            <charts:GoogleChartsView x:Name="MyGoogleChartLine" WidthRequest="300"  HeightRequest="200" />
            
            <charts:GoogleChartsView x:Name="MyGoogleChartPie" WidthRequest="300"  HeightRequest="200" />
           </HorizontalStackLayout>

           <charts:GoogleChartsView x:Name="MyGoogleChartBar" WidthRequest="300"  HeightRequest="200" />
         </StackLayout>

</ContentPage>

  1. Set the chart data, options, and type in your page's code-behind:
using System.Collections.Generic;
using Microsoft.Maui.Controls;
using MyApp;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();

          var data = new
        {
            cols = new List<object>
                {
                    new { id = "", label = "Year", pattern = "", type = "string" },
                    new { id = "", label = "Sales", pattern = "", type = "number" },
                    new { id = "", label = "Expenses", pattern = "", type = "number" }
                },
            rows = new List<object>
                {
                    new { c = new List<object> { new { v = "2017" }, new { v = 1000 }, new { v = 400 } } },
                    new { c = new List<object> { new { v = "2018" }, new { v = 1170 }, new { v = 460 } } },
                    new { c = new List<object> { new { v = "2019" }, new { v = 660 }, new { v = 1120 } } },
                    new { c = new List<object> { new { v = "2020" }, new { v = 1030 }, new { v = 540 } } }
                }
        };

        var options = new
        {
            title = "Company Performance",
            curveType = "function",
            legend = new { position = "bottom" },
            backgroundColor = "#f5f5f5",
            colors = new[] { "#2196F3", "#FF5722" },
            fontSize = 12,
            fontName = "Arial",
            lineWidth = 3,
            pointSize = 5,
            hAxis = new
            {
                title = "Year",
                minValue = 0,
                textStyle = new { fontSize = 10, color = "#333" },
                titleTextStyle = new { fontSize = 12, color = "#666" }
            },
            vAxis = new
            {
                title = "Amount",
                minValue = 0,
                maxValue = 1500,
                textStyle = new { fontSize = 10, color = "#333" },
                titleTextStyle = new { fontSize = 12, color = "#666" },
                gridlines = new { count = 6 }
            },
            chartArea = new
            {
                width = "80%",
                height = "70%"
            },
            tooltip = new
            {
                isHtml = true,
                showColorCode = true
            },
            animation = new
            {
                duration = 1000,
                easing = "out",
                startup = true
            }
        };


        MyGoogleChartLine.Data = data;
        MyGoogleChartLine.ChartType = "LineChart";
        MyGoogleChartLine.Options = options;

        var data2 = new
        {
            cols = new List<object>
            {
                new { id = "", label = "Task", pattern = "", type = "string" },
                new { id = "", label = "Hours per Day", pattern = "", type = "number" }
            },
            rows = new List<object>
            {
                new { c = new List<object> { new { v = "Work" }, new { v = 11 } } },
                new { c = new List<object> { new { v = "Eat" }, new { v = 2 } } },
                new { c = new List<object> { new { v = "Commute" }, new { v = 2 } } },
                new { c = new List<object> { new { v = "Watch TV" }, new { v = 2 } } },
                new { c = new List<object> { new { v = "Sleep" }, new { v = 7 } } }
            }
        };

        var options2 = new
        {
            title = "My Daily Activities"
        };

        MyGoogleChartPie.Data = data2;
        MyGoogleChartPie.ChartType = "PieChart";
        MyGoogleChartPie.Options = options2;
        var options3 = new
        {
            title = "My Daily Activities",
            orientation = "vertical"
        };

        MyGoogleChartBar.Data = data2;
        MyGoogleChartBar.ChartType = "BarChart";
        MyGoogleChartBar.Options = options3;
    }
}

Properties that can be used in your options object

Properties that can be used in your options object like in the above sampes

Option Description Supported Chart Types
title The chart title displayed above the chart. All
curveType Sets the type of curve used to render the chart lines (e.g., "function" for a smooth curve). LineChart
legend Configures the chart legend (e.g., { position: "bottom" }). All
backgroundColor The background color of the chart area. All
colors An array of colors used for data series (e.g., new[] { "#2196F3", "#FF5722" }). All
fontSize The default font size for all chart text. All
fontName The default font family for all chart text. All
lineWidth The width of the chart lines in pixels. LineChart, AreaChart
pointSize The diameter of displayed points in pixels. LineChart, AreaChart
hAxis Configures the horizontal axis (e.g., title, minValue, textStyle, titleTextStyle). All
vAxis Configures the vertical axis (e.g., title, minValue, maxValue, textStyle, titleTextStyle, gridlines). All
chartArea Configures the chart's drawing area (e.g., width and height as percentage of the total chart area). All
tooltip Configures the tooltip displayed when hovering over data points (e.g., isHtml, showColorCode). All
animation Configures chart animation (e.g., duration, easing, startup). All
is3D Enables 3D rendering for the chart. PieChart, BarChart
pieHole Creates a donut-shaped chart by specifying the size of the hole (e.g., 0.4 for 40% of the chart radius). PieChart
reverseCategories Reverses the order of categories on the horizontal axis. BarChart, ColumnChart
orientation Sets the orientation of the chart (e.g., "horizontal" or "vertical"). BarChart
axisTitlesPosition Sets the position of axis titles ("out", "in", "none"). All
explorer Enables exploration mode in the chart to pan and zoom (e.g., { actions: ['dragToZoom', 'rightClickToReset'] }). LineChart, AreaChart
trendlines Adds trendlines to the chart to show trends in the data (e.g., { 0: { type: 'linear' } }). ScatterChart, ColumnChart

Contributing

Contributions are always welcome!

Support

For any issues please contact us at : websiterztech@gmail.com

License

Plugin.MAUI.GoogleChartsView is licensed under the MIT

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-maccatalyst16.1 is compatible.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows10.0.19041 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.
  • net7.0-android33.0

    • No dependencies.
  • net7.0-ios16.1

    • No dependencies.
  • net7.0-maccatalyst16.1

    • No dependencies.
  • net7.0-windows10.0.19041

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.1.2 94 5/8/2024
0.0.1.1 76 5/8/2024
0.0.0.6 94 5/4/2024
0.0.0.5 96 4/25/2024
0.0.0.4 255 4/11/2023
0.0.0.3 149 4/10/2023

This is our 2nd official beta release.Any feedback would be appriciated.We fixed the sample in the readmefile.