Simple Graph ver 2.0

Introduction
License
Disclaimer
Files
Install components
Data series 
Real Time Graphing
History
Contact me

Introduction

This is a set of 32 bit Delphi components and classes for 2D plot. It is relatively simple. It is more gauge then presentation element. The main features are:

The main component is Tsp_XYPlot. It holds four Tsp_Axis and controls Data Series. The Tsp_XYPlot and Tsp_Axis provide base plot functionality like auto scale, zoom and pan and so on. The Data Series must be derived from Tsp_DataSeries and implements data storage and how data are painted on the plot canvas. An example of these components is Tsp_XYLine and Tsp_SpectrLines.

License

The component files are freeware. You may copy those files as long as you COPY ALL OF THEM. You cannot distribute source of main units in modified form, except unit for data series. Copyright © 1998-1999, Sergei P. Pod'yachev.

Disclaimer

This software and the accompanying files are provided "As Is" and without any warranties as to performance of merchantability or any other warranties whether expressed or implied. The Author cannot and does not guarantee that any functions contained in the Software will be error free. The author is not liable for any damages resulting from the use and misuse of the component.

Files

sgr_misc.pas Auxiliary unit, used by sgr_def.dcu.
sgr_scale.pas Auxiliary unit, there is implementation of plot axis ancestor.
sgr_def.pas    Main unit. There are Tsp_xyPlot, Tsp_Axis and Tsp_DataSeries.
sgr_data.pas  Data series for Tsp_xyPlot derived from Tsp_DataSeries.
sgr_reg.pas    Registers components, used to install components.
sgr_reg.dcr    Components  images.
sgr.dpk           Can be used to install components (Delphi 3 and may be Delphi 4).
sgr.res            Need to compile sgr.dpk file.

subdirectory help contains

sgr_def.hlp    Components help file
sgr_def.cnt    Help context file
sgr_def.kwf   Key words file for Delphi 2 help system.

subdirectory demo contains files of demo program.

sgraph_demo.gif (8339 bytes)

Install components

Extract files.

You have to use unzip program which preserve long file name or you must correct names manually if they was cut. Place to one directory next files: sgr_reg.pas, sgr_reg.dcr, sgr_data.pas, sgr_misc.pas, sgr_scale.pas, sgr_def.pas, sgr.dpk .

Delphi 2

Run Delphi. Click Install Component menu item. Do not forget that Delphi must find directory where you place component files (see Search Path). Press Add button and open sgr_reg.pas

Delphi 3

You can install components by Install Component item and sgr_reg.pas file. You also can use sgr.dpk packet file. In this case, click Open menu item and select sgr.dpk, then press Compile and when packet will be compiled press Install. If Delphi did know components directory, add it to Library Path on the Library Page of Environment Options.

Delphi 4

You can install components by Install Component item and add sgr_reg.pas file.

Help

To install help file for Delphi 3

I do not check installation for Delphi 4, but I find that there are DELPHI4.CFG and DELPHI4.CNT files in \HELP directory are same as ones in Delphi 3.

After installation I recommend to compile demo program to check components. It also demonstrates how you can customize simple graph to more complex graph (title and so on) by using OnDrawField and OnDrawEnd events.

Data series

There are no many kinds of data series. But you can write it yourself, and they will match your needs. Inherit it from Tsp_DataSeries component and implement 1 procedure and 4 functions:

Of course you should also implement data storage. See sgr_data.pas and sgr_def.hlp for more details.
If you agree to store data in variant array there is more simple way. Derive Data Series from Ts_XYDataSeries. See how Tsp_XYLine was derived from Tsp_XYDataSeries in sgr_data.pas. At last simplest way is to use Tsp_XYLine. In this case Draw procedure paints lines between data points and/or points markers.

Real Time Graphing

The Tsp_XYPlot and Tsp_XYLine have special features to enable real time data record. This features are:
 1 Tsp_XYPlot.BufferedDisplay property
 2 procedure Tsp_XYDataSeries.AddXYArrays(pX,pY:pointer; n:integer);
 3 procedure Tsp_XYLine.QuickAddXY(aX,aY:double);

If data rate is relatively slow (<10 1/sec) it simplest way set BufferedDisplay=True to draw plot throughout internal buffer and have flicker free paint. To add data point by point and immediately reflect changes on screen use procedure AddXY(aX,aY:double). This procedure add values at the end of series data and update Plot (not invalidate but update!)

If it is not enough, then use procedure AddXYArrays(pX,pY:pointer; n:integer) to add data by portion of several (n) points. In this case the plot will invalidate only one time for several (n) points.

At last to have maximum data rate, use procedure QuickAddXY(aX,aY:double). It adds values at end of data storage like AddXY, but don't spend time to update Plot, instead of that it directly draw next line segment or/and last point, but therefore AutoMin and AutoMax are ignored.

History

08.98 v.1.0  First version was publicized as Simple Graph 1.0 for Delphi 3.

09.98 v.1.0e Bug with punning without ticks was fixed. Units for Delphi 2 and Delphi 4 was added.

10.98 v.1.1  Bug in autoscaling was fixed. Tsp_XYLine was rewritten and now also can draw points markers.

11.98 v.1.2  There was problem with help files, and problem with archive on DSP. In this version : Help file, Demo program and sgr_data.pas was changed. Main units was not changed.

01.99 v.2.0  There are no serious changes of components, but now full source was included.

Contact me

I'm glad about any kind of serious feedback!
If there are will be new components version,  they will be uploaded to Torry's Delphi Pages or  Delphi Super Page. There is also my WWW home page where also you can find latest versions of sgraph. If you have any suggestions especially about the bug mentioned - send me e-mail.

My best wishes.

Sergei. P. Pod'yachev.
e-mail :  pod@iae.nsk.su.
WWW : www.iae.nsk.su/~lab12/pod
Novosibirsk. Russia.