how to set line colour in libgoffice charts



Hello everyone,

I've just updated from 0.7.4 to 0.7.8 (the version that's packaged
with the current Ubuntu as v0.8) and my code can no longer set line
colours.

I made a tiny test program:

----------------
/* Compile with:

       gcc -g -Wall chart.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/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 };

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

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

  gtk_init (&argc, &argv);

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

  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 = go_styled_object_get_style (GO_STYLED_OBJECT (series));
  style->line.color = RGB_RED;
  style->line.auto_color = FALSE;
  gog_object_request_update (GOG_OBJECT (series));

  // tried this too
  // go_styled_object_style_changed (GO_STYLED_OBJECT (series));

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
--------------------

What's the recommended way to set a line colour in 0.7.8?

John



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