diff --git a/README.md b/README.md index ad0be09..2b4009b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,25 @@ # Creating-a-Stacked-Area-Chart-for-U.S.-Primary-Energy-Consumption This sample demonstrates how to create a Stacked Area Chart for U.S. Primary Energy Consumption. + +The [StackedAreaSeries](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Charts.StackedAreaSeries.html) is representing the multiple of area series are stacked vertically one above the other. + +### Introduction + +Here, we will explain about stacked area chart to visualize the energy utility consumption of Coal, PetroleumLiquid, PetroleumCoke, Conventional HydroElectric, Nuclear and NaturalGas using WinUI cartesian chart. + +Primary energy utility consumption in the United States refers to the amount of energy consumed by various sectors of the economy, such as residential, commercial, industrial, and transportation, before any conversion or transformation. This energy consumption is measured in terms of the raw energy sources used, including fossil fuels (such as coal, natural gas, and petroleum), renewable sources (such as hydroelectric, solar, wind), and nuclear energy. + +### Customize chart tooltip behavior + +We can customize the tooltip value using the TooltipBehavior in the SfCartesianChart by initializing the ChartTooltipBehavior class. +By using the Duration property, we can set how long the tooltip value is displayed while hovering the mouse over the series, and we can animate the tooltip value using the EnableAnimation property. +Additionally, we can customize the appearance of the tooltip using the Style property in the ChartTooltipBehavior. + + +### Configure chart zoom pan behavior + +We can display the chart area while zoomed in by enabling panning using the EnablePanning property. To prevent pinch zooming and mouse wheel zooming actions, we can disable them using the EnablePinchZooming and EnableMouseWheelZooming properties, respectively. + +### Output + +![StackedAreaChart_Output](https://github.com/SyncfusionExamples/Creating-a-Stacked-Area-Chart-for-U.S.-Primary-Energy-Consumption/assets/105482474/2af3e7da-97c4-4591-b214-af346a392ccd) diff --git a/US_Energy_Consumption/App.xaml b/US_Energy_Consumption/App.xaml new file mode 100644 index 0000000..de94b76 --- /dev/null +++ b/US_Energy_Consumption/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/US_Energy_Consumption/App.xaml.cs b/US_Energy_Consumption/App.xaml.cs new file mode 100644 index 0000000..36b465f --- /dev/null +++ b/US_Energy_Consumption/App.xaml.cs @@ -0,0 +1,50 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using Microsoft.UI.Xaml.Shapes; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace US_Energy_Consumption +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + public partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + } + + /// + /// Invoked when the application is launched. + /// + /// Details about the launch request and process. + protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) + { + m_window = new MainWindow(); + m_window.Activate(); + } + + private Window m_window; + } +} diff --git a/US_Energy_Consumption/Assets/LockScreenLogo.scale-200.png b/US_Energy_Consumption/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000..7440f0d Binary files /dev/null and b/US_Energy_Consumption/Assets/LockScreenLogo.scale-200.png differ diff --git a/US_Energy_Consumption/Assets/SplashScreen.scale-200.png b/US_Energy_Consumption/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000..32f486a Binary files /dev/null and b/US_Energy_Consumption/Assets/SplashScreen.scale-200.png differ diff --git a/US_Energy_Consumption/Assets/Square150x150Logo.scale-200.png b/US_Energy_Consumption/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000..53ee377 Binary files /dev/null and b/US_Energy_Consumption/Assets/Square150x150Logo.scale-200.png differ diff --git a/US_Energy_Consumption/Assets/Square44x44Logo.scale-200.png b/US_Energy_Consumption/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000..f713bba Binary files /dev/null and b/US_Energy_Consumption/Assets/Square44x44Logo.scale-200.png differ diff --git a/US_Energy_Consumption/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/US_Energy_Consumption/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000..dc9f5be Binary files /dev/null and b/US_Energy_Consumption/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/US_Energy_Consumption/Assets/StoreLogo.png b/US_Energy_Consumption/Assets/StoreLogo.png new file mode 100644 index 0000000..a4586f2 Binary files /dev/null and b/US_Energy_Consumption/Assets/StoreLogo.png differ diff --git a/US_Energy_Consumption/Assets/Wide310x150Logo.scale-200.png b/US_Energy_Consumption/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000..8b4a5d0 Binary files /dev/null and b/US_Energy_Consumption/Assets/Wide310x150Logo.scale-200.png differ diff --git a/US_Energy_Consumption/Converter/AxisLabelConverter.cs b/US_Energy_Consumption/Converter/AxisLabelConverter.cs new file mode 100644 index 0000000..27ac9e4 --- /dev/null +++ b/US_Energy_Consumption/Converter/AxisLabelConverter.cs @@ -0,0 +1,112 @@ +using Microsoft.UI.Xaml.Data; +using Syncfusion.UI.Xaml.Charts; +using System; + +namespace US_Energy_Consumption +{ + public class AxisLabelConverter : IValueConverter + { + EnergyUtilityConsumption viewModel = new EnergyUtilityConsumption(); + public object Convert(object value, Type targetType, object parameter, string language) + { + ChartAxisLabel chartAxisLabel = value as ChartAxisLabel; + if (viewModel != null && chartAxisLabel != null) + { + var label = double.Parse((string)chartAxisLabel.Content); + return label > 1000 ? (label / 1000).ToString() + "K" : chartAxisLabel.Content; + + } + return string.Empty; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } + + public class ToolTipConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if(value != null) + { + var segment = value as StackedAreaSegment; + if (segment != null) + { + var name =segment.Series.Name; + return "United States: " + name; + } + return value; + } + + return string.Empty; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } + + public class ToolTipXValueConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value != null && value is DateTime date) + { + var month = date.Date; + return month.ToString("MMMM-yyyy"); + } + + return string.Empty; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } + + public class ToolTipYValueConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value != null && value is double val) + { + string yValue = val.ToString("###,###"); + return yValue; + } + + return string.Empty; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } + + public class FillConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value != null) + { + var segment = value as StackedAreaSegment; + if (segment != null) + { + return segment.Series.Fill; + } + return value; + } + + return string.Empty; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/US_Energy_Consumption/MainWindow.xaml b/US_Energy_Consumption/MainWindow.xaml new file mode 100644 index 0000000..506c36e --- /dev/null +++ b/US_Energy_Consumption/MainWindow.xaml @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/US_Energy_Consumption/MainWindow.xaml.cs b/US_Energy_Consumption/MainWindow.xaml.cs new file mode 100644 index 0000000..68329c0 --- /dev/null +++ b/US_Energy_Consumption/MainWindow.xaml.cs @@ -0,0 +1,54 @@ +using Microsoft.UI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; + +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace US_Energy_Consumption +{ + /// + /// An empty window that can be used on its own or navigated to within a Frame. + /// + public sealed partial class MainWindow : Window + { + public MainWindow() + { + this.InitializeComponent(); + } + + private void SfCartesianChart_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) + { + var count = chart.Series.Count; + for (int i = 0; i < count; i++) + { + var series = chart.Series[i]; + series.EnableTooltip = true; + } + } + + private void SfCartesianChart_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) + { + var count = chart.Series.Count; + for (int i = 0; i < count; i++) + { + var series = chart.Series[i]; + series.EnableTooltip = false; + } + } + } +} diff --git a/US_Energy_Consumption/Model/EnergyUtilityProducts.cs b/US_Energy_Consumption/Model/EnergyUtilityProducts.cs new file mode 100644 index 0000000..ec67ad2 --- /dev/null +++ b/US_Energy_Consumption/Model/EnergyUtilityProducts.cs @@ -0,0 +1,26 @@ +using System; + +namespace US_Energy_Consumption +{ + public class EnergyUtilityProducts + { + public DateTime Month { get; set; } + public double Coal { get; set; } + public double PetroleumLiquid { get; set; } + public double PetroleumCoke { get; set; } + public double NaturalGas { get; set; } + public double Nuclear { get; set; } + public double HydroElectric { get; set; } + + public EnergyUtilityProducts(DateTime month,double coal,double petroleumLiquid,double petroleumCoke,double naturalGas,double nuclear, double hydroElectric) + { + Month = month; + Coal = coal; + PetroleumLiquid = petroleumLiquid; + PetroleumCoke = petroleumCoke; + NaturalGas = naturalGas; + Nuclear = nuclear; + HydroElectric = hydroElectric; + } + } +} diff --git a/US_Energy_Consumption/Package.appxmanifest b/US_Energy_Consumption/Package.appxmanifest new file mode 100644 index 0000000..5bf909e --- /dev/null +++ b/US_Energy_Consumption/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + US_Energy_Consumption + NanthiniMahalingam + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/US_Energy_Consumption/Properties/PublishProfiles/win10-arm64.pubxml b/US_Energy_Consumption/Properties/PublishProfiles/win10-arm64.pubxml new file mode 100644 index 0000000..a7fdd16 --- /dev/null +++ b/US_Energy_Consumption/Properties/PublishProfiles/win10-arm64.pubxml @@ -0,0 +1,20 @@ + + + + + FileSystem + ARM64 + win10-arm64 + bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true + False + False + True + + + \ No newline at end of file diff --git a/US_Energy_Consumption/Properties/PublishProfiles/win10-x64.pubxml b/US_Energy_Consumption/Properties/PublishProfiles/win10-x64.pubxml new file mode 100644 index 0000000..26ea7e5 --- /dev/null +++ b/US_Energy_Consumption/Properties/PublishProfiles/win10-x64.pubxml @@ -0,0 +1,20 @@ + + + + + FileSystem + x64 + win10-x64 + bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true + False + False + True + + + \ No newline at end of file diff --git a/US_Energy_Consumption/Properties/PublishProfiles/win10-x86.pubxml b/US_Energy_Consumption/Properties/PublishProfiles/win10-x86.pubxml new file mode 100644 index 0000000..34d14d4 --- /dev/null +++ b/US_Energy_Consumption/Properties/PublishProfiles/win10-x86.pubxml @@ -0,0 +1,20 @@ + + + + + FileSystem + x86 + win10-x86 + bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true + False + False + True + + + \ No newline at end of file diff --git a/US_Energy_Consumption/Properties/launchSettings.json b/US_Energy_Consumption/Properties/launchSettings.json new file mode 100644 index 0000000..370ab13 --- /dev/null +++ b/US_Energy_Consumption/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "US_Energy_Consumption (Package)": { + "commandName": "MsixPackage" + }, + "US_Energy_Consumption (Unpackaged)": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/US_Energy_Consumption/Resources/us_energy_consumption_data.csv b/US_Energy_Consumption/Resources/us_energy_consumption_data.csv new file mode 100644 index 0000000..27936d2 --- /dev/null +++ b/US_Energy_Consumption/Resources/us_energy_consumption_data.csv @@ -0,0 +1,271 @@ +Date,Coal,Petroleum liquids,Petroleum coke,Natural gas,Nuclear,Conventional hydroelectric +Jan-01,73363,19742,108,156993,48876,17128 +Feb-01,62598,9738,100,143268,43547,15735 +Mar-01,65101,10917,80,171278,43477,18545 +Apr-01,59019,11246,53,210339,39042,15807 +May-01,64936,11355,77,233213,43312,17212 +Jun-01,69113,12487,111,260189,47850,18766 +Jul-01,76352,11270,139,353858,48447,16581 +Aug-01,77714,14186,177,359381,48266,17635 +Sep-01,65983,7931,145,255222,43857,14149 +Oct-01,63130,6358,145,229563,41177,14157 +Nov-01,61267,5503,122,154920,41415,14287 +Dec-01,67694,5636,160,158063,44941,17801 +Jan-02,65580,6266,151,148293,46960,20353 +Feb-02,56877,4686,150,135922,40348,18511 +Mar-02,59499,7660,146,160938,42230,19010 +Apr-02,55926,8049,133,170117,39054,21895 +May-02,60775,8430,218,181097,40469,24086 +Jun-02,66216,7524,224,232524,42988,25956 +Jul-02,73074,8920,181,297000,46101,23863 +Aug-02,72262,8930,211,287812,45960,19769 +Sep-02,65930,7895,213,228057,41859,15918 +Oct-02,62803,7845,168,174856,39233,15716 +Nov-02,61493,5665,149,125045,38577,17754 +Dec-02,67367,6725,181,118023,43601,19471 +Jan-03,68149,9940,184,133642,41878,18683 +Feb-03,59584,7612,206,108572,37137,18145 +Mar-03,59204,8660,122,123315,35618,21927 +Apr-03,54322,7073,175,124442,33618,22405 +May-03,58635,8556,187,148609,36565,26813 +Jun-03,63318,10505,229,155451,38259,26094 +Jul-03,70528,10994,263,216715,43247,22897 +Aug-03,71368,11219,248,229759,41914,20852 +Sep-03,63408,8748,219,154540,38150,16690 +Oct-03,60450,8627,276,132888,35839,16416 +Nov-03,61088,5407,214,121259,35285,17395 +Dec-03,67330,7979,230,114570,41319,21305 +Jan-04,69751,9218,377,121084,43402,20691 +Feb-04,61958,7256,329,119177,38875,19221 +Mar-04,58817,7598,301,115097,38192,20897 +Apr-04,54318,7456,273,123001,37397,18824 +May-04,62086,9434,367,162210,38982,21897 +Jun-04,66054,10556,349,174467,40588,23473 +Jul-04,71211,11626,374,210743,43818,21600 +Aug-04,69985,10185,406,204412,42801,19751 +Sep-04,64670,8839,333,181033,39931,18638 +Oct-04,62141,7642,337,156468,35936,17278 +Nov-04,62327,6170,352,116396,33917,19279 +Dec-04,68906,7814,351,125356,41842,23996 +Jan-05,67341,8021,326,135901,39724,21815 +Feb-05,58713,5664,330,109035,34413,19580 +Mar-05,60498,6136,326,138473,36007,20793 +Apr-05,53928,5858,318,137120,32146,20434 +May-05,59431,6351,385,163863,33062,24936 +Jun-05,65932,8886,398,222450,36050,24608 +Jul-05,70549,10949,391,290667,40035,23990 +Aug-05,71631,12223,424,288794,40065,20049 +Sep-05,64943,10625,318,210997,37508,16127 +Oct-05,61619,7782,293,164002,33800,16067 +Nov-05,59718,5545,283,137122,33967,17265 +Dec-05,67047,10183,339,136437,39519,19889 +Jan-06,63248,4753,353,115142,39347,24643 +Feb-06,59205,3642,341,131336,34568,22303 +Mar-06,59892,2791,295,163301,35328,22483 +Apr-06,53692,3864,299,175515,29859,26239 +May-06,60269,3622,272,206071,31917,28260 +Jun-06,64900,5149,320,255572,36757,27208 +Jul-06,71401,5736,380,340237,39705,22923 +Aug-06,72173,8003,342,336378,39758,19604 +Sep-06,62105,3912,300,218550,36747,15504 +Oct-06,60911,4257,288,209168,31856,15252 +Nov-06,59841,4143,209,163495,32015,17985 +Dec-06,65753,3658,221,163631,37484,19459 +Jan-07,67154,4327,259,180467,39514,23791 +Feb-07,61339,6561,254,170826,34700,17033 +Mar-07,59368,4187,255,161896,35547,21994 +Apr-07,54851,4682,205,180930,31069,21526 +May-07,60332,4530,247,207779,33625,23720 +Jun-07,65749,5166,278,250824,36342,21142 +Jul-07,70772,5337,236,297735,39368,21051 +Aug-07,72670,7312,256,387418,39005,18714 +Sep-07,64492,4723,230,271352,35750,13649 +Oct-07,61024,4739,208,250029,31687,13610 +Nov-07,60509,2501,162,181269,33202,14118 +Dec-07,66504,2845,218,195892,37745,16385 +Jan-08,69124,3222,207,213194,38151,18537 +Feb-08,62923,2683,205,177384,34653,16686 +Mar-08,59671,2434,182,192667,33988,19219 +Apr-08,56466,2934,164,185967,31410,19757 +May-08,60866,3151,142,208397,32746,24659 +Jun-08,65603,4510,219,273427,37034,26958 +Jul-08,71829,3631,193,309036,40097,23345 +Aug-08,70200,3423,220,311165,38454,19142 +Sep-08,62384,3992,191,247929,34936,14697 +Oct-08,57481,2639,198,227412,32658,14062 +Nov-08,58593,2809,199,189226,31811,13999 +Dec-08,65187,3569,176,194331,38318,18585 +Jan-09,66535,4402,265,197397,39454,21395 +Feb-09,54408,2562,230,188726,33754,15938 +Mar-09,53064,2335,312,216765,34856,19416 +Apr-09,49581,2138,265,188630,31064,23209 +May-09,52633,2868,271,221387,33796,26842 +Jun-09,59827,2916,252,282521,36633,26688 +Jul-09,63066,2957,253,329356,39076,20998 +Aug-09,64759,3153,249,346858,38084,17473 +Sep-09,55923,2299,244,291103,34002,15917 +Oct-09,55597,2590,121,229615,30109,17915 +Nov-09,54755,1749,116,197075,29344,19056 +Dec-09,65468,1879,183,221847,37103,22350 +Jan-10,67211,4381,283,244970,39345,20298 +Feb-10,59279,1599,258,211934,34945,18752 +Mar-10,56252,1775,308,207974,33460,18546 +Apr-10,49997,1633,253,210270,30946,16812 +May-10,56847,2593,261,261882,34506,22803 +Jun-10,64891,3667,319,314471,35835,27661 +Jul-10,69933,3545,340,387996,38536,22611 +Aug-10,69860,3232,286,411663,38021,18465 +Sep-10,58199,2154,296,306156,37188,15854 +Oct-10,51353,1581,245,260110,31226,15718 +Nov-10,52962,1487,201,219357,32112,17612 +Dec-10,64645,3161,274,254209,38722,20970 +Jan-11,66083,2207,400,238731,37742,23602 +Feb-11,54434,1590,295,208813,34119,22187 +Mar-11,54115,1737,344,217538,34201,28401 +Apr-11,49443,2091,218,243866,28964,28280 +May-11,54959,1886,232,268818,28502,29436 +Jun-11,62690,1745,302,330305,34635,29631 +Jul-11,69942,1906,359,430187,38444,29180 +Aug-11,68137,1749,330,421042,37435,23866 +Sep-11,55844,1427,333,306699,34639,19289 +Oct-11,50644,1481,229,266740,33558,17509 +Nov-11,48879,1488,155,242306,34107,18732 +Dec-11,54146,1539,252,271041,38952,21300 +Jan-12,52338,1495,297,285194,38270,20834 +Feb-12,46908,1245,230,274977,33117,18363 +Mar-12,43413,1360,107,295548,30601,23554 +Apr-12,39920,1339,120,321202,27884,24174 +May-12,46900,1441,150,376968,31384,26048 +Jun-12,53708,1733,169,403071,34052,24540 +Jul-12,64433,2032,182,492043,35999,24767 +Aug-12,61480,1597,170,447137,36149,21575 +Sep-12,51516,1279,180,358829,33384,16309 +Oct-12,49060,1372,156,304811,31289,14912 +Nov-12,51276,1282,175,265122,29038,16928 +Dec-12,54516,1345,170,277026,33656,20933 +Jan-13,55688,1809,253,310174,36748,22563 +Feb-13,49022,1279,220,278139,31144,18316 +Mar-13,52038,1334,236,293545,31426,18349 +Apr-13,45540,1335,217,268467,28991,22654 +May-13,48328,1419,361,295973,32977,25924 +Jun-13,56015,1321,348,363204,34504,24686 +Jul-13,61387,1732,337,432493,36733,24705 +Aug-13,61396,1402,332,442939,37177,19864 +Sep-13,53126,1170,326,365005,34459,15422 +Oct-13,49423,1247,289,312216,31605,15619 +Nov-13,49621,1305,217,284526,32939,15975 +Dec-13,56743,1473,272,323768,37412,18964 +Jan-14,61198,4513,349,325184,38847,19673 +Feb-14,55170,1885,276,266184,32937,15973 +Mar-14,51654,1924,332,272114,32612,22423 +Apr-14,41232,1283,212,270418,30312,22977 +May-14,47195,1296,314,323672,33760,23933 +Jun-14,55606,1180,339,348601,35898,23790 +Jul-14,60316,1309,299,393278,38031,22624 +Aug-14,60292,1311,298,426786,37182,18251 +Sep-14,50798,1297,281,356329,35296,14895 +Oct-14,45053,1219,178,323887,32017,15863 +Nov-14,46637,1230,229,289294,34552,17369 +Dec-14,50062,1269,335,304188,38428,20415 +Jan-15,50856,2069,313,347733,39377,22523 +Feb-15,47941,3593,332,332165,33478,21075 +Mar-15,42297,1244,196,348531,33328,22523 +Apr-15,36112,1233,213,330291,31053,20156 +May-15,42889,1251,261,362129,35089,18481 +Jun-15,50678,1381,235,447668,35150,18429 +Jul-15,56288,1481,334,510811,37055,19004 +Aug-15,54094,1399,311,497761,38482,17813 +Sep-15,46780,1230,294,433385,35034,15062 +Oct-15,39104,1216,227,381518,31886,15378 +Nov-15,35526,1349,181,367223,30751,17901 +Dec-15,37973,1178,232,394101,35997,21296 +Jan-16,45683,1739,302,393680,37974,23579 +Feb-16,37815,1491,272,356141,34281,22015 +Mar-16,31215,1099,283,380955,34445,25125 +Apr-16,28818,1058,326,364349,34036,23742 +May-16,33928,1216,296,410066,36531,23508 +Jun-16,46432,1281,308,501265,37000,21716 +Jul-16,54224,1713,325,572833,37919,20030 +Aug-16,53951,1647,337,568640,37927,18241 +Sep-16,44881,1131,311,454547,33919,15283 +Oct-16,39543,1159,172,370827,30016,16149 +Nov-16,35322,1254,240,336785,33082,17599 +Dec-16,47359,1419,261,346904,37268,20799 +Jan-17,47008,1422,301,341450,38425,24538 +Feb-17,35705,1146,218,295336,33911,21937 +Mar-17,35893,1346,215,354767,34693,27285 +Apr-17,31624,1176,110,334851,30217,26825 +May-17,37582,1288,265,377189,31728,29918 +Jun-17,43955,1301,283,438443,35022,28240 +Jul-17,52225,1183,272,556028,37874,24415 +Aug-17,49209,1263,228,520120,38667,20221 +Sep-17,39596,1208,211,435863,35496,17664 +Oct-17,36413,1329,172,388175,35038,16270 +Nov-17,36042,1187,235,343343,34541,17894 +Dec-17,41940,1790,233,408068,38871,20469 +Jan-18,47999,4527,297,430221,39366,23106 +Feb-18,34219,1122,235,367620,33941,22864 +Mar-18,32513,1099,199,400399,35262,23638 +Apr-18,30538,1172,195,376300,30580,25598 +May-18,35435,1343,141,463895,34479,28055 +Jun-18,42687,1383,270,524974,36437,25778 +Jul-18,48467,1219,285,645124,38293,23303 +Aug-18,48047,1298,273,611046,38885,20050 +Sep-18,40475,1407,260,535085,34377,17368 +Oct-18,35706,1373,159,460419,31364,17571 +Nov-18,38129,1284,196,398836,33043,19630 +Dec-18,41670,1220,242,389505,38223,20373 +Jan-19,41504,1691,260,446364,39806,22391 +Feb-19,33539,1108,224,416656,34243,20610 +Mar-19,31855,1164,194,436004,34213,23839 +Apr-19,24636,1049,110,402826,32063,25266 +May-19,30408,1311,220,462774,35416,29266 +Jun-19,33720,1372,152,543144,36847,25767 +Jul-19,42490,1332,230,662656,39023,22846 +Aug-19,39931,1478,203,681637,39218,20913 +Sep-19,35621,1310,185,577303,34770,17045 +Oct-19,27323,1309,65,497666,32289,16625 +Nov-19,30628,1231,102,427094,32923,18467 +Dec-19,29953,1393,139,469200,39861,19330 +Jan-20,27497,1445,205,508973,40721,22509 +Feb-20,23845,1151,148,482717,36079,23948 +Mar-20,21823,965,211,490399,35133,21612 +Apr-20,17118,883,182,432222,32827,20901 +May-20,19941,1019,187,468847,34392,27694 +Jun-20,27899,1194,258,563573,36388,26532 +Jul-20,38421,1301,261,708738,37583,25226 +Aug-20,39078,1290,237,670087,37544,21967 +Sep-20,29774,1109,117,528997,36043,17567 +Oct-20,25061,1263,83,505328,31641,17451 +Nov-20,24746,1121,159,410077,32605,19456 +Dec-20,31784,1231,228,473220,37995,19787 +Jan-21,33381,1380,212,455887,39472,22459 +Feb-21,36381,2320,224,408270,34339,18612 +Mar-21,25817,1183,204,400861,35325,18971 +Apr-21,22591,1195,107,411897,30126,17256 +May-21,27108,1207,148,436804,33491,21178 +Jun-21,36328,1295,149,580307,36854,21827 +Jul-21,42314,1246,220,658825,38371,20109 +Aug-21,42612,1757,245,661843,38752,18598 +Sep-21,33753,1402,190,512711,35306,15289 +Oct-21,25833,1323,204,477617,34522,15383 +Nov-21,23627,1266,258,455865,34882,17373 +Dec-21,25103,1355,183,464658,39244,21635 +Jan-22,35728,2448,168,507070,39295,24187 +Feb-22,28683,1297,188,421134,34300,20933 +Mar-22,24262,1333,144,408697,34385,22978 +Apr-22,22108,1115,156,394532,30252,17546 +May-22,26485,1304,214,489511,35037,21197 +Jun-22,32034,1326,225,620465,36908,25057 +Jul-22,38041,1417,178,748783,38888,22854 +Aug-22,36431,1391,179,724032,38921,20211 +Sep-22,28269,1446,211,580215,35914,15445 +Oct-22,23441,1467,193,494888,32085,13359 +Nov-22,23408,1397,184,480213,33612,17190 +Dec-22,31682,4091,255,524065,38335,19767 +Jan-23,27444,1496,116,507306,40507,20587 +Feb-23,20112,1385,108,451898,34281,17524 +Mar-23,21274,1388,75,488923,36091,18489 +Apr-23,16158,1306,77,461358,33413,16133 +May-23,18592,1409,76,544102,34877,25981 +Jun-23,26327,1392,107,622573,37151,18414 diff --git a/US_Energy_Consumption/US_Energy_Consumption.csproj b/US_Energy_Consumption/US_Energy_Consumption.csproj new file mode 100644 index 0000000..435dcff --- /dev/null +++ b/US_Energy_Consumption/US_Energy_Consumption.csproj @@ -0,0 +1,56 @@ + + + WinExe + net6.0-windows10.0.19041.0 + 10.0.17763.0 + US_Energy_Consumption + app.manifest + x86;x64;ARM64 + win10-x86;win10-x64;win10-arm64 + win10-$(Platform).pubxml + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + diff --git a/US_Energy_Consumption/US_Energy_Consumption.csproj.user b/US_Energy_Consumption/US_Energy_Consumption.csproj.user new file mode 100644 index 0000000..5fc5cf7 --- /dev/null +++ b/US_Energy_Consumption/US_Energy_Consumption.csproj.user @@ -0,0 +1,15 @@ + + + + + + Designer + + + Designer + + + Designer + + + \ No newline at end of file diff --git a/US_Energy_Consumption/US_Energy_Consumption.sln b/US_Energy_Consumption/US_Energy_Consumption.sln new file mode 100644 index 0000000..c15fa21 --- /dev/null +++ b/US_Energy_Consumption/US_Energy_Consumption.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34018.315 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "US_Energy_Consumption", "US_Energy_Consumption.csproj", "{8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|ARM64.Build.0 = Debug|ARM64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|x64.ActiveCfg = Debug|x64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|x64.Build.0 = Debug|x64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|x64.Deploy.0 = Debug|x64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|x86.ActiveCfg = Debug|x86 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|x86.Build.0 = Debug|x86 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Debug|x86.Deploy.0 = Debug|x86 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|ARM64.ActiveCfg = Release|ARM64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|ARM64.Build.0 = Release|ARM64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|ARM64.Deploy.0 = Release|ARM64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|x64.ActiveCfg = Release|x64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|x64.Build.0 = Release|x64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|x64.Deploy.0 = Release|x64 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|x86.ActiveCfg = Release|x86 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|x86.Build.0 = Release|x86 + {8D93614F-EE13-4C7F-AC1F-20CF93EFDFD2}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C95EA68-3B9E-4E5F-8184-88EAF9B9B6B2} + EndGlobalSection +EndGlobal diff --git a/US_Energy_Consumption/ViewModel/EnergyUtilityConsumption.cs b/US_Energy_Consumption/ViewModel/EnergyUtilityConsumption.cs new file mode 100644 index 0000000..e336018 --- /dev/null +++ b/US_Energy_Consumption/ViewModel/EnergyUtilityConsumption.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace US_Energy_Consumption +{ + public class EnergyUtilityConsumption + { + public ObservableCollection Coal { get; set; } + + public ObservableCollection PetroleumLiquid { get; set; } + + public ObservableCollection PetroleumCoke { get; set; } + + public ObservableCollection NaturalGas { get; set; } + + public ObservableCollection Nuclear { get; set; } + + public ObservableCollection HydroElectric { get; set; } + + public EnergyUtilityConsumption() + { + + Coal = new ObservableCollection(ReadCSV("US_Energy_Consumption.Resources.us_energy_consumption_data.csv")); + PetroleumLiquid = new ObservableCollection(ReadCSV("US_Energy_Consumption.Resources.us_energy_consumption_data.csv")); + PetroleumCoke = new ObservableCollection(ReadCSV("US_Energy_Consumption.Resources.us_energy_consumption_data.csv")); + NaturalGas = new ObservableCollection(ReadCSV("US_Energy_Consumption.Resources.us_energy_consumption_data.csv")); + Nuclear = new ObservableCollection(ReadCSV("US_Energy_Consumption.Resources.us_energy_consumption_data.csv")); + HydroElectric = new ObservableCollection(ReadCSV("US_Energy_Consumption.Resources.us_energy_consumption_data.csv")); + + } + + + private IEnumerable ReadCSV(string resourceStream) + { + Assembly executingAssembly = typeof(App).GetTypeInfo().Assembly; + Stream inputStream = executingAssembly.GetManifestResourceStream(resourceStream); + + string? line; + List lines = new List(); + using StreamReader reader = new StreamReader(inputStream); + while ((line = reader.ReadLine()) != null) + { + lines.Add(line); + } + lines.RemoveAt(0); + return lines.Select(line => + { + string[] data = line.Split(','); + DateTime date = DateTime.ParseExact(data[0], "MMM-yy", CultureInfo.InvariantCulture); + return new EnergyUtilityProducts(date, Convert.ToDouble(data[1]), Convert.ToDouble(data[2]), Convert.ToDouble(data[3]), Convert.ToDouble(data[4]), Convert.ToDouble(data[5]), Convert.ToDouble(data[6])); + }); + } + } +} diff --git a/US_Energy_Consumption/app.manifest b/US_Energy_Consumption/app.manifest new file mode 100644 index 0000000..826ec56 --- /dev/null +++ b/US_Energy_Consumption/app.manifest @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + \ No newline at end of file