Visit Gigasoft's Web Site
 ProEssentials v10 Help
Chapter 2: WPF NET80 Charting C# Walk-Through VS2022 VS2019

 ProEssentials charting WPF interfaces are used when creating stand-alone client-side EXEs to be distributed and ran on an end-users machine. This Wpf Charting Walk-through includes instructions for Visual Studio in C#.

 

It is recommended that the namespace: Gigasoft.ProEssentials.Enums be included at the top of your source code files. In C#, use the using keyword:

using Gigasoft.ProEssentials.Enums;

 

Walk-Through:

The following information demonstrates how to create your first .NET WPF NET80 Charting ProEssentials implementation using the C# language. It discusses using the Wpf interfaces to add interactive charting content to your EXEs. Other examples are provided within the product/evaluation.
 

1) Start Visual Studio.NET and create a new project targeting [C#] [Windows] [Desktop] and [WPF Application]. Accept the default name of [WpfApp1]. Note to make sure this project type is set to WPF Application and not [.NET FrameWork]. We optionally have assemblies for .Net 4.8 Framework and a different Walk-Through to target the .Net Framework 4.8.

Wpf charting NET80 NET60 new project C# VS2022 VS2019

2) When the new project opens, you will be presented the design view of "MainWindow.xaml and MainWindow.xaml.cs".
 

WPF Chart control walkthrough in Visual Studio vs2022 vs2019

 

MainWindow.xaml.cs [Design]... Adding charts to toolbox nuget.org


3) Installing Wpf charts into Visual Studio.NET via Nuget Package. Note our evaluation setup program will install a local nuget source [ Gigasoft (Local) ] as an easier location to find our nuget packages. If you installed our eval, then use the [Package Source] drop-down list box (the green 1. below) and select Gigasoft (Local).

 

 

 VS2022 - VS2019 Instructions

  • 1. Within the Solution Explorer window, Right Click [Dependencies] and select [Manage NuGet Packages...],
  • gigasoft charting nuget package vs2022 vs2019
  • 2. Within the NuGet Package Manager window,
    • 1. check source is nuget or Gigasoft (Local), we recommend Local
    • 2. select Browse and optionally enter "Gigasoft Net80" in the search box if on Nuget.org,
    • 3. select ProEssentials.Chart.Net80.Wpf, optionally ProEssentials.Chart.Net80.x64.Wpf is recommended for VS2022
    • 4. select Install

  • gigasoft proessentials charting nuget net60 components
  • 3. Accept installing the package,
  • 4. ProEssentials components will now show within the ProEssentials tab within your toolbox as seen in this image.
  • net charting WPF components in vs2022 vs2019 toolbar
MainWindow.xaml.cs [Design]... Adding wpf chart to the window...
 
 

4) Double Click the [PegoWpf] charting icon within the toolbox and the IDE will automatically insert the chart into MainWindow.xaml.cs between the <Grid > and </Grid> tags. * Note, use the Build menu, Rebuild project to allow the IDE to compile all that is necessary to see the chart in the Designer window.

C# WPF Chart property Window in VS2022 VS2019

 

MainWindow.xaml.cs [Code]... Name property and Loaded event ...
   


This represents the default state of a ProEssentials Graph. The default state has one subset with four data points. In the course of constructing your own charts, you'll set the properties PeData.Subsets and PeData.Points which define the quantity of data your chart will hold. You'll then pass data via the PeData.Y[subset, point] two dimensional property array. The following section shows example code of passing data.

ProEssentials uses the terms Subsets and Points but you can think of these as Rows and Columns. Passing data is as simple as filling each Subset with Points worth of data.

 
 


5) After embedding the chart in your window, place the cursor within the PegoWpf tag and type "Name=" and provide a name for your chart "Pego1" and then type "Loaded=" and accept the default loaded event and right click and select Navigate to Event Handler. Your xaml should look like...

Adding WPF name and loaded event

With the cursor within the Pego1_Loaded code section, enter the following code into this section.

You can copy and paste, but hand-typing a few lines of this code will help familiarize yourself with the Gigasoft.ProEssentials namespace.  

Note: adding the following using declaration at the top of "MainWindow.xaml.cs" will shorten enumeration syntax.
using Gigasoft.ProEssentials.Enums;
 

Pego1.PeString.MainTitle = "Hello World";
Pego1.PeString.SubTitle = "";

Pego1.PeData.Subsets = 2;
Pego1.PeData.Points = 6;
Pego1.PeData.Y[0, 0] = 10; Pego1.PeData.Y[0, 1] = 30;
Pego1.PeData.Y[0, 2] = 20; Pego1.PeData.Y[0, 3] = 40;
Pego1.PeData.Y[0, 4] = 30; Pego1.PeData.Y[0, 5] = 50;
Pego1.PeData.Y[1, 0] = 15; Pego1.PeData.Y[1, 1] = 63;
Pego1.PeData.Y[1, 2] = 74; Pego1.PeData.Y[1, 3] = 54;
Pego1.PeData.Y[1, 4] = 25; Pego1.PeData.Y[1, 5] = 34;

Pego1.PeString.PointLabels[0] = "Jan";
Pego1.PeString.PointLabels[1] = "Feb";
Pego1.PeString.PointLabels[2] = "Mar";
Pego1.PeString.PointLabels[3] = "Apr";
Pego1.PeString.PointLabels[4] = "May";
Pego1.PeString.PointLabels[5] = "June";

Pego1.PeString.SubsetLabels[0] = "For .Net Framework";
Pego1.PeString.SubsetLabels[1] = "or MFC, ActiveX, VCL";
Pego1.PeString.YAxisLabel = "Simple Quality Rendering";

Pego1.PeColor.SubsetColors[0] = Color.FromArgb(60, 0, 180, 0);
Pego1.PeColor.SubsetColors[1] = Color.FromArgb(180, 0, 0, 130);

Pego1.PeColor.BitmapGradientMode = false;
Pego1.PeColor.QuickStyle = Gigasoft.ProEssentials.Enums.QuickStyle.LightShadow;
Pego1.PeTable.Show = Gigasoft.ProEssentials.Enums.GraphPlusTable.Both;
Pego1.PeData.Precision = Gigasoft.ProEssentials.Enums.DataPrecision.NoDecimals;
Pego1.PeFont.Label.Bold = true;
Pego1.PePlot.Method = Gigasoft.ProEssentials.Enums.GraphPlottingMethod.Bar;
Pego1.PePlot.Option.GradientBars = 8;
Pego1.PePlot.Option.BarGlassEffect = true;
Pego1.PeLegend.Location = Gigasoft.ProEssentials.Enums.LegendLocation.Left;
Pego1.PePlot.DataShadows = Gigasoft.ProEssentials.Enums.DataShadows.ThreeDimensional;
Pego1.PeFont.FontSize = Gigasoft.ProEssentials.Enums.FontSize.Large;

Pego1.PeConfigure.RenderEngine = Gigasoft.ProEssentials.Enums.RenderEngine.Direct2D;
Pego1.PeConfigure.AntiAliasGraphics = true;
Pego1.PeConfigure.AntiAliasText = true;
Pego1.PeUserInterface.HotSpot.Data = true;
Pego1.PeFunction.ReinitializeResetImage();
// Pego1.Invalidate(); // optional help for real-time charts or certain update scenarios.
// Pego1.UpdateLayout(); // optional help for real-time charts or certain update scenarios.



Your project code should look similar to...

WPF C# vs2022 code window
 

 

WPF Charting events... Adding a PeDataHotSpot event...
event window for HotSpot event vs2022

6) The code above enabled the DataHotSpot event, so we should place some appropriate code in the DataHotSpot event.

Left click the Pego Wpf chart control within visual designer to give it the focus.

From the main menu select [View] and [Properties Window] in case the property window is not showing.

Within the [Properties Window], click the [Events] icon.

Within the available events, double-click PeDataHotSpot

This opens the code view with cursor located at "Pego1_PeDataHotSpot".

Add the following code to the Pego1_PeDataHotSpot event.

System.Windows.MessageBox.Show("Subset " + e.SubsetIndex.ToString() +
", Point " + e.PointIndex.ToString() + " with a value of " +
Pego1.PeData.Y[e.SubsetIndex, e.PointIndex].ToString());


7) Save and run the project. Your project will show an image as follows. Move the mouse over chart and click a bar to trigger the DataHotSpot event.

This completes this WPF charting walkthrough. Please review the demo code and documentation that's installed with the eval/product. Demo projects can be accessed via shortcut... Start / All Programs / ProEssentials v10 Note that our main demo is replicated in native WPF C#, WinForm C#.NET, VC++ and MFC  projects all accessible from the start menu. These are great for modifying an existing demo to test potential charting modifications before implementing within your applications. WPF Chart in Visual Studio 2022 2019 with C# .Net language.