how to use the GoGraphWidget

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to use the GoGraphWidget

PICCA Frederic-Emmanuel
Hello,

I would like to plot a bunch of x-y plot in a graph.

So my question is : where can I find a simple tutorial in order to achieve this with the C API

I started with

priv->graph = GO_GRAPH_WIDGET(go_graph_widget_new(NULL));

but then, I am a little bit lost :)

thanks for your help.

Frederic
_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use the GoGraphWidget

Jean Bréfort-2
Hi,

There are sample codes in the goffice source tree:
https://git.gnome.org/browse/goffice/tree/tests/go-demo.c
https://git.gnome.org/browse/goffice/tree/tests/pie-demo.c

Hope this helps,
Jean


Le jeudi 13 avril 2017 à 12:13 +0000, PICCA Frederic-Emmanuel a écrit :

> Hello,
>
> I would like to plot a bunch of x-y plot in a graph.
>
> So my question is : where can I find a simple tutorial in order to
> achieve this with the C API
>
> I started with
>
> priv->graph = GO_GRAPH_WIDGET(go_graph_widget_new(NULL));
>
> but then, I am a little bit lost :)
>
> thanks for your help.
>
> Frederic
> _______________________________________________
> gnumeric-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gnumeric-list

_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE:how to use the GoGraphWidget

PICCA Frederic-Emmanuel
Hello

> There are sample codes in the goffice source tree:
> https://git.gnome.org/browse/goffice/tree/tests/go-demo.c
> https://git.gnome.org/browse/goffice/tree/tests/pie-demo.c

thanks

> Hope this helps,
> Jean

Yes a lot

Frédéric
_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE:how to use the GoGraphWidget

PICCA Frederic-Emmanuel
In reply to this post by Jean Bréfort-2
> There are sample codes in the goffice source tree:
> https://git.gnome.org/browse/goffice/tree/tests/go-demo.c
> https://git.gnome.org/browse/goffice/tree/tests/pie-demo.c

Re-Hello

So now I can plot  an XY curve

I would like to give my users the possibility to modify the graph like in gnumeric via the graphical interface.
Select the color of the graph, change the title, etc...

what is the appropriate way to do this goffice.

Is there a propriety in order to avec an inter-active widget instead of a static view like I have now.

thanks

Frederic
_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use the GoGraphWidget

Jean Bréfort-2
Le vendredi 14 avril 2017 à 09:18 +0000, PICCA Frederic-Emmanuel a
écrit :

> > There are sample codes in the goffice source tree:
> > https://git.gnome.org/browse/goffice/tree/tests/go-demo.c
> > https://git.gnome.org/browse/goffice/tree/tests/pie-demo.c
>
> Re-Hello
>
> So now I can plot  an XY curve
>
> I would like to give my users the possibility to modify the graph
> like in gnumeric via the graphical interface.
> Select the color of the graph, change the title, etc...
>
> what is the appropriate way to do this goffice.
>
> Is there a propriety in order to avec an inter-active widget instead
> of a static view like I have now.
>
Yes, you can use the GogGuru which is also used in gnumeric. You'll
need to derive your own GogDataAllocator (which provide the widget used
to select the data which, in your case might be a label or a list of
available data). I wrote a demonstrator several years ago, you can find
the code in:
http://svn.savannah.gnu.org/viewvc/gchemutils/trunk/gchemutils/programs/table/gchemtable-curve.cc?revision=1969&view=markup
(look at GChemTableCurve::OnProperties ())

The allocator code is in
http://svn.savannah.gnu.org/viewvc/gchemutils/trunk/gchemutils/programs/table/gchemtable-data-allocator.cc?revision=1718&view=markup
http://svn.savannah.gnu.org/viewvc/gchemutils/trunk/gchemutils/programs/table/gchemtable-data-allocator.h?revision=1718&view=markup

Regards,
Jean
_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE:how to use the GoGraphWidget

PICCA Frederic-Emmanuel
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));
}
_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Loading...