MS Access Charting ActiveX教程,显示用于读取SQL表和填充图表的VBA代码。

point 1
symbol 2
symbol
shape
shape
point
shape
symbol

ACCESS ACTIVEX CHART COMPONENT Walk Through in Visual Basic

ProEssentials ActiveX Charting components are used when creating stand-alone client-side EXEs or within containers that accept ActiveX components. This ActiveX Charting Walk-through includes instructions for Microsoft Access 2007-2017 and should apply to later and earlier versions of Access. For Excel Click here for Excel Charting ActiveX Walkthrough

查看演示
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 ActiveX specific features in our help system, the .Net Reference section is the best source for researching properties. Our help topics show ActiveX OCX specific syntax in the OCX/VCL header near top of topic.

When installing ProEssentials, the setup program installs the ProEssentials 32 bit DLL into the System32 directory on 32 bit systems. On 64 bit systems, the 32 bit DLL is installed in SysWow64 and the 64 bit DLL is installed in System32.

The setup also installs the following Charting OCX files into the same system folders as DLLs and registers them. Note, you do not register our DLLs. Note, the 32 bit and 64 bit OCXs have the same file names and classIDs and the OS will correctly invoke the appropriate version based on the run time need. The relevant files are:

Pro Components:

  • PEGOG.OCX : Graph Component
  • PESGOG.OCX : Scientific Graph Component
  • PE3DOG.OCX : 3D Scientific Graph Component
  • PEPSOG.OCX : Polar Smith Component
  • PEPCOG.OCX : Pie Chart Component
  • PEGRP32G.DLL : 32 bit Pro DLL
  • PEGRP64G.DLL : 64 bit Pro DLL

Standard Components:

  • PEGOSG.OCX : Graph Component
  • PESGOSG.OCX : Scientific Graph Component
  • PE3DOSG.OCX : 3D Scientific Graph Component
  • PEPSOSG.OCX : Polar Smith Component
  • PEPCOSG.OCX : Pie Chart Component
  • PEGRPSG.DLL : 32bit Standard DLL
  • PEGRP6SG.DLL : 64bit Standard DLL

The following information demonstrates how to create your first ProEssentials Access ActiveX Charting implementation using the Visual Basic. It discusses using the OCX charting components to add interactive engineering and scientific charting content to your Access Databases. Please see the other charting examples provided within the product/evaluation; including a larger MS Access example database already containing charts and example code on various forms.


New MS Access Charting ActiveX Project...

1) From the [New] menu, create a new [Blank Database]

Gigasoft ActiveX Chart OCX in MS Access

The project opens and shows a default blank table.

MS Access Gigasoft chart activex ocx reading table example code
Adding a New Blank Form...

2) Using the [Create] menu, Add a new [Blank Form].

MS Access adding new form to hold Gigasoft chart activex.

Below shows newly created blank form.

MS Access form to hold Gigasoft charting activex
Add example data we will read with VB code...

3) Click / select the Table1 and referring to below image, enter the following fields and data as shown.

  • Field 1: number type
  • Field 2: number type
  • Field 3: default short string type
MS Access with Gigasoft Activex Charting code to read database data
Adding ActiveX Chart to MS Access form...

4) Adding the Gigasoft ActiveX Chart to MS Access form.

Click / select the Form1 tab, then...

  • 1: click the [Design View button] on the far bottom right corner of the main MS Access application window
    Adding the Charting ActiveX requires design view
  • 2: click the main [Design] menu (purple color below),
  • 3: click the menu [Controls] and /or the bottom right button [More] for more Controls...
    Adding the Charting ActiveX requires design view
  • 4: select the [ActiveX Controls] menu item.
Adding the Gigasoft Charting OCX to MS Access

You see the Insert ActiveX Control dialog showing all ActiveX controls registered with the operating system.

This image shows ProEssentials v7 and v9 installed, which will only be the case if both the v7 and v9 setup programs have been installed.

Select the Pego v9 Control and select OK.

MS Access inserting Gigasoft charting component

The Pego ActiveX is placed on the form. You may position and size the control as needed.

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 (Pesgo), 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.

Note the design view image may not fully refresh while resizing, toggling between design view and layout will cause the chart to re-draw to your new size.

Select the [Design] menu, and then [Property Sheet] menu item to show the property window.

We recommend positioning to top left corner and then setting the Anchor properties to Both. The Anchor properties are found within the Format tab.

MS Access auto sizing Gigasoft charting activex component

Important, select the All tab to show all properties, and change the Name property of the new control to Pego1. The code will we be adding in the next section will require the Name property to be Pego1.

MS Access naming the Gigasoft charting activex component
Adding Form OnLoad event...

5) Within the [Property Sheet] section, make sure Form is shown as the Selection Type, click the Event tab, and click the [...] for the OnLoad event to open the Visual Basic editor and add the code below to the Form_Load event. Note that within the design view editor, clicking the solid grey area below the detail section will also select the Form and show Form related properties and events.

MS Access adding OnLoad to initialize the charting activex
Visual Basic [Code]...

Enter the code as shown below. You may copy and paste, but also try to write a few lines that use enums to see intellisense.

'// Simple to code = simple to implement and maintain //
Pego1.SubsetByPoint = False   '// Allows data to be dynamic //
Pego1.Subsets = 2  '// Subsets = Rows //
Pego1.Points = 10000#  '// Points = Columns, set to a max, later reduced //

Pego1.MainTitle = "Hello World"
Pego1.SubTitle = ""
Pego1.SubsetLabels(0) = "For .Net Framework"
Pego1.SubsetLabels(1) = "or MFC, ActiveX, VCL"
Pego1.YAxisLabel = "Simple Quality Rendering"
Pego1.SubsetColors(0) = Pego1.PEargb(60, 0, 180, 0)
Pego1.SubsetColors(1) = Pego1.PEargb(180, 0, 0, 130)

'// Quick way to set many colors via QuickStyle property //
Pego1.BitmapGradientMode = True
Pego1.QuickStyle = PEQS_LIGHT_SHADOW
Pego1.DeskColor = Pego1.PEargb(255, 255, 255, 255)

Pego1.GraphPlusTable = PEGPT_BOTH
Pego1.DataPrecision = PEDP_NODECIMALS
Pego1.LabelBold = True
Pego1.PlottingMethod = GPM_BAR
Pego1.GradientBars = 8
Pego1.BarGlassEffect = True
Pego1.LegendLocation = PELL_LEFT
Pego1.DataShadows = PEDS_3D
Pego1.FixedFonts = True
Pego1.FontSize = PEFS_LARGE

'// You will likely set these for all charts //
Pego1.PrepareImages = True
Pego1.CacheBmp = True
Pego1.RenderEngine = PERE_DIRECT2D
Pego1.AntiAliasGraphics = True
Pego1.AntiAliasText = True

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

Pego1.AllowDataHotSpots = True

'// Always finish your property settings with this setting //
Pego1.PEactions = REINITIALIZE_RESETIMAGE

'// VB Code to load data from Table1 //
Dim db As Database
Dim MyRS As DAO.Recordset
Dim MySQL As String
MySQL = "select Field1, Field2, Field3 from Table1"
Set db = CurrentDb()
Set MyRS = db.OpenRecordset(MySQL)
Dim nCount As Integer
Do While (MyRS.EOF = False)
Pego1.YData(0, nCount) = MyRS("Field1")
Pego1.YData(1, nCount) = MyRS("Field2")
Pego1.PointLabels(nCount) = MyRS("Field3")
nCount = nCount + 1
MyRS.MoveNext
Loop
Pego1.Points = nCount
MyRS.Close
Set MyRS = Nothing

Pego1.PEactions = REINITIALIZE_RESETIMAGE

Your project code should look similar to...

Visual Basic charting active example code
Adding a DataHotSpot event...

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

To add the DataHotSpot event, we need to be inside the Visual Basic editor.

If the editor is not open, within the [Property Sheet] section, make sure Form is shown as the Selection Type, click the Event tab, and click the [...] area for the OnLoad event to open the Visual Basic editor.

Now use the top drop down list boxes to 1, select Pego1 and 2, select the DataHotSpot event.

Visual Basic Chart adding hotspot event

Add the following code to the Pego1_DataHotSpot event.

Call MsgBox("Subset " + Str$(SubsetIndex) + _
", Point " + Str$(PointIndex) + _
" with a value of " + Str$(Pego1.YData(SubsetIndex, PointIndex)))


Success!!!

7) Save the database, accept all the default names, with Form1 selected, switch to Form View by right clicking the Form1 tab and selecting Form View, or click the Form View button at very bottom right of the Access application window (Next to NUMLOCK). Move the mouse over a bar and click to trigger the DataHotSpot event.

This completes this walkthrough.

Please read the remaining sections within Chapter 3 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.

Activex Chart MS Access Gigasoft Chart within your custom database and software!


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

Activex Chart OCX Tutorial MS Access Gigasoft Chart

我们的任务

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

我们是工程师

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

谢谢

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