Skip to content

Commit 5ab8a64

Browse files
Merge pull request #1 from SyncfusionExamples/Prepare-sample-for-different-corner-radius-for-column
Prepare sample for custom corner radius in column in .NET MAUI Cartesian charts
2 parents a509c79 + 6241707 commit 5ab8a64

Some content is hidden

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

41 files changed

+9113
-1
lines changed

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

ColumnCustomCorners/App.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace ColumnCustomCorners;
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 AppShell());
13+
}
14+
}

ColumnCustomCorners/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="ColumnCustomCorners.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:ColumnCustomCorners"
7+
Shell.FlyoutBehavior="Disabled"
8+
Title="ColumnCustomCorners">
9+
10+
<ShellContent
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace ColumnCustomCorners;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
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>
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);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+
16+
<OutputType>Exe</OutputType>
17+
<RootNamespace>ColumnCustomCorners</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>ColumnCustomCorners</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.columncustomcorners</ApplicationId>
28+
29+
<!-- Versions -->
30+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
31+
<ApplicationVersion>1</ApplicationVersion>
32+
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>
38+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
39+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
40+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
41+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
42+
</PropertyGroup>
43+
44+
<ItemGroup>
45+
<!-- App Icon -->
46+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
47+
48+
<!-- Splash Screen -->
49+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
50+
51+
<!-- Images -->
52+
<MauiImage Include="Resources\Images\*" />
53+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
54+
55+
<!-- Custom Fonts -->
56+
<MauiFont Include="Resources\Fonts\*" />
57+
58+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
59+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
60+
</ItemGroup>
61+
62+
<ItemGroup>
63+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
64+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
65+
<PackageReference Include="Syncfusion.Maui.Toolkit" Version="*" />
66+
</ItemGroup>
67+
68+
</Project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColumnCustomCorners", "ColumnCustomCorners\ColumnCustomCorners.csproj", "{607CFDA1-0152-4001-BC92-BAE7EF9C6649}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Debug|x86 = Debug|x86
13+
Release|Any CPU = Release|Any CPU
14+
Release|x64 = Release|x64
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Debug|x64.ActiveCfg = Debug|Any CPU
21+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Debug|x64.Build.0 = Debug|Any CPU
22+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Debug|x86.ActiveCfg = Debug|Any CPU
23+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Debug|x86.Build.0 = Debug|Any CPU
24+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Release|x64.ActiveCfg = Release|Any CPU
27+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Release|x64.Build.0 = Release|Any CPU
28+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Release|x86.ActiveCfg = Release|Any CPU
29+
{607CFDA1-0152-4001-BC92-BAE7EF9C6649}.Release|x86.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
EndGlobal

ColumnCustomCorners/MainPage.xaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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="ColumnCustomCorners.MainPage"
5+
xmlns:chart="clr-namespace:Syncfusion.Maui.Toolkit.Charts;assembly=Syncfusion.Maui.Toolkit"
6+
xmlns:local="clr-namespace:ColumnCustomCorners">
7+
<ContentPage.BindingContext>
8+
<local:ViewModel x:Name="viewModel"/>
9+
</ContentPage.BindingContext>
10+
11+
<chart:SfCartesianChart Margin="30">
12+
<chart:SfCartesianChart.XAxes>
13+
<chart:CategoryAxis ShowMajorGridLines="False">
14+
<chart:CategoryAxis.Title>
15+
<chart:ChartAxisTitle Text="Month"/>
16+
</chart:CategoryAxis.Title>
17+
</chart:CategoryAxis>
18+
</chart:SfCartesianChart.XAxes>
19+
<chart:SfCartesianChart.YAxes>
20+
<chart:NumericalAxis RangePadding="Additional" Minimum="-10000">
21+
<chart:NumericalAxis.Title>
22+
<chart:ChartAxisTitle Text="Sales"/>
23+
</chart:NumericalAxis.Title>
24+
</chart:NumericalAxis>
25+
</chart:SfCartesianChart.YAxes>
26+
<local:ColumnSeriesExt ItemsSource="{Binding SalesData}"
27+
XBindingPath="Month"
28+
YBindingPath="ProfitLoss"
29+
Width="0.5"
30+
ShowDataLabels="True">
31+
<local:ColumnSeriesExt.DataLabelSettings>
32+
<chart:CartesianDataLabelSettings LabelPlacement="Outer">
33+
<chart:CartesianDataLabelSettings.LabelStyle>
34+
<chart:ChartDataLabelStyle Background="White"/>
35+
</chart:CartesianDataLabelSettings.LabelStyle>
36+
</chart:CartesianDataLabelSettings>
37+
</local:ColumnSeriesExt.DataLabelSettings>
38+
</local:ColumnSeriesExt>
39+
</chart:SfCartesianChart>
40+
</ContentPage>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Syncfusion.Maui.Toolkit.Charts;
2+
3+
namespace ColumnCustomCorners;
4+
5+
public partial class MainPage : ContentPage
6+
{
7+
public MainPage()
8+
{
9+
InitializeComponent();
10+
}
11+
}
12+
13+
public class ColumnSeriesExt : ColumnSeries
14+
{
15+
protected override ChartSegment CreateSegment()
16+
{
17+
return new ColumnSegmentExt();
18+
}
19+
}
20+
21+
public class ColumnSegmentExt : ColumnSegment
22+
{
23+
protected override void Draw(ICanvas canvas)
24+
{
25+
var rect = new Rect() { Left = Left, Top = Top, Right = Right, Bottom = Bottom };
26+
if (Item is Model model)
27+
{
28+
if (model.ProfitLoss > 0)
29+
{
30+
canvas.FillColor = Colors.Green;
31+
canvas.FillRoundedRectangle(rect, 50.0, 50.0, 0.0, 0.0);
32+
}
33+
else
34+
{
35+
canvas.FillColor = Colors.Red;
36+
canvas.FillRoundedRectangle(rect, 0.0, 0.0, 50.0, 50.0);
37+
}
38+
}
39+
}
40+
}
41+

ColumnCustomCorners/MauiProgram.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Toolkit.Hosting;
3+
4+
namespace ColumnCustomCorners;
5+
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureSyncfusionToolkit()
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+
}

ColumnCustomCorners/Model/Model.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace ColumnCustomCorners.Model;
4+
5+
public class Model
6+
{
7+
public string Month { get; set; }
8+
public double ProfitLoss { get; set; }
9+
10+
public Model(string month, double profitLoss)
11+
{
12+
Month = month;
13+
ProfitLoss = profitLoss;
14+
}
15+
}

0 commit comments

Comments
 (0)