Make your own free website on

F: Programming tips.

F: Programming tips. (See new notes for 2.0)

This section is intended for developers who wish to tinker with the code and add their own modifications. This will cover some stuff that will help you understand and hack the code better. In general remember that the Palm device screen is small so keep your legends, data etc. in low numbers so as not to clutter the screen or overwrite information.

Look into the code - it is commented and can give you significant information on the working. All the DEFINEs used in gr.c are found in gr.h.

Version 2.0 Notes

Using the Pie graph

Pie Graphs can be resource-hoggers due to trigonometric calculations involved in plotting points on a circle. Pay close attention to the variable PIE_SPACE and line_space, they can save lot of processing overhead. If you graph is color, you can even do away with calling grLibDrawCircle and directly call the drawPieGraph routine. I would recommend line_space of 3 does not look to pretty due to spaced out lines but is much faster (well, 3 times as faster).

pie graphs look good on Color. But on B&W the slice coloring is pretty much indistinguishable -for this reason, the lines in B&W pie are only the slice boundaries and not the internal ones.

Previous versions ================= The ‘group’ data variable

All graphs are drawn based on three crucial parameters, the X-axis value, the Y-axis value and the ‘group’. Consider the graphs shown above. Here, it is the group variable that causes each bar (or line) to be displayed in a separate color (or separate patterns in a Black-and-white display), the group variables places a set of data points under the same category.

Coordinate calculations

Coordinates calculation are based on the following points
a) The fact the top left screen is 0,0 - but the graph '0' is usually below

b)the actual values of the charts must be 'scaled' the screen dimensions specified for the chart/graph frame

Look for the CY, CX macros and the cY,cX calculations for further hints.

Stack Graphs

in these graphs, not only are the curX and curY parameters important, but prevX and prevY too - as the new bar "sits" on top of the previous. Also, here the 'Y' axis parameter for the graph is not the scaled on the 'Y' axis like the bar graphs - but considered as an "absolute" value. E.g. if the Y axis denotes tons - 0 to 100 tons - and the stacked bar shows the tons carried by each machine type - the value would be absolute as in "15","25","40" etc. and not drawn to touch the 15,25,40 points on the Y scale.

Color Control

a) Color displays - The Drawing API’s use the group variable to create each new data point in a new color. Currently the user has no control over what colors these are (though adding that support is fairly simple). The macro WIN_SET_FORE_COLOR in gr.h takes group as the input and creates a color based on a simple equation. You may wish to change the equation to create different color combinations.

v 1.3 has a simple useful function (called RGB() )that takes r,g,b values and returns the associated index. One could use any downloable color utility to see r,g,b values for a color - and then use the RGB() function to get the index. see app.c for examples, and also macros RED, LIGHT_BLUE etc.

b) Non-Color displays - here, instead of color, the fill pattern changes with each new group. The fill patterns should be specified in fill.h, and the respective cases coded in gr.c. The header file comes inbuilt with some fill patterns. You may want to add new patterns as you wish. The B&W graphs are an example.

Error checking

While there is quite a bit of error checking to make sure there is no spurious data, it is important that the developer ensures sanity of data before he/she begins to insert data. Since an application is expected to be debugged before deployment, more typical errors will come out during debugging and hence the API themselves do not do a whole lot of checking - this saves space and reduces redundant checking.


The APIs provide an ability to draw a bare bones graph, group by group and then add legends, grids etc. on a need basis - it allows some simple but interesting presentation possibility-

power-point type slide presentation by printing a data point (a bar, stack or line) one by one by tapping a stylus - or overlay one graph on the others (assuming base scales and coordinates are same) sequentially.

Alphabetic index

This page was generated with the help of DOC++.