C++ QT 차트 라이브러리 자습서 소스 코드는 C++ 언어로 차트를 추가합니다. - VS2019

point 1
symbol 2
symbol
shape
shape
point
shape
symbol

VS2022 VS2019 MINIMAL C++ QT CHARTING LIBRARY Walk Through

ProEssentials DLL 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 Minimal C++ QT Charting Walk-through includes instructions for Visual Studio. For a C++ MFC walkthrough see: Click here for VS2019 MFC Walkthough.

데모보기
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

IMPORTANT: For help finding DLL specific features in our help system, click the Contents Tab at the top-left location, then near the bottom click ProEssentials Reference, and then see the Alphabetic Listing. The .Net Reference section is the best source for researching properties and still shows DLL specific syntax.

When installing ProEssentials, the setup program installs the ProEssentials DLL into the System32 directory, SysWow64 on 64 bit systems. It also installs a header file and import library into the C:\ProEssentials9\VC directory. The relevant files are:

  • PEGRP32G.DLL : ProEssentials Pro DLL
  • PEGRP32G.LIB : ProEssentials Pro LIB File
  • PEGRPAPI.H : ProEssentials Header File

  • PEGRPSG.DLL : ProEssentials Standard DLL
  • PEGRPSG.LIB : ProEssentials Standard LIB File

Creating a new project...

1) Start Visual Studio.NET and create a new project targeting [C++] [Windows] [Desktop] and [Windows Desktop Application]. Accept the default project name of [WindowsProject1].

C++ charting component new project VS 2019

C++ Charting Project, Adding Existing Items...

2) First manually copy 'PEGRPAPI.H' and 'PEGRP32G.LIB' from the C:\ProEssentials9\VC demo directory to where the WindowsProject1 project files are located.

Note, if using the Standard version instead of Pro version, use 'PEGRPSG.LIB'.

From the top level Visual Studio menus, use [Project / Add Exiting Item...] menu to add 'PEGRPAPI.H' and 'PEGRP32G.LIB' to the WindowsProject1 project.

The image shows the existing files being added to your project.

C++ Chart property Window in VS2019
C++ Charting Project, Adding Header File...

3) Open the file 'WindowsProject1.cpp' and near the top add the lines:

#include “Pegrpapi.h“
 HWND hPE;

The include statement adds the ProEssentials header file which contains constants and function declarations.

The variable hPE is used to store the Window handle for the ProEssentials chart control.

C++ Chart Component adding header file VS2019
C++ Charting Project, Adding a Window Handle for the Chart...

4) Also within the file 'WindowsProject1.cpp' add this line to the InitInstance function:

hPE = NULL;

This will initialize our window handle to NULL at the start of the process, and we will later set to a valid handle in WM_CREATE. The chart we create will be a standard Window; as if we called the CreateWindow API call.


C++ Chart Component adding windows handle
C++ Charting Project, Adding simple data...

5) Near the top of WndProc, add variables used later to initialize the chart.

RECT r;
int s, p;
int dwColor;
float f[] = {10, 30, 20, 40, 30, 50, 15, 63, 74, 54, 25, 34};

C++ Chart Component WndProc
C++ Charting Project, Message Switch statement...

6)Add the below message switch statements. See images below for clarity.

case WM_CREATE: creates and initialzes a chart after parent window is created.

::GetClientRect(hWnd, &r);

// PEcreate is similar to CreateWindow API call, returns a Window Handle //
hPE = PEcreate(PECONTROL_GRAPH, 0, &r, hWnd, 1000);
PEszset(hPE, PEP_szMAINTITLE, (LPWSTR) L"Hello World");
PEszset(hPE, PEP_szSUBTITLE, (LPWSTR) L"");
PEnset(hPE, PEP_nSUBSETS, 2); // Subsets = Rows //
PEnset(hPE, PEP_nPOINTS, 6);  // Points = Columns //

// Passing data one piece at a time //
for (s=0; s<2; s++)
{
    for (p=0; p<6; p++)
    {   // (s*6)+p or (SubsetIndex * NumberPoints) + PointIndex //
        PEvsetcellEx(hPE, PEP_faYDATA, s, p, &f[(s*6)+p]);
    }
}
// or Passing data in one call is much faster: PEvset(hPE, PEP_faYDATA, f, 12); //

PEvsetcell(hPE, PEP_szaPOINTLABELS, 0, (LPVOID) TEXT("Jan"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 1, (LPVOID) TEXT("Feb"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 2, (LPVOID) TEXT("Mar"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 3, (LPVOID) TEXT("Apr"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 4, (LPVOID) TEXT("May"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 5, (LPVOID) TEXT("June"));
PEvsetcell(hPE, PEP_szaSUBSETLABELS, 0, (LPVOID) TEXT("For .Net Framework"));
PEvsetcell(hPE, PEP_szaSUBSETLABELS, 1, (LPVOID) TEXT("or MFC, ActiveX, VCL"));
PEszset(hPE, PEP_szYAXISLABEL, (LPWSTR) L"Simple Quality Rendering");
PEszset(hPE, PEP_szXAXISLABEL, (LPWSTR) L"");
dwColor = PERGB(60, 0, 180, 0); PEvsetcell(hPE, PEP_dwaSUBSETCOLORS, 0, &dwColor);
dwColor = PERGB(180, 0, 0, 130); PEvsetcell(hPE, PEP_dwaSUBSETCOLORS, 1, &dwColor);

// Quick way to set many colors via QuickStyle property //
PEnset(hPE, PEP_bBITMAPGRADIENTMODE, FALSE);
PEnset(hPE, PEP_nQUICKSTYLE, PEQS_LIGHT_SHADOW);

PEnset(hPE, PEP_nGRAPHPLUSTABLE, PEGPT_BOTH);
PEnset(hPE, PEP_nDATAPRECISION, 0);
PEnset(hPE, PEP_bLABELBOLD, TRUE);
PEnset(hPE, PEP_nPLOTTINGMETHOD, PEGPM_BAR);
PEnset(hPE, PEP_nGRADIENTBARS, 8);
PEnset(hPE, PEP_bBARGLASSEFFECT, TRUE);
PEnset(hPE, PEP_nLEGENDLOCATION, PELL_LEFT);
PEnset(hPE, PEP_nDATASHADOWS, PEDS_3D);
PEnset(hPE, PEP_bFIXEDFONTS, TRUE);
PEnset(hPE, PEP_nFONTSIZE, PEFS_LARGE);

// You will likely set these for all charts //
PEnset(hPE, PEP_bPREPAREIMAGES, TRUE);
PEnset(hPE, PEP_bCACHEBMP, TRUE);
PEnset(hPE, PEP_nRENDERENGINE, PERE_DIRECT2D);
PEnset(hPE, PEP_bANTIALIASGRAPHICS, TRUE);
PEnset(hPE, PEP_bANTIALIASTEXT, TRUE);

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

PEnset(hPE, PEP_bALLOWDATAHOTSPOTS, TRUE);

// Always finish your property settings with these function calls //
PEreinitialize(hPE);
PEresetimage(hPE, 0, 0);

case WM_DESTROY: clean up chart resource at same time parent is cleaned up

if (hPE) { PEdestroy(hPE); hPE = 0; }

case WM_SIZE: this causes chart to always fill client rect of parent

if (hPE)
{
    RECT r; ::GetClientRect(hWnd, &r);
    ::MoveWindow(hPE, 0, 0, r.right, r.bottom, FALSE);
}

case WM_COMMAND: listen for notification message to handle hot spot

int wmId = LOWORD(wParam);
int wmEvent = HIWORD(wParam);
switch (wmEvent)
{
case PEWN_CLICKED:
    HOTSPOTDATA hsd; TCHAR buffer[128]; float yvalue;
    PEvget(hPE, PEP_structHOTSPOTDATA, &hsd);
    if (hsd.nHotSpotType == PEHS_DATAPOINT)
    {
        PEvgetcellEx(hPE, PEP_faYDATA, hsd.w1, hsd.w2, &yvalue);
        swprintf_s(buffer, (LPWSTR) L“DataPoint %d value %.2f“, hsd.w2, yvalue);
        ::MessageBox(hWnd, buffer, (LPWSTR) L“Hello World“, 0);
    }
    break;
}

Your project code files should look similar to...

C++ Chart code window for WM_CREATE VS2019
C++ Chart code window for WM_COMMAND VS2019
C++ Chart code window for WM_DESTROY and WM_SIZE VS2019

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

C++ Charting Library within your software!


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

C++ Charting Library Tutorial Scientific Financial 2D Contour 3D Surface Scatter

우리의 미션

귀사의 조직과 최종 사용자들에게 가장 쉽고 가장 전문적인 혜택을 제공함으로써 귀사께서 성공하시는 것이 당사의 최우선 목표입니다.

저희는 엔지니어입니다

프로에센셜은 자체 차트 컴포넌트가 필요한 전기 공학 전문가들로부터 태어났습니다. 프로에센셜을 사용하는 탑 엔지니어링 기업들 명단에 참여히세요.

정말 감사합니다

프로에센셜 고객이 되어주셔서 감사드리며, 프로에센셜 차트 제작 엔진을 연구해주셔서 감사드립니다.