|Simple Graph||Lab Report|
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
Delphi 3 (to recompile)
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