Chart of the Week: Creating a .NET MAUI Line Chart to Analyze Wage Trends in the Texas Oil Gas Extraction Industry
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (178).NET Core  (29).NET MAUI  (214)Angular  (110)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (223)BoldSign  (15)DocIO  (24)Essential JS 2  (109)Essential Studio  (200)File Formats  (68)Flutter  (133)JavaScript  (225)Microsoft  (120)PDF  (81)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (936)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (52)Windows Forms  (61)WinUI  (71)WPF  (162)Xamarin  (161)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (9)Business intelligence  (55)Button  (4)C#  (156)Chart  (138)Chart of the week  (53)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (67)Development  (650)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (6)Essential Tools  (14)Excel  (43)Extensions  (22)File Manager  (7)Gantt  (19)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (512)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (4)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (12)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (393)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (607)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Chart of the Week Creating a .NET MAUI Sunburst Chart to Visualize the Most Popular Wikipedia Articles

Chart of the Week: Creating a .NET MAUI Line Chart to Analyze Wage Trends in the Texas Oil Gas Extraction Industry

TL;DR: Let’s visualize wage trends in the Texas oil and gas extraction industry over the last fifteen years using the Syncfusion .NET MAUI Line Chart. Discover how to gather and link data to the chart while enhancing visualization by customizing elements such as title, axis, and tooltip.

Welcome to our Chart of the Week blog series!

In the heart of Texas lies an industry that has long been synonymous with prosperity and innovation: oil and gas extraction. As we delve into the present landscape of this sector, one question looms large: What do the current wage trends reveal about its state?

In this article, we embark on a journey of data exploration, harnessing the power of Syncfusion .NET MAUI Line Chart to analyze current wage trends in the Texas oil and gas extraction industry.

These current wage trends hold significant implications for various stakeholders within and beyond the Texas oil and gas extraction industry. Employers gain valuable insights into current labor market dynamics, informing their hiring and compensation strategies. Policymakers glean insights to craft policies that support workforce development and economic growth. Meanwhile, workers themselves can better understand current wage trends to make informed career decisions.

Let’s examine the percentage of employment growth or decline over the last fifteen years in the Texas oil and gas extraction industry. The following image shows the chart we’re going to build.

Visualizing wage trends of the Texas oil and gas extraction industry using Syncfusion .NET MAUI Line Chart
Visualizing wage trends of the Texas oil and gas extraction industry using Syncfusion .NET MAUI Line Chart

Step 1: Gathering the data

Before proceeding, let’s collect data on wage trends from employment profiles in Texas’s oil and gas extraction industry.

Step 2: Preparing the data for the chart

Create the OilGasEmploymentModel class to hold employment details using the EmploymentPercent, EmploymentCount, Date, and other properties. 

Refer to the following code example.

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

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

Then, we generate the employment count and percentage collection using the OilGasEmploymentViewModel class and its EmploymentDetails property. Assign the CSV data to the EmploymentDetails data collection using the ReadCSV method and store it in the EmploymentDetails property.

Refer to the following code example.

public class OilGasEmploymentViewModel
{
    public ObservableCollection<OilGasEmploymentModel> EmploymentDetails { get; set; }
    public ObservableCollection<Brush> CustomBrushes { get; set; }
    public Geometry? Green { get; set; } = (Geometry?)(new PathGeometryConverter().ConvertFromInvariantString("M16.000016,0L24.000008,10.7 32,21.399999 16.000016,21.399999 0,21.399999 7.9999928,10.7z"));
    public Geometry? Red { get; set; } = (Geometry?)(new PathGeometryConverter().ConvertFromInvariantString("M0.87499046,0L31.12499,0C31.92399,0,32.22299,0.49899435,31.82399,0.9979887L16.648991,21.064764C16.24999,21.563759,15.65099,21.563759,15.250991,21.064764L0.1759901,0.9979887C-0.22300911,0.49899435,0.075990677,0,0.87499046,0z"));

    public OilGasEmploymentViewModel()
    {
           
        EmploymentDetails = new ObservableCollection<OilGasEmploymentModel>(ReadCSV());

        CustomBrushes = new ObservableCollection<Brush>();

        foreach (var item in EmploymentDetails)
        {
            if (item.EmploymentCount >= 0)
            {
                item.Path = Green;
                item.FillPath = new SolidColorBrush(Color.FromHex("#619624"));
                CustomBrushes.Add(new SolidColorBrush(Color.FromHex("#619624")));
            }
            else if (item.EmploymentCount < 0)
            {
                item.Path = Red;
                item.FillPath = new SolidColorBrush(Color.FromHex("#eb6569"));
                CustomBrushes.Add(new SolidColorBrush(Color.FromHex("#eb6569")));
            }
        }
    }

    private IEnumerable<OilGasEmploymentModel> ReadCSV()
    {
        Assembly executingAssembly = typeof(App).GetTypeInfo().Assembly;
        Stream inputStream = executingAssembly.GetManifestResourceStream("OilGasExtraction.Resources.Raw.data.csv");

        string? line;
        List<string> lines = new List<string>();

        using StreamReader reader = new StreamReader(inputStream);
        while ((line = reader.ReadLine()) != null)
        {
            lines.Add(line);
        }

        lines[0].Remove(0);
        return lines.Select(line =>
        {
            string[] data = line.Split(',');
            DateTime day = DateTime.Parse(data[0]);
                
         return new OilGasEmploymentModel(day, Convert.ToDouble(data[1]), Convert.ToDouble(data[2]));
               
        });
    }
}

Step 3: Configuring the Syncfusion .NET MAUI Cartesian Charts

Now, configure the Syncfusion .NET MAUI Cartesian Charts control using this documentation.

Refer to the following code example.

<chart:SfCartesianChart>

  <chart:SfCartesianChart.XAxes>
        <chart:DateTimeAxis>
        </chart:DateTimeAxis>
  </chart:SfCartesianChart.XAxes>

  <chart:SfCartesianChart.YAxes>
      <chart:NumericalAxis>
       </chart:NumericalAxis>
  </chart:SfCartesianChart.YAxes>
          
</chart:SfCartesianChart>

Step 4: Initialize the BindingContext for the chart

Now, configure the OilGasEmploymentViewModel class to bind its properties to the BindingContext of the SfCartesianChart.

Refer to the following code example.

<chart:SfCartesianChart.BindingContext>
                <local:OilGasEmploymentViewModel/>
</chart:SfCartesianChart.BindingContext>

Step 5: Bind the wage trends data to the .NET MAUI Line Chart

We’ll use the Syncfusion LineSeries instance to analyze wage trends in the oil and gas extraction industry over time. 

Refer to the following code example.

<chart:LineSeries ItemsSource="{Binding EmploymentDetails}" 
                  XBindingPath="Month" YBindingPath="EmploymentPercent">
</chart:LineSeries>

In the above code example, we’ve bound the ItemSource property to the EmploymentDetails property. We’ve also bound the XBindingPath and YBindingPath properties to the Month and EmploymentPercent properties, respectively.

Step 6: Customizing the chart appearance

Let’s customize the appearance of the .NET MAUI Line Chart for better data visualization.

Adding chart title

We can use the Title property to customize the .NET MAUI Line Chart title. As per the documentation, you can also add any view to the Title property.

Refer to the following code example.

<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="Analyze the Wage Trends in the Texas Oil Gas Extraction Industry"/>
        </HorizontalStackLayout>
    </Grid>
</chart:SfCartesianChart.Title>

Customize the axis crossing and tick line styles

We can adjust the axis position anywhere in the chart area using the CrossesAt property. Additionally, we can determine whether the crossing axis should be placed at the crossing position or not using the RenderNextToCrossingValue property. We can use the ShowMajorGridLines and ShowMinorGridLines properties to turn the grid lines on or off.

Then, customize the axis tick styles using the MajorTickStyle property and change the color and width of the ticks using the Stroke and StrokeWidth properties, respectively.

Refer to the following code example.

<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>

Customize the axis label

Let’s customize the axis LabelFormat in the LabelStyle. Then, set the Minimum and Maximum range for the axis.

<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>

Customize the line series appearance

You can set the stroke width for the line series using the StrokeWidth property. To display information about the count and percentage details of employed people, you can enable the EnableTooltip property and customize the appearance of the tooltip using the TooltipTemplate property.

You can also set a palette to the series to apply pre-defined brushes to the line series segments using the PaletteBrushes property. This can help analyze the trend more effectively.

Refer to the following code example.

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

Step 7: Customize tooltip behavior

Finally, specify the duration time in seconds for which the tooltip should be displayed using the Duration property.

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

After executing the above code examples, we will get the output that resembles the following image.

Visualizing wage trends of the Texas oil and gas extraction industry using Syncfusion .NET MAUI Line Chart
Visualizing wage trends of the Texas oil and gas extraction industry using Syncfusion .NET MAUI Line Chart

GitHub reference

For more details, refer to the Creating a .NET MAUI Line Chart to visualize wage trends GitHub Demo.

Conclusion

Thanks for reading! We have demonstrated how to visualize the data on employed individuals in the Texas oil and gas extraction industry using the Syncfusion .NET MAUI Line Chart. We encourage you to try the steps discussed and share your thoughts in the comments below.

The existing customers can download the latest version of Essential Studio from the License and Downloads page. If you are new, try our 30-day free trial to explore our incredible features. 

If you require assistance, please don’t hesitate to contact us via our support forumssupport portal, or feedback portal. We are always eager to help you!

Test Flight
App Center Badge
Google Play Store Badge
Microsoft Badge
Github Store Badge

Related

 

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed
Syncfusion Ad