Asp Charts example source code.

Charts within ASP

 

ASP Chart Walk-Through, adding charts to your web site

[ ASP Server-Side IIS Development ]

The following demonstrates how to create your first ASP Charts implementation. 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:

PEGRP32D.DLL

ProEssentials Pro DLL
PEGO32D.OCX Graph Object
PESGO32D.OCX Scientific Graph Object
PE3DO32D.OCX 3D Scientific Graph Object
PEPSO32D.OCX Polar Object
PEPCO32D.OCX Pie Chart Object
PE6API.INC ProEssentials ASP Include File
 

PEGRPDS.DLL

ProEssentials Standard DLL
PEGODS.OCX Graph Object
PESGODS.OCX Scientific Graph Object
PE3DODS.OCX 3D Scientific Graph Object
PEPSODS.OCX Polar Object
PEPCODS.OCX Pie Chart Object
PE6API.INC ProEssentials ASP Include File
 

PEGRPDL.DLL

ProEssentials Lite DLL
PEGODL.OCX Graph Object
PESGODL.OCX Scientific Graph Object
PE3DODL.OCX 3D Scientific Graph Object
PEPSODL.OCX Polar Object
PEPCODL.OCX Pie Chart Object
PE6API.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 dir. 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...

Asp Chart HTML Source.

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

Asp Chart VBScript Source in NotePad.exe

<%
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, PEGOD.Pegodctrl.1 is the ClassID for the ProEssentials Graph Object. Note, Standard users use PEGODSTD.PegodStdCtrl.1 and Lite users use PEGODLITE.PegodLiteCtrl.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 a PNG with VBScript and ASP Chart...

Asp Chart 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 about our Asp Chart, see Chapter 3

Online interactive demo

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

view our online Asp.Net Chart 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!