Usage of Rt-Tools2D VCL by Example |
||
---|---|---|
The task of generating a two-dimensional graph may initially seem complicated when you look at the Cartesian graph components and their numerous options. A walkthrough of a small example program is thus offered as a usage demonstration. The sample program draws the sine and cosine functions in the range 0-360° as 0-2π: |
||
|
Now create a new project in the IDE and name the form GraphExample. Open the "Rt-Graph2D" palette and place three |
|
|
Now place a |
|
|
Now change the names and captions of the axes. The x-axis is modified by clicking on it and editing the corresponding Name to read AngleAxis and the Caption to read Angle/Radiant within the object inspector. Do the same for the y-axis, setting Name to FunctionAxis and Caption to Sine and Cosine. |
|
|
With the graph now visible, add data points to display on it to demonstrate the sine and cosine functions. To do this, place two |
|
|
||
|
||
|
||
![]() |
To assist you in finding the most appropriate line and point settings, the graph will show some random points representing each series. Your graph should now look similar to the graph displayed on the left. |
|
Since with this example you want to display the sine and cosine functions, you need to implement a method to fill the data vectors mentioned above. The simplest way to do this is by placing a TButton component to the form and then setting the OnClick event to the following procedure: procedure TGraphExample.Button1Click(Sender: TObject); |
||
|
As you see, the data vectors can be handled as if they are zero based arrays of double. But writing to it, you must not take care for the size of the array. This is adjusted automatically by the TRtDoubleVector component. If you want to compile the project and run it, please click "Button1". Your output should look like the image on the left. |
|
Another way to access the data is to treat it as a list of doubles. This is described in the example with the OnClick event of a second button. On clicking this button, the graph is extended by one point. procedure TGraphExample.Button2Click(Sender: TObject);
|
||
|
You might want a legend for the series, showing line styles and captions. Do this by adding a |
|
|
||
As you can see, it takes only a few minutes to create a fully working graph program. More Information see PDF-Manual(2.08MB).
Copyright © 2018 Horst Reichert all rights reserved |