diff --git a/BiggestCashCrop/BiggestCashCrop.sln b/BiggestCashCrop/BiggestCashCrop.sln new file mode 100644 index 0000000..77d27ca --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BiggestCashCrop", "BiggestCashCrop\BiggestCashCrop.csproj", "{04238966-782E-4126-8E2C-22289A496147}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {04238966-782E-4126-8E2C-22289A496147}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04238966-782E-4126-8E2C-22289A496147}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04238966-782E-4126-8E2C-22289A496147}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04238966-782E-4126-8E2C-22289A496147}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B6383EF6-A945-4797-BDB2-12A11ED54040} + EndGlobalSection +EndGlobal diff --git a/BiggestCashCrop/BiggestCashCrop/App.xaml b/BiggestCashCrop/BiggestCashCrop/App.xaml new file mode 100644 index 0000000..c4c90d1 --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/BiggestCashCrop/BiggestCashCrop/App.xaml.cs b/BiggestCashCrop/BiggestCashCrop/App.xaml.cs new file mode 100644 index 0000000..63f6630 --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace BiggestCashCrop +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/BiggestCashCrop/BiggestCashCrop/AssemblyInfo.cs b/BiggestCashCrop/BiggestCashCrop/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/BiggestCashCrop/BiggestCashCrop/BiggestCashCrop.csproj b/BiggestCashCrop/BiggestCashCrop/BiggestCashCrop.csproj new file mode 100644 index 0000000..71a107e --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/BiggestCashCrop.csproj @@ -0,0 +1,14 @@ + + + + WinExe + net6.0-windows + enable + true + + + + + + + diff --git a/BiggestCashCrop/BiggestCashCrop/MainWindow.xaml b/BiggestCashCrop/BiggestCashCrop/MainWindow.xaml new file mode 100644 index 0000000..653b19e --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/MainWindow.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BiggestCashCrop/BiggestCashCrop/MainWindow.xaml.cs b/BiggestCashCrop/BiggestCashCrop/MainWindow.xaml.cs new file mode 100644 index 0000000..94057ac --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/MainWindow.xaml.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BiggestCashCrop +{ + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + this.StateChanged += MainWindow_StateChanged; + } + + private void MainWindow_StateChanged(object? sender, EventArgs e) + { + if (this.WindowState == WindowState.Minimized) + { + header.Margin = new Thickness(-50, 3, 0, 10); + } + else if (this.WindowState == WindowState.Maximized) + { + header.Margin = new Thickness(-400, 3, 0, 10); + } + else if (this.WindowState == WindowState.Normal) + { + header.Margin = new Thickness(-50, 3, 0, 10); + } + } + } +} diff --git a/BiggestCashCrop/BiggestCashCrop/Model/CashCropModel.cs b/BiggestCashCrop/BiggestCashCrop/Model/CashCropModel.cs new file mode 100644 index 0000000..cfa8863 --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/Model/CashCropModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BiggestCashCrop +{ + public class CashCropModel + { + public string Category { get; set; } + public double Value { get; set; } + + public CashCropModel(string category, double value) + { + Category = category; + Value = value; + } + } +} diff --git a/BiggestCashCrop/BiggestCashCrop/ViewModel/CashCropData.cs b/BiggestCashCrop/BiggestCashCrop/ViewModel/CashCropData.cs new file mode 100644 index 0000000..6bb27f3 --- /dev/null +++ b/BiggestCashCrop/BiggestCashCrop/ViewModel/CashCropData.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BiggestCashCrop +{ + public class CashCropData + { + public ObservableCollection Data { get; set; } + + public CashCropData() + { + this.Data = new ObservableCollection + { + new CashCropModel("Cotton", 7.5), + new CashCropModel("Corn", 82.6), + new CashCropModel("Cannabis", 5), + new CashCropModel("Soybeans", 57.5), + new CashCropModel("Hay", 19.3), + new CashCropModel("Wheat", 11.9) + }; + } + } +} diff --git a/README.md b/README.md index a32607f..0cebd5b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ -# Creating-a-3D-Pie-Chart-for-the-Biggest-Cash-Crop-in-the-U.S -This article explains how to create a 3D pie chart to visualize the biggest cash crops in the US in 2022. +# Creating a 3D Pie Chart for the Biggest Cash Crop in the U.S + +## Description +The [3D pie chart](https://www.syncfusion.com/wpf-controls/charts/wpf-3d-pie-chart) is a visual representation of data that utilizes three dimensions to illustrate the proportions of various parts of a whole. In a 3D pie chart, the slices of the pie are distinguished not only by their angles and areas but also by their depth, resulting in a three-dimensional effect. + +## Customization +We can customize the 3D chart view using properties such as [Depth](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Charts.SfChart3D.html#Syncfusion_UI_Xaml_Charts_SfChart3D_Depth), [Rotation](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Charts.SfChart3D.html#Syncfusion_UI_Xaml_Charts_SfChart3D_Rotation), and [Tilt](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Charts.SfChart3D.html#Syncfusion_UI_Xaml_Charts_SfChart3D_Tilt). Additionally, we can enable dynamic rotation of the chart in three dimensions using the [EnableRotation](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Charts.SfChart3D.html#Syncfusion_UI_Xaml_Charts_SfChart3D_EnableRotation) property. + +We have enhanced the appearance of our chart by customizing pie series appearances using [CircleCoefficient](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Charts.CircularSeriesBase3D.html#Syncfusion_UI_Xaml_Charts_CircularSeriesBase3D_CircleCoefficient) and [Palette](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Charts.ChartSeriesBase.html#Syncfusion_UI_Xaml_Charts_ChartSeriesBase_Palette) properties. + +This article explains how to create a 3D pie chart to visualize the six biggest cash crops in the US for 2022. +Demo + +## Troubleshooting +### Path too long exception +If you are facing a path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project. + +For a step-by-step procedure, refer to the [Biggest Cash Crop in US]() blog post.