Re: Graphs in Gnumeric, usable for Gnucash too?

On Fri, May 30, 2003 at 04:55:09PM +0200, Christian Stimming wrote:

Ok. Now I have found the code. Do you also have a place where the 
sheet-object-graph is used, as an example?

The sheet-object-graph is currently gnumeric specific.  Although I'd
like to move the sheet-object layer down into goffice it will take a
while.  For now you want to use the lower level display in

That gives you a foocanvas item to display a GogView.
From gnucash, we loved to use the libguppitank interface in guppi3. 
There, each barchart/ piechart/ scatter plot was defined by a number of 
arguments passed by a GtkArg list, which were defined in the 
guppi_object_pie_class, and all the putting together with axis, legends 
and lines was fully done inside libguppitank. I.e., in gnucash we didn't 
have to care about axes, legends, scaling etc. at all. This went very 
smoothly. I was wondering whether it is possible in principle to copy 
the code from guppi3/libguppitank into that new goffice/graph library... 
any spontaneous ideas on how difficult that would be?

The new library is a lot closer semantically to guppitank than guppi
in many ways.  You'll need to do a bit of manual labour to create
the models, but its not too bad.  For a simple graph with 1 chart
and 1 plot (see README for glossary) All you'd need would be

        graph = g_object_new (GOG_GRAPH_TYPE, NULL);
        chart = gog_object_add_by_name (graph, "Chart", NULL));
        plot  = gog_object_add_by_name (chart, "Plot",
                gog_plot_new_by_name ("GogBarColPlot"));
        g_object_set (plot,
                      "horizontal", FALSE,
                      "type",       "stacked",
        GogSeries *series = gog_plot_new_series (GOG_PLOT (plot));
        gog_series_set_dim (series, 1,
                gnu_cash_data_new (.....), NULL);

That should be enough to generate a model with 1 stacked col plot
with some gnu_cash supplied data.  You'd need to manually tack on a
        legend = gog_object_add_by_name (chart, "Legend", NULL));
but my goal is to autogenerate axis and gridlines.  They would will
still be changeable by you, but at least the initial creation would
be handled automagicly.  I can't really comment on axes yet because
that code is not quite ready.

To display it
        foocanvasitem = foo_canvas_item_new (
                foo_canvas_root (FOO_CANVAS (canvas)), GOG_CONTROL_FOOCANVAS_TYPE,
                "model", graph,
                "w",    how big do you want it in pixels
                "logical_width_pts",   how big is it logically in points

I've only written a foocanvas wrapper rather than a gnome-canvas,
but the amount of code is trivial.  Its basicly just using the
libart renderer to generate a pixbuf.  You could create so other
display mechanism if necessary.  Printing and svg export are also
unwritten at present, they will required another rendering backend.
Again, the amount of code should hopefully be inconsequential.

Hope that answers more questions than it raises

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]