Skip to content

Commit

Permalink
Merge pull request #1 from SyncfusionExamples/line-chart
Browse files Browse the repository at this point in the history
882505-Creating a Line Chart to Analysis the Wage Trends in Texas Oil Gas Extraction Industry
  • Loading branch information
SyncfusionKarthikeyan authored May 2, 2024
2 parents eac72f7 + ce68549 commit 640301f
Show file tree
Hide file tree
Showing 44 changed files with 1,456 additions and 2 deletions.
14 changes: 14 additions & 0 deletions OilGasExtraction/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:OilGasExtraction"
x:Class="OilGasExtraction.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions OilGasExtraction/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace OilGasExtraction
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new MainPage();
}
}
}
15 changes: 15 additions & 0 deletions OilGasExtraction/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="OilGasExtraction.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:OilGasExtraction"
Shell.FlyoutBehavior="Disabled"
Title="OilGasExtraction">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions OilGasExtraction/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace OilGasExtraction
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
23 changes: 23 additions & 0 deletions OilGasExtraction/Converter/Converter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Globalization;

namespace OilGasExtraction
{
public class Converter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is double)
{
double val = double.Parse(value.ToString()) / 1000;

return " " + val.ToString() + "K";
}
return null;
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
97 changes: 97 additions & 0 deletions OilGasExtraction/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts"
xmlns:local="clr-namespace:OilGasExtraction"
x:Class="OilGasExtraction.MainPage">


<Border StrokeShape="RoundRectangle 5"
StrokeThickness="1"
Stroke="Black"
Margin="{OnPlatform WinUI='20, 20, 20, 20', Android='5', iOS='10', MacCatalyst='30'}">
<chart:SfCartesianChart Margin="5">
<chart:SfCartesianChart.Resources>
<local:Converter x:Key="converter" />
<DataTemplate x:Key="tooltip">
<VerticalStackLayout>
<Label Text="{Binding Item.Month,StringFormat='{0:MMMM dd, yyyy}'}"
TextColor="White"
FontAttributes="Bold"
FontSize="12"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<BoxView WidthRequest="100" Margin="0,3,0,0" HeightRequest="1"
BackgroundColor="GhostWhite" />
<HorizontalStackLayout >
<Path Data="{Binding Item.Path}" Scale="0.65"
Fill="{Binding Item.FillPath}"/>
<Label Text="{Binding Item.EmploymentPercent, StringFormat='{0:0.##}%'}"
TextColor="White" FontSize="12" Margin="0,-5,0,0"
HorizontalOptions="Center" VerticalOptions="Center"/>
<Label Text=" : " TextColor="White" FontSize="12"
Margin="0,-5,0,0" HorizontalOptions="Center"
VerticalOptions="Center"/>
<Label Text="{Binding Item.EmploymentCount,Converter={StaticResource converter}}"
TextColor="White" FontSize="12" Margin="0,-5,0,0"
HorizontalOptions="Center" VerticalOptions="Center"/>
</HorizontalStackLayout>
</VerticalStackLayout>

</DataTemplate>
</chart:SfCartesianChart.Resources>
<chart:SfCartesianChart.Title>
<Grid >
<HorizontalStackLayout Margin="{OnPlatform Default='10' ,iOS='5',Android='2'}"
HorizontalOptions="Center" VerticalOptions="Center">
<Image Source="growth.png" HeightRequest="40" WidthRequest="40"/>
<Label TextColor="Black" FontFamily="TimeSpan"
FontSize="{OnPlatform WinUI='20',Default='20', Android='16', iOS='16'}"
FontAttributes="Bold" HorizontalOptions="Center"
Margin="{OnPlatform Default='0,8,0,0',Android='0,4,0,0',iOS='0,4,0,0'}"
VerticalTextAlignment="Center"
Text="Analysis the Wage Trends in the Texas Oil Gas Extraction Industry" />
</HorizontalStackLayout>
</Grid>
</chart:SfCartesianChart.Title>
<chart:SfCartesianChart.BindingContext>
<local:OilGasEmploymentViewModel/>
</chart:SfCartesianChart.BindingContext>

<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis ShowMajorGridLines="False" RenderNextToCrossingValue="True"
CrossesAt="0" ShowMinorGridLines="False" >
<chart:DateTimeAxis.MajorTickStyle>
<chart:ChartAxisTickStyle Stroke="LightGray" StrokeWidth="1"/>
</chart:DateTimeAxis.MajorTickStyle>
</chart:DateTimeAxis>
</chart:SfCartesianChart.XAxes>

<chart:SfCartesianChart.YAxes>

<chart:NumericalAxis ShowMajorGridLines="False" CrossesAt="{Binding CrossesAt}"
RenderNextToCrossingValue="True" ShowMinorGridLines="False"
Minimum="-20" Maximum="20"
x:Name="yAxis">
<chart:NumericalAxis.MajorTickStyle>
<chart:ChartAxisTickStyle StrokeWidth="1" Stroke="LightGray"/>
</chart:NumericalAxis.MajorTickStyle>
<chart:NumericalAxis.LabelStyle>
<chart:ChartAxisLabelStyle LabelFormat="0' %"/>
</chart:NumericalAxis.LabelStyle>
</chart:NumericalAxis>

</chart:SfCartesianChart.YAxes>
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior Duration="3" />
</chart:SfCartesianChart.TooltipBehavior>

<chart:LineSeries StrokeWidth="2" ItemsSource="{Binding EmploymentDetails}"
EnableTooltip="True" PaletteBrushes="{Binding CustomBrushes}"
XBindingPath="Month" YBindingPath="EmploymentPercent"
TooltipTemplate="{StaticResource tooltip}" >
</chart:LineSeries>

</chart:SfCartesianChart>
</Border>
</ContentPage>
11 changes: 11 additions & 0 deletions OilGasExtraction/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace OilGasExtraction
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}

}
}
27 changes: 27 additions & 0 deletions OilGasExtraction/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Extensions.Logging;
using Syncfusion.Maui.Core.Hosting;

namespace OilGasExtraction
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureSyncfusionCore()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

#if DEBUG
builder.Logging.AddDebug();
#endif

return builder.Build();
}
}
}
21 changes: 21 additions & 0 deletions OilGasExtraction/Model/OilGasEmploymentModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Maui.Controls.Shapes;

namespace OilGasExtraction
{
public class OilGasEmploymentModel
{
public OilGasEmploymentModel(DateTime month, double employmentCount, double employmentGrowth)
{
Month = month;
EmploymentPercent = employmentCount;
EmploymentCount = employmentGrowth;
}

public DateTime Month { get; set; }
public double EmploymentPercent { get; set; }
public double EmploymentCount { get; set; }
public Geometry? Path { get; set; }
public Brush FillPath { get; set; }
}

}
79 changes: 79 additions & 0 deletions OilGasExtraction/OilGasExtraction.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>OilGasExtraction</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>OilGasExtraction</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.oilgasextraction</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<MauiAsset Remove="Resources\Raw\data.csv" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Images\growth.png" />
<None Remove="Resources\Raw\data.csv" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Raw\data.csv" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Syncfusion.Maui.Charts" Version="*" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions OilGasExtraction/OilGasExtraction.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<ItemGroup>
<None Update="App.xaml">
<SubType>Designer</SubType>
</None>
<None Update="AppShell.xaml">
<SubType>Designer</SubType>
</None>
<None Update="MainPage.xaml">
<SubType>Designer</SubType>
</None>
<None Update="Platforms\Windows\App.xaml">
<SubType>Designer</SubType>
</None>
<None Update="Platforms\Windows\Package.appxmanifest">
<SubType>Designer</SubType>
</None>
<None Update="Resources\Styles\Colors.xaml">
<SubType>Designer</SubType>
</None>
<None Update="Resources\Styles\Styles.xaml">
<SubType>Designer</SubType>
</None>
</ItemGroup>
</Project>
27 changes: 27 additions & 0 deletions OilGasExtraction/OilGasExtraction.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34219.65
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OilGasExtraction", "OilGasExtraction.csproj", "{36CB1837-EB76-46E9-8E0C-44822DE00386}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{36CB1837-EB76-46E9-8E0C-44822DE00386}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36CB1837-EB76-46E9-8E0C-44822DE00386}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36CB1837-EB76-46E9-8E0C-44822DE00386}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{36CB1837-EB76-46E9-8E0C-44822DE00386}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36CB1837-EB76-46E9-8E0C-44822DE00386}.Release|Any CPU.Build.0 = Release|Any CPU
{36CB1837-EB76-46E9-8E0C-44822DE00386}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B19C383B-1563-4B5D-A333-6A6148BB13C1}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions OilGasExtraction/Platforms/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Loading

0 comments on commit 640301f

Please sign in to comment.