gnumeric r17055 - in trunk: . src
- From: jbrefort svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17055 - in trunk: . src
- Date: Wed, 31 Dec 2008 18:25:40 +0000 (UTC)
Author: jbrefort
Date: Wed Dec 31 18:25:40 2008
New Revision: 17055
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17055&view=rev
Log:
2008-12-31 Jean Brefort <jean brefort normalesup org>
* src/graph.h: add widgets to force using rows/columns as chart series,
and to use first row/column as shared x values in scatter plots.
* src/selection.c: (sv_selection_to_plot): ditto.
* src/sheet-object-graph.c: (cb_graph_data_closure_done),
(cb_selection_mode_changed), (cb_shared_mode_changed),
(sheet_object_graph_guru): ditto.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/src/graph.h
trunk/src/selection.c
trunk/src/sheet-object-graph.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Wed Dec 31 18:25:40 2008
@@ -22,6 +22,8 @@
Jean:
* Fix crash when exporting an empty contour plot to .xls. [#557027]
+ * Add widgets in the graph guru first page to allow finer selection
+ of data.
Jody:
* Display top-left when selecting a rel ref to a merged region.
Modified: trunk/src/graph.h
==============================================================================
--- trunk/src/graph.h (original)
+++ trunk/src/graph.h Wed Dec 31 18:25:40 2008
@@ -40,6 +40,14 @@
GType gnm_go_data_matrix_get_type (void);
GOData *gnm_go_data_matrix_new_expr (Sheet *sheet, GnmExprTop const *texpr);
+/* closure for data allocation */
+typedef struct {
+ int colrowmode; /* 0 = auto; 1 = columns; 2 = rows */
+ gboolean share_x;
+ GObject *obj;
+ GogDataAllocator *dalloc;
+} GraphDataClosure;
+
G_END_DECLS
#endif /* _GNM_GRAPH_H_ */
Modified: trunk/src/selection.c
==============================================================================
--- trunk/src/selection.c (original)
+++ trunk/src/selection.c Wed Dec 31 18:25:40 2008
@@ -1369,6 +1369,8 @@
GogPlot *plot = go_plot;
GogPlotDesc const *desc;
GogSeries *series;
+ GogGraph *graph = gog_object_get_graph (GOG_OBJECT (go_plot));
+ GraphDataClosure *data = g_object_get_data (G_OBJECT (graph), "data-closure");
gboolean is_string_vec, first_series = TRUE, first_value_dim = TRUE;
unsigned i, count, cur_dim = 0, num_series = 1;
gboolean has_header, as_cols;
@@ -1386,7 +1388,7 @@
}
/* Excel docs claim that rows == cols uses rows */
- default_to_cols = (num_cols < num_rows);
+ default_to_cols = (!data || data->colrowmode == 0)? (num_cols < num_rows): data->colrowmode == 1;
desc = gog_plot_description (plot);
series = gog_plot_new_series (plot);
@@ -1486,6 +1488,11 @@
!first_series && desc->series.dim[cur_dim].is_shared)
++cur_dim;
+ /* skip over index series if shared */
+ while (data->share_x && cur_dim < desc->series.num_dim &&
+ !first_series && desc->series.dim[cur_dim].val_type == GOG_DIM_INDEX)
+ ++cur_dim;
+
while (cur_dim < desc->series.num_dim && desc->series.dim[cur_dim].priority == GOG_SERIES_ERRORS)
++cur_dim;
if (cur_dim >= desc->series.num_dim)
Modified: trunk/src/sheet-object-graph.c
==============================================================================
--- trunk/src/sheet-object-graph.c (original)
+++ trunk/src/sheet-object-graph.c Wed Dec 31 18:25:40 2008
@@ -42,6 +42,7 @@
#include <goffice/graph/gog-graph.h>
#include <goffice/graph/gog-object.h>
#include <goffice/graph/gog-object-xml.h>
+#include <goffice/graph/gog-plot.h>
#include <goffice/graph/gog-data-allocator.h>
#include <goffice/graph/gog-data-set.h>
#include <goffice/graph/gog-renderer.h>
@@ -617,12 +618,77 @@
wbcg_edit_finish (wbcg, WBC_EDIT_REJECT, NULL);
}
+static void
+cb_graph_data_closure_done (GraphDataClosure *data)
+{
+ if (data->obj)
+ g_object_set_data (data->obj,"data-closure", NULL);
+ g_free (data);
+}
+
+static void
+cb_selection_mode_changed (GtkComboBox *box, GraphDataClosure *data)
+{
+ GogObject *graph = (GogObject *) g_object_get_data (data->obj, "graph");
+ data->colrowmode = gtk_combo_box_get_active (box);
+ if (graph) {
+ GogObject *gobj = gog_object_get_child_by_name (graph, "Chart");
+ gobj = gog_object_get_child_by_name (gobj, "Plot");
+ if (!gobj)
+ return;
+ gog_plot_clear_series (GOG_PLOT (gobj));
+ gog_data_allocator_allocate (data->dalloc, GOG_PLOT (gobj));
+ }
+}
+
+static void
+cb_shared_mode_changed (GtkToggleButton *btn, GraphDataClosure *data)
+{
+ GogObject *graph = (GogObject *) g_object_get_data (data->obj, "graph");
+ data->share_x = gtk_toggle_button_get_active (btn);
+ if (graph) {
+ GogObject *gobj = gog_object_get_child_by_name (graph, "Chart");
+ gobj = gog_object_get_child_by_name (gobj, "Plot");
+ if (!gobj)
+ return;
+ gog_plot_clear_series (GOG_PLOT (gobj));
+ gog_data_allocator_allocate (data->dalloc, GOG_PLOT (gobj));
+ }
+}
+
void
sheet_object_graph_guru (WBCGtk *wbcg, GogGraph *graph,
GClosure *closure)
{
GtkWidget *dialog = gog_guru (graph, GOG_DATA_ALLOCATOR (wbcg),
GO_CMD_CONTEXT (wbcg), closure);
+ if (!graph) {
+ GraphDataClosure *data = (GraphDataClosure *) g_new0 (GraphDataClosure, 1);
+ GtkWidget *custom = gtk_table_new (2, 2, FALSE), *w;
+ GObject *object;
+
+ data->dalloc = GOG_DATA_ALLOCATOR (wbcg);
+ g_object_set (custom, "row-spacing", 6, "column-spacing", 12, NULL);
+ w = gtk_label_new (_("Series as:"));
+ g_object_set (w, "xalign", 0., NULL);
+ gtk_table_attach (GTK_TABLE (custom), w, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+ w = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (w), _("Auto"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (w), _("Columns"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (w), _("Rows"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0);
+ g_signal_connect (G_OBJECT (w), "changed", G_CALLBACK (cb_selection_mode_changed), data);
+ gtk_table_attach (GTK_TABLE (custom), w, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+ w = gtk_check_button_new_with_label (_("Use first series as shared abscissa"));
+ g_signal_connect (G_OBJECT (w), "toggled", G_CALLBACK (cb_shared_mode_changed), data);
+ gtk_table_attach (GTK_TABLE (custom), w, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+ data->obj = G_OBJECT (custom);
+ gog_guru_add_custom_widget (dialog, custom);
+ object = (GObject*) g_object_get_data (data->obj, "graph");
+ if (object)
+ g_object_set_data (object, "data-closure", data);
+ g_object_set_data_full (G_OBJECT (custom), "data-closure", data, (GDestroyNotify) cb_graph_data_closure_done);
+ }
gnumeric_init_help_button (
gog_guru_get_help_button (dialog),
"sect-graphics-plots");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]