Chart VBScript graph example source-code for ActiveX

VBScript Graphing

 

Chart VBScript example on for adding Charting to your web site

[ ASP Server-Side IIS Development ]

The following demonstrates how to create your first Chart/Graphs with VBScript. It discusses using ASP to serve up a dynamically generated PNG image. Other examples are provided within this website and the product/evaluation. For more information, refer to the "Readme.htm" and "AspReadMe.htm" files installed onto your system with the eval/product (accessible via Start menu).

Installation...

When installing the ProEssentials evaluation and/or product, the setup program installs the ProEssentials DLL and ActiveX interfaces into the system directory. Files relevant to ASP development are:

PEGRP32E.DLL

ProEssentials Pro DLL
PEGO32E.OCX Graph Object
PESGO32E.OCX Scientific Graph Object
PE3DO32E.OCX 3D Scientific Graph Object
PEPSO32E.OCX Polar Object
PEPCO32E.OCX Pie Chart Object
PE7API.INC ProEssentials ASP Include File
 

PEGRPSE.DLL

ProEssentials Standard DLL
PEGOSE.OCX Graph Object
PESGOSE.OCX Scientific Graph Object
PE3DOSE.OCX 3D Scientific Graph Object
PEPSOSE.OCX Polar Object
PEPCOSE.OCX Pie Chart Object
PE7API.INC ProEssentials ASP Include File
 

PEGRPLE.DLL

ProEssentials Lite DLL
PEGOLE.OCX Graph Object
PESGOLE.OCX Scientific Graph Object
PE3DOLE.OCX 3D Scientific Graph Object
PEPSOLE.OCX Polar Object
PEPCOLE.OCX Pie Chart Object
PE7API.INC ProEssentials ASP Include File

The setup program also registers the ActiveXs with the operating system which prepares IIS for creating ProEssentials components. You can manually register an ActiveX with "REGSVR32.EXE" found in your system/system32 or syswow64 on 64 bit systems. You can also use this utility to manually un-register an ActiveX by using the "-u" command. Un-Registering is useful when you want to test CAB download/installation issues on your development machine.


myfirst.htm / myfirst.asp Serving up a PNG...

Chart HTML for VBScript

<HTML>
<HEAD></HEAD>
<BODY>
<P>Run ASP Server Script via IMG src</P>
<IMG src = "myfirst.asp">
</BODY></HTML>

Open Notepad and enter the code shown to the left.

For simplicity, we recommend the IMG src line reference just a file name, with no path, but make sure to save files into the wwwroot dir.

Name this file "MyFirst.htm". Your server's local root directory is commonly C:\Inetpub\wwwroot.

This simple web page contains a single line paragraph followed by an image. The image's src is pointing to an ASP page "MyFirst.asp" which causes server-side code to execute and send back the image in a binary stream, ideal for web-farm environments.


myfirst.htm / myfirst.asp Serving up a PNG...

Cahrt VbScript ASP source code.

<%
dim myobj
Set myobj = server.CreateObject("PEGOD.Pegodctrl.1")
myobj.MainTitle = "Hello Internet"
myobj.SubTitle = ""
myobj.PrepareImages = True
myobj.Subsets = 4
myobj.Points = 12
dim i
dim j
for i = 0 to 3
    for j = 0 to 11
       myobj.YData(i,j) = 5 + Rnd(20)
    next
next
Response.BinaryWrite (myobj.PNGToStream(300,300))
Set myobj = Nothing
%>

Using NotePad, create another file called "MyFirst.asp" and enter the corresponding code shown to the left.

Again, save this file into your web server's local root directory as you did with "MyFirst.htm".

Note the entire contents of "MyFirst.asp" are within <% ... %> tags. Make sure no spaces or ascii exist before or after tags!!!!!

"MyFirst.asp" contains ASP code (VBScript) which creates a ProEssentials component via the CreateObject method. CreateObject's only argument is a ClassID. In this case, PEGOE.Pegoectrl.1 is the ClassID for the ProEssentials Graph Object. Note, Standard users use PEGOESTD.PegoeStdCtrl.1 and Lite users use PEGOELITE.PegoeLiteCtrl.1

Next, the code sets the control's MainTitle and SubTitle properties.

Next, Subsets and Points properties are set and define the amount of data the control will contain.

Then, a nested for-next loop passes 48 random data points into the YData(s,p) two dimensional property array.

Next, FontSize is set to 0 which denotes large font. You will likely use our ProEssentials ASP Include file and then prototype your ASP code within Visual Basic. This lets you copy and paste your Visual Basic code directly into an ASP page because the include file holds the declarations for property enumerations.


myfirst.htm / myfirst.asp Serving up an Chart with VBScript...

Chart via VBScript within your Browser!

Finally, the Response.BinaryWrite ASP function retrieves a stream of image data from the ProEssentials PNGToStream method and passes it to the client's browser.

If you point your internet browser towards the file "MyFirst.htm", you will see a page similar to that shown to the left.

Refer to the "ASP Readme" file accessed via the Start menu to see more examples, including, rendering as an ActiveX, automatic downloading the ActiveX, client-side event scripting, and more.

 

Online developer reference

Complete online technical reference to the ProEssentials product. Chapter 2's .NET Reference is the best mechanism to navigate the large quantity of properties and features.  Walk-Throughs of .NET charting in VB.NET, C#.NET, ASP, VC, VB6, and Delphi get you started quickly.

learn more, VBScript Chapter 3, Asp.Net is Chapter 2

Online interactive demo

Financial, Engineering, Scientific, and Business examples give you an instant taste of ProEssentials' power.

view our Net Charting Demo

Letter from the President

CONGRATULATIONS! Reading this page means you're likely a product manager, product owner, or should be one.

Charting Component Strengths, print it, read it!