Re: libgoffice help

2009/4/30 Jean Bréfort <jean brefort normalesup org>:
You should call gog_object_request_update instead of

Hi Jean, thank you for the reply, but I still don't get a red line :-(

I made a tiny example program:

/* Compile with:

        gcc -g -Wall try156.c `pkg-config libgoffice-0.8 --cflags --libs`


#include <gtk/gtk.h>

#include <goffice/goffice.h>

#include <goffice/app/go-plugin.h>
#include <goffice/app/go-plugin-loader-module.h>

#include <goffice/data/go-data-simple.h>

#include <goffice/graph/gog-data-set.h>
#include <goffice/graph/gog-label.h>
#include <goffice/graph/gog-object.h>
#include <goffice/graph/gog-plot.h>
#include <goffice/graph/gog-series.h>
#include <goffice/graph/gog-style.h>

#include <goffice/gtk/go-graph-widget.h>

#include <goffice/utils/go-color.h>

static double xes[] = { 1.0, 2.0, 3.0 };
static double yes[] = { 1.0, 12.0, 5.0 };

main (int argc, char **argv)
  GtkWidget *window;

  GtkWidget *graph;
  GogChart *chart;
  GogPlot *plot;
  GogSeries *series;
  GOData *data;
  GError *error;
  GogStyle *style;

  gtk_init (&argc, &argv);

  libgoffice_init ();
  go_plugins_init (NULL, NULL, NULL, NULL, TRUE,

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  graph = go_graph_widget_new (NULL);
  gtk_container_add (GTK_CONTAINER (window), graph);

  chart = go_graph_widget_get_chart (GO_GRAPH_WIDGET (graph));

  plot = gog_plot_new_by_name ("GogXYPlot");
  gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT (plot));

  series = gog_plot_new_series (plot);
  data = go_data_vector_val_new (xes, 3, NULL);
  gog_series_set_dim (series, 0, data, &error);
  data = go_data_vector_val_new (yes, 3, NULL);
  gog_series_set_dim (series, 1, data, &error);

  style = gog_styled_object_get_style (GOG_STYLED_OBJECT (series));
  style->line.color = RGB_RED;
  gog_object_request_update (GOG_OBJECT (series));

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;

What's the best way to make the line red?

My motivation: this is for displaying image profiles, so I need to
display three series as a line graph, and they need to be red, green,


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