Skip to content

Commit 8a2bc91

Browse files
Merge pull request #4 from SyncfusionExamples/MultipleAxesCartesian
Updated Project sample with .Net 9 version.
2 parents 0322d5f + f5ad5c7 commit 8a2bc91

Some content is hidden

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

54 files changed

+8346
-305
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This article explains how to add multiple Y-axes in the .NET MAUI charts.
33
<br><br>
44
Consider the use case of plotting the graph for two different scenarios with varying unit rates on the same field as shown in the following image. It has been achieved by using the XAxes and YAxes of the SfCartesianChart.
55
<br>
6-
<img width="708" alt="SampleUseCase" src="https://user-images.githubusercontent.com/105496706/201910264-03b79ba5-b8e7-402a-af6a-b3314256901a.PNG">
6+
<img width="708" alt="SampleUseCase" src="https://github.com/user-attachments/assets/37089603-08e1-45c0-a9ec-850a63b5a98f">
77
<br>
88
**Step 1:** Populate the chart with multiple axes. Add multiple axes to the SfCartesianChart.YAxes property. Then, assign the axis Name property for each axis as follows:
99
<br>
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.0.31611.283
4+
VisualStudioVersion = 17.13.35931.197 d17.13
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultipleAxesCartesianChart", "MultipleAxesCartesianChart\MultipleAxesCartesianChart.csproj", "{E20FE7D8-BC84-4C95-991B-23451107BF0E}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultipleAxesCartesianChart", "MultipleAxesCartesianChart\MultipleAxesCartesianChart.csproj", "{797A1BD3-A239-4756-9177-D8E0BC69B083}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{E20FE7D8-BC84-4C95-991B-23451107BF0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{E20FE7D8-BC84-4C95-991B-23451107BF0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{E20FE7D8-BC84-4C95-991B-23451107BF0E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17-
{E20FE7D8-BC84-4C95-991B-23451107BF0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
18-
{E20FE7D8-BC84-4C95-991B-23451107BF0E}.Release|Any CPU.Build.0 = Release|Any CPU
19-
{E20FE7D8-BC84-4C95-991B-23451107BF0E}.Release|Any CPU.Deploy.0 = Release|Any CPU
14+
{797A1BD3-A239-4756-9177-D8E0BC69B083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{797A1BD3-A239-4756-9177-D8E0BC69B083}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{797A1BD3-A239-4756-9177-D8E0BC69B083}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{797A1BD3-A239-4756-9177-D8E0BC69B083}.Release|Any CPU.Build.0 = Release|Any CPU
2018
EndGlobalSection
2119
GlobalSection(SolutionProperties) = preSolution
2220
HideSolutionNode = FALSE
2321
EndGlobalSection
2422
GlobalSection(ExtensibilityGlobals) = postSolution
25-
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
23+
SolutionGuid = {A813F203-BA6E-4433-8090-858506463FDC}
2624
EndGlobalSection
2725
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace MultipleAxesCartesianChart
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new MainPage());
13+
}
14+
}
15+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
55
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
66
xmlns:local="clr-namespace:MultipleAxesCartesianChart"
7-
Shell.FlyoutBehavior="Disabled">
7+
Shell.FlyoutBehavior="Flyout"
8+
Title="MultipleAxesCartesianChart">
89

910
<ShellContent
1011
Title="Home"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MultipleAxesCartesianChart
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xmlns:viewmodel="clr-namespace:MultipleAxesCartesianChart"
66
xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts">
77

8-
<chart:SfCartesianChart EnableSideBySideSeriesPlacement="False">
8+
<chart:SfCartesianChart EnableSideBySideSeriesPlacement="False" Margin="0,15,0,0">
99

1010
<chart:SfCartesianChart.BindingContext>
1111
<viewmodel:ViewModel/>
@@ -23,6 +23,9 @@
2323
<chart:DateTimeAxis.LabelStyle>
2424
<chart:ChartAxisLabelStyle LabelFormat="MMM" TextColor="#6d7372" FontSize="12"/>
2525
</chart:DateTimeAxis.LabelStyle>
26+
<chart:DateTimeAxis.Title>
27+
<chart:ChartAxisTitle Text="Months"/>
28+
</chart:DateTimeAxis.Title>
2629
</chart:DateTimeAxis>
2730
</chart:SfCartesianChart.XAxes>
2831

@@ -31,13 +34,19 @@
3134
<chart:NumericalAxis.LabelStyle>
3235
<chart:ChartAxisLabelStyle TextColor="#0091E6" FontSize="12" FontAttributes="Bold" LabelFormat="$0.#"/>
3336
</chart:NumericalAxis.LabelStyle>
37+
<chart:NumericalAxis.Title>
38+
<chart:ChartAxisTitle Text="Amount" FontSize="12" FontAttributes="Bold" TextColor="#0091E6"/>
39+
</chart:NumericalAxis.Title>
3440
</chart:NumericalAxis>
3541

3642
<chart:NumericalAxis CrossesAt="{Static x:Double.MaxValue}" ShowMajorGridLines="False" RenderNextToCrossingValue="True"
3743
Name="secondaryY" Interval="25" Minimum="0" Maximum="125" EdgeLabelsDrawingMode="Center" PlotOffsetEnd="10">
3844
<chart:NumericalAxis.LabelStyle>
3945
<chart:ChartAxisLabelStyle TextColor="#ff1493" FontSize="12" FontAttributes="Bold" LabelFormat="0.#'%'"/>
4046
</chart:NumericalAxis.LabelStyle>
47+
<chart:NumericalAxis.Title>
48+
<chart:ChartAxisTitle Text="Percentage" TextColor="#ff1493" FontSize="12" FontAttributes="Bold" />
49+
</chart:NumericalAxis.Title>
4150
</chart:NumericalAxis>
4251

4352
</chart:SfCartesianChart.YAxes>
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 MultipleAxesCartesianChart
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: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<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>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
66
<!-- 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> -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net9.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+
816
<OutputType>Exe</OutputType>
917
<RootNamespace>MultipleAxesCartesianChart</RootNamespace>
1018
<UseMaui>true</UseMaui>
1119
<SingleProject>true</SingleProject>
1220
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
1322

1423
<!-- Display name -->
1524
<ApplicationTitle>MultipleAxesCartesianChart</ApplicationTitle>
1625

1726
<!-- App Identifier -->
1827
<ApplicationId>com.companyname.multipleaxescartesianchart</ApplicationId>
19-
<ApplicationIdGuid>81e99d47-c5e9-4c62-907d-cc784e9c1116</ApplicationIdGuid>
2028

2129
<!-- Versions -->
2230
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
2331
<ApplicationVersion>1</ApplicationVersion>
2432

25-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
26-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
33+
<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
34+
<WindowsPackageType>None</WindowsPackageType>
35+
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
37+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
2738
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
2839
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
2940
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
@@ -39,7 +50,7 @@
3950

4051
<!-- Images -->
4152
<MauiImage Include="Resources\Images\*" />
42-
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
53+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
4354

4455
<!-- Custom Fonts -->
4556
<MauiFont Include="Resources\Fonts\*" />
@@ -49,7 +60,15 @@
4960
</ItemGroup>
5061

5162
<ItemGroup>
52-
<PackageReference Include="Syncfusion.Maui.Charts" Version="*" />
63+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
64+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
65+
<PackageReference Include="Syncfusion.Maui.Charts" Version="*" />
66+
</ItemGroup>
67+
68+
<ItemGroup>
69+
<MauiXaml Update="MainPage.xaml">
70+
<Generator>MSBuild:Compile</Generator>
71+
</MauiXaml>
5372
</ItemGroup>
5473

5574
</Project>

0 commit comments

Comments
 (0)