ASP and Diagrams

by Jan Verhoeven, 22 November 2001

Using DHTML you can generate diagrams from your database data in a html page. But for quality diagrams you need a canvas to draw on. The freeware janDiagrams.dll COM object can be used both server-side and client side to generate GIF-image diagrams.

 

Create the object

In you ASP page you create an instance of the object:

  d=server.createObject("janDiagrams.diagram")

After use you release the object with:

  set d=nothing

Example script

You can run the following script under the scripting host. In an ASP page you can use

'test script for jandiagrams.diagram object

  sn=WScript.scriptfullname
  p=instrrev(sn,"\")
  fn=left(sn,p) & "diag1.gif"


  set d=createObject("janDiagrams.diagram")
  d.height=200
  d.width=600
  w=d.width
  h=d.height
  d.brushclear
  d.drawborder
  d.fontbold
  d.fontname "verdana"
  d.fontsize 10
  d.fontcolor "c9c9c9"
  d.drawtextangle w-10,10,-90,"Jan Verhoeven"
  d.brushcolor "FF0000"
  d.pensolid
  d.penwidth 5
  d.drawrectangle 10,30,150,40

  d.save(fn)
  set d=nothing

Methods and properties of janDiagrams.diagram

Below you will find all the methods and properties of janDiagrams.diagram.

property Width
Get or set the width of the diagram. The diagram will be cleared white when you set the width.

property Height
Get or set the height of the diagram. The diagram will be cleared white when you set the height.

method save(afilename)
Will save the diagram to the given file in the GIF format.

method drawtextangle left, top, angle, text
Draws text at position left,top under the given angle.

method drawtext left,top,text
Draws text at position left,top

method drawrectangle left,top,right.bottom
Draws a rectangle between left,top and right,bottom.

method drawline left,top,right,bottom
Draws a line from top,left to bottom,right.

method drawellipse left,top,right,bottom
Draws an ellipse between left,top and right,bottom.

method brushclear
Sets a clear (transparent) brush mode.

method brushsolid
Sets a solid brush mode.

method penclear
Sets a clear (transparent) pen mode.

method pensolid
Sets a solid pen mode.

method fontname aname
Sets the canvas font name to aname.

method fontsize asize
Sets the canvas font size to the given integer asize.

method fontcolor acolor
Sets the canvas font color to the given Hex color string (without the #), e.g.:
d.fontcolor "FF0000" to set a red font color.

method fontnormal
Sets normal font style.

method fontbold
Adds the bold style to the set of font styles.

method fontitalic
Adds the italic style to the set of font styles.

method fontunderline
Adds the underline style to the set of font styles.

method brushcolor acolor
Sets the canvas brush color to the given Hex color string (without the #), e.g.:
d.brushcolor "FF0000" to set a red font color.

method pencolor acolor
Sets the canvas pen color to the given Hex color string (without the #), e.g.:
d.pencolor "FF0000" to set a red font color.

method getTextHeight atext
Will return the integer text height in pixels that the given atext will need on the canvas with the current font settings.

method getTextWidth atext
Will return the integer text width in pixels that the given atext will need on the canvas with the current font settings.

method drawborder
Draws a black single pixel border around the diagram.

method penwidth awidth
Sets the width of the pen to awidth (in pixels).