Skip to content

Commit a9e9df4

Browse files
added sample
1 parent 0fc288b commit a9e9df4

30 files changed

+763
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31710.8
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PieChartDemo", "PieChartDemo\PieChartDemo.csproj", "{01293D4A-08A3-4D47-8660-BD22D508F5C7}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{01293D4A-08A3-4D47-8660-BD22D508F5C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{01293D4A-08A3-4D47-8660-BD22D508F5C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{01293D4A-08A3-4D47-8660-BD22D508F5C7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{01293D4A-08A3-4D47-8660-BD22D508F5C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{01293D4A-08A3-4D47-8660-BD22D508F5C7}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{01293D4A-08A3-4D47-8660-BD22D508F5C7}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {2D1F2E5D-D9DC-40E0-A728-5F9752C7E8C0}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3+
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
4+
xmlns:local="clr-namespace:MauiApp2"
5+
x:Class="MauiApp2.App"
6+
windows:Application.ImageDirectory="Assets">
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
10+
<Color x:Key="PrimaryColor">#512bdf</Color>
11+
<Color x:Key="SecondaryColor">White</Color>
12+
13+
<Style TargetType="Label">
14+
<Setter Property="TextColor" Value="{DynamicResource PrimaryColor}" />
15+
<Setter Property="FontFamily" Value="OpenSansRegular" />
16+
</Style>
17+
18+
<Style TargetType="Button">
19+
<Setter Property="TextColor" Value="{DynamicResource SecondaryColor}" />
20+
<Setter Property="FontFamily" Value="OpenSansRegular" />
21+
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}" />
22+
<Setter Property="Padding" Value="14,10" />
23+
</Style>
24+
25+
</ResourceDictionary>
26+
</Application.Resources>
27+
</Application>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Charts;
2+
using Microsoft.Maui;
3+
using Microsoft.Maui.Controls;
4+
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
5+
using Microsoft.Maui.Graphics;
6+
using Application = Microsoft.Maui.Controls.Application;
7+
using TabbedPage = Microsoft.Maui.Controls.TabbedPage;
8+
9+
namespace MauiApp2
10+
{
11+
public partial class App : Application
12+
{
13+
public App()
14+
{
15+
InitializeComponent();
16+
17+
TabbedPage tab = new TabbedPage() { BarTextColor = Colors.White };
18+
tab.Children.Add(new MainPage() { Title = "Using xaml" });
19+
tab.Children.Add(new PieDemo() { Title = "Using C#" });
20+
MainPage = tab;
21+
}
22+
}
23+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3+
x:Class="Charts.MainPage"
4+
xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts"
5+
xmlns:viewModel ="clr-namespace:Charts.ViewModel"
6+
BackgroundColor="{DynamicResource PageBackgroundColor}">
7+
8+
<Grid HorizontalOptions="FillAndExpand" Padding="20" BackgroundColor="White" VerticalOptions="FillAndExpand">
9+
<chart:SfCircularChart>
10+
<chart:SfCircularChart.BindingContext>
11+
<viewModel:ViewModel/>
12+
</chart:SfCircularChart.BindingContext>
13+
<chart:SfCircularChart.Legend>
14+
<chart:ChartLegend Placement="Right" />
15+
</chart:SfCircularChart.Legend>
16+
<chart:SfCircularChart.Title>
17+
<Label Text="Rural population of various countries" FontSize="Large" Margin="5,10,5,10" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand"></Label>
18+
</chart:SfCircularChart.Title>
19+
<chart:SfCircularChart.Series>
20+
<chart:PieSeries ItemsSource="{Binding Data}" ShowDataLabels="True" Palette="Custom" CustomBrushes="{Binding CustomBrushes}"
21+
XBindingPath="Country"
22+
YBindingPath="Counts">
23+
<chart:PieSeries.DataLabelSettings>
24+
<chart:CircularDataLabelSettings>
25+
<chart:CircularDataLabelSettings.LabelStyle>
26+
<chart:ChartDataLabelStyle LabelFormat="0'%"/>
27+
</chart:CircularDataLabelSettings.LabelStyle>
28+
</chart:CircularDataLabelSettings>
29+
</chart:PieSeries.DataLabelSettings>
30+
</chart:PieSeries>
31+
</chart:SfCircularChart.Series>
32+
</chart:SfCircularChart>
33+
</Grid>
34+
</ContentPage>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Microsoft.Maui.Controls;
4+
using Syncfusion.Maui.Charts;
5+
namespace Charts
6+
{
7+
public partial class MainPage : ContentPage
8+
{
9+
public MainPage()
10+
{
11+
InitializeComponent();
12+
}
13+
}
14+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Maui;
2+
using Microsoft.Maui.Controls.Compatibility;
3+
using Microsoft.Maui.Controls.Hosting;
4+
using Microsoft.Maui.Hosting;
5+
using Syncfusion.Maui.Core.Hosting;
6+
using Syncfusion.Maui.Graphics.Internals;
7+
8+
namespace MauiApp2
9+
{
10+
public static class MauiProgram
11+
{
12+
public static MauiApp CreateMauiApp()
13+
{
14+
var builder = MauiApp.CreateBuilder();
15+
builder
16+
.UseMauiApp<App>()
17+
.ConfigureSyncfusionCore()
18+
.ConfigureFonts(fonts =>
19+
{
20+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
21+
});
22+
23+
return builder.Build();
24+
}
25+
}
26+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
5+
<!--<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>-->
6+
<OutputType>Exe</OutputType>
7+
<RootNamespace>MauiApp2</RootNamespace>
8+
<UseMaui>true</UseMaui>
9+
<SingleProject>true</SingleProject>
10+
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
11+
12+
<!-- Display name -->
13+
<ApplicationTitle>MauiApp2</ApplicationTitle>
14+
15+
<!-- App Identifier -->
16+
<ApplicationId>com.companyname.MauiApp2</ApplicationId>
17+
18+
<!-- Versions -->
19+
<ApplicationVersion>1.0</ApplicationVersion>
20+
<AndroidVersionCode>1</AndroidVersionCode>
21+
22+
<!-- Required for C# Hot Reload -->
23+
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<!-- App Icon -->
28+
<MauiImage Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" IsAppIcon="true" Color="#512BD4" />
29+
30+
<!-- Splash Screen -->
31+
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />
32+
33+
<!-- Images -->
34+
<MauiImage Include="Resources\Images\*" />
35+
36+
<!-- Custom Fonts -->
37+
<MauiFont Include="Resources\Fonts\*" />
38+
</ItemGroup>
39+
40+
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
41+
<!-- Required - WinUI does not yet have buildTransitive for everything -->
42+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-experimental1" />
43+
<PackageReference Include="Microsoft.WindowsAppSDK.Foundation" Version="1.0.0-experimental1" />
44+
<PackageReference Include="Microsoft.WindowsAppSDK.WinUI" Version="1.0.0-experimental1" />
45+
<PackageReference Include="Microsoft.WindowsAppSDK.InteractiveExperiences" Version="1.0.0-experimental1" NoWarn="NU1701" />
46+
</ItemGroup>
47+
48+
<ItemGroup>
49+
<PackageReference Include="Syncfusion.Maui.Charts" Version="19.3.43-preview" />
50+
</ItemGroup>
51+
52+
<!--<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
53+
<OutputType>WinExe</OutputType>
54+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
55+
</PropertyGroup>-->
56+
57+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
5+
<ActiveDebugFramework>net6.0-android</ActiveDebugFramework>
6+
<ActiveDebugProfile>OnePlus A5000 (Android 8.1 - API 27)</ActiveDebugProfile>
7+
<SelectedDevice>OnePlus A5000</SelectedDevice>
8+
<DefaultDevice>kiler_2_q_10_0_-_api_29</DefaultDevice>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
11+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
12+
</PropertyGroup>
13+
<PropertyGroup Condition="'$(TargetPlatformIdentifier)'=='iOS'">
14+
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
15+
<PlatformTarget>x64</PlatformTarget>
16+
</PropertyGroup>
17+
</Project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Microsoft.Maui.Controls;
4+
using Microsoft.Maui.Graphics;
5+
using Syncfusion.Maui.Charts;
6+
7+
namespace Charts
8+
{
9+
public class PieDemo : ContentPage
10+
{
11+
public PieDemo()
12+
{
13+
SfCircularChart chart = new SfCircularChart();
14+
chart.BindingContext = new ViewModel.ViewModel();
15+
16+
//Legend
17+
chart.Legend = new ChartLegend() { Placement = Syncfusion.Maui.Core.LegendPlacement.Right };
18+
19+
//Initialize series
20+
var binding = new Binding() { Path = "Data" };
21+
var series = new PieSeries()
22+
{
23+
XBindingPath = "Country",
24+
YBindingPath = "Counts",
25+
ShowDataLabels = true,
26+
Palette = ChartColorPalette.Custom,
27+
};
28+
29+
series.SetBinding(ChartSeries.ItemsSourceProperty, binding);
30+
series.SetBinding(ChartSeries.CustomBrushesProperty, new Binding() { Path = "CustomBrushes" });
31+
32+
chart.Series.Add(series);
33+
34+
//Chart title
35+
var title = new Label()
36+
{
37+
HorizontalOptions = LayoutOptions.FillAndExpand,
38+
HorizontalTextAlignment = Microsoft.Maui.TextAlignment.Center,
39+
Text = "Rural population of various countries",
40+
FontSize = 16,
41+
Margin = new Microsoft.Maui.Thickness(5, 10, 5, 10),
42+
};
43+
chart.Title = title;
44+
45+
var grid = new Grid()
46+
{
47+
HorizontalOptions = LayoutOptions.FillAndExpand,
48+
VerticalOptions = LayoutOptions.FillAndExpand,
49+
Padding = new Microsoft.Maui.Thickness(20),
50+
};
51+
52+
grid.Children.Add(chart);
53+
54+
this.Content = grid;
55+
}
56+
}
57+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
4+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
</manifest>

0 commit comments

Comments
 (0)