gnumeric r16821 - in trunk/src: dialogs tools
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16821 - in trunk/src: dialogs tools
- Date: Mon, 22 Sep 2008 04:41:02 +0000 (UTC)
Author: guelzow
Date: Mon Sep 22 04:41:02 2008
New Revision: 16821
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16821&view=rev
Log:
2008-09-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-tools.h (analysis_tools_data_moving_average_t): new field
* analysis-tools.c (analysis_tool_moving_average_engine_run): create
graph if requested
2008-09-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-analysis-tools.c (AverageToolState): new field
(average_tool_ok_clicked_cb): handle new field
(dialog_average_tool): setup new control
* moving-averages.glade: enable graph checkbox
Modified:
trunk/src/dialogs/ChangeLog
trunk/src/dialogs/dialog-analysis-tools.c
trunk/src/dialogs/moving-averages.glade
trunk/src/tools/ChangeLog
trunk/src/tools/analysis-tools.c
trunk/src/tools/analysis-tools.h
Modified: trunk/src/dialogs/dialog-analysis-tools.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tools.c (original)
+++ trunk/src/dialogs/dialog-analysis-tools.c Mon Sep 22 04:41:02 2008
@@ -187,6 +187,7 @@
GtkWidget *central_button;
GtkWidget *offset_button;
GtkWidget *offset_spin;
+ GtkWidget *graph_button;
} AverageToolState;
typedef struct {
@@ -2424,6 +2425,7 @@
err = entry_to_int (GTK_ENTRY (state->offset_spin), &data->offset, TRUE);
data->std_error_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (state->show_std_errors));
+ data->show_graph = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (state->graph_button));
data->df = gnumeric_glade_group_value (state->base.gui, n_group);
@@ -2589,6 +2591,7 @@
state->offset_button = glade_xml_get_widget (state->base.gui, "offset-button");
state->offset_spin = glade_xml_get_widget (state->base.gui, "offset-spinbutton");
state->show_std_errors = glade_xml_get_widget (state->base.gui, "std-errors-button");
+ state->graph_button = glade_xml_get_widget (state->base.gui, "graph-check");
g_signal_connect_after (G_OBJECT (state->n_button),
"toggled",
Modified: trunk/src/dialogs/moving-averages.glade
==============================================================================
--- trunk/src/dialogs/moving-averages.glade (original)
+++ trunk/src/dialogs/moving-averages.glade Mon Sep 22 04:41:02 2008
@@ -34,48 +34,6 @@
<placeholder/>
</child>
<child>
- <widget class="GtkCheckButton" id="labels_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">_Labels</property>
- <property name="use_underline">True</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Grouped by:</property>
- </widget>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="var1-label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Input range:</property>
- <property name="use_underline">True</property>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
@@ -113,6 +71,48 @@
<property name="y_options"></property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel" id="var1-label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Input range:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Grouped by:</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="labels_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Labels</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</widget>
</child>
<child>
@@ -131,18 +131,28 @@
<property name="n_rows">4</property>
<property name="n_columns">1</property>
<child>
- <widget class="GtkRadioButton" id="sma-button1">
+ <widget class="GtkRadioButton" id="sma-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Simple moving average</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="cma-button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Spencer's 15-point moving average</property>
+ <property name="label" translatable="yes">Cumulative moving average</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<property name="group">sma-button</property>
</widget>
<packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
</packing>
</child>
<child>
@@ -161,30 +171,20 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="cma-button">
+ <widget class="GtkRadioButton" id="sma-button1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Cumulative moving average</property>
+ <property name="label" translatable="yes">Spencer's 15-point moving average</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<property name="group">sma-button</property>
</widget>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
</packing>
</child>
- <child>
- <widget class="GtkRadioButton" id="sma-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Simple moving average</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </widget>
- </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -216,55 +216,45 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkRadioButton" id="nm2-button">
+ <widget class="GtkLabel" id="label3">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">nâ2</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">n-button</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Interval:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">interval-entry</property>
</widget>
<packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="nm1-button">
+ <widget class="GtkEntry" id="interval-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">nâ1</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">n-button</property>
+ <property name="invisible_char">*</property>
+ <property name="text" translatable="yes">3</property>
+ <property name="xalign">1</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="n-button">
+ <widget class="GtkCheckButton" id="std-errors-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">n</property>
+ <property name="label" translatable="yes">_Standard errors</property>
+ <property name="use_underline">True</property>
<property name="response_id">0</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -283,47 +273,57 @@
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="std-errors-button">
+ <widget class="GtkRadioButton" id="n-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">_Standard errors</property>
- <property name="use_underline">True</property>
+ <property name="label" translatable="yes">n</property>
<property name="response_id">0</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
- <property name="right_attach">4</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkEntry" id="interval-entry">
+ <widget class="GtkRadioButton" id="nm1-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- <property name="text" translatable="yes">3</property>
- <property name="xalign">1</property>
+ <property name="label" translatable="yes">nâ1</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">n-button</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">4</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label3">
+ <widget class="GtkRadioButton" id="nm2-button">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Interval:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">interval-entry</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">nâ2</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">n-button</property>
</widget>
<packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
</packing>
</child>
</widget>
@@ -348,27 +348,25 @@
<placeholder/>
</child>
<child>
- <widget class="GtkSpinButton" id="offset-spinbutton">
+ <widget class="GtkRadioButton" id="prior-button">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="xalign">1</property>
- <property name="adjustment">0 0 100 1 10 10</property>
- <property name="climb_rate">0.20000000000000001</property>
+ <property name="label" translatable="yes">Prior moving average</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="offset-button">
+ <widget class="GtkRadioButton" id="central-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Other offset</property>
+ <property name="label" translatable="yes">Central moving average</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
@@ -376,17 +374,17 @@
</widget>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="central-button">
+ <widget class="GtkRadioButton" id="offset-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Central moving average</property>
+ <property name="label" translatable="yes">Other offset</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
@@ -394,24 +392,26 @@
</widget>
<packing>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="prior-button">
+ <widget class="GtkSpinButton" id="offset-spinbutton">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Prior moving average</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
+ <property name="xalign">1</property>
+ <property name="adjustment">0 0 100 1 10 10</property>
+ <property name="climb_rate">0.20000000000000001</property>
</widget>
<packing>
+ <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
@@ -440,7 +440,6 @@
<child>
<widget class="GtkCheckButton" id="graph-check">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Include chart</property>
<property name="response_id">0</property>
Modified: trunk/src/tools/analysis-tools.c
==============================================================================
--- trunk/src/tools/analysis-tools.c (original)
+++ trunk/src/tools/analysis-tools.c Mon Sep 22 04:41:02 2008
@@ -50,6 +50,13 @@
#include "sheet-object-cell-comment.h"
#include "workbook-control.h"
#include "command-context.h"
+#include "sheet-object-graph.h"
+#include "graph.h"
+#include <goffice/graph/gog-graph.h>
+#include <goffice/graph/gog-object.h>
+#include <goffice/graph/gog-chart.h>
+#include <goffice/graph/gog-plot.h>
+#include <goffice/graph/gog-series.h>
#include <goffice/utils/go-glib-extras.h>
#include <string.h>
@@ -3432,6 +3439,8 @@
GSList *l;
gint col = 0;
gint source;
+ SheetObject *so = NULL;
+ GogPlot *plot = NULL;
if (info->base.labels) {
fd_index = gnm_func_lookup ("INDEX", NULL);
@@ -3446,7 +3455,19 @@
fd_average = gnm_func_lookup ("AVERAGE", NULL);
gnm_func_ref (fd_average);
fd_offset = gnm_func_lookup ("OFFSET", NULL);
- gnm_func_ref (fd_offset);
+ gnm_func_ref (fd_offset);
+
+ if (info->show_graph) {
+ GogGraph *graph;
+ GogChart *chart;
+
+ graph = g_object_new (GOG_GRAPH_TYPE, NULL);
+ chart = GOG_CHART (gog_object_add_by_name (GOG_OBJECT (graph), "Chart", NULL));
+ plot = gog_plot_new_by_name ("GogLinePlot");
+ gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT (plot));
+ so = sheet_object_graph_new (graph);
+ g_object_unref (graph);
+ }
for (l = info->base.input, source = 1; l; l = l->next, col++, source++) {
GnmValue *val = value_dup ((GnmValue *)l->data);
@@ -3461,6 +3482,7 @@
guint delta_x;
guint delta_y;
gint row;
+ Sheet *sheet;
if (info->base.labels) {
val_c = value_dup (val);
@@ -3504,8 +3526,24 @@
break;
}
+ sheet = val->v_range.cell.a.sheet;
expr_input = gnm_expr_new_constant (val);
+ if (plot != NULL) {
+ GogSeries *series;
+
+ series = gog_plot_new_series (plot);
+ gog_series_set_dim (series, 1,
+ gnm_go_data_vector_new_expr (sheet,
+ gnm_expr_top_new (gnm_expr_copy (expr_input))),
+ NULL);
+
+ series = gog_plot_new_series (plot);
+ gog_series_set_dim (series, 1,
+ dao_go_data_vector (dao, col, 1, col, height),
+ NULL);
+ }
+
(*mover) = 1 - info->interval + info->offset;
for (row = 1; row <= height; row++, (*mover)++) {
if ((*mover >= 0) && (*mover + info->interval - 1 < height)) {
@@ -3554,6 +3592,9 @@
gnm_expr_free (expr_input);
}
+ if (so != NULL)
+ dao_set_sheet_object (dao, 0, 1, so);
+
if (fd_index != NULL)
gnm_func_unref (fd_index);
if (fd_sqrt != NULL)
Modified: trunk/src/tools/analysis-tools.h
==============================================================================
--- trunk/src/tools/analysis-tools.h (original)
+++ trunk/src/tools/analysis-tools.h Mon Sep 22 04:41:02 2008
@@ -91,6 +91,7 @@
int std_error_flag;
int df;
int offset;
+ gboolean show_graph;
} analysis_tools_data_moving_average_t;
gboolean analysis_tool_moving_average_engine (data_analysis_output_t *dao, gpointer specs,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]