RE:how to use the GoGraphWidget
- From: PICCA Frederic-Emmanuel <frederic-emmanuel picca synchrotron-soleil fr>
- To: Jean Brefort <jean brefort normalesup org>, "gnumeric-list gnome org" <gnumeric-list gnome org>
- Subject: RE:how to use the GoGraphWidget
- Date: Fri, 14 Apr 2017 10:10:05 +0000
thanke a lot, I will look at your code, once I figure out how t plot only one curve :)
I wrote this but I get this errors when running.
** (ghkl:24316): CRITICAL **: gog_plot_get_series: assertion 'GOG_IS_PLOT (plot)' failed
** (ghkl:24316): CRITICAL **: gog_plot_new_series: assertion 'GOG_IS_PLOT (plot)' failed
** (ghkl:24316): WARNING **: gog_dataset_set_dim called with invalid GogDataset
** (ghkl:24316): WARNING **: gog_dataset_set_dim called with invalid GogDataset
Am I missing something ?
I use goffice-0.10 n Debian stretch (testing)
static double values[6] = {10., 20., 30., 40., 50., 60.};
static double indexs[6] = {1, 2, 3, 4, 5, 6};
static void
insert_histogram_data (GogPlot *plot)
{
GSList *list;
GogSeries *series;
GOData *data;
GError *error;
/* Create a series for the plot and populate it with some simple data */
list = (GSList *)gog_plot_get_series (plot);
if (g_slist_length (list) == 1)
series = g_slist_nth_data (list, 0);
else
series = gog_plot_new_series (plot);
data = go_data_vector_val_new (indexs, 6, NULL);
gog_series_set_dim (series, 0, data, &error);
data = go_data_vector_val_new (values, 5, NULL);
gog_series_set_dim (series, 1, data, &error);
}
static void set_up_trajectory(HklGuiWindow* self)
{
HklGuiWindowPrivate *priv = HKL_GUI_WINDOW_GET_PRIVATE(self);
if(NULL == priv->graph){
GogGraph *graph;
GogChart *chart;
GogLabel *label;
GogPlot *plot;
GOData *data;
const char *service_id = "GogXYPlot";
priv->graph = GO_GRAPH_WIDGET(go_graph_widget_new(NULL));
graph = go_graph_widget_get_graph(priv->graph);
/* Add a title */
label = (GogLabel *) g_object_new (GOG_TYPE_LABEL, NULL);
data = go_data_scalar_str_new (service_id, FALSE);
gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
gog_object_add_by_name (GOG_OBJECT (graph), "Title", GOG_OBJECT (label));
/* Get the chart created by the widget initialization */
chart = go_graph_widget_get_chart (priv->graph);
/* Create a plot and add it to the chart */
plot = (GogPlot *) gog_plot_new_by_name (service_id);
gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT (plot));
/* Add a legend to the chart */
gog_object_add_by_name (GOG_OBJECT (chart), "Legend", NULL);
insert_histogram_data(plot);
}
gtk_box_pack_start (GTK_BOX(priv->box_trajectory),
GTK_WIDGET(priv->graph),
TRUE, TRUE, (guint) 0);
gtk_widget_show_all(GTK_WIDGET(priv->box_trajectory));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]