Friday, May 3, 2024
HomeC#Making a WPF 3D Pie Chart to Show the Greatest Money Crops...

Making a WPF 3D Pie Chart to Show the Greatest Money Crops within the U.S


Welcome to our Chart of the Week weblog sequence!

In the present day, we’ll delve into the main points of the US’ six most worthwhile agricultural commodities in line with the Leafly Hashish Report utilizing the Syncfusion WPF 3D Pie Chart management.

Agricultural commodities, or money crops, are cultivated to promote and make a revenue relatively than for private consumption. A number of crops have a considerable financial influence on the U.S. economic system because of their intensive cultivation and business worth. Let’s take a more in-depth take a look at six of those main money crops in line with the Leafly Hashish Report:

  • Corn: This versatile crop serves a number of functions, together with getting used as animal feed, in ethanol manufacturing, and as an ingredient in varied meals.
  • Soybeans: These are a significant supply of protein for animal feed and are additionally utilized in producing vegetable oil and industrial merchandise.
  • Hay: It is a major feed supply for livestock, supplying important vitamins comparable to carbohydrates, proteins, and fiber. It turns into notably essential when recent forage is scarce, comparable to in winter or throughout dry spells.
  • Wheat: A staple in a nutritious diet and a significant export commodity. Wheat is utilized in varied meals merchandise, together with bread, pasta, and cereals.
  • Cotton: This essential fiber is used within the textile business and is a big oil and animal feed supply.
  • Hashish: Often known as marijuana, this crop is often used for leisure and medicinal functions.

On this weblog, we’ll visualize the main points of those money crop harvests utilizing the Syncfusion WPF 3D Pie Chart.Visualizing the Biggest Cash Crops in the U.S. Using the WPF 3D Pie Chart

Step 1: Acquire information about money crops

First, we have to collect the money crop information from the Leafly Crops Report. Particularly, we’ll look at the web page quantity 4.

Step 2: Put together information for the chart

Then, create a CashCropModel class with the properties Class and Worth to retailer the details about money crop harvest values within the U.S. for 2022.

Confer with the next code instance.

public class CashCropModel
{
    public string Class { get; set; }
    public double Worth { get; set; }

    public CashCropModel(string class, double worth)
    {
        Class = class;
        Worth = worth;
    }
}

Subsequent, configure the CashCropData class with the Knowledge property to create a group of harvest particulars for money crops in the US.

Confer with the next code instance.

public class CashCropData
{
    public ObservableCollection<CashCropModel> Knowledge { get; set; }

    public CashCropData()
    {
        this.Knowledge = new ObservableCollection<CashCropModel>
        {
             new CashCropModel("Cotton", 7.5),
             new CashCropModel("Corn", 82.6),
             new CashCropModel("Hashish", 5),
             new CashCropModel("Soybeans", 57.5),
             new CashCropModel("Hay", 19.3),
             new CashCropModel("Wheat", 11.9)
        };
    }
}

Step 3: Configuring the Syncfusion WPF 3D Chart

Configure the Syncfusion WPF 3D Chart management by following this documentation.

Confer with the next code instance.

<chart:SfChart3D>
</chart:SfChart3D>

Step 4: Bind the information to the 3D Pie Chart

Now, we’ll create a Pie Chart to visualise the harvest values of money crops.

<chart:SfChart3D>
 <chart:PieSeries3D ItemsSource="{Binding Knowledge}" XBindingPath="Class" YBindingPath="Worth"/>
</chart:SfChart3D>

Within the code instance, we’ve certain the ItemsSource, XBindingPath, and YBindingPath properties with the Knowledge, Class, and Worth properties, respectively.

Step 5: Customise the chart look

Let’s customise the looks of our WPF 3D Pie Chart to make it extra visually interesting and informative.

Customizing the chart angle, dimension, and sequence colour

We will enhance the chart’s dimension, angle, depth, and colour utilizing the Depth, Rotation, Tilt, CircleCoefficient, and Palette properties.

Confer with the next code instance.

<chart:SfChart3D Depth="40" Rotation="-20" Tilt="-30">
 <chart:PieSeries3D CircleCoefficient="0.85" Palette="Customized">
  <chart:PieSeries3D.ColorModel>
    <chart:ChartColorModel>
     <chart:ChartColorModel.CustomBrushes>
      <SolidColorBrush Shade="#E6586D"/>
      <SolidColorBrush Shade="#199AFB"/>
      <SolidColorBrush Shade="#DF76D3"/>
      <SolidColorBrush Shade="#A0DB69"/>
      <SolidColorBrush Shade="#FEC430"/>
      <SolidColorBrush Shade="#F6954F"/>
     </chart:ChartColorModel.CustomBrushes>
    </chart:ChartColorModel>
  </chart:PieSeries3D.ColorModel>
 </chart:PieSeries3D>
</chart:SfChart3D>

Customizing the chart title

Including a title to the chart may help customers perceive the information being visualized. Right here’s how one can customise the chart title.

<chart:SfChart3D.Header>
 <Grid Margin="-50,3,0,10" x:Identify="header">
  <Grid.ColumnDefinitions>
   <ColumnDefinition Width="20"/>
   <ColumnDefinition Width="*"/>
  </Grid.ColumnDefinitions>
  <StackPanel Orientation="Vertical" Margin="0,10,5,0" Background="#199AFB"/>
  <StackPanel Grid.Column="1" >
   <TextBlock Textual content="The Six Greatest Money Crops within the U.S" FontSize="35" FontWeight="SemiBold" Foreground="White"/>
   <TextBlock Textual content="Crops with the largest wholesale harvest worth in the usin 2022(in billions of USD)" FontSize="18" Foreground="Grey"/>
  </StackPanel>
 </Grid>
</chart:SfChart3D.Header>

Customizing the chart legend

Confer with the next code to allow and customise the legend.

<chart:SfChart3D>
 <chart:SfChart3D.Legend>
  <chart:ChartLegend DockPosition="Proper" Foreground="White" FontSize="15" IconWidth="18" IconHeight="18" ItemMargin="2"/>
 </chart:SfChart3D.Legend>
 <chart:PieSeries3D LegendIcon="Circle"/>
</chart:SfChart3D>

Including information labels

We will allow and customise the chart information label parts, such because the label place, connector line, font dimension, and connector kind.

<chart:SfChart3D>
 <chart:PieSeries3D ConnectorType="Bezier" LabelPosition="Exterior">
  <chart:PieSeries3D.AdornmentsInfo>
   <chart:ChartAdornmentInfo3D ShowLabel="True" ShowConnectorLine="True" ConnectorHeight="40" FontSize="13"/>
  </chart:PieSeries3D.AdornmentsInfo>
 </chart:PieSeries3D>          
</chart:SfChart3D>

Enabling the interactive options

The WPF 3D Pie Chart allows us to view information dynamically from the very best angle utilizing a mouse or contact system with the EnableRotation property.

Confer with the next code instance.

<chart:SfChart3D EnableRotation="True">
</chart:SfChart3D>

After executing the earlier code examples, the output will resemble the next picture.

Visualizing the Biggest Cash Crops in the U.S. Using the WPF 3D Pie Chart
Visualizing the Greatest Money Crops within the U.S. Utilizing the WPF 3D Pie Chart

GitHub reference

For extra particulars, seek advice from the mission on GitHub.

Conclusion

Thanks for studying! On this weblog, we’ve got proven visualize the harvest particulars of money crops within the U.S. utilizing the Syncfusion WPF 3D Pie Chart. We encourage you to observe the steps outlined on this weblog and share your worthwhile suggestions within the feedback part under.

In the event you require help, please don’t hesitate to contact us by way of our help discussion boardhelp portal, or suggestions portal. We’re at all times keen that can assist you!

Associated blogs

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments