Basic conceptsRMChart.dll

RMChart is a standard WINDOWS dll. The whole communication between you, the developer, and RMChart takes place with function calls, not by sending messages. Basically the library can be used with any compiler, which is able to call external DLLs. Definitely it can be used with several C/C++-compilers, with PowerBASIC 7.xx/8.xx and with Visual BASIC 6. If you want to use it with another development system - just try it out. In the following I will concentrate on how to use RMChart with PowerBASIC 7/8, which is also valid for most other compilers.

Creating a chart

You have two possibilities for generating a chart: building it "from scratch" with function RMC_CreateChart() or via "playback" of a *.rmc-file (or a string, which holds the content of such a file) with function RMC_CreateChartFromFile. A RMC-file is a simple textfile, which holds all necessary informations to generate the chart which created the file. The charting engine parses the string and calls all needed functions with the appropriate parameters. The file (or the content string) can be created with RMCDesigner or with function RMC_WriteRMCFile from within your application. After the resulting chart is created that way, you can deal with it as if you would have created it from scratch: you can print/save/copy it, you can alter it, and you can save it again into a RMC-file or in a string. If you create your chart with one of these functions, a control is created which is located and visible in the window, whose handle is passed as the first parameter to the function. If you use RMChart with VB6 (instead of the ActiveX), you must call RMC_CreateChartOnDC or RMC_CreateChartFromFileOnDC. For examples how to use the DLL with VB6 please see the demo project in directory VB6_DLL in the installation folder.

Your programm can have up to 20 instances of RMChart at the same time running. Each chart must consist of at least one region and can have a maximum number of six regions. A region is an user-defined aerea inside the control's boundary, which is defined as a rectangle with Left, Top, Width and Height. Each region can have either one gridbased chart (Bar/Line/XY) with 1 to 15 data series or one none-grid based chart (Pie/Donut/Pyramide). For a better understanding of this concept load the following example files into RMCDesigner:

  • simplebar.rmc: This is a simple chart with one region and a gridbased chart. The region owns a caption, a grid, a data axis, a label axis and as chart type a bar chart.
  • 2 regions.rmc: This one has two regions, both with gridbased charts. The upper region has a RMC_HighLowSeries and a caption, the lower a RMC_VolumeBarSeries.
  • More sophisticated is this one: 4 regions.rmc - it has four regions. The both in the upper half have gridbased charts, the region in the lower left owns a gridless series, the one in the lower right again has a grdibased series.

Adding objects to the chart

These are the steps you have to go after you've created the chart with RMC_CreateChart: Now you have to decide wether you want a grid based chart type (Bar, Line etc.), a XY scatter chart or a none-grid based chart (Pie/Donut/Pyramide).

In case of a grid based chart type: In case of a XY scatter chart:
  • Add a grid to the region with RMC_AddGrid
  • Add a X axis with RMC_AddXAxis
  • Add a Y axis with RMC_AddYAxis

  • Repeat this two steps if you want to have two indepentend pairs of X- and Y-axis.
    Impportant: X and Y axes must always have a counterpart on the other side, they can only exist as a pair of axes. It's not possible for example to have one X axis and two Y axes. For each X axis must exsit a Y axis, for each Y axis a X axis.
  • Add one or more XY series with RMC_AddXYSeries
In case of a none-grid based chart type:

Drawing the chart

After your chart is created, designed and provided with the necessary data you can

As long as the chart control is not deleted, you may call one (or all ) of the above mentioned functions, without a mandatory order. Normally you would first show the chart and let may be your user decide, if he wants to print/save/copy it. But you could also first copy the chart to the clipboard, then print it and then draw it (or not) to the screen.

Changing an existing chart

Once your chart is created (and normally visible on the screen) and you (or your user) want to change something, you have two choices: you can delete the control and build it new with the changed attributes. Or you change only the things, which need to be changed, followed by a call to RMC_Draw(). On this way, which is of course more convenient than recreating the control again and again, you can alter nearly every property and even the series' data (as a whole or only single data points). Even resizing the chart or moving it in the parent dialog is a breeze. Have a look on the "Minidesigner", which you find in pbdemo.bas: there you can see some of these functions in action. Please notice also the callback function in the "ready-to-go" source, which you can get from RMCDesigner: besides other useful techniques you'll find an example how to move/resize the chart at runtime.

Deleting the chart

Normally there is no need for an explicit deleting of a chart. When you close the window, which owns the chart, the chart control and all internal structures, used memory and so on is deleted by the system. If you want to delete the chart explicit, call RMC_DeleteChart().