Line Graphs and Reports

Christian Stimming
Sun, 17 Feb 2002 17:17:27 +0100


On Saturday 16 February 2002 19:28, Michael T. Garrison Stuber wrote:
> 	I am interesting in writing a (small) family of reports to track
> investments.  One of the critical needs for what I want to do is a line
> graph.  

That's great news to hear. Yes, the need for a line graph had arised earlier, 
but so far nobody made it to implement one.

> I've been studying the current reporting architecture and trying
> to understand it.  If I understand things correctly, GnuCash has
> implemented its own Scheme wrappers around Guppi, and Guppi provides the
> graphing functionality.  Is this correct?

Kind of. I'd describe it this way (stable branch 1.6.x only): From the 
viewpoint of the Scheme report code, the graphs are created through the 
Scheme functions inside the files 
src/scm/html-{barchart,piechart,scatter}.htm. Note that those commands don't 
'connect' anywhere, they only provide the proper HTML code for graph objects. 
Upon setup of the gtkhtml widget in src/gnome/gnc-html-guppi.c , gnucash 
registeres a special object type for guppi graphs in gtkhtml. 

At display time, the gtkhtml widget recognizes the HTML code for the guppi 
graphs and calls the appropriate callbacks in gnc-html-guppi.c, e.g. 
gnc_html_embedded_piechart() etc. Those C functions take the options from the 
HTML code (which was generated from Scheme) and pass it on to Guppi's 
libguppitank interface.

The libguppitank interface of Guppi was designed to be a *very* easy and 
quick way of coding Guppi plots to be displayed. Kind of a wrapper for the 
(extremely powerful but complex) Guppi core API, if you wish. (It was also 
meant to provide a layer of independence from Guppi core API changes, which 
were/are still likely to happen.) It is *not* meant to be an exhaustive set 
of what kind of plots Guppi can display, and in fact, the Guppi maintainer 
Jon Trowbridge <> is not planning on updating/extending this 
interface anymore (if I recall correctly). There is some documentation on the 
libguppitank interface in Guppi's CVS (HEAD branch, currently 0.40.4) under 
doc/developer-docs/guppitank (might be not totally up-to-date, i.e. one needs 
to double-check option names in the source code before using them). The 
libguppitank interface does currently *not* offer any line plot type.

That said, there is no inherent need for Gnucash to rely on the libguppitank 
API. The executable gets linked against both libguppitank and libguppi, so we 
can just as well switch to use the Guppi core API directly instead of using 
the libguppitank API as a wrapper for the former. I mean, if you want to have 
a line plot graph, you need to create the necessary code for that anyway. The 
choice between libguppitank and Guppi core merely reduces to the question of 
where the main part of this new code should exist: either in Guppi's 
libguppitank portion, or in Gnucash directly. 

Since new code has to be written anyway, I'd strongly suggest using the Guppi 
core API directly from Gnucash. This would basically mean that the code which 
currently accesses the Guppi core API and lies in Guppi's directory 
libguppitank/guppi-object-{barchart,pie,scatter}.c would the lie inside 
Gnucash's src/gnome/gnc-html-guppi.c or similar. You should have a look at 
those libguppitank files to see what needs to be done. Unfortunately I don't 
find any examples on how line graphs are *used* within Guppi, but I know they 
exist and are working now.

Christian Stimming
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: For info see