Skip to content

Commit caa3b33

Browse files
Merge pull request #1 from SyncfusionExamples/895065-Update-blog-sample-and-readme
895065 Update blog sample and readme
2 parents c9552a1 + a217d75 commit caa3b33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1358
-2
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.10.35013.160
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DoughnutChart", "DoughnutChart\DoughnutChart.csproj", "{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}"
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+
{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{4FD7603D-239C-45BC-9F3C-F1828D8FAC3E}.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 = {F549FB43-CE95-40A3-9A56-72E1337BC5FA}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:DoughnutChart"
5+
x:Class="DoughnutChart.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace DoughnutChart
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="DoughnutChart.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:DoughnutChart"
7+
Shell.FlyoutBehavior="Disabled"
8+
Title="DoughnutChart">
9+
10+
<ShellContent
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace DoughnutChart
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
8+
9+
<!-- Note for MacCatalyst:
10+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
11+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
12+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
13+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
14+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
15+
16+
<OutputType>Exe</OutputType>
17+
<RootNamespace>DoughnutChart</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>DoughnutChart</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.doughnutchart</ApplicationId>
28+
29+
<!-- Versions -->
30+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
31+
<ApplicationVersion>1</ApplicationVersion>
32+
33+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
34+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
35+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
37+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
38+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
39+
</PropertyGroup>
40+
41+
<ItemGroup>
42+
<!-- App Icon -->
43+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
44+
45+
<!-- Splash Screen -->
46+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
47+
48+
<!-- Images -->
49+
<MauiImage Include="Resources\Images\*" />
50+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
51+
52+
<!-- Custom Fonts -->
53+
<MauiFont Include="Resources\Fonts\*" />
54+
55+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
56+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
57+
</ItemGroup>
58+
59+
<ItemGroup>
60+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
61+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
62+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
63+
<PackageReference Include="Syncfusion.Maui.Charts" Version="*" />
64+
</ItemGroup>
65+
66+
<ItemGroup>
67+
<MauiXaml Update="SecondaryPage.xaml">
68+
<Generator>MSBuild:Compile</Generator>
69+
</MauiXaml>
70+
</ItemGroup>
71+
72+
</Project>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts"
5+
xmlns:local="clr-namespace:DoughnutChart"
6+
x:Class="DoughnutChart.MainPage">
7+
8+
<Border StrokeThickness="1" Stroke="Black" Margin="{OnPlatform Default=8, iOS=20}" >
9+
10+
<Border.StrokeShape>
11+
<RoundRectangle CornerRadius="14" />
12+
</Border.StrokeShape>
13+
14+
<Grid>
15+
16+
<chart:SfCircularChart Margin="{OnPlatform Default='10', iOS='-70, 10, 10, 10'}" >
17+
18+
<chart:SfCircularChart.BindingContext>
19+
<local:DataViewModel />
20+
</chart:SfCircularChart.BindingContext>
21+
22+
<chart:SfCircularChart.Resources>
23+
<local:CenterViewDimension x:Key="dimension"/>
24+
</chart:SfCircularChart.Resources>
25+
26+
<chart:SfCircularChart.Title>
27+
<Grid ColumnSpacing="10" Margin="5, 0, 0, 0">
28+
29+
<Grid.ColumnDefinitions>
30+
<ColumnDefinition Width="Auto" />
31+
<ColumnDefinition Width="*" />
32+
</Grid.ColumnDefinitions>
33+
34+
<BoxView Color="#34ea61" WidthRequest="{OnPlatform Android=10, Default=15, iOS=10}"
35+
HeightRequest="{OnPlatform Android=35, WinUI=80, MacCatalyst=50, iOS=35}"/>
36+
37+
<VerticalStackLayout Grid.Column="1" Margin="{OnPlatform Android='-5, 0, 0, 0'}">
38+
<Label Text="Agriculture is the Biggest Employer in India"
39+
FontSize="{OnPlatform Android=Small, Default=Large, iOS=Small}" FontAttributes="Bold"
40+
Grid.Row="0"/>
41+
42+
<Label Text="Share of workers in India, by broad industry of (2021-2022)"
43+
TextColor="DarkSlateGray" FontSize="{OnPlatform Android=Micro, Default=Small, iOS=Small}"
44+
Grid.Row="1"/>
45+
</VerticalStackLayout>
46+
47+
</Grid>
48+
</chart:SfCircularChart.Title>
49+
50+
<chart:SfCircularChart.Legend>
51+
<chart:ChartLegend Placement="{OnPlatform Android=Bottom, Default=Right, iOS=Bottom}" />
52+
</chart:SfCircularChart.Legend>
53+
54+
<chart:DoughnutSeries ItemsSource="{Binding DataCollection}"
55+
XBindingPath="Industry"
56+
YBindingPath="Percent"
57+
LabelContext="Percentage"
58+
InnerRadius="0.6"
59+
ShowDataLabels="True"
60+
PaletteBrushes="{Binding CustomBrushes}">
61+
62+
<chart:DoughnutSeries.DataLabelSettings>
63+
<chart:CircularDataLabelSettings LabelPosition="Outside" />
64+
</chart:DoughnutSeries.DataLabelSettings>
65+
66+
<chart:DoughnutSeries.CenterView>
67+
<StackLayout HeightRequest="{Binding CenterHoleSize, Converter={StaticResource dimension}}" WidthRequest="{Binding CenterHoleSize}" VerticalOptions="Center" HorizontalOptions="Center" Margin="{OnPlatform Default='0, -10, 0, 0', Android='0', MacCatalyst='0, 30, 0, 0', iOS='0'}">
68+
<Image Source="agri.png" WidthRequest="{OnPlatform Android=40, iOS=40, WinUI=60, MacCatalyst=150}" IsVisible="{OnPlatform Default='True', Android='False', iOS='False'}"/>
69+
<Label Text="Agriculture employs 45.5% of India's workforce" MaxLines="4" FontSize="{OnPlatform Android=12, iOS=12, MacCatalyst=18}" VerticalOptions="Center"
70+
Margin="{OnPlatform Default='10, 0, 10, 0', MacCatalyst='0', Android='2, 27, 2, 0', iOS='0, 20, 0, 0'}" HorizontalTextAlignment="Center"
71+
MaximumWidthRequest="{OnPlatform MacCatalyst=280, iOS=90}"/>
72+
</StackLayout>
73+
</chart:DoughnutSeries.CenterView>
74+
75+
<!--To enable the selection support-->
76+
<chart:DoughnutSeries.SelectionBehavior>
77+
<chart:DataPointSelectionBehavior SelectionChanging="DataPointSelectionBehavior_SelectionChanging"/>
78+
</chart:DoughnutSeries.SelectionBehavior>
79+
80+
</chart:DoughnutSeries>
81+
82+
</chart:SfCircularChart>
83+
</Grid>
84+
</Border>
85+
</ContentPage>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+

2+
using Syncfusion.Maui.Charts;
3+
using System.Collections;
4+
using System.Globalization;
5+
6+
namespace DoughnutChart
7+
{
8+
public partial class MainPage : ContentPage
9+
{
10+
public MainPage()
11+
{
12+
InitializeComponent();
13+
}
14+
15+
private void DataPointSelectionBehavior_SelectionChanging(object sender, ChartSelectionChangingEventArgs e)
16+
{
17+
var series = sender as DoughnutSeries;
18+
int selectedIndex = e.NewIndexes[0];
19+
20+
if (series == null || series.ItemsSource is not IList items)
21+
{
22+
return;
23+
}
24+
25+
//Get selected segment data
26+
var selectedData = items[selectedIndex] as DataModel;
27+
28+
if (selectedData != null)
29+
{
30+
// Navigate to the next page which is representing the chart with details.
31+
Navigation.PushAsync(new SecondaryPage(selectedData, series.PaletteBrushes[selectedIndex]));
32+
e.Cancel = true;
33+
}
34+
}
35+
}
36+
37+
public class CenterViewDimension : IValueConverter
38+
{
39+
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
40+
{
41+
double size = 0d;
42+
43+
if(value == null)
44+
{
45+
return size;
46+
}
47+
48+
string? para = value.ToString();
49+
50+
#if MACCATALYST
51+
if(string.IsNullOrEmpty(para) && double.TryParse(para, out size))
52+
{
53+
return (double)value / 2;
54+
}
55+
#endif
56+
57+
return value;
58+
}
59+
60+
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
61+
{
62+
throw new NotImplementedException();
63+
}
64+
}
65+
66+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
4+
namespace DoughnutChart
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureSyncfusionCore()
14+
.ConfigureFonts(fonts =>
15+
{
16+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
17+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
18+
});
19+
20+
#if DEBUG
21+
builder.Logging.AddDebug();
22+
#endif
23+
24+
return builder.Build();
25+
}
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections.ObjectModel;
2+
3+
namespace DoughnutChart
4+
{
5+
public class DataModel
6+
{
7+
public string? Industry {get; set;}
8+
public double Percent {get; set;}
9+
public string? Gender {get; set;}
10+
public ObservableCollection<DataModel>? Collections {get; set;}
11+
12+
public DataModel(string? gender, double percent)
13+
{
14+
Gender = gender;
15+
Percent = percent;
16+
}
17+
18+
public DataModel(string industry, double percent, ObservableCollection<DataModel>? collections)
19+
{
20+
Industry = industry;
21+
Percent = percent;
22+
Collections = collections;
23+
}
24+
}
25+
}
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+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
4+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
</manifest>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace DoughnutChart
6+
{
7+
[Activity(Theme = "@style/Maui.SplashTheme", ScreenOrientation = ScreenOrientation.Landscape , MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
8+
public class MainActivity : MauiAppCompatActivity
9+
{
10+
}
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace DoughnutChart
5+
{
6+
[Application]
7+
public class MainApplication : MauiApplication
8+
{
9+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10+
: base(handle, ownership)
11+
{
12+
}
13+
14+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15+
}
16+
}

0 commit comments

Comments
 (0)