Embarcadero中的Builder C++图表教程

point 1
symbol 2
symbol
shape
shape
point
shape
symbol

Chapter 4 VCL Builder C++ Charting Walk-Through

The following information demonstrates how to create your first Embarcadero Builder 13 C++ ProEssentials VCL Charting implementation. It discusses installation, adding ProEssentials to a project, writing your first few lines of code. For Delphi Click here for Delphi

AI 驱动的开发

ProEssentials 包含一个使用 pe_query.py 的 AI 代码助手系统,为 AI 工具提供对完整 API 的按需访问——通过 Ground Truth 验证防止虚构属性路径。

支持 Claude、Gemini、GitHub Copilot、Cursor 和 ChatGPT。

查看演示
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

For help finding VCL specific features in our help system, the .Net Reference section is the best source for researching properties. Our help topics show VCL specific syntax in the OCX/VCL header near top of topic.

When running the ProEssentials setup, the setup program installs the ProEssentials DLLs into System32 and SysWow64. It also installs the ProEssentials VCL interfaces into C:\ProEssentials10\Builder and C:\ProEssentials10\Delphi. Note if your Embarcadero IDE has both Delphi and Builder personalities, install into Builder first. The relevant files are:

  • PEGRP64H.DLL : ProEssentials x64 64 bit DLL
  • PEGRP32H.DLL : ProEssentials x86 32 bit DLL
  • GIGASOFT.CBPROJ : Builder Package
  • GIGASOFT.CPP : Builder CPP helper for VCLs
  • PEGRPAPI.PAS : ProEssentials Constants and Declarations
  • PEGVCL.PAS : Graph Object
  • PESGVCL.PAS : Scientific Graph Object
  • PE3DVCL.PAS : 3D Scientific Graph Object
  • PEPSVCL.PAS : Polar Object
  • PEPCVCL.PAS : Pie Chart Object
  • PEGRP64H.LIB (modern) : Win64x import lib to PEGRP64H.DLL
  • PEGRP64H.a (legacy) : Win64 import lib to PEGRP64H.DLL
  • PEGRP32H.LIB : Win32 import lib to PEGRP32H.DLL


Open Gigasoft.cbproj / Installation...

If upgrading from an earlier ProEssentials, first remove the ProEssentials components from the Builder IDE before proceeding. Remove with Component menu, Install Packages menu, deselect Gigasoft and select Remove.

1) Open Builder and/or click Close All menu item.

2) Use the Open, Project menu item and open "GIGASOFT.CBPROJ" which is located in the c:\ProEssentials10\Builder dir.

3) If planning on developing for Win64 platform, Activate the Win64 target and select Build All Projects. Activate Win64x target and select Build All.

4) Activate the Win32 target and select Build All Projects.

5) Right Click "Gigasoft.bpl" in the project window and select "Install".

6) If the Builder IDE happens to be 64bit, then reverse above and activate/build Win32 first and end up building Win64 last and then install.

Builder C++ charting package

Builder C++ charting package

The PAS interfaces are compiled and ProEssentials components installed into the "Additional" tab. We provide the PAS source which is far better than providing precompiled bins.

vcl charting components in builder toolbarvcl charting components in builder toolbar
Adding ProEssentials VCL Chart to Form...

4) Use the top menus, [View / Tool Palette...] menu to show the Tool Palette and click the PEGraph control from the Additional ToolBox.
VCL Chart PEGraph
Then click and drag a rectangle selection on Form1's canvas. Size the vcl chart control as needed.

The adjacent image shows what you see. 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 Subsets and Points which define the quantity of data your chart will hold. You'll then pass data via the YData[subset, point] two dimensional property array. The following section shows example code of passing data. Note, if we were constructing a Scientific Graph (PESGraph1), we'd also set XData[subset, point].

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.

VCL Chart Window

To automatically maintain Form1 client area with chart, we can set the align property. Use the top menus, [View / Object Inspector] menu to show the Object Inspector and adjust the Align property for the PEgraph1 control to "alClient".

VCL Chart Align PEGraph1 to Window
Unit1.Pas [Code]...

5) Using the Object Inspector, select "Form1" from top drop down listbox, select "Events" tab and find the "OnShow" event and double click the OnShow event.

VCL Chart Form OnShow event

Enter the code as shown below. You may copy and paste, but also try to write a few lines that use enums to see Delphi's intellisense. For example typing "PEGraph1->PlottingMethod = ::" should prompt the ePlottingMethod enum. If this does not work, or Pegvcl and PEGraph1 is not recognized, the Library Path setting set above likely had a mistake.

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

PEGraph1->MainTitle = "Hello World";
PEGraph1->SubTitle = "";

PEGraph1->Subsets = 2; // Subsets = Rows //
PEGraph1->Points = 6; // Points = Cols //
PEGraph1->YData[0][0] = 10; PEGraph1->YData[0][1] = 30;
PEGraph1->YData[0][2] = 20; PEGraph1->YData[0][3] = 40;
PEGraph1->YData[0][4] = 30; PEGraph1->YData[0][5] = 50;
PEGraph1->YData[1][0] = 15; PEGraph1->YData[1][1] = 63;
PEGraph1->YData[1][2] = 74; PEGraph1->YData[1][3] = 54;
PEGraph1->YData[1][4] = 25; PEGraph1->YData[1][5] = 34;

PEGraph1->PointLabels[0] = "Jan"; PEGraph1->PointLabels[1] = "Feb";
PEGraph1->PointLabels[2] = "Mar"; PEGraph1->PointLabels[3] = "Apr";
PEGraph1->PointLabels[4] = "May"; PEGraph1->PointLabels[5] = "June";
PEGraph1->SubsetLabels[0] = "For .Net Framework";
PEGraph1->SubsetLabels[1] = "or MFC, ActiveX, VCL";
PEGraph1->YAxisLabel = "Simple Quality Rendering";
PEGraph1->SubsetColors[0] = PEGraph1->PEargb(60, 0, 180, 0);
PEGraph1->SubsetColors[1] = PEGraph1->PEargb(180, 0, 0, 130);

// Quick way to set many colors via QuickStyle property //
PEGraph1->BitmapGradientMode = false;
PEGraph1->QuickStyle = ::gLightShadow;

PEGraph1->GraphPlusTable = ::gGraphPlusTable;
PEGraph1->DataPrecision = ::gNoDecimals;
PEGraph1->LabelBold = true;
PEGraph1->PlottingMethod = ::gBar;
PEGraph1->GradientBars = 8;
PEGraph1->BarGlassEffect = true;
PEGraph1->LegendLocation = ::gLegendLeft;
PEGraph1->DataShadows = ::gWithThreeD;
PEGraph1->FixedFonts = true;
PEGraph1->FontSize = ::gLarge;

// You will likely set these for all charts //
PEGraph1->PrepareImages = true;
PEGraph1->CacheBmp = true;
PEGraph1->RenderEngine = ::gDirect2D;
PEGraph1->AntiAliasGraphics = true;
PEGraph1->AntiAliasText = true;

// Setting this True will enable Data HotSpots, //
// but we need to add code to respond to hot spot event //

PEGraph1->AllowDataHotSpots = true;

// Always finish your property settings with this setting //
PEGraph1->PEactions = ::gReinitAndReset;

Your project code should look similar to...

VCL Chart example c++ code
Adding a DataHotSpot event...

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

Using the Object Inspector, select "PEGraph1" from top drop down listbox, select "Events" tab and find the "OnDataHotSpot" event and double click the OnDataHotSpot event.

VCL Chart adding hotspot event

Add the following code to the TForm1::PEGraph1DataHotSpot event.

UnicodeString uS = SubsetIndex;
UnicodeString uP = PointIndex;
UnicodeString uV = PEGraph1->YData[SubsetIndex][PointIndex];
ShowMessage("Subset " + uS + ", Point " + uP + " with a value of " + uV );


Success!!!

7) Save, Build All, 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 4 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 v10 / 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.

VCL Charting Component within your custom Builder C++ software!


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

C++ Builder Charting VCL for Scientific Financial Engineering Embedded

我们的任务

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

我们是工程师

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

谢谢

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