Skip to content

Commit aebd9d0

Browse files
Merge pull request #1 from SyncfusionExamples/895076-Creating-the-.NET-MAUI-Bar-Chart-to-Compare-Generative-AI-Usage
895076-Comparing Generative AI Use for Creating Media vs Obtaining Information
2 parents 745c49b + 76ec53e commit aebd9d0

39 files changed

+1238
-2
lines changed

BarChart/App.xaml

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:BarChart"
5+
x:Class="BarChart.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>

BarChart/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace BarChart
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}
12+
}

BarChart/AppShell.xaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="BarChart.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:BarChart"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
ContentTemplate="{DataTemplate local:MainPage}"
11+
Route="MainPage" />
12+
13+
</Shell>

BarChart/AppShell.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace BarChart
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

BarChart/BarChart.csproj

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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>BarChart</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>BarChart</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.barchart</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+
</Project>

BarChart/BarChart.sln

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.35027.167
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BarChart", "BarChart.csproj", "{1E91A863-CC6B-4C56-99D1-5947EB0B266C}"
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+
{1E91A863-CC6B-4C56-99D1-5947EB0B266C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1E91A863-CC6B-4C56-99D1-5947EB0B266C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1E91A863-CC6B-4C56-99D1-5947EB0B266C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{1E91A863-CC6B-4C56-99D1-5947EB0B266C}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{1E91A863-CC6B-4C56-99D1-5947EB0B266C}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{1E91A863-CC6B-4C56-99D1-5947EB0B266C}.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 = {4C009597-7D8A-4C13-9F7B-7CD22739B926}
26+
EndGlobalSection
27+
EndGlobal

BarChart/MainPage.xaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
x:Class="BarChart.MainPage"
5+
xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts"
6+
xmlns:model="clr-namespace:BarChart">
7+
8+
<ContentPage.BindingContext>
9+
<model:ViewModel/>
10+
</ContentPage.BindingContext>
11+
12+
<Border Stroke="Lightgray" StrokeThickness="1" Margin="{OnPlatform Default='5,15,5,5', iOS='25,0,20,25'}">
13+
<Border.StrokeShape>
14+
<RoundRectangle CornerRadius="10"/>
15+
</Border.StrokeShape>
16+
17+
<Grid BackgroundColor="#011327">
18+
<Grid.ColumnDefinitions>
19+
<ColumnDefinition/>
20+
<ColumnDefinition/>
21+
</Grid.ColumnDefinitions>
22+
23+
<Grid.RowDefinitions>
24+
<RowDefinition Height="1*"></RowDefinition>
25+
<RowDefinition Height="9*"></RowDefinition>
26+
</Grid.RowDefinitions>
27+
28+
<HorizontalStackLayout Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
29+
<StackLayout Margin="{OnPlatform Default='10,14,10,5',Android='7,12,5,3',MacCatalyst='10,-10,10,5'}" WidthRequest="{OnPlatform Default=16,Android=10,iOS=10}" HeightRequest="{OnPlatform Default=48,Android=33,iOS=31}" BackgroundColor="#a37bf8"/>
30+
<VerticalStackLayout>
31+
<Label Margin="{OnPlatform Default='0,14,0,8', Android='0,0,0,4',iOS='0,5,0,2'}" Text="Comparing Generative AI Use for Creating Media vs Obtaining Information"
32+
TextColor="White"
33+
FontSize="{OnPlatform Android=15, WinUI=18, iOS=14, MacCatalyst=18}"
34+
FontFamily="TimeSpan"
35+
FontAttributes="Bold"/>
36+
<Label Text="The percentage of respondents who have attempted to use a generative AI tool (e.g. ChatGPT) for the following applications"
37+
TextColor="White"
38+
FontSize="{OnPlatform Android=12, WinUI=15, iOS=11, MacCatalyst=15}"
39+
FontFamily="TimeSpan"/>
40+
</VerticalStackLayout>
41+
</HorizontalStackLayout>
42+
43+
<chart:SfCartesianChart Grid.Column="0" Grid.Row="1" Margin="{OnPlatform Default='25,25,25,25',iOS='-15,25,25,25'}" IsTransposed="True" >
44+
45+
<chart:SfCartesianChart.Title>
46+
<HorizontalStackLayout Margin="{OnPlatform Default='0,0,0,20', iOS ='0,0,0,10', Android='0,0,0,10'}" HorizontalOptions="Center">
47+
<Label Text="For getting information" FontFamily="TimeSpan" TextColor="White" FontAttributes="Bold" FontSize="{OnPlatform Android=15, WinUI=18, iOS=15, MacCatalyst=18}" HorizontalOptions="Center" ></Label>
48+
</HorizontalStackLayout>
49+
</chart:SfCartesianChart.Title>
50+
51+
<chart:SfCartesianChart.XAxes>
52+
<chart:CategoryAxis IsInversed="True" ShowMajorGridLines="False">
53+
<chart:CategoryAxis.AxisLineStyle>
54+
<chart:ChartLineStyle Stroke="#011327"/>
55+
</chart:CategoryAxis.AxisLineStyle>
56+
<chart:CategoryAxis.MajorTickStyle>
57+
<chart:ChartAxisTickStyle Stroke="#011327"/>
58+
</chart:CategoryAxis.MajorTickStyle>
59+
<chart:CategoryAxis.LabelStyle>
60+
<chart:ChartAxisLabelStyle FontSize="{OnPlatform Default=17,Android=8,iOS=8}" TextColor="White" ></chart:ChartAxisLabelStyle>
61+
</chart:CategoryAxis.LabelStyle>
62+
</chart:CategoryAxis>
63+
</chart:SfCartesianChart.XAxes>
64+
65+
<chart:SfCartesianChart.YAxes>
66+
<chart:NumericalAxis ShowMajorGridLines="False" IsVisible="False" >
67+
<chart:NumericalAxis.AxisLineStyle>
68+
<chart:ChartLineStyle Stroke="#011327"/>
69+
</chart:NumericalAxis.AxisLineStyle>
70+
<chart:NumericalAxis.MajorTickStyle>
71+
<chart:ChartAxisTickStyle Stroke="#011327"/>
72+
</chart:NumericalAxis.MajorTickStyle>
73+
</chart:NumericalAxis>
74+
</chart:SfCartesianChart.YAxes>
75+
76+
<chart:ColumnSeries ItemsSource="{Binding GettingInformationDetails}"
77+
ShowDataLabels="True"
78+
Fill="#a37bf8"
79+
XBindingPath="Purpose"
80+
YBindingPath="Percentage">
81+
<chart:ColumnSeries.DataLabelSettings>
82+
<chart:CartesianDataLabelSettings UseSeriesPalette="False" LabelPlacement="Inner">
83+
<chart:CartesianDataLabelSettings.LabelStyle>
84+
<chart:ChartDataLabelStyle FontSize="{OnPlatform Default=15,Android=10,iOS=10}" FontAttributes="Bold" TextColor="Black" ></chart:ChartDataLabelStyle>
85+
</chart:CartesianDataLabelSettings.LabelStyle>
86+
</chart:CartesianDataLabelSettings>
87+
</chart:ColumnSeries.DataLabelSettings>
88+
</chart:ColumnSeries>
89+
90+
</chart:SfCartesianChart>
91+
92+
<chart:SfCartesianChart Grid.Column="1" Grid.Row="1" Margin="25" IsTransposed="True" >
93+
94+
<chart:SfCartesianChart.Title>
95+
<HorizontalStackLayout Margin="{OnPlatform Default='0,0,0,20', iOS='0,0,0,10', Android='0,0,0,10'}" HorizontalOptions="Center" >
96+
<Label Text="For creating media" FontFamily="TimeSpan" TextColor="White" FontAttributes="Bold" FontSize="{OnPlatform Android=15, WinUI=18, iOS=15, MacCatalyst=18}" HorizontalOptions="Center" ></Label>
97+
</HorizontalStackLayout>
98+
</chart:SfCartesianChart.Title>
99+
100+
<chart:SfCartesianChart.XAxes>
101+
<chart:CategoryAxis IsInversed="True" ShowMajorGridLines="False">
102+
<chart:CategoryAxis.AxisLineStyle>
103+
<chart:ChartLineStyle Stroke="#011327"/>
104+
</chart:CategoryAxis.AxisLineStyle>
105+
<chart:CategoryAxis.MajorTickStyle>
106+
<chart:ChartAxisTickStyle Stroke="#011327"/>
107+
</chart:CategoryAxis.MajorTickStyle>
108+
<chart:CategoryAxis.LabelStyle>
109+
<chart:ChartAxisLabelStyle FontSize="{OnPlatform Default=17,Android=8,iOS=8}" TextColor="White"></chart:ChartAxisLabelStyle>
110+
</chart:CategoryAxis.LabelStyle>
111+
</chart:CategoryAxis>
112+
</chart:SfCartesianChart.XAxes>
113+
114+
<chart:SfCartesianChart.YAxes>
115+
<chart:NumericalAxis ShowMajorGridLines="False" IsVisible="False"/>
116+
</chart:SfCartesianChart.YAxes>
117+
118+
<chart:ColumnSeries ItemsSource="{Binding CreatingMediaDetails}"
119+
ShowDataLabels="True"
120+
Fill="#bbece9"
121+
XBindingPath="Purpose"
122+
YBindingPath="Percentage">
123+
<chart:ColumnSeries.DataLabelSettings>
124+
<chart:CartesianDataLabelSettings UseSeriesPalette="False" LabelPlacement="Inner">
125+
<chart:CartesianDataLabelSettings.LabelStyle>
126+
<chart:ChartDataLabelStyle FontSize="{OnPlatform Default=15,Android=10,iOS=10}" FontAttributes="Bold" TextColor="Black" ></chart:ChartDataLabelStyle>
127+
</chart:CartesianDataLabelSettings.LabelStyle>
128+
</chart:CartesianDataLabelSettings>
129+
</chart:ColumnSeries.DataLabelSettings>
130+
</chart:ColumnSeries>
131+
132+
</chart:SfCartesianChart>
133+
</Grid>
134+
</Border>
135+
136+
</ContentPage>

BarChart/MainPage.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace BarChart
2+
{
3+
public partial class MainPage : ContentPage
4+
{
5+
public MainPage()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
11+
}

BarChart/MauiProgram.cs

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 BarChart
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+
}

BarChart/Model/Model.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace BarChart
8+
{
9+
public class Model
10+
{
11+
public string Purpose { get; set; }
12+
public double Percentage { get; set; }
13+
public Model(string purpose, double percentage)
14+
{
15+
Purpose = purpose;
16+
Percentage = percentage;
17+
}
18+
19+
}
20+
}

0 commit comments

Comments
 (0)