Re: Error inserting a graph widget in a custom glade widget
- From: Emmanuel Pacaud <emmanuel pacaud univ-poitiers fr>
- To: aalvarez igalia com
- Cc: gnumeric-list gnome org
- Subject: Re: Error inserting a graph widget in a custom glade widget
- Date: Tue, 01 Apr 2008 16:06:21 +0200
Hi,
Le lundi 31 mars 2008 à 10:31 +0200, aalvarez igalia com a écrit :
I have subscribed to this list because I'm very interested in libgoffice,
because I have to paint some charts in an application that I have to
develop.
It's the right list for this kind of discussion.
I have created a xml structure with glade, where i let a custom widget
where to paint charts with libgoffice. The problem is that the charts are
randomly painted bad.
Very strange, indeed.
Could you please try to post a basic application that shows the issue.
It will help us to replicate it.
Thanks.
Emmanuel.
The code of the function that creates the custom widget with a pie chart
is here:
GtkWidget* create_chart (MyTime* self, const char* str1, const char* str2,
gint int1, gint int2) {
GtkWidget *widget;
GogChart *chart;
GogGraph *graph;
GogLabel *label;
GogPlot *pie;
GogSeries *series;
GogStyle *style;
GOData *data;
GError *error;
PangoFontDescription *desc;
char const *title = "Some statistics";
char const * const legends[] = {"first", "second", "third",
"fourth"};
double values[] = {10., 20., 30., 40.};
// Initialize libgoffice
libgoffice_init ();
// Initialize plugins manager
go_plugins_init (NULL, NULL, NULL, NULL, TRUE,
GO_PLUGIN_LOADER_MODULE_TYPE);
// Create a graph widget
widget = go_graph_widget_new (NULL);
// Get the embedded graph
graph = go_graph_widget_get_graph (GO_GRAPH_WIDGET (widget));
// Add a title
label = (GogLabel *) g_object_new (GOG_LABEL_TYPE, NULL);
data = go_data_scalar_str_new (title, FALSE);
gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
gog_object_add_by_name (GOG_OBJECT (graph), "Title", GOG_OBJECT
(label));
// Change the title font
style = gog_styled_object_get_style (GOG_STYLED_OBJECT (label));
desc = pango_font_description_from_string ("Sans bold 16");
gog_style_set_font_desc (style, desc);
// Get the chart created by the widget initialization
chart = go_graph_widget_get_chart (GO_GRAPH_WIDGET (widget));
// Create a pie plot and add it to the chart
pie = (GogPlot *) gog_plot_new_by_name ("GogPiePlot");
gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT
(pie));
// Create a series for the plot and populate it with some simple data
series = gog_plot_new_series (pie);
data = go_data_vector_str_new (legends, 4, NULL);
gog_series_set_dim (series, 0, data, &error);
data = go_data_vector_val_new (values, 4, NULL);
gog_series_set_dim (series, 1, data, &error);
// Add a legend to the chart
gog_object_add_by_name (GOG_OBJECT (chart), "Legend", NULL);
gtk_widget_show (GTK_WIDGET (widget));
return widget;
}
I attach too an image of the "strange" behaviour.
Thanks in advance.
--
Antonio Álvarez Feijoo
mailto:aalvarez igalia com
_______________________________________________
gnumeric-list mailing list
gnumeric-list gnome org
http://mail.gnome.org/mailman/listinfo/gnumeric-list
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]