Simple Graph  Lab Report
Simple Line Graph

Create a simple graph, y = a* | sin(b*x)|.  Show the graph in a single step, or show the graph as it is being drawn.

Materials and Equipment

Software Requirements
Windows 95
Delphi 3 (to recompile)

Hardware Requirements
VGA display


  1. Double click on the SimpleGraph.EXE icon to start the program.
  2. With the Dynamic checkbox checked, press the Draw Graph button.
  3. Press the Clear button and uncheck the Dynamic checkbox.
  4. Press the Draw Graph button again.
  5. If desired, press the Write BMP button to create an 800-by-600 pixel SimpleGraph.BMP file.
  6. If desired, press the Print button to print a full-page graph in landscape orientation.

The DrawLineGraphs procedure draws lines on the Image.Canvas, the Printer.Canvas or a Bitmap.Canvas. The DrawState parameter to DrawLineGraphs is a bit of a kludge. When this parameter has the value ptShowGraph, and the Dynamic checkbox is checked, the Image is updated every 20th plotted point.

As a simple way to blank an image, the ButtonClearClick method assigns NIL to Image.Picture.

This example showed how to create a simple graph "from scratch" using 2D vectors and a TPantograph object.

In Delphi 3, and for more complicated examples, the new TChart component is probably a better alternative for small datasets. For very large datasets, this approach shown here might be attractive.

TPantograph, Vector2D, MoveTo, LineTo, Repaint, PointAt, TextOut

Delphi 3 Source and EXE (140 KB): SimpleGraph.ZIP

26 Feb 2005

since 1 Nov 1998