Winforms VB.Net图表演示 VS2022 — VS2019

point 1
symbol 2
symbol
shape
shape
point
shape
symbol

VS2022 - VS2019 VB.NET CHARTING COMPONENT Winforms 4.8 Framework Walk Through

ProEssentials WinForms interfaces are used when creating stand-alone Desktop or Embedded EXEs to be distributed royalty-free and ran on an end-users machine. This VS2022-VS2019 VB.NET Charting Walk-through includes instructions for Visual Studio VS2022-VS2019. If you prefer C#: Click here for C# Charting in VS2022-VS2019 or for VB.NET in an earlier VS: Click here for VB.NET and VS2015-VS2012.

查看演示
Best WPF Chart to download, evaluate, and choose for your Financial Scientific Charting.
Best .NET Chart download for Scientific Charting, Engineering Charting.
Hello World - Walk Through - Tutorial

The WinForm interfaces support adapting to changes in the parent form's font and background color. They are designed so that the grid number text size (grid numbers are the grid line labels such as 70, 80, 90 along y axis) matches that of the other standard controls such as TextBox, Radio Button, and Labels. As long as you don't explicitly change the font and background color for the chart, you will be able to change the form's font size and backcolor and all other controls on the form will adapt to match. Note that the default form text size of 8 points is fairly small. You may want to increase it to 9 or 10 points depending on your needs. This feature results in a clean looking user interface where the charting control appears to be a true sibling of the other standard controls.

You will have to write a little code (see below) to develop your graphing solutions. In the end, you'll prefer our .NET (property, method, event) interface. 99% of your code will set simple properties.

Creating a new project...

1) Start Visual Studio.NET and create a new project targeting [Visual Basic] [Windows] [Desktop] and [WinForms .Net Framework]. Accept the default name of [WindowsApp1]. Note, Do not select Windows Forms .NET (without the Framework) as the Framework is required and we recommend .Net 4.8 Framework for this tutorial. We optionally have assemblies for Net60 (Windows) but these are installed via Nuget package via Package Manager and adjusting Package Source to [ Gigasoft (Local) ] or searching for "Gigasoft" if installing from Nuget.org.


Vb.Net Charting new project 2019

2) When the new project opens, you will be presented the design view of "Form1.vb".

Adding designer controls to your Toolbox...

3) Installing WinForms interfaces into Visual Studio.NET

VS2022 Instructions

  • Note 1. For VS2022 we recommend our x64 assemblies else the first time our AnyCpu assembly is added to the Toolbar and a chart is placed on a form, VS2022 should be running with Admin privileges. Subsequent use will not require privileges.
  • 1. With the Designer window having focus, Click the [Toolbox] vertical tab,
  • 2. Right Click the area below the [General] tab,
  • 3. Select [Add Tab],
  • 4. Enter [Gigasoft] for the tab's name,
  • 5. Right Click the area below new [Gigasoft] tab,
  • 6. Select [Choose Items...],
  • 7. If not selected, left click the [.NET Framework Components] tab,
  • 8. Left click the [Browse...] button and find the file "Gigasoft.ProEssentials.dll" found in our \DotNet48\x64 subfolder where you installed ProEssentials. By default, this should be located at "C:\ProEssentials9\DotNet48\x64",
  • 9. Select the file "Gigasoft.ProEssentials.dll" and close the [Open File] dialog,
  • 10. The [Choose Toolbox Items] dialog should now show 5 highlighted controls: Pe3do, Pego, Pepco, Pepso, and Pesgo.
  • 11. Close dialog and 5 ProEssentials components will show within the Gigasoft tab as shown in the bottom right image.
  • Note 2. Attemping to add our x86 assembly (DotNet48\x86) to the VS2022 toolbox will result in an error as the VS2022 designer is 64 bit.
  • Note 3. When deploying your finished project and prefer to support AnyCpu, x64 or x86, close the Designer window, in Solution Explorer remove Reference and replace with any of our other References. The project will now support compiling as AnyCpu, x64, or x86 that matches the Reference added. To again add our charts to a form via the Designer, change Reference to our x64 assembly.

net charting components in vs2022 vs2019 toolbar

VS2019 Instructions

  • Note 1. The first time our AnyCpu assembly is added to the Toolbar and a chart is placed on a form, VS2019 should be running with Admin privileges. Subsequent use will not require privileges. You may optionally install our assembly within the \DotNet48\x86 subfolder which does not require first time Admin privileges however adjust the Project Build setting Platform/CPU Target to x86.
  • 1. With the Designer window having focus, Click the [Toolbox] vertical tab,
  • 2. Right Click the area below the [General] tab,
  • 3. Select [Add Tab],
  • 4. Enter [Gigasoft] for the tab's name,
  • 5. Right Click the area below new [Gigasoft] tab,
  • 6. Select [Choose Items...],
  • 7. If not selected, left click the [.NET Framework Components] tab,
  • 8. Left click the [Browse...] button and find the file "Gigasoft.ProEssentials.dll" found in our \DotNet48\AnyCpu subfolder where you installed ProEssentials. By default, this should be located at "C:\ProEssentials9\DotNet48\AnyCpu",
  • 9. Select the file "Gigasoft.ProEssentials.dll" and close the [Open File] dialog,
  • 10. The [Choose Toolbox Items] dialog should now show 5 highlighted controls: Pe3do, Pego, Pepco, Pepso, and Pesgo.
  • 11. Close dialog and 5 ProEssentials components will show within the Gigasoft tab as shown in the bottom right image.
  • Note 2. Attemping to add our x64 assembly located in \DotNet48\x64 to VS2019 and earlier toolbox will result in an error as the VS2019 designer is 32 bit.
  • Note 3. When deploying your finished project and prefer to change the target to x64, or x86, close the Designer window, in Solution Explorer remove our Reference and replace with any of our other References. The project will now support compiling as x64, x86 or AnyCpu that matches the Reference added. To again add our charts to a form via the Designer, change Reference to our AnyCpu or x86 assemblies.

net charting components in vs2022 vs2012 toolbar
Adding ProEssentials to the Form...

4) Double click the [Pego] tool within the toolbox. This places an instance of the Pego component within "Form1.vb".

Left click bottom-right corner of control and drag down-right to fill up client area of Form1. The adjacent image shows what you see.

vb.net Chart control in Visual Studio vs2019

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.

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.

To enable the chart to match the size of it's container, let us change the chart's Dock setting.

Left click the pego control within Form1 to give it the focus.

From the main menu select [View] and [Properties Window]

Within the [Properties Window], scroll and locate the Layout section and then the Dock item.

Modify the Dock setting by clicking the center section or 'Fill' mode.

VB.Net Chart control in Visual Studio vs2019
Adjusting design time settings...

5) We recommend setting the parent Form's versions of back color, font, etc properties as ProEssentials will use the parent form's settings to help facilitate a uniform look among sibling controls.

We also recommend coding your property settings as this creates a record for you and others as to what settings are being used. And you might be able to re-use this code in other areas for other charts.

If new to VB.Net, the (Name) property is probably the most fundamental property as its name is reflected in all code. For example: Pego1.PeData.Subsets = 1 is a line of code, and it shows how the (Name) property (Pego1) starts the line.

VB.Net Chart property Window in VS2019
Form1.vb [Code]...

6) Double click Form1's Title/Caption Bar to open the code view for "Form1.vb" with default Form1_Load event initialized.

The cursor will be within the Form1_Load 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 Imports declaration at the top of "Form1.vb" will shorten enumeration syntax.
Imports Gigasoft.ProEssentials.Enums;

'// Simple to code = simple to implement and maintain //

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) = 75 : 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) = System.Drawing.Color.FromArgb(60, 0, 180, 0)
Pego1.PeColor.SubsetColors(1) = System.Drawing.Color.FromArgb(190, 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.PeFont.FontSize = Gigasoft.ProEssentials.Enums.FontSize.Large
Pego1.PePlot.SubsetLineTypes(0) = Gigasoft.ProEssentials.Enums.LineType.MediumSolid
Pego1.PePlot.SubsetLineTypes(1) = Gigasoft.ProEssentials.Enums.LineType.MediumDash

Pego1.PeLegend.Location = Gigasoft.ProEssentials.Enums.LegendLocation.Left
Pego1.PePlot.Option.BarGlassEffect = True
Pego1.PePlot.Option.GradientBars = 8
Pego1.PePlot.DataShadows = Gigasoft.ProEssentials.Enums.DataShadows.ThreeDimensional

'// This enables data hot spots, But we need to define code in the HotSpot event //
Pego1.PeUserInterface.HotSpot.Data = True

'// These settings will be used for all charts //
Pego1.PeConfigure.RenderEngine = Gigasoft.ProEssentials.Enums.RenderEngine.Direct2D
Pego1.PeConfigure.PrepareImages = True
Pego1.PeConfigure.CacheBmp = True
Pego1.PeConfigure.AntiAliasGraphics = True
Pego1.PeConfigure.AntiAliasText = True

'// Call this at end of setting properties //
Pego1.PeFunction.ReinitializeResetImage()
Pego1.Refresh() '// Call standard .NET Refresh method to force paint

Your project code should look similar to...

VB.NET Chart code window for form load event vs2012
Adding a DataHotSpot event...

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

Left click the pego control within Form1 to give it the focus.

From the main menu select [View] and [Properties Window]

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

Within the available events, double-click PeDataHotSpot

This opens the code view of "Form1.vb" with cursor within the pego1.PeDataHotSpot event handler.

VB.NET Chart event window for HotSpot event vs2012

Add the following code to the pego1.PeDataHotSpot event.

System.Windows.Forms.MessageBox.Show("Subset " + e.SubsetIndex.ToString() +
", Point " + e.PointIndex.ToString() + " with a value of " +
pego1.PeData.Y(e.SubsetIndex, e.PointIndex).ToString())


Success!!!

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

This completes this walkthrough.

Please read the remaining sections within Chapter 2 and review the demo code and documentation that's installed with the eval/product.

Once installed, the demo program can be accessed via shortcut...

Start / ProEssentials v9 / PeDemo

Note that our main charting demo is replicated in WPF and Winform C#.NET,  VB.NET, VC++ MFC, Delphi, Builder all accessible from where you installed ProEssentials.   These are great for modifying an existing demo to test potential modifications before implementing within your applications.

VB.Net chart within your Visual Studio software!


Thank you for researching. Please contact our engineers if you have a question.

VB.Net Chart Component Scientific Financial Fast Robust

我们的任务

我们的首要目标是通过为您的机构和终端用户提供最简单、最专业的服务,达成您的成功。

我们是工程师

ProEssentials是由需要自定义图表组件的专业电气工程师创立的。加入使用ProEssentials的顶级工程公司名单。

谢谢

感谢您成为ProEssentials的客户,也感谢您研究ProEssentials图表引擎。