Skip to content

Commit ab0e616

Browse files
Merge pull request #1 from SyncfusionExamples/AxisElementsCustomization
MAUI-3582 Add a sample for the chart axis elements customization
2 parents 82265ea + 2ba8824 commit ab0e616

39 files changed

+1196
-1
lines changed

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

ChartAxisDemo/App.xaml.cs

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

ChartAxisDemo/AppShell.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+
<Shell
3+
x:Class="ChartAxisDemo.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:ChartAxisDemo"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

ChartAxisDemo/AppShell.xaml.cs

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

ChartAxisDemo/ChartAxisDemo.csproj

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.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);net6.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ChartAxisDemo</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>ChartAxisDemo</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.chartaxisdemo</ApplicationId>
19+
<ApplicationIdGuid>C02D7503-2557-4DEC-B364-AFF1D7D5B06D</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
44+
<!-- Custom Fonts -->
45+
<MauiFont Include="Resources\Fonts\*" />
46+
47+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="Syncfusion.Maui.Charts" Version="20.3.52" />
53+
</ItemGroup>
54+
55+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugFramework>net6.0-windows10.0.19041.0</ActiveDebugFramework>
5+
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
6+
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
7+
</PropertyGroup>
8+
</Project>

ChartAxisDemo/ChartAxisDemo.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.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChartAxisDemo", "ChartAxisDemo.csproj", "{52894750-6BC3-4938-B901-3AC7D8BAB8F2}"
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+
{52894750-6BC3-4938-B901-3AC7D8BAB8F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{52894750-6BC3-4938-B901-3AC7D8BAB8F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{52894750-6BC3-4938-B901-3AC7D8BAB8F2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{52894750-6BC3-4938-B901-3AC7D8BAB8F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{52894750-6BC3-4938-B901-3AC7D8BAB8F2}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{52894750-6BC3-4938-B901-3AC7D8BAB8F2}.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 = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26+
EndGlobalSection
27+
EndGlobal

ChartAxisDemo/MainPage.xaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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:viewModel="clr-namespace:ChartAxisDemo"
6+
x:Class="ChartAxisDemo.MainPage">
7+
8+
<Grid>
9+
<chart:SfCartesianChart Title="Axis elements customization">
10+
<chart:SfCartesianChart.BindingContext>
11+
<viewModel:ViewModel />
12+
</chart:SfCartesianChart.BindingContext>
13+
14+
<chart:SfCartesianChart.Resources>
15+
<chart:ChartAxisLabelStyle x:Key="axisLableStyle" TextColor="Red"/>
16+
<chart:ChartLineStyle x:Key="axisLineStyle" Stroke="Yellow" />
17+
<chart:ChartLineStyle x:Key="majorLineStyle" Stroke="Brown"/>
18+
<chart:ChartAxisTickStyle x:Key="majorTickStyle" Stroke="Brown"/>
19+
<chart:ChartLineStyle x:Key="minorLineStyle" Stroke="Gray"/>
20+
<chart:ChartAxisTickStyle x:Key="minorTickStyle" Stroke="Gray"/>
21+
</chart:SfCartesianChart.Resources>
22+
23+
<chart:SfCartesianChart.XAxes>
24+
<chart:CategoryAxis AxisLineStyle="{StaticResource axisLineStyle}"
25+
LabelStyle="{StaticResource axisLableStyle}"
26+
MajorGridLineStyle="{StaticResource majorLineStyle}"
27+
MajorTickStyle="{StaticResource majorTickStyle}" />
28+
</chart:SfCartesianChart.XAxes>
29+
30+
<chart:SfCartesianChart.YAxes>
31+
<chart:NumericalAxis MinorTicksPerInterval="2"
32+
Minimum="0"
33+
AxisLineStyle="{StaticResource axisLineStyle}"
34+
LabelStyle="{StaticResource axisLableStyle}"
35+
MajorGridLineStyle="{StaticResource majorLineStyle}"
36+
MajorTickStyle="{StaticResource majorTickStyle}"
37+
MinorGridLineStyle="{StaticResource minorLineStyle}"
38+
MinorTickStyle="{StaticResource minorTickStyle}" />
39+
</chart:SfCartesianChart.YAxes>
40+
41+
<chart:SplineSeries XBindingPath="XValue"
42+
YBindingPath="YValue"
43+
ItemsSource="{Binding Data}"/>
44+
45+
</chart:SfCartesianChart>
46+
</Grid>
47+
48+
</ContentPage>

ChartAxisDemo/MainPage.xaml.cs

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

ChartAxisDemo/MauiProgram.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Syncfusion.Maui.Core.Hosting;
2+
namespace ChartAxisDemo;
3+
4+
public static class MauiProgram
5+
{
6+
public static MauiApp CreateMauiApp()
7+
{
8+
var builder = MauiApp.CreateBuilder();
9+
builder
10+
.UseMauiApp<App>()
11+
.ConfigureSyncfusionCore()
12+
.ConfigureFonts(fonts =>
13+
{
14+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
15+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
16+
});
17+
18+
return builder.Build();
19+
}
20+
}

0 commit comments

Comments
 (0)